Commit 18b3fa1a authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Borislav Petkov

x86/fpu: Convert restore_fpregs_from_fpstate() to struct fpstate

Convert restore_fpregs_from_fpstate() and related code to the new
register storage mechanism in preparation for dynamically sized buffers.

No functional change.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20211013145322.347395546@linutronix.de
parent f83ac56a
...@@ -40,7 +40,7 @@ extern bool copy_fpstate_to_sigframe(void __user *buf, void __user *fp, int size ...@@ -40,7 +40,7 @@ extern bool copy_fpstate_to_sigframe(void __user *buf, void __user *fp, int size
extern void fpu__clear_user_states(struct fpu *fpu); extern void fpu__clear_user_states(struct fpu *fpu);
extern bool fpu__restore_sig(void __user *buf, int ia32_frame); extern bool fpu__restore_sig(void __user *buf, int ia32_frame);
extern void restore_fpregs_from_fpstate(union fpregs_state *fpstate, u64 mask); extern void restore_fpregs_from_fpstate(struct fpstate *fpstate, u64 mask);
extern bool copy_fpstate_to_sigframe(void __user *buf, void __user *fp, int size); extern bool copy_fpstate_to_sigframe(void __user *buf, void __user *fp, int size);
......
...@@ -74,7 +74,7 @@ static inline void fpregs_restore_userregs(void) ...@@ -74,7 +74,7 @@ static inline void fpregs_restore_userregs(void)
*/ */
mask = xfeatures_mask_restore_user() | mask = xfeatures_mask_restore_user() |
xfeatures_mask_supervisor(); xfeatures_mask_supervisor();
restore_fpregs_from_fpstate(&fpu->state, mask); restore_fpregs_from_fpstate(fpu->fpstate, mask);
fpregs_activate(fpu); fpregs_activate(fpu);
fpu->last_cpu = cpu; fpu->last_cpu = cpu;
......
...@@ -129,7 +129,7 @@ void save_fpregs_to_fpstate(struct fpu *fpu) ...@@ -129,7 +129,7 @@ void save_fpregs_to_fpstate(struct fpu *fpu)
frstor(&fpu->state.fsave); frstor(&fpu->state.fsave);
} }
void restore_fpregs_from_fpstate(union fpregs_state *fpstate, u64 mask) void restore_fpregs_from_fpstate(struct fpstate *fpstate, u64 mask)
{ {
/* /*
* AMD K7/K8 and later CPUs up to Zen don't save/restore * AMD K7/K8 and later CPUs up to Zen don't save/restore
...@@ -146,18 +146,18 @@ void restore_fpregs_from_fpstate(union fpregs_state *fpstate, u64 mask) ...@@ -146,18 +146,18 @@ void restore_fpregs_from_fpstate(union fpregs_state *fpstate, u64 mask)
} }
if (use_xsave()) { if (use_xsave()) {
os_xrstor(&fpstate->xsave, mask); os_xrstor(&fpstate->regs.xsave, mask);
} else { } else {
if (use_fxsr()) if (use_fxsr())
fxrstor(&fpstate->fxsave); fxrstor(&fpstate->regs.fxsave);
else else
frstor(&fpstate->fsave); frstor(&fpstate->regs.fsave);
} }
} }
void fpu_reset_from_exception_fixup(void) void fpu_reset_from_exception_fixup(void)
{ {
restore_fpregs_from_fpstate(&init_fpstate.regs, xfeatures_mask_fpstate()); restore_fpregs_from_fpstate(&init_fpstate, xfeatures_mask_fpstate());
} }
#if IS_ENABLED(CONFIG_KVM) #if IS_ENABLED(CONFIG_KVM)
...@@ -176,7 +176,7 @@ void fpu_swap_kvm_fpu(struct fpu *save, struct fpu *rstor, u64 restore_mask) ...@@ -176,7 +176,7 @@ void fpu_swap_kvm_fpu(struct fpu *save, struct fpu *rstor, u64 restore_mask)
if (rstor) { if (rstor) {
restore_mask &= xfeatures_mask_fpstate(); restore_mask &= xfeatures_mask_fpstate();
restore_fpregs_from_fpstate(&rstor->state, restore_mask); restore_fpregs_from_fpstate(rstor->fpstate, restore_mask);
} }
fpregs_mark_activate(); fpregs_mark_activate();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment