]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: SVM: Properly check RAX in the emulator for SVM instructions
authorYosry Ahmed <yosry@kernel.org>
Mon, 16 Mar 2026 20:27:24 +0000 (20:27 +0000)
committerSean Christopherson <seanjc@google.com>
Fri, 3 Apr 2026 23:08:00 +0000 (16:08 -0700)
commitc85aaff26d55920d783adac431a59ec738a35aef
tree9dfe1ba69b0565294d35de5cdb75dd554d6efdc8
parent7212094baef5acabef1969d77781a6527c09d743
KVM: SVM: Properly check RAX in the emulator for SVM instructions

Architecturally, VMRUN/VMLOAD/VMSAVE should generate a #GP if the
physical address in RAX is not supported. check_svme_pa() hardcodes this
to checking that bits 63-48 are not set. This is incorrect on HW
supporting 52 bits of physical address space. Additionally, the emulator
does not check if the address is not aligned, which should also result
in #GP.

Use page_address_valid() which properly checks alignment and the address
legality based on the guest's MAXPHYADDR. Plumb it through
x86_emulate_ops, similar to is_canonical_addr(), to avoid directly
accessing the vCPU object in emulator code.

Fixes: 01de8b09e606 ("KVM: SVM: Add intercept checks for SVM instructions")
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Yosry Ahmed <yosry@kernel.org>
Link: https://patch.msgid.link/20260316202732.3164936-2-yosry@kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/emulate.c
arch/x86/kvm/kvm_emulate.h
arch/x86/kvm/x86.c