]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
KVM: vmx: shadow more fields that are read/written on every vmexits
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 13 Dec 2017 10:05:19 +0000 (11:05 +0100)
committerBrian Maly <brian.maly@oracle.com>
Mon, 5 Nov 2018 21:14:48 +0000 (16:14 -0500)
Compared to when VMCS shadowing was added to KVM, we are reading/writing
a few more fields: the PML index, the interrupt status and the preemption
timer value.  The first two are because we are exposing more features
to nested guests.  Adding them to the shadow VMCS field lists reduces
the cost of a vmexit by about 1000 clock cycles for each field that exists
on bare metal.

On the other hand, the guest BNDCFGS and TSC offset are not written on
fast paths, so remove them.

Suggested-by: Jim Mattson <jmattson@google.com>
Cc: Jim Mattson <jmattson@google.com>
Cc: Wanpeng Li <wanpeng.li@hotmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
(cherry picked from commit c5d167b27e00026711ad19a33a23d5d3d562148a)

Orabug: 28581045

Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
Conflicts:
arch/x86/kvm/vmx.c
Different context and dropped VMX_PREEMPTION_TIMER_VALUE shadow at it requires
a lot more dependencies.

Signed-off-by: Brian Maly <brian.maly@oracle.com>
arch/x86/kvm/vmx.c

index 8dd43d555b44e81b9d599c1a60aa8a9daae8bd43..5bda65682185c4ffb380550d03fd47ca9d7bb32b 100644 (file)
@@ -766,11 +766,11 @@ static unsigned long shadow_read_write_fields[] = {
        GUEST_CS_LIMIT,
        GUEST_CS_BASE,
        GUEST_ES_BASE,
-       GUEST_BNDCFGS,
+       GUEST_PML_INDEX,
+       GUEST_INTR_STATUS,
        CR0_GUEST_HOST_MASK,
        CR0_READ_SHADOW,
        CR4_READ_SHADOW,
-       TSC_OFFSET,
        EXCEPTION_BITMAP,
        CPU_BASED_VM_EXEC_CONTROL,
        VM_ENTRY_EXCEPTION_ERROR_CODE,
@@ -3433,9 +3433,18 @@ static void init_vmcs_shadow_fields(void)
        /* No checks for read only fields yet */
 
        for (i = j = 0; i < max_shadow_read_write_fields; i++) {
+               /*
+                * PML and the preemption timer can be emulated, but the
+                * processor cannot vmwrite to fields that don't exist
+                * on bare metal.
+                */
                switch (shadow_read_write_fields[i]) {
-               case GUEST_BNDCFGS:
-                       if (!vmx_mpx_supported())
+               case GUEST_PML_INDEX:
+                       if (!cpu_has_vmx_pml())
+                               continue;
+                       break;
+               case GUEST_INTR_STATUS:
+                       if (!cpu_has_vmx_apicv())
                                continue;
                        break;
                default:
@@ -6332,10 +6341,6 @@ static __init int hardware_setup(void)
 
        if (!cpu_has_vmx_vpid())
                enable_vpid = 0;
-       if (!cpu_has_vmx_shadow_vmcs())
-               enable_shadow_vmcs = 0;
-       if (enable_shadow_vmcs)
-               init_vmcs_shadow_fields();
 
        if (!cpu_has_vmx_ept() ||
            !cpu_has_vmx_ept_4levels()) {
@@ -6440,6 +6445,11 @@ static __init int hardware_setup(void)
                kvm_x86_ops->enable_log_dirty_pt_masked = NULL;
        }
 
+       if (!cpu_has_vmx_shadow_vmcs())
+               enable_shadow_vmcs = 0;
+       if (enable_shadow_vmcs)
+               init_vmcs_shadow_fields();
+
        return alloc_kvm_area();
 
 out8: