On Fri, Jan 18, 2019 at 1:22 PM Sean Christopherson <sean.j.christopherson@xxxxxxxxx> wrote: > > 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. > > Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> Reviewed-by: Jim Mattson <jmattson@xxxxxxxxxx>