|
|
Log in / Subscribe / Register

KVM: nVMX: Disallow access to vmcs12 fields that aren't supported by "hardware"

From:  Sean Christopherson <seanjc-AT-google.com>
To:  Sean Christopherson <seanjc-AT-google.com>, Paolo Bonzini <pbonzini-AT-redhat.com>
Subject:  [PATCH v3 0/4] KVM: nVMX: Disallow access to vmcs12 fields that aren't supported by "hardware"
Date:  Thu, 08 Jan 2026 20:15:19 -0800
Message-ID:  <20260109041523.1027323-1-seanjc@google.com>
Cc:  kvm-AT-vger.kernel.org, linux-kernel-AT-vger.kernel.org, Xiaoyao Li <xiaoyao.li-AT-intel.com>, Chao Gao <chao.gao-AT-intel.com>, Xin Li <xin-AT-zytor.com>, Yosry Ahmed <yosry.ahmed-AT-linux.dev>
Archive-link:  Article

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.

v3:
 - Collect reviews. [Xin, Chao]
 - Actually filter out vmcs12 fields when configuring shadow VMCS. [Chao]
 - Move VMX MSR configuration into nested_vmx_hardware_setup().
 - Add ENC_TO_VMCS12_IDX. [Xiaoyao]
 - Use a Xiaoyao's crazy double ROL16 math. :-) [Xiaoyao, obviously]

v2:
 - https://lore.kernel.org/all/20251230220220.4122282-1-sean...
 - 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-sean...

Sean Christopherson (4):
  KVM: nVMX: Setup VMX MSRs on loading CPU during
    nested_vmx_hardware_setup()
  KVM: VMX: Add a wrapper around ROL16() to get a vmcs12 from a field
    encoding
  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/hyperv_evmcs.c |  2 +-
 arch/x86/kvm/vmx/hyperv_evmcs.h |  2 +-
 arch/x86/kvm/vmx/nested.c       | 28 +++++++------
 arch/x86/kvm/vmx/vmcs.h         |  9 ++++
 arch/x86/kvm/vmx/vmcs12.c       | 74 +++++++++++++++++++++++++++++++--
 arch/x86/kvm/vmx/vmcs12.h       |  8 ++--
 arch/x86/kvm/vmx/vmx.c          |  2 -
 7 files changed, 101 insertions(+), 24 deletions(-)


base-commit: 9448598b22c50c8a5bb77a9103e2d49f134c9578
-- 
2.52.0.457.g6b5491de43-goog




Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds