]> git.ipfire.org Git - thirdparty/linux.git/commit
KVM: x86: Generalize IBRS virtualization on emulated VM-exit
authorYosry Ahmed <yosry.ahmed@linux.dev>
Fri, 21 Feb 2025 16:33:52 +0000 (16:33 +0000)
committerSean Christopherson <seanjc@google.com>
Thu, 24 Apr 2025 18:18:32 +0000 (11:18 -0700)
commit656d9624bd21d35499eaa5ee97fda6def62901c8
tree2c92de11ac0f5026cf8c6f4cad8173ce208cd6cb
parent65ca2872015c232d6743b497e3c08ff96596b917
KVM: x86: Generalize IBRS virtualization on emulated VM-exit

Commit 2e7eab81425a ("KVM: VMX: Execute IBPB on emulated VM-exit when
guest has IBRS") added an IBPB in the emulated VM-exit path on Intel to
properly virtualize IBRS by providing separate predictor modes for L1
and L2.

AMD requires similar handling, except when IbrsSameMode is enumerated by
the host CPU (which is the case on most/all AMD CPUs). With
IbrsSameMode, hardware IBRS is sufficient and no extra handling is
needed from KVM.

Generalize the handling in nested_vmx_vmexit() by moving it into a
generic function, add the AMD handling, and use it in
nested_svm_vmexit() too. The main reason for using a generic function is
to have a single place to park the huge comment about virtualizing IBRS.

Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Reviewed-by: Jim Mattson <jmattson@google.com>
Link: https://lore.kernel.org/r/20250221163352.3818347-4-yosry.ahmed@linux.dev
[sean: use kvm_nested_vmexit_handle_spec_ctrl() for the helper]
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/nested.c
arch/x86/kvm/vmx/nested.c
arch/x86/kvm/x86.h