• Paolo Bonzini's avatar
    KVM: VMX: optimize shadow VMCS copying · 44900ba6
    Paolo Bonzini authored
    Because all fields can be read/written with a single vmread/vmwrite on
    64-bit kernels, the switch statements in copy_vmcs12_to_shadow and
    copy_shadow_to_vmcs12 are unnecessary.
    
    What I did in this patch is to copy the two parts of 64-bit fields
    separately on 32-bit kernels, to keep all complicated #ifdef-ery
    in init_vmcs_shadow_fields.  The disadvantage is that 64-bit fields
    have to be listed separately in shadow_read_only/read_write_fields,
    but those are few and we can validate the arrays when building the
    VMREAD and VMWRITE bitmaps.  This saves a few hundred clock cycles
    per nested vmexit.
    
    However there is still a "switch" in vmcs_read_any and vmcs_write_any.
    So, while at it, this patch reorders the fields by type, hoping that
    the branch predictor appreciates it.
    
    Cc: Jim Mattson <jmattson@google.com>
    Cc: Wanpeng Li <wanpeng.li@hotmail.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
    44900ba6
vmx.c 346 KB