提交 9cb470cb 编写于 作者: T Thomas Gleixner 提交者: Aichun Shi

x86/fpu: Provide a proper function for ex_handler_fprestore()

mainline inclusion
from mainline-v5.16-rc1
commit 079ec41b
category: feature
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I590ZC
CVE: NA

Intel-SIG: commit 079ec41b x86/fpu: Provide a proper function for
ex_handler_fprestore().

--------------------------------

To make upcoming changes for support of dynamically enabled features
simpler, provide a proper function for the exception handler which removes
exposure of FPU internals.
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
Signed-off-by: NBorislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20211015011540.053515012@linutronix.deSigned-off-by: NLin Wang <lin.x.wang@intel.com>
Signed-off-by: NAichun Shi <aichun.shi@intel.com>
上级 6a08c572
......@@ -86,6 +86,7 @@ static inline void update_pasid(void) { }
/* Trap handling */
extern int fpu__exception_code(struct fpu *fpu, int trap_nr);
extern void fpu_sync_fpstate(struct fpu *fpu);
extern void fpu_reset_from_exception_fixup(void);
/* Boot, hotplug and resume */
extern void fpu__init_cpu(void);
......@@ -102,9 +103,6 @@ static inline void fpstate_init_soft(struct swregs_state *soft) {}
/* State tracking */
DECLARE_PER_CPU(struct fpu *, fpu_fpregs_owner_ctx);
/* fpstate */
extern union fpregs_state init_fpstate;
/* fpstate-related functions which are exported to KVM */
extern void fpu_init_fpstate_user(struct fpu *fpu);
......
......@@ -155,6 +155,11 @@ void restore_fpregs_from_fpstate(union fpregs_state *fpstate, u64 mask)
}
}
void fpu_reset_from_exception_fixup(void)
{
restore_fpregs_from_fpstate(&init_fpstate, xfeatures_mask_fpstate());
}
#if IS_ENABLED(CONFIG_KVM)
void fpu_swap_kvm_fpu(struct fpu *save, struct fpu *rstor, u64 restore_mask)
{
......
......@@ -2,6 +2,8 @@
#ifndef __X86_KERNEL_FPU_INTERNAL_H
#define __X86_KERNEL_FPU_INTERNAL_H
extern union fpregs_state init_fpstate;
/* CPU feature check wrappers */
static __always_inline __pure bool use_xsave(void)
{
......
......@@ -4,8 +4,7 @@
#include <linux/sched/debug.h>
#include <xen/xen.h>
#include <asm/fpu/signal.h>
#include <asm/fpu/xstate.h>
#include <asm/fpu/api.h>
#include <asm/sev-es.h>
#include <asm/traps.h>
#include <asm/kdebug.h>
......@@ -66,7 +65,7 @@ __visible bool ex_handler_fprestore(const struct exception_table_entry *fixup,
WARN_ONCE(1, "Bad FPU state detected at %pB, reinitializing FPU registers.",
(void *)instruction_pointer(regs));
restore_fpregs_from_fpstate(&init_fpstate, xfeatures_mask_fpstate());
fpu_reset_from_exception_fixup();
return true;
}
EXPORT_SYMBOL_GPL(ex_handler_fprestore);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册