public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: Handle MXCSR in kvm_arch_vcpu_ioctl_{get,set}_fpu.
@ 2022-09-17  0:09 Justinien Bouron
  2022-09-20 21:33 ` Sean Christopherson
  0 siblings, 1 reply; 2+ messages in thread
From: Justinien Bouron @ 2022-09-17  0:09 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H. Peter Anvin
  Cc: Justinien Bouron, kvm, linux-kernel

kvm_arch_vcpu_ioctl_get_fpu does not set the mxcsr in the kvm_fpu
struct; conversely kvm_arch_vcpu_ioctl_set_fpu does not set the mxcsr
value in the fxregs_state struct of the vcpu.
This leads to the KVM_GET_FPU ioctl returning 0 as the mxcsr value,
regardless of the actual value on the vcpu; while KVM_SET_FPU leaves the
MXCSR on the vcpu untouched.

Fix kvm_arch_vcpu_ioctl_{get,set}_fpu to properly handle MXCSR.

Signed-off-by: Justinien Bouron <justinien.bouron@gmail.com>
---
 arch/x86/kvm/x86.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 43a6a7efc6ec..c33a2599a497 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -11462,6 +11462,7 @@ int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
 	fpu->last_ip = fxsave->rip;
 	fpu->last_dp = fxsave->rdp;
 	memcpy(fpu->xmm, fxsave->xmm_space, sizeof(fxsave->xmm_space));
+	fpu->mxcsr = fxsave->mxcsr;
 
 	vcpu_put(vcpu);
 	return 0;
@@ -11486,6 +11487,7 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
 	fxsave->rip = fpu->last_ip;
 	fxsave->rdp = fpu->last_dp;
 	memcpy(fxsave->xmm_space, fpu->xmm, sizeof(fxsave->xmm_space));
+	fxsave->mxcsr = fpu->mxcsr;
 
 	vcpu_put(vcpu);
 	return 0;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-20 21:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-17  0:09 [PATCH] KVM: x86: Handle MXCSR in kvm_arch_vcpu_ioctl_{get,set}_fpu Justinien Bouron
2022-09-20 21:33 ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox