Skip to content

Commit dc7ff4b

Browse files
hcahcaAlexander Gordeev
authored andcommitted
s390/uaccess: Replace EX_TABLE_UA_LOAD_MEM exception handling
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>
1 parent 67e959a commit dc7ff4b

File tree

3 files changed

+8
-24
lines changed

3 files changed

+8
-24
lines changed

arch/s390/include/asm/asm-extable.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define EX_TYPE_FIXUP 1
1111
#define EX_TYPE_BPF 2
1212
#define EX_TYPE_UA_FAULT 3
13-
#define EX_TYPE_UA_LOAD_MEM 4
1413
#define EX_TYPE_UA_LOAD_REG 5
1514
#define EX_TYPE_UA_LOAD_REGPAIR 6
1615
#define EX_TYPE_ZEROPAD 7
@@ -73,9 +72,6 @@
7372
#define EX_TABLE_UA_FAULT(_fault, _target, _regerr) \
7473
__EX_TABLE(__ex_table, _fault, _target, EX_TYPE_UA_FAULT, _regerr, _regerr, 0)
7574

76-
#define EX_TABLE_UA_LOAD_MEM(_fault, _target, _regerr, _regmem, _len) \
77-
__EX_TABLE(__ex_table, _fault, _target, EX_TYPE_UA_LOAD_MEM, _regerr, _regmem, _len)
78-
7975
#define EX_TABLE_UA_LOAD_REG(_fault, _target, _regerr, _regzero) \
8076
__EX_TABLE(__ex_table, _fault, _target, EX_TYPE_UA_LOAD_REG, _regerr, _regzero, 0)
8177

arch/s390/include/asm/uaccess.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,18 @@ __get_user_##type##_noinstr(unsigned type *to, \
184184
\
185185
asm volatile( \
186186
" lr %%r0,%[spec]\n" \
187-
"0: mvcos 0(%[to]),%[from],%[size]\n" \
187+
"0: mvcos %[to],%[from],%[size]\n" \
188188
"1: lhi %[rc],0\n" \
189189
"2:\n" \
190-
EX_TABLE_UA_LOAD_MEM(0b, 2b, %[rc], %[to], %[ksize]) \
191-
EX_TABLE_UA_LOAD_MEM(1b, 2b, %[rc], %[to], %[ksize]) \
192-
: [rc] "=d" (rc), "=Q" (*to) \
190+
EX_TABLE_UA_FAULT(0b, 2b, %[rc]) \
191+
EX_TABLE_UA_FAULT(1b, 2b, %[rc]) \
192+
: [rc] "=d" (rc), [to] "=Q" (*to) \
193193
: [size] "d" (size), [from] "Q" (*from), \
194-
[spec] "d" (__oac_spec.val), [to] "a" (to), \
195-
[ksize] "K" (size) \
194+
[spec] "d" (__oac_spec.val) \
196195
: "cc", "0"); \
196+
if (likely(!rc)) \
197+
return 0; \
198+
*to = 0; \
197199
return rc; \
198200
} \
199201
\

arch/s390/mm/extable.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,6 @@ static bool ex_handler_ua_fault(const struct exception_table_entry *ex, struct p
3636
return true;
3737
}
3838

39-
static bool ex_handler_ua_load_mem(const struct exception_table_entry *ex, struct pt_regs *regs)
40-
{
41-
unsigned int reg_addr = FIELD_GET(EX_DATA_REG_ADDR, ex->data);
42-
unsigned int reg_err = FIELD_GET(EX_DATA_REG_ERR, ex->data);
43-
size_t len = FIELD_GET(EX_DATA_LEN, ex->data);
44-
45-
regs->gprs[reg_err] = -EFAULT;
46-
memset((void *)regs->gprs[reg_addr], 0, len);
47-
regs->psw.addr = extable_fixup(ex);
48-
return true;
49-
}
50-
5139
static bool ex_handler_ua_load_reg(const struct exception_table_entry *ex,
5240
bool pair, struct pt_regs *regs)
5341
{
@@ -99,8 +87,6 @@ bool fixup_exception(struct pt_regs *regs)
9987
return ex_handler_bpf(ex, regs);
10088
case EX_TYPE_UA_FAULT:
10189
return ex_handler_ua_fault(ex, regs);
102-
case EX_TYPE_UA_LOAD_MEM:
103-
return ex_handler_ua_load_mem(ex, regs);
10490
case EX_TYPE_UA_LOAD_REG:
10591
return ex_handler_ua_load_reg(ex, false, regs);
10692
case EX_TYPE_UA_LOAD_REGPAIR:

0 commit comments

Comments
 (0)