~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/s390/mm/extable.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 
  3 #include <linux/bitfield.h>
  4 #include <linux/extable.h>
  5 #include <linux/string.h>
  6 #include <linux/errno.h>
  7 #include <linux/panic.h>
  8 #include <asm/asm-extable.h>
  9 #include <asm/extable.h>
 10 
 11 const struct exception_table_entry *s390_search_extables(unsigned long addr)
 12 {
 13         const struct exception_table_entry *fixup;
 14         size_t num;
 15 
 16         fixup = search_exception_tables(addr);
 17         if (fixup)
 18                 return fixup;
 19         num = __stop_amode31_ex_table - __start_amode31_ex_table;
 20         return search_extable(__start_amode31_ex_table, num, addr);
 21 }
 22 
 23 static bool ex_handler_fixup(const struct exception_table_entry *ex, struct pt_regs *regs)
 24 {
 25         regs->psw.addr = extable_fixup(ex);
 26         return true;
 27 }
 28 
 29 static bool ex_handler_ua_store(const struct exception_table_entry *ex, struct pt_regs *regs)
 30 {
 31         unsigned int reg_err = FIELD_GET(EX_DATA_REG_ERR, ex->data);
 32 
 33         regs->gprs[reg_err] = -EFAULT;
 34         regs->psw.addr = extable_fixup(ex);
 35         return true;
 36 }
 37 
 38 static bool ex_handler_ua_load_mem(const struct exception_table_entry *ex, struct pt_regs *regs)
 39 {
 40         unsigned int reg_addr = FIELD_GET(EX_DATA_REG_ADDR, ex->data);
 41         unsigned int reg_err = FIELD_GET(EX_DATA_REG_ERR, ex->data);
 42         size_t len = FIELD_GET(EX_DATA_LEN, ex->data);
 43 
 44         regs->gprs[reg_err] = -EFAULT;
 45         memset((void *)regs->gprs[reg_addr], 0, len);
 46         regs->psw.addr = extable_fixup(ex);
 47         return true;
 48 }
 49 
 50 static bool ex_handler_ua_load_reg(const struct exception_table_entry *ex,
 51                                    bool pair, struct pt_regs *regs)
 52 {
 53         unsigned int reg_zero = FIELD_GET(EX_DATA_REG_ADDR, ex->data);
 54         unsigned int reg_err = FIELD_GET(EX_DATA_REG_ERR, ex->data);
 55 
 56         regs->gprs[reg_err] = -EFAULT;
 57         regs->gprs[reg_zero] = 0;
 58         if (pair)
 59                 regs->gprs[reg_zero + 1] = 0;
 60         regs->psw.addr = extable_fixup(ex);
 61         return true;
 62 }
 63 
 64 static bool ex_handler_zeropad(const struct exception_table_entry *ex, struct pt_regs *regs)
 65 {
 66         unsigned int reg_addr = FIELD_GET(EX_DATA_REG_ADDR, ex->data);
 67         unsigned int reg_data = FIELD_GET(EX_DATA_REG_ERR, ex->data);
 68         unsigned long data, addr, offset;
 69 
 70         addr = regs->gprs[reg_addr];
 71         offset = addr & (sizeof(unsigned long) - 1);
 72         addr &= ~(sizeof(unsigned long) - 1);
 73         data = *(unsigned long *)addr;
 74         data <<= BITS_PER_BYTE * offset;
 75         regs->gprs[reg_data] = data;
 76         regs->psw.addr = extable_fixup(ex);
 77         return true;
 78 }
 79 
 80 bool fixup_exception(struct pt_regs *regs)
 81 {
 82         const struct exception_table_entry *ex;
 83 
 84         ex = s390_search_extables(instruction_pointer(regs));
 85         if (!ex)
 86                 return false;
 87         switch (ex->type) {
 88         case EX_TYPE_FIXUP:
 89                 return ex_handler_fixup(ex, regs);
 90         case EX_TYPE_BPF:
 91                 return ex_handler_bpf(ex, regs);
 92         case EX_TYPE_UA_STORE:
 93                 return ex_handler_ua_store(ex, regs);
 94         case EX_TYPE_UA_LOAD_MEM:
 95                 return ex_handler_ua_load_mem(ex, regs);
 96         case EX_TYPE_UA_LOAD_REG:
 97                 return ex_handler_ua_load_reg(ex, false, regs);
 98         case EX_TYPE_UA_LOAD_REGPAIR:
 99                 return ex_handler_ua_load_reg(ex, true, regs);
100         case EX_TYPE_ZEROPAD:
101                 return ex_handler_zeropad(ex, regs);
102         }
103         panic("invalid exception table entry");
104 }
105 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php