x86/fpu: Provide fpu_update_guest_xfd() for IA32_XFD emulation
Guest XFD can be updated either in the emulation path or in the restore path. Provide a wrapper to update guest_fpu::fpstate::xfd. If the guest fpstate is currently in-use, also update the per-cpu xfd cache and the actual MSR. Signed-off-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Jing Liu <jing2.liu@intel.com> Signed-off-by: Yang Zhong <yang.zhong@intel.com> Message-Id: <20220105123532.12586-10-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
5ab2f45bba
commit
8eb9a48ac1
|
@ -140,6 +140,12 @@ extern void fpu_free_guest_fpstate(struct fpu_guest *gfpu);
|
|||
extern int fpu_swap_kvm_fpstate(struct fpu_guest *gfpu, bool enter_guest);
|
||||
extern int fpu_enable_guest_xfd_features(struct fpu_guest *guest_fpu, u64 xfeatures);
|
||||
|
||||
#ifdef CONFIG_X86_64
|
||||
extern void fpu_update_guest_xfd(struct fpu_guest *guest_fpu, u64 xfd);
|
||||
#else
|
||||
static inline void fpu_update_guest_xfd(struct fpu_guest *guest_fpu, u64 xfd) { }
|
||||
#endif
|
||||
|
||||
extern void fpu_copy_guest_fpstate_to_uabi(struct fpu_guest *gfpu, void *buf, unsigned int size, u32 pkru);
|
||||
extern int fpu_copy_uabi_to_guest_fpstate(struct fpu_guest *gfpu, const void *buf, u64 xcr0, u32 *vpkru);
|
||||
|
||||
|
|
|
@ -283,6 +283,18 @@ int fpu_enable_guest_xfd_features(struct fpu_guest *guest_fpu, u64 xfeatures)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(fpu_enable_guest_xfd_features);
|
||||
|
||||
#ifdef CONFIG_X86_64
|
||||
void fpu_update_guest_xfd(struct fpu_guest *guest_fpu, u64 xfd)
|
||||
{
|
||||
fpregs_lock();
|
||||
guest_fpu->fpstate->xfd = xfd;
|
||||
if (guest_fpu->fpstate->in_use)
|
||||
xfd_update_state(guest_fpu->fpstate);
|
||||
fpregs_unlock();
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(fpu_update_guest_xfd);
|
||||
#endif /* CONFIG_X86_64 */
|
||||
|
||||
int fpu_swap_kvm_fpstate(struct fpu_guest *guest_fpu, bool enter_guest)
|
||||
{
|
||||
struct fpstate *guest_fps = guest_fpu->fpstate;
|
||||
|
|
Loading…
Reference in New Issue