Deeper look into guest-mode transition

  • Switching to the guest-mode

    • Intel
      • VMLAUNCH - used for first transition with the VMCS
      • VMRESUME - used for subsequent transitions
    • AMD: VMRUN
  • Our implementation:

    AMD: run_vm_svm()Intel: run_vm_vmx()
    1Save host GPRs into stackSave host GPRs into stack
    2Load guest GPRs from memoryLoad guest GPRs from memory
    3VMRUNif launched { VMRESUME } else { set up host RIP and RSP, then VMLAUNCH }
    4Save guest GPRs into memorySave guest GPRs into memory
    5Load host GPRs from stackLoad host GPRs from stack
  • Contents of the GPRs are manually switched, because the VMRUN, VMLAUNCH, VMRESUME instructions do not do it