Message ID | 20211208000359.2853257-9-yang.zhong@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | AMX Support in KVM | expand |
On Tue, Dec 07 2021 at 19:03, Yang Zhong wrote: > From: Jing Liu <jing2.liu@intel.com> > > xfd_update_state() is the interface to update IA32_XFD and its per-cpu > cache. All callers of this interface are currently in fpu core. KVM only > indirectly triggers IA32_XFD update via a helper function > (fpu_swap_kvm_fpstate()) when switching between user fpu and guest fpu. > > Supporting AMX in guest now requires KVM to directly update IA32_XFD > with the guest value (when emulating WRMSR) so XSAVE/XRSTOR can manage > XSTATE components correctly inside guest. > > This patch moves xfd_update_state() from fpu/xstate.h to fpu/xstate.c s/This patch moves/Move/ please. See Documentation/process/submitting-patches.rst and search for 'This patch' > and export it for reference outside of fpu core. > > Signed-off-by: Jing Liu <jing2.liu@intel.com> > Signed-off-by: Yang Zhong <yang.zhong@intel.com> > --- > arch/x86/include/asm/fpu/api.h | 2 ++ > arch/x86/kernel/fpu/xstate.c | 12 ++++++++++++ > arch/x86/kernel/fpu/xstate.h | 14 +------------- > 3 files changed, 15 insertions(+), 13 deletions(-) > > diff --git a/arch/x86/include/asm/fpu/api.h b/arch/x86/include/asm/fpu/api.h > index 7532f73c82a6..999d89026be9 100644 > --- a/arch/x86/include/asm/fpu/api.h > +++ b/arch/x86/include/asm/fpu/api.h > @@ -131,8 +131,10 @@ DECLARE_PER_CPU(struct fpu *, fpu_fpregs_owner_ctx); > /* Process cleanup */ > #ifdef CONFIG_X86_64 > extern void fpstate_free(struct fpu *fpu); > +extern void xfd_update_state(struct fpstate *fpstate); > #else > static inline void fpstate_free(struct fpu *fpu) { } > +static void xfd_update_state(struct fpstate *fpstate) { } Try a 32bit build to see the warnings this causes. That wants to be 'static inline void' obviously. > #ifdef CONFIG_X86_64 > -static inline void xfd_update_state(struct fpstate *fpstate) > -{ > - if (fpu_state_size_dynamic()) { > - u64 xfd = fpstate->xfd; > - > - if (__this_cpu_read(xfd_state) != xfd) { > - wrmsrl(MSR_IA32_XFD, xfd); > - __this_cpu_write(xfd_state, xfd); > - } > - } > -} > -#else > -static inline void xfd_update_state(struct fpstate *fpstate) { } > +extern void xfd_update_state(struct fpstate *fpstate); Why? It's already declared in the global header. So all of this has to be simply removed, no? Thanks, tglx
diff --git a/arch/x86/include/asm/fpu/api.h b/arch/x86/include/asm/fpu/api.h index 7532f73c82a6..999d89026be9 100644 --- a/arch/x86/include/asm/fpu/api.h +++ b/arch/x86/include/asm/fpu/api.h @@ -131,8 +131,10 @@ DECLARE_PER_CPU(struct fpu *, fpu_fpregs_owner_ctx); /* Process cleanup */ #ifdef CONFIG_X86_64 extern void fpstate_free(struct fpu *fpu); +extern void xfd_update_state(struct fpstate *fpstate); #else static inline void fpstate_free(struct fpu *fpu) { } +static void xfd_update_state(struct fpstate *fpstate) { } #endif /* fpstate-related functions which are exported to KVM */ diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index fe3d8ed3db0e..3c39789deeb9 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c @@ -1750,6 +1750,18 @@ int xfd_enable_guest_features(struct fpu_guest *guest_fpu) return __xfd_enable_feature(xfd_err, guest_fpu); } +void xfd_update_state(struct fpstate *fpstate) +{ + if (fpu_state_size_dynamic()) { + u64 xfd = fpstate->xfd; + + if (__this_cpu_read(xfd_state) != xfd) { + wrmsrl(MSR_IA32_XFD, xfd); + __this_cpu_write(xfd_state, xfd); + } + } +} +EXPORT_SYMBOL_GPL(xfd_update_state); #else /* CONFIG_X86_64 */ static inline int xstate_request_perm(unsigned long idx, bool guest) { diff --git a/arch/x86/kernel/fpu/xstate.h b/arch/x86/kernel/fpu/xstate.h index 3254e2b5f17f..651bd29977b9 100644 --- a/arch/x86/kernel/fpu/xstate.h +++ b/arch/x86/kernel/fpu/xstate.h @@ -149,19 +149,7 @@ static inline void xfd_validate_state(struct fpstate *fpstate, u64 mask, bool rs #endif #ifdef CONFIG_X86_64 -static inline void xfd_update_state(struct fpstate *fpstate) -{ - if (fpu_state_size_dynamic()) { - u64 xfd = fpstate->xfd; - - if (__this_cpu_read(xfd_state) != xfd) { - wrmsrl(MSR_IA32_XFD, xfd); - __this_cpu_write(xfd_state, xfd); - } - } -} -#else -static inline void xfd_update_state(struct fpstate *fpstate) { } +extern void xfd_update_state(struct fpstate *fpstate); #endif /*