]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: nSVM: Clear exit_code_hi in VMCB when synthesizing nested VM-Exits
authorSean Christopherson <seanjc@google.com>
Thu, 13 Nov 2025 22:56:13 +0000 (14:56 -0800)
committerSean Christopherson <seanjc@google.com>
Thu, 4 Dec 2025 15:24:04 +0000 (07:24 -0800)
Explicitly clear exit_code_hi in the VMCB when synthesizing "normal"
nested VM-Exits, as the full exit code is a 64-bit value (spoiler alert),
and all exit codes for non-failing VMRUN use only bits 31:0.

Cc: Jim Mattson <jmattson@google.com>
Cc: Yosry Ahmed <yosry.ahmed@linux.dev>
Cc: stable@vger.kernel.org
Reviewed-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Link: https://patch.msgid.link/20251113225621.1688428-2-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/svm.c
arch/x86/kvm/svm/svm.h

index 9d29b2e7e855d6da0d7c58e83bcfb1bc310c860e..eeeb4ae4c617ebadfd9a4bd2697c8bc72a14ec88 100644 (file)
@@ -2435,6 +2435,7 @@ static bool check_selective_cr0_intercepted(struct kvm_vcpu *vcpu,
 
        if (cr0 ^ val) {
                svm->vmcb->control.exit_code = SVM_EXIT_CR0_SEL_WRITE;
+               svm->vmcb->control.exit_code_hi = 0;
                ret = (nested_svm_exit_handled(svm) == NESTED_EXIT_DONE);
        }
 
@@ -4611,6 +4612,7 @@ static int svm_check_intercept(struct kvm_vcpu *vcpu,
        if (static_cpu_has(X86_FEATURE_NRIPS))
                vmcb->control.next_rip  = info->next_rip;
        vmcb->control.exit_code = icpt_info.exit_code;
+       vmcb->control.exit_code_hi = 0;
        vmexit = nested_svm_exit_handled(svm);
 
        ret = (vmexit == NESTED_EXIT_DONE) ? X86EMUL_INTERCEPTED
index dd78e64023450bb9f15d60c3b33680996bd4b507..e66a16e59b1a5fc3fd80c61ccf7c5dc52496c54d 100644 (file)
@@ -764,9 +764,10 @@ int nested_svm_vmexit(struct vcpu_svm *svm);
 
 static inline int nested_svm_simple_vmexit(struct vcpu_svm *svm, u32 exit_code)
 {
-       svm->vmcb->control.exit_code   = exit_code;
-       svm->vmcb->control.exit_info_1 = 0;
-       svm->vmcb->control.exit_info_2 = 0;
+       svm->vmcb->control.exit_code    = exit_code;
+       svm->vmcb->control.exit_code_hi = 0;
+       svm->vmcb->control.exit_info_1  = 0;
+       svm->vmcb->control.exit_info_2  = 0;
        return nested_svm_vmexit(svm);
 }