Skip to content

Commit 124c49b

Browse files
mrutland-armwilldeacon
authored andcommitted
arm64: armv8_deprecated: rework deprected instruction handling
Support for deprecated instructions can be enabled or disabled at runtime. To handle this, the code in armv8_deprecated.c registers and unregisters undef_hooks, and makes cross CPU calls to configure HW support. This is rather complicated, and the synchronization required to make this safe ends up serializing the handling of instructions which have been trapped. This patch simplifies the deprecated instruction handling by removing the dynamic registration and unregistration, and changing the trap handling code to determine whether a handler should be invoked. This removes the need for dynamic list management, and simplifies the locking requirements, making it possible to handle trapped instructions entirely in parallel. Where changing the emulation state requires a cross-call, this is serialized by locally disabling interrupts, ensuring that the CPU is not left in an inconsistent state. To simplify sysctl management, each insn_emulation is given a separate sysctl table, permitting these to be registered separately. The core sysctl code will iterate over all of these when walking sysfs. I've tested this with userspace programs which use each of the deprecated instructions, and I've concurrently modified the support level for each of the features back-and-forth between HW and emulated to check that there are no spurious SIGILLs sent to userspace when the support level is changed. Signed-off-by: Mark Rutland <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: James Morse <[email protected]> Cc: Joey Gouly <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 0c5f416 commit 124c49b

File tree

3 files changed

+149
-192
lines changed

3 files changed

+149
-192
lines changed

arch/arm64/include/asm/traps.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,16 @@
1313

1414
struct pt_regs;
1515

16-
struct undef_hook {
17-
struct list_head node;
18-
u32 instr_mask;
19-
u32 instr_val;
20-
u64 pstate_mask;
21-
u64 pstate_val;
22-
int (*fn)(struct pt_regs *regs, u32 instr);
23-
};
16+
#ifdef CONFIG_ARMV8_DEPRECATED
17+
bool try_emulate_armv8_deprecated(struct pt_regs *regs, u32 insn);
18+
#else
19+
static inline bool
20+
try_emulate_armv8_deprecated(struct pt_regs *regs, u32 insn)
21+
{
22+
return false;
23+
}
24+
#endif /* CONFIG_ARMV8_DEPRECATED */
2425

25-
void register_undef_hook(struct undef_hook *hook);
26-
void unregister_undef_hook(struct undef_hook *hook);
2726
void force_signal_inject(int signal, int code, unsigned long address, unsigned long err);
2827
void arm64_notify_segfault(unsigned long addr);
2928
void arm64_force_sig_fault(int signo, int code, unsigned long far, const char *str);

0 commit comments

Comments
 (0)