[PATCH v2 0/2] KVM: nVMX: Disallow access to unsupported vmcs12 fields

Sean Christopherson
2025-12-30T22:02:22Z

Disallow accesses to vmcs12 fields that are defined by KVM, but are unsupported
in the current incarnation of KVM, e.g. due to lack of hardware support for the
underlying VMCS fields.

The primary motivation is to avoid having to carry the same logic for shadowed
VMCS fields, which can't play nice with unsupported fields since VMREAD/VMWRITE
will fail when attempting to transfer state between vmcs12 and the shadow VMCS.

v2:
- Name the array of KVM-defined fields kvm_supported_vmcs12_field_offsets,
e.g. so that it's no confused with what's supported by hardware. [Xin]
- Combine encodings in switch statements for fields shared fate. [Xin]
- Drop the extern declaration of supported_vmcs12_field_offsets. [Chao]
- Handle GUEST_INTR_STATUS in cpu_has_vmcs12_field() and add a patch to
drop the custom handling from init_vmcs_shadow_fields(). [Chao]

v1: https://lore.kernel.org/all/20251216012918.1707681-1-seanjc@google.com

Sean Christopherson (2):
KVM: nVMX: Disallow access to vmcs12 fields that aren't supported by
"hardware"
KVM: nVMX: Remove explicit filtering of GUEST_INTR_STATUS from shadow
VMCS fields

arch/x86/kvm/vmx/nested.c | 17 +++-------
arch/x86/kvm/vmx/vmcs.h | 8 +++++
arch/x86/kvm/vmx/vmcs12.c | 70 +++++++++++++++++++++++++++++++++++++--
arch/x86/kvm/vmx/vmcs12.h | 6 ++--
arch/x86/kvm/vmx/vmx.c | 2 ++
5 files changed, 86 insertions(+), 17 deletions(-)

base-commit: 9448598b22c50c8a5bb77a9103e2d49f134c9578
--
2.52.0.351.gbe84eed79e-goog