• S
    KVM: VMX: Modify only RSP when creating a placeholder for guest's RCX · 831a3011
    Sean Christopherson 提交于
    In the vCPU-run asm blob, the guest's RCX is temporarily saved onto the
    stack after VM-Exit as the exit flow must first load a register with a
    pointer to the vCPU's save area in order to save the guest's registers.
    RCX is arbitrarily designated as the scratch register.
    
    Since the stack usage is to (1)save host, (2)save guest, (3)load host
    and (4)load guest, the code can't conform to the stack's natural FIFO
    semantics, i.e. it can't simply do PUSH/POP.  Regardless of whether it
    is done for the host's value or guest's value, at some point the code
    needs to access the stack using a non-traditional method, e.g. MOV
    instead of POP.  vCPU-run opts to create a placeholder on the stack for
    guest's RCX (by adjusting RSP) and saves RCX to its place immediately
    after VM-Exit (via MOV).
    
    In other words, the purpose of the first 'PUSH RCX' at the start of
    the vCPU-run asm blob  is to adjust RSP down, i.e. there's no need to
    actually access memory.  Use 'SUB $wordsize, RSP' instead of 'PUSH RCX'
    to make it more obvious that the intent is simply to create a gap on
    the stack for the guest's RCX.
    Reviewed-by: NJim Mattson <jmattson@google.com>
    Reviewed-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: NSean Christopherson <sean.j.christopherson@intel.com>
    Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
    831a3011
vmx.c 218.6 KB