OSDN Git Service

KVM: nVMX: Implement evmcs_field_offset() suitable for handle_vmread()
authorVitaly Kuznetsov <vkuznets@redhat.com>
Wed, 12 Jan 2022 17:01:33 +0000 (18:01 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 28 Jan 2022 12:38:26 +0000 (07:38 -0500)
commit892a42c10ddb945d3a4dcf07dccdf9cb98b21548
tree1e0ef7923f90ca66eaed8aa6ace9fa5fa6c31d60
parent2423a4c0d17418eca1ba1e3f48684cb2ab7523d5
KVM: nVMX: Implement evmcs_field_offset() suitable for handle_vmread()

In preparation to allowing reads from Enlightened VMCS from
handle_vmread(), implement evmcs_field_offset() to get the correct
read offset. get_evmcs_offset(), which is being used by KVM-on-Hyper-V,
is almost what's needed but a few things need to be adjusted. First,
WARN_ON() is unacceptable for handle_vmread() as any field can (in
theory) be supplied by the guest and not all fields are defined in
eVMCS v1. Second, we need to handle 'holes' in eVMCS (missing fields).
It also sounds like a good idea to WARN_ON() if such fields are ever
accessed by KVM-on-Hyper-V.

Implement dedicated evmcs_field_offset() helper.

No functional change intended.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20220112170134.1904308-5-vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/evmcs.c
arch/x86/kvm/vmx/evmcs.h