]> git.apps.os.sepia.ceph.com Git - ceph-client.git/commitdiff
s390/uaccess: Replace EX_TABLE_UA_LOAD_MEM exception handling
authorHeiko Carstens <hca@linux.ibm.com>
Mon, 13 Jan 2025 12:37:04 +0000 (13:37 +0100)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Sun, 26 Jan 2025 16:24:06 +0000 (17:24 +0100)
Remove EX_TABLE_UA_LOAD_MEM exception handling and replace it with
EX_TABLE_UA_FAULT. Open code the return code check, and also open code
setting of the destination to zero in case of an error. In almost all cases
the compiler is able to optimize the open coded checks away, since all
users of get_users() must check the return code, and are not supposed to
use the result in case of an error.

In addition this allows to change the get_user() inline assembly so that
the "Q" constraint can be used for the destination, instead of only an "a"
constraint. This generates slightly better code.

Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
arch/s390/include/asm/asm-extable.h
arch/s390/include/asm/uaccess.h
arch/s390/mm/extable.c

index 5f47569c908ab87ee197b7948beb3a633b246487..2e829c16fd8ad2404fb49f12f21b1da56d88d495 100644 (file)
@@ -10,7 +10,6 @@
 #define EX_TYPE_FIXUP          1
 #define EX_TYPE_BPF            2
 #define EX_TYPE_UA_FAULT       3
-#define EX_TYPE_UA_LOAD_MEM    4
 #define EX_TYPE_UA_LOAD_REG    5
 #define EX_TYPE_UA_LOAD_REGPAIR        6
 #define EX_TYPE_ZEROPAD                7
@@ -73,9 +72,6 @@
 #define EX_TABLE_UA_FAULT(_fault, _target, _regerr)                    \
        __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_UA_FAULT, _regerr, _regerr, 0)
 
-#define EX_TABLE_UA_LOAD_MEM(_fault, _target, _regerr, _regmem, _len)  \
-       __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_UA_LOAD_MEM, _regerr, _regmem, _len)
-
 #define EX_TABLE_UA_LOAD_REG(_fault, _target, _regerr, _regzero)       \
        __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_UA_LOAD_REG, _regerr, _regzero, 0)
 
index 8f6170852410aa3c47ebb85ecfbed7a145cee774..db22aefd452c56d1e54f55ec7922db262c5d6c5c 100644 (file)
@@ -184,16 +184,18 @@ __get_user_##type##_noinstr(unsigned type *to,                            \
                                                                        \
        asm volatile(                                                   \
                "       lr      %%r0,%[spec]\n"                         \
-               "0:     mvcos   0(%[to]),%[from],%[size]\n"             \
+               "0:     mvcos   %[to],%[from],%[size]\n"                \
                "1:     lhi     %[rc],0\n"                              \
                "2:\n"                                                  \
-               EX_TABLE_UA_LOAD_MEM(0b, 2b, %[rc], %[to], %[ksize])    \
-               EX_TABLE_UA_LOAD_MEM(1b, 2b, %[rc], %[to], %[ksize])    \
-               : [rc] "=d" (rc), "=Q" (*to)                            \
+               EX_TABLE_UA_FAULT(0b, 2b, %[rc])                        \
+               EX_TABLE_UA_FAULT(1b, 2b, %[rc])                        \
+               : [rc] "=d" (rc), [to] "=Q" (*to)                       \
                : [size] "d" (size), [from] "Q" (*from),                \
-                 [spec] "d" (__oac_spec.val), [to] "a" (to),           \
-                 [ksize] "K" (size)                                    \
+                 [spec] "d" (__oac_spec.val)                           \
                : "cc", "0");                                           \
+       if (likely(!rc))                                                \
+               return 0;                                               \
+       *to = 0;                                                        \
        return rc;                                                      \
 }                                                                      \
                                                                        \
index 37a3e6d46e0fb3fe1edad2967861425cd00e5dd2..a046be1715cf0019e1f8cbcd71572413ac4b2930 100644 (file)
@@ -36,18 +36,6 @@ static bool ex_handler_ua_fault(const struct exception_table_entry *ex, struct p
        return true;
 }
 
-static bool ex_handler_ua_load_mem(const struct exception_table_entry *ex, struct pt_regs *regs)
-{
-       unsigned int reg_addr = FIELD_GET(EX_DATA_REG_ADDR, ex->data);
-       unsigned int reg_err = FIELD_GET(EX_DATA_REG_ERR, ex->data);
-       size_t len = FIELD_GET(EX_DATA_LEN, ex->data);
-
-       regs->gprs[reg_err] = -EFAULT;
-       memset((void *)regs->gprs[reg_addr], 0, len);
-       regs->psw.addr = extable_fixup(ex);
-       return true;
-}
-
 static bool ex_handler_ua_load_reg(const struct exception_table_entry *ex,
                                   bool pair, struct pt_regs *regs)
 {
@@ -99,8 +87,6 @@ bool fixup_exception(struct pt_regs *regs)
                return ex_handler_bpf(ex, regs);
        case EX_TYPE_UA_FAULT:
                return ex_handler_ua_fault(ex, regs);
-       case EX_TYPE_UA_LOAD_MEM:
-               return ex_handler_ua_load_mem(ex, regs);
        case EX_TYPE_UA_LOAD_REG:
                return ex_handler_ua_load_reg(ex, false, regs);
        case EX_TYPE_UA_LOAD_REGPAIR: