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 <bitops.h> 13 #include <asm/asm-offsets.h> 14 #include <asm/interrupt.h> 15 #include <asm/page.h> 16 #include <asm/cmm.h> 17 #include <asm/facility.h> 18 19 static uint8_t pagebuf[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); 20 21 extern int diag308_load_reset(u64); 22 test_params(void)23static void test_params(void) 24 { 25 report_prefix_push("invalid ORC 8"); 26 expect_pgm_int(); 27 essa(8, (unsigned long)pagebuf); 28 check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); 29 report_prefix_pop(); 30 } 31 test_priv(void)32static void test_priv(void) 33 { 34 report_prefix_push("privileged"); 35 expect_pgm_int(); 36 enter_pstate(); 37 essa(ESSA_GET_STATE, (unsigned long)pagebuf); 38 check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION); 39 report_prefix_pop(); 40 } 41 test_reset_no_translate(void)42static void test_reset_no_translate(void) 43 { 44 const uint64_t mask_no_translate = BIT(63 - 58); 45 unsigned long state; 46 47 if (!test_facility(147)) { 48 report_prefix_push("no-translate unavailable"); 49 expect_pgm_int(); 50 essa(ESSA_SET_STABLE_NODAT, (unsigned long)pagebuf); 51 check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); 52 report_prefix_pop(); 53 return; 54 } 55 56 report_prefix_push("reset no-translate"); 57 essa(ESSA_SET_STABLE_NODAT, (unsigned long)pagebuf); 58 59 state = essa(ESSA_GET_STATE, (unsigned long)pagebuf); 60 report(state & mask_no_translate, "no-translate bit set before reset"); 61 62 /* Load normal reset - includes subsystem reset */ 63 diag308_load_reset(1); 64 65 state = essa(ESSA_GET_STATE, (unsigned long)pagebuf); 66 report(!(state & mask_no_translate), "no-translate bit unset after reset"); 67 68 report_prefix_pop(); 69 } 70 main(void)71int main(void) 72 { 73 bool has_essa = check_essa_available(); 74 75 report_prefix_push("cmm"); 76 if (!has_essa) { 77 report_skip("ESSA is not available"); 78 goto done; 79 } 80 81 test_priv(); 82 test_params(); 83 test_reset_no_translate(); 84 done: 85 report_prefix_pop(); 86 return report_summary(); 87 } 88