• Sean Christopherson's avatar
    KVM: VMX: Move RESET emulation to vmx_vcpu_reset() · 06692e4b
    Sean Christopherson authored
    
    
    Move vCPU RESET emulation, including initializating of select VMCS state,
    to vmx_vcpu_reset().  Drop the open coded "vCPU load" sequence, as
    ->vcpu_reset() is invoked while the vCPU is properly loaded (which is
    kind of the point of ->vcpu_reset()...).  Hopefully KVM will someday
    expose a dedicated RESET ioctl(), and in the meantime separating "create"
    from "RESET" is a nice cleanup.
    
    Deferring VMCS initialization is effectively a nop as it's impossible to
    safely access the VMCS between the current call site and its new home, as
    both the vCPU and the pCPU are put immediately after init_vmcs(), i.e.
    the VMCS isn't guaranteed to be loaded.
    
    Note, task preemption is not a problem as vmx_sched_in() _can't_ touch
    the VMCS as ->sched_in() is invoked before the vCPU, and thus VMCS, is
    reloaded.  I.e. the preemption path also can't consume VMCS state.
    
    Cc: Reiji Watanabe <reijiw@google.com>
    Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    Message-Id: <20210921000303.400537-9-seanjc@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    06692e4b
vmx.c 225 KB