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 static struct lowcore *lc = (struct lowcore *)0x0; 17 18 /* Decodes the protection exceptions we'll most likely see */ 19 static void print_decode_pgm_prot(uint64_t teid) 20 { 21 if (prot_is_lap(teid)) { 22 printf("Type: LAP\n"); 23 return; 24 } 25 26 if (prot_is_iep(teid)) { 27 printf("Type: IEP\n"); 28 return; 29 } 30 31 if (prot_is_datp(teid)) { 32 printf("Type: DAT\n"); 33 return; 34 } 35 } 36 37 void print_decode_teid(uint64_t teid) 38 { 39 int asce_id = teid & 3; 40 bool dat = lc->pgm_old_psw.mask & PSW_MASK_DAT; 41 42 printf("Memory exception information:\n"); 43 printf("DAT: %s\n", dat ? "on" : "off"); 44 45 printf("AS: "); 46 switch (asce_id) { 47 case AS_PRIM: 48 printf("Primary\n"); 49 break; 50 case AS_ACCR: 51 printf("Access Register\n"); 52 break; 53 case AS_SECN: 54 printf("Secondary\n"); 55 break; 56 case AS_HOME: 57 printf("Home\n"); 58 break; 59 } 60 61 if (lc->pgm_int_code == PGM_INT_CODE_PROTECTION) 62 print_decode_pgm_prot(teid); 63 64 /* 65 * If teid bit 61 is off for these two exception the reported 66 * address is unpredictable. 67 */ 68 if ((lc->pgm_int_code == PGM_INT_CODE_SECURE_STOR_ACCESS || 69 lc->pgm_int_code == PGM_INT_CODE_SECURE_STOR_VIOLATION) && 70 !test_bit_inv(61, &teid)) { 71 printf("Address: %lx, unpredictable\n ", teid & PAGE_MASK); 72 return; 73 } 74 printf("TEID: %lx\n", teid); 75 printf("Address: %lx\n\n", teid & PAGE_MASK); 76 } 77