1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * CMM tests (ESSA) 4 * 5 * Copyright (c) 2018 IBM Corp 6 * 7 * Authors: 8 * Janosch Frank <frankja@linux.vnet.ibm.com> 9 */ 10 11 #include <libcflat.h> 12 #include <asm/asm-offsets.h> 13 #include <asm/interrupt.h> 14 #include <asm/page.h> 15 #include <asm/cmm.h> 16 17 static uint8_t pagebuf[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); 18 19 static void test_params(void) 20 { 21 report_prefix_push("invalid ORC 8"); 22 expect_pgm_int(); 23 essa(8, (unsigned long)pagebuf); 24 check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); 25 report_prefix_pop(); 26 } 27 28 static void test_priv(void) 29 { 30 report_prefix_push("privileged"); 31 expect_pgm_int(); 32 enter_pstate(); 33 essa(ESSA_GET_STATE, (unsigned long)pagebuf); 34 check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION); 35 report_prefix_pop(); 36 } 37 38 int main(void) 39 { 40 bool has_essa = check_essa_available(); 41 42 report_prefix_push("cmm"); 43 if (!has_essa) { 44 report_skip("ESSA is not available"); 45 goto done; 46 } 47 48 test_priv(); 49 test_params(); 50 done: 51 report_prefix_pop(); 52 return report_summary(); 53 } 54