1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Library to decode addressing related exceptions 4 * 5 * Copyright 2021 IBM Corp. 6 * 7 * Authors: 8 * Janosch Frank <frankja@linux.ibm.com> 9 */ 10 #include <libcflat.h> 11 #include <bitops.h> 12 #include <asm/arch_def.h> 13 #include <asm/page.h> 14 #include <fault.h> 15 16 /* Decodes the protection exceptions we'll most likely see */ 17 static void print_decode_pgm_prot(uint64_t teid) 18 { 19 if (prot_is_lap(teid)) { 20 printf("Type: LAP\n"); 21 return; 22 } 23 24 if (prot_is_iep(teid)) { 25 printf("Type: IEP\n"); 26 return; 27 } 28 29 if (prot_is_datp(teid)) { 30 printf("Type: DAT\n"); 31 return; 32 } 33 } 34 35 void print_decode_teid(uint64_t teid) 36 { 37 int asce_id = teid & 3; 38 bool dat = lowcore.pgm_old_psw.mask & PSW_MASK_DAT; 39 40 printf("Memory exception information:\n"); 41 printf("DAT: %s\n", dat ? "on" : "off"); 42 43 printf("AS: "); 44 switch (asce_id) { 45 case AS_PRIM: 46 printf("Primary\n"); 47 break; 48 case AS_ACCR: 49 printf("Access Register\n"); 50 break; 51 case AS_SECN: 52 printf("Secondary\n"); 53 break; 54 case AS_HOME: 55 printf("Home\n"); 56 break; 57 } 58 59 if (lowcore.pgm_int_code == PGM_INT_CODE_PROTECTION) 60 print_decode_pgm_prot(teid); 61 62 /* 63 * If teid bit 61 is off for these two exception the reported 64 * address is unpredictable. 65 */ 66 if ((lowcore.pgm_int_code == PGM_INT_CODE_SECURE_STOR_ACCESS || 67 lowcore.pgm_int_code == PGM_INT_CODE_SECURE_STOR_VIOLATION) && 68 !test_bit_inv(61, &teid)) { 69 printf("Address: %lx, unpredictable\n ", teid & PAGE_MASK); 70 return; 71 } 72 printf("TEID: %lx\n", teid); 73 printf("Address: %lx\n\n", teid & PAGE_MASK); 74 } 75