]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: SVM: Truncate INVLPGA address in compatibility mode
authorSean Christopherson <seanjc@google.com>
Fri, 29 May 2026 22:21:44 +0000 (15:21 -0700)
committerSean Christopherson <seanjc@google.com>
Wed, 3 Jun 2026 12:34:45 +0000 (05:34 -0700)
Check for full 64-bit mode, not just long mode, when truncating the
virtual address as part of INVLPGA emulation.  Compatibility mode doesn't
support 64-bit addressing.

Note, the FIXME still applies, e.g. if the guest deliberately targeted
EAX while in 64-bit via an address size override.  That flaw isn't worth
fixing as it would require decoding the code stream, which would open an
entirely different can of worms, and in practice no sane guest would shove
garbage into RAX[63:32] and execute INVLPGA.

Note #2, VMSAVE, VMLOAD, and VMRUN all suffer from the same architectural
flaw of not providing the full linear address in a VMCB exit information
field, because, quoting the APM verbatim:

  the linear address is available directly from the guest rAX register

(VMSAVE, VMLOAD, and VMRUN take a physical address, but their behavior
with respect to rAX is otherwise identical).

Fixes: bc9eff67fc35 ("KVM: SVM: Use default rAX size for INVLPGA emulation")
Reviewed-by: Yosry Ahmed <yosry@kernel.org>
Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com>
Link: https://patch.msgid.link/20260529222223.870923-2-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/svm.c

index 95c411da6f2ceeec0147febb43d8c1e6fd2c1103..be15cb51680323e6e851644c11b89d5c1d1153d5 100644 (file)
@@ -2404,7 +2404,7 @@ static int invlpga_interception(struct kvm_vcpu *vcpu)
                return 1;
 
        /* FIXME: Handle an address size prefix. */
-       if (!is_long_mode(vcpu))
+       if (!is_64_bit_mode(vcpu))
                gva = (u32)gva;
 
        trace_kvm_invlpga(to_svm(vcpu)->vmcb->save.rip, asid, gva);