Skip to contentSkip to conversation

x86/kvm/nVMX: set exit_qualification correctly when nested_vmx_load_msr() fails

PATCH Applied Vitaly Kuznetsov 3 participants 4 messages Jul 12, 2018 – Jul 15, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/kvm/nVMX: set exit_qualification correctly when nested_vmx_load_msr() fails

Commit e79f245ddec1 ("X86/KVM: Properly update 'tsc_offset' to represent the running guest") introduced a regression in enter_vmx_non_root_mode():
when nested_vmx_load_msr() fails exit_qualification needs to point to the entry number we failed to validate. Intel's SDM states:

"VM-entry failure due to MSR loading. The exit qualification is loaded to indicate which entry in the VM-entry MSR-load area caused the problem (1 for the first entry, 2 for the second, etc.)."

Fixes e79f245ddec1 ("X86/KVM: Properly update 'tsc_offset' to represent the running guest")
---
 arch/x86/kvm/vmx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kvm/vmx.c +3 -1
index 65968649b365..be468c822892 100644
@@ -11720,8 +11720,10 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu)
 	msr_entry_idx = nested_vmx_load_msr(vcpu,
 					    vmcs12->vm_entry_msr_load_addr,
 					    vmcs12->vm_entry_msr_load_count);
-	if (msr_entry_idx)
+	if (msr_entry_idx) {
+		exit_qual = msr_entry_idx;
 		goto fail;
+	}
 
 	/*
 	 * Note no nested_vmx_succeed or nested_vmx_fail here. At this point
Signature · 1 line
2.14.4
#1 lore raw

This looks similar to my "[PATCH] kvm: nVMX: Restore exit qual for VM-entry failure due to MSR loading"

Quoted 35 lines · Vitaly Kuznetsov

Commit e79f245ddec1 ("X86/KVM: Properly update 'tsc_offset' to represent the running guest") introduced a regression in enter_vmx_non_root_mode():
when nested_vmx_load_msr() fails exit_qualification needs to point to the entry number we failed to validate. Intel's SDM states:

"VM-entry failure due to MSR loading. The exit qualification is loaded to indicate which entry in the VM-entry MSR-load area caused the problem (1 for the first entry, 2 for the second, etc.)."

Fixes e79f245ddec1 ("X86/KVM: Properly update 'tsc_offset' to represent the running guest")
---
 arch/x86/kvm/vmx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kvm/vmx.c +3 -2
index 65968649b365..be468c822892 100644
@@ -11720,8 +11720,10 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu)
        msr_entry_idx = nested_vmx_load_msr(vcpu,
                                            vmcs12->vm_entry_msr_load_addr,
                                            vmcs12->vm_entry_msr_load_count);
-       if (msr_entry_idx)
+       if (msr_entry_idx) {
+               exit_qual = msr_entry_idx;
                goto fail;
+       }
 
        /*
         * Note no nested_vmx_succeed or nested_vmx_fail here. At this point
--

2.14.4

#2 lore raw
Quoted 3 lines · Jim Mattson

This looks similar to my "[PATCH] kvm: nVMX: Restore exit qual for VM-entry failure due to MSR loading"

... which is still not in kvm/queue. Missed that, sorry! Let this one just be a gentle ping then :-)

Signature · 1 line
  Vitaly
maintainer Applied
#3 lore raw
Quoted 9 lines · Vitaly Kuznetsov
Quoted 3 lines · Jim Mattson

This looks similar to my "[PATCH] kvm: nVMX: Restore exit qual for VM-entry failure due to MSR loading"

... which is still not in kvm/queue. Missed that, sorry! Let this one just be a gentle ping then :-)

I queued Jim's patch, thanks.

Paolo