Skip to content

Commit ae02615

Browse files
hcahcaAlexander Gordeev
authored andcommitted
s390/fpu: Add fpc exception handler / remove fixup section again
The fixup section was added again by mistake when test_fp_ctl() was removed. The reason for the removal of the fixup section is described in commit 484a8ed ("s390/extable: add dedicated uaccess handler"). Remove it again for the same reason. Add an exception handler which handles exceptions when the floating point control register is attempted to be set to invalid values. The exception handler sets the floating point control register to zero and continues execution at the specified address. The new sfpc inline assembly is open-coded to make back porting a bit easier. Fixes: 7026442 ("s390/fpu: get rid of test_fp_ctl()") Cc: [email protected] Reviewed-by: Alexander Gordeev <[email protected]> Signed-off-by: Heiko Carstens <[email protected]> Signed-off-by: Alexander Gordeev <[email protected]>
1 parent f684b79 commit ae02615

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define EX_TYPE_UA_LOAD_REG 5
1515
#define EX_TYPE_UA_LOAD_REGPAIR 6
1616
#define EX_TYPE_ZEROPAD 7
17+
#define EX_TYPE_FPC 8
1718

1819
#define EX_DATA_REG_ERR_SHIFT 0
1920
#define EX_DATA_REG_ERR GENMASK(3, 0)
@@ -84,4 +85,7 @@
8485
#define EX_TABLE_ZEROPAD(_fault, _target, _regdata, _regaddr) \
8586
__EX_TABLE(__ex_table, _fault, _target, EX_TYPE_ZEROPAD, _regdata, _regaddr, 0)
8687

88+
#define EX_TABLE_FPC(_fault, _target) \
89+
__EX_TABLE(__ex_table, _fault, _target, EX_TYPE_FPC, __stringify(%%r0), __stringify(%%r0), 0)
90+
8791
#endif /* __ASM_EXTABLE_H */

arch/s390/include/asm/fpu-insn.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,12 @@ static __always_inline void fpu_lfpc(unsigned int *fpc)
100100
*/
101101
static inline void fpu_lfpc_safe(unsigned int *fpc)
102102
{
103-
u32 tmp;
104-
105103
instrument_read(fpc, sizeof(*fpc));
106104
asm_inline volatile(
107-
"0: lfpc %[fpc]\n"
108-
"1: nopr %%r7\n"
109-
".pushsection .fixup, \"ax\"\n"
110-
"2: lghi %[tmp],0\n"
111-
" sfpc %[tmp]\n"
112-
" jg 1b\n"
113-
".popsection\n"
114-
EX_TABLE(1b, 2b)
115-
: [tmp] "=d" (tmp)
105+
" lfpc %[fpc]\n"
106+
"0: nopr %%r7\n"
107+
EX_TABLE_FPC(0b, 0b)
108+
:
116109
: [fpc] "Q" (*fpc)
117110
: "memory");
118111
}

arch/s390/kernel/vmlinux.lds.S

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ SECTIONS
5252
SOFTIRQENTRY_TEXT
5353
FTRACE_HOTPATCH_TRAMPOLINES_TEXT
5454
*(.text.*_indirect_*)
55-
*(.fixup)
5655
*(.gnu.warning)
5756
. = ALIGN(PAGE_SIZE);
5857
_etext = .; /* End of text section */

arch/s390/mm/extable.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ static bool ex_handler_zeropad(const struct exception_table_entry *ex, struct pt
7777
return true;
7878
}
7979

80+
static bool ex_handler_fpc(const struct exception_table_entry *ex, struct pt_regs *regs)
81+
{
82+
asm volatile("sfpc %[val]\n" : : [val] "d" (0));
83+
regs->psw.addr = extable_fixup(ex);
84+
return true;
85+
}
86+
8087
bool fixup_exception(struct pt_regs *regs)
8188
{
8289
const struct exception_table_entry *ex;
@@ -99,6 +106,8 @@ bool fixup_exception(struct pt_regs *regs)
99106
return ex_handler_ua_load_reg(ex, true, regs);
100107
case EX_TYPE_ZEROPAD:
101108
return ex_handler_zeropad(ex, regs);
109+
case EX_TYPE_FPC:
110+
return ex_handler_fpc(ex, regs);
102111
}
103112
panic("invalid exception table entry");
104113
}

0 commit comments

Comments
 (0)