• Sean Christopherson's avatar
    KVM: nVMX: initialize vmcs02 constant exactly once (per VMCS) · 9d6105b2
    Sean Christopherson authored
    Add a dedicated flag to track if vmcs02 has been initialized, i.e.
    the constant state for vmcs02 has been written to the backing VMCS.
    The launched flag (in struct loaded_vmcs) gets cleared on logical
    CPU migration to mirror hardware behavior[1], i.e. using the launched
    flag to determine whether or not vmcs02 constant state needs to be
    initialized results in unnecessarily re-initializing the VMCS when
    migrating between logical CPUS.
    
    [1] The active VMCS needs to be VMCLEARed before it can be migrated
        to a different logical CPU.  Hardware's VMCS cache is per-CPU
        and is not coherent between CPUs.  VMCLEAR flushes the cache so
        that any dirty data is written back to memory.  A side effect
        of VMCLEAR is that it also clears the VMCS's internal launch
        flag, which KVM must mirror because VMRESUME must be used to
        run a previously launched VMCS.
    Suggested-by: default avatarJim Mattson <jmattson@google.com>
    Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
    Reviewed-by: default avatarJim Mattson <jmattson@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    9d6105b2
vmx.c 410 KB