Re: [PATCH v9 21/22] KVM: nVMX: Guard SHADOW_FIELD_R[OW] macros with VMX feature checks

From: Chao Gao

Date: Tue Dec 02 2025 - 01:35:47 EST


On Sun, Oct 26, 2025 at 01:19:09PM -0700, Xin Li (Intel) wrote:
>From: Xin Li <xin3.li@xxxxxxxxx>
>
>Add VMX feature checks to the SHADOW_FIELD_R[OW] macros to prevent access
>to VMCS fields that may be unsupported on some CPUs.
>
>Functions like copy_shadow_to_vmcs12() and copy_vmcs12_to_shadow() access
>VMCS fields that may not exist on certain hardware, such as
>INJECTED_EVENT_DATA. To avoid VMREAD/VMWRITE warnings, skip syncing fields
>tied to unsupported VMX features.
>
>Signed-off-by: Xin Li <xin3.li@xxxxxxxxx>
>Signed-off-by: Xin Li (Intel) <xin@xxxxxxxxx>
>Tested-by: Shan Kang <shan.kang@xxxxxxxxx>
>Tested-by: Xuelian Guo <xuelian.guo@xxxxxxxxx>

Reviewed-by: Chao Gao <chao.gao@xxxxxxxxx>