diff mbox series

[v3,4/4] KVM: SVM: fix emulation of msr reads/writes of MSR_FS_BASE and MSR_GS_BASE

Message ID 20240815123349.729017-5-mlevitsk@redhat.com (mailing list archive)
State New, archived
Headers show
Series Relax canonical checks on some arch msrs | expand

Commit Message

Maxim Levitsky Aug. 15, 2024, 12:33 p.m. UTC
If these msrs are read by the emulator (e.g due to 'force emulation'
prefix), SVM code currently fails to extract the corresponding segment
bases, and return them to the emulator.

Fix that.

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 arch/x86/kvm/svm/svm.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Sean Christopherson Aug. 16, 2024, 10:04 p.m. UTC | #1
On Thu, Aug 15, 2024, Maxim Levitsky wrote:
> If these msrs are read by the emulator (e.g due to 'force emulation'
> prefix), SVM code currently fails to extract the corresponding segment
> bases, and return them to the emulator.

I'll apply this one for 6.11 and tag it for stable, i.e. no need to include this
patch in v4.
Sean Christopherson Aug. 24, 2024, 12:07 a.m. UTC | #2
On Fri, Aug 16, 2024, Sean Christopherson wrote:
> On Thu, Aug 15, 2024, Maxim Levitsky wrote:
> > If these msrs are read by the emulator (e.g due to 'force emulation'
> > prefix), SVM code currently fails to extract the corresponding segment
> > bases, and return them to the emulator.
> 
> I'll apply this one for 6.11 and tag it for stable, i.e. no need to include this
> patch in v4.

I appear to have missed my normal "thank you" for this, so here it is, in kvm-x86
fixes:

[1/4] KVM: SVM: fix emulation of msr reads/writes of MSR_FS_BASE and MSR_GS_BASE
      https://github.com/kvm-x86/linux/commit/dad1613e0533
diff mbox series

Patch

diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index a04f6627b237..be3fc54700e3 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -2876,6 +2876,12 @@  static int svm_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 	case MSR_CSTAR:
 		msr_info->data = svm->vmcb01.ptr->save.cstar;
 		break;
+	case MSR_GS_BASE:
+		msr_info->data = svm->vmcb01.ptr->save.gs.base;
+		break;
+	case MSR_FS_BASE:
+		msr_info->data = svm->vmcb01.ptr->save.fs.base;
+		break;
 	case MSR_KERNEL_GS_BASE:
 		msr_info->data = svm->vmcb01.ptr->save.kernel_gs_base;
 		break;
@@ -3101,6 +3107,12 @@  static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
 	case MSR_CSTAR:
 		svm->vmcb01.ptr->save.cstar = data;
 		break;
+	case MSR_GS_BASE:
+		svm->vmcb01.ptr->save.gs.base = data;
+		break;
+	case MSR_FS_BASE:
+		svm->vmcb01.ptr->save.fs.base = data;
+		break;
 	case MSR_KERNEL_GS_BASE:
 		svm->vmcb01.ptr->save.kernel_gs_base = data;
 		break;