extable.c (d52a7344bdfa9c3442d3f86fb3501d9343726c76) extable.c (5ce8e39f55521c762f0e6d1bba9597284b1f2e69)
1// SPDX-License-Identifier: GPL-2.0-only
2#include <linux/extable.h>
3#include <linux/uaccess.h>
4#include <linux/sched/debug.h>
5#include <linux/bitfield.h>
6#include <xen/xen.h>
7
8#include <asm/fpu/api.h>
9#include <asm/sev.h>
10#include <asm/traps.h>
11#include <asm/kdebug.h>
12#include <asm/insn-eval.h>
1// SPDX-License-Identifier: GPL-2.0-only
2#include <linux/extable.h>
3#include <linux/uaccess.h>
4#include <linux/sched/debug.h>
5#include <linux/bitfield.h>
6#include <xen/xen.h>
7
8#include <asm/fpu/api.h>
9#include <asm/sev.h>
10#include <asm/traps.h>
11#include <asm/kdebug.h>
12#include <asm/insn-eval.h>
13#include <asm/sgx.h>
13
14static inline unsigned long *pt_regs_nr(struct pt_regs *regs, int nr)
15{
16 int reg_offset = pt_regs_offset(regs, nr);
17 static unsigned long __dummy;
18
19 if (WARN_ON_ONCE(reg_offset < 0))
20 return &__dummy;

--- 21 unchanged lines hidden (view full) ---

42
43static bool ex_handler_fault(const struct exception_table_entry *fixup,
44 struct pt_regs *regs, int trapnr)
45{
46 regs->ax = trapnr;
47 return ex_handler_default(fixup, regs);
48}
49
14
15static inline unsigned long *pt_regs_nr(struct pt_regs *regs, int nr)
16{
17 int reg_offset = pt_regs_offset(regs, nr);
18 static unsigned long __dummy;
19
20 if (WARN_ON_ONCE(reg_offset < 0))
21 return &__dummy;

--- 21 unchanged lines hidden (view full) ---

43
44static bool ex_handler_fault(const struct exception_table_entry *fixup,
45 struct pt_regs *regs, int trapnr)
46{
47 regs->ax = trapnr;
48 return ex_handler_default(fixup, regs);
49}
50
51static bool ex_handler_sgx(const struct exception_table_entry *fixup,
52 struct pt_regs *regs, int trapnr)
53{
54 regs->ax = trapnr | SGX_ENCLS_FAULT_FLAG;
55 return ex_handler_default(fixup, regs);
56}
57
50/*
51 * Handler for when we fail to restore a task's FPU state. We should never get
52 * here because the FPU state of a task using the FPU (task->thread.fpu.state)
53 * should always be valid. However, past bugs have allowed userspace to set
54 * reserved bits in the XSAVE area using PTRACE_SETREGSET or sys_rt_sigreturn().
55 * These caused XRSTOR to fail when switching to the task, leaking the FPU
56 * registers of the task previously executing on the CPU. Mitigate this class
57 * of vulnerability by restoring from the initial state (essentially, zeroing

--- 144 unchanged lines hidden (view full) ---

202 break;
203 case EX_TYPE_RDMSR_IN_MCE:
204 ex_handler_msr_mce(regs, false);
205 break;
206 case EX_TYPE_POP_ZERO:
207 return ex_handler_pop_zero(e, regs);
208 case EX_TYPE_IMM_REG:
209 return ex_handler_imm_reg(e, regs, reg, imm);
58/*
59 * Handler for when we fail to restore a task's FPU state. We should never get
60 * here because the FPU state of a task using the FPU (task->thread.fpu.state)
61 * should always be valid. However, past bugs have allowed userspace to set
62 * reserved bits in the XSAVE area using PTRACE_SETREGSET or sys_rt_sigreturn().
63 * These caused XRSTOR to fail when switching to the task, leaking the FPU
64 * registers of the task previously executing on the CPU. Mitigate this class
65 * of vulnerability by restoring from the initial state (essentially, zeroing

--- 144 unchanged lines hidden (view full) ---

210 break;
211 case EX_TYPE_RDMSR_IN_MCE:
212 ex_handler_msr_mce(regs, false);
213 break;
214 case EX_TYPE_POP_ZERO:
215 return ex_handler_pop_zero(e, regs);
216 case EX_TYPE_IMM_REG:
217 return ex_handler_imm_reg(e, regs, reg, imm);
218 case EX_TYPE_FAULT_SGX:
219 return ex_handler_sgx(e, regs, trapnr);
210 }
211 BUG();
212}
213
214extern unsigned int early_recursion_flag;
215
216/* Restricted version used during very early boot */
217void __init early_fixup_exception(struct pt_regs *regs, int trapnr)

--- 59 unchanged lines hidden ---
220 }
221 BUG();
222}
223
224extern unsigned int early_recursion_flag;
225
226/* Restricted version used during very early boot */
227void __init early_fixup_exception(struct pt_regs *regs, int trapnr)

--- 59 unchanged lines hidden ---