提交 3f050fa0 编写于 作者: T Thomas Gleixner 提交者: Lin Wang

x86/fpu: Rename fregs-related copy functions

mainline inclusion
from mainline-v5.14-rc1
commit 6fdc908c
category: feature
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I590ZC
CVE: NA

Intel-SIG: commit 6fdc908c x86/fpu: Rename fregs-related copy functions.

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

The function names for fnsave/fnrstor operations are horribly named and
a permanent source of confusion.

Rename:
	copy_kernel_to_fregs() to frstor()
	copy_fregs_to_user()   to fnsave_to_user_sigframe()
	copy_user_to_fregs()   to frstor_from_user_sigframe()

so it's clear what these are doing. All these functions are really low
level wrappers around the equally named instructions, so mapping to the
documentation is just natural.

No functional change.
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
Signed-off-by: NBorislav Petkov <bp@suse.de>
Reviewed-by: NBorislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210623121454.223594101@linutronix.deSigned-off-by: NLin Wang <lin.x.wang@intel.com>
上级 aaefc990
...@@ -125,7 +125,7 @@ static inline void fpstate_init_soft(struct swregs_state *soft) {} ...@@ -125,7 +125,7 @@ static inline void fpstate_init_soft(struct swregs_state *soft) {}
_ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_fprestore) \ _ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_fprestore) \
: output : input) : output : input)
static inline int copy_fregs_to_user(struct fregs_state __user *fx) static inline int fnsave_to_user_sigframe(struct fregs_state __user *fx)
{ {
return user_insn(fnsave %[fx]; fwait, [fx] "=m" (*fx), "m" (*fx)); return user_insn(fnsave %[fx]; fwait, [fx] "=m" (*fx), "m" (*fx));
} }
...@@ -163,17 +163,17 @@ static inline int fxrstor_from_user_sigframe(struct fxregs_state __user *fx) ...@@ -163,17 +163,17 @@ static inline int fxrstor_from_user_sigframe(struct fxregs_state __user *fx)
return user_insn(fxrstorq %[fx], "=m" (*fx), [fx] "m" (*fx)); return user_insn(fxrstorq %[fx], "=m" (*fx), [fx] "m" (*fx));
} }
static inline void copy_kernel_to_fregs(struct fregs_state *fx) static inline void frstor(struct fregs_state *fx)
{ {
kernel_insn(frstor %[fx], "=m" (*fx), [fx] "m" (*fx)); kernel_insn(frstor %[fx], "=m" (*fx), [fx] "m" (*fx));
} }
static inline int copy_kernel_to_fregs_err(struct fregs_state *fx) static inline int frstor_safe(struct fregs_state *fx)
{ {
return kernel_insn_err(frstor %[fx], "=m" (*fx), [fx] "m" (*fx)); return kernel_insn_err(frstor %[fx], "=m" (*fx), [fx] "m" (*fx));
} }
static inline int copy_user_to_fregs(struct fregs_state __user *fx) static inline int frstor_from_user_sigframe(struct fregs_state __user *fx)
{ {
return user_insn(frstor %[fx], "=m" (*fx), [fx] "m" (*fx)); return user_insn(frstor %[fx], "=m" (*fx), [fx] "m" (*fx));
} }
...@@ -390,7 +390,7 @@ static inline void __copy_kernel_to_fpregs(union fpregs_state *fpstate, u64 mask ...@@ -390,7 +390,7 @@ static inline void __copy_kernel_to_fpregs(union fpregs_state *fpstate, u64 mask
if (use_fxsr()) if (use_fxsr())
fxrstor(&fpstate->fxsave); fxrstor(&fpstate->fxsave);
else else
copy_kernel_to_fregs(&fpstate->fsave); frstor(&fpstate->fsave);
} }
} }
......
...@@ -318,7 +318,7 @@ static inline void copy_init_fpstate_to_fpregs(u64 features_mask) ...@@ -318,7 +318,7 @@ static inline void copy_init_fpstate_to_fpregs(u64 features_mask)
else if (use_fxsr()) else if (use_fxsr())
fxrstor(&init_fpstate.fxsave); fxrstor(&init_fpstate.fxsave);
else else
copy_kernel_to_fregs(&init_fpstate.fsave); frstor(&init_fpstate.fsave);
if (boot_cpu_has(X86_FEATURE_OSPKE)) if (boot_cpu_has(X86_FEATURE_OSPKE))
copy_init_pkru_to_fpregs(); copy_init_pkru_to_fpregs();
......
...@@ -133,7 +133,7 @@ static inline int copy_fpregs_to_sigframe(struct xregs_state __user *buf) ...@@ -133,7 +133,7 @@ static inline int copy_fpregs_to_sigframe(struct xregs_state __user *buf)
else if (use_fxsr()) else if (use_fxsr())
err = fxsave_to_user_sigframe((struct fxregs_state __user *) buf); err = fxsave_to_user_sigframe((struct fxregs_state __user *) buf);
else else
err = copy_fregs_to_user((struct fregs_state __user *) buf); err = fnsave_to_user_sigframe((struct fregs_state __user *) buf);
if (unlikely(err) && __clear_user(buf, fpu_user_xstate_size)) if (unlikely(err) && __clear_user(buf, fpu_user_xstate_size))
err = -EFAULT; err = -EFAULT;
...@@ -274,7 +274,7 @@ static int copy_user_to_fpregs_zeroing(void __user *buf, u64 xbv, int fx_only) ...@@ -274,7 +274,7 @@ static int copy_user_to_fpregs_zeroing(void __user *buf, u64 xbv, int fx_only)
} else if (use_fxsr()) { } else if (use_fxsr()) {
return fxrstor_from_user_sigframe(buf); return fxrstor_from_user_sigframe(buf);
} else } else
return copy_user_to_fregs(buf); return frstor_from_user_sigframe(buf);
} }
static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size)
...@@ -465,7 +465,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) ...@@ -465,7 +465,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size)
goto out; goto out;
fpregs_lock(); fpregs_lock();
ret = copy_kernel_to_fregs_err(&fpu->state.fsave); ret = frstor_safe(&fpu->state.fsave);
} }
if (!ret) if (!ret)
fpregs_mark_activate(); fpregs_mark_activate();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册