Index: /trunk/include/VBox/vmm/hm_svm.h
===================================================================
--- /trunk/include/VBox/vmm/hm_svm.h	(revision 67915)
+++ /trunk/include/VBox/vmm/hm_svm.h	(revision 67916)
@@ -467,11 +467,11 @@
  */
 /** External or virtual interrupt. */
-#define SVM_EVENT_EXTERNAL_IRQ                  0
+#define SVM_EVENT_EXTERNAL_IRQ                0
 /** Non-maskable interrupt. */
-#define SVM_EVENT_NMI                           2
+#define SVM_EVENT_NMI                         2
 /** Exception; fault or trap. */
-#define SVM_EVENT_EXCEPTION                     3
+#define SVM_EVENT_EXCEPTION                   3
 /** Software interrupt. */
-#define SVM_EVENT_SOFTWARE_INT                  4
+#define SVM_EVENT_SOFTWARE_INT                4
 /** @} */
 
@@ -728,5 +728,5 @@
     SVMAVIC     AvicBar;
     /** Offset 0xa0-0xa7 - Reserved. */
-    uint8_t     u8Reserved2[0xA8-0xA0];
+    uint8_t     u8Reserved2[0xA8 - 0xA0];
     /** Offset 0xa8 - Event injection. */
     SVMEVENT    EventInject;
@@ -819,13 +819,13 @@
     SVMSEL      TR;
     /** Offset 0x4A0-0x4CA - Reserved. */
-    uint8_t     u8Reserved4[0x4CB-0x4A0];
+    uint8_t     u8Reserved4[0x4CB - 0x4A0];
     /** Offset 0x4CB - CPL. */
     uint8_t     u8CPL;
     /** Offset 0x4CC-0x4CF - Reserved. */
-    uint8_t     u8Reserved5[0x4D0-0x4CC];
+    uint8_t     u8Reserved5[0x4D0 - 0x4CC];
     /** Offset 0x4D0 - EFER. */
     uint64_t    u64EFER;
     /** Offset 0x4D8-0x547 - Reserved. */
-    uint8_t     u8Reserved6[0x548-0x4D8];
+    uint8_t     u8Reserved6[0x548 - 0x4D8];
     /** Offset 0x548 - CR4. */
     uint64_t    u64CR4;
@@ -843,9 +843,9 @@
     uint64_t    u64RIP;
     /** Offset 0x580-0x5D7 - Reserved. */
-    uint8_t     u8Reserved7[0x5D8-0x580];
+    uint8_t     u8Reserved7[0x5D8 - 0x580];
     /** Offset 0x5D8 - RSP. */
     uint64_t    u64RSP;
     /** Offset 0x5E0-0x5F7 - Reserved. */
-    uint8_t     u8Reserved8[0x5F8-0x5E0];
+    uint8_t     u8Reserved8[0x5F8 - 0x5E0];
     /** Offset 0x5F8 - RAX. */
     uint64_t    u64RAX;
@@ -869,5 +869,5 @@
     uint64_t    u64CR2;
     /** Offset 0x648-0x667 - Reserved. */
-    uint8_t     u8Reserved9[0x668-0x648];
+    uint8_t     u8Reserved9[0x668 - 0x648];
     /** Offset 0x668 - G_PAT. */
     uint64_t    u64GPAT;
@@ -941,9 +941,9 @@
     SVMVMCBCTRL ctrl;
     /** Offset 0x100-0x3FF - Reserved. */
-    uint8_t     u8Reserved3[0x400-0x100];
+    uint8_t     u8Reserved3[0x400 - 0x100];
     /** Offset 0x400 - State save area. */
     SVMVMCBSTATESAVE guest;
     /** Offset 0x698-0xFFF- Reserved. */
-    uint8_t     u8Reserved10[0x1000-0x698];
+    uint8_t     u8Reserved10[0x1000 - 0x698];
 } SVMVMCB;
 #pragma pack()
@@ -952,7 +952,7 @@
 /** Pointer to a const SVMVMCB structure. */
 typedef const SVMVMCB *PCSVMVMCB;
-AssertCompileMemberOffset(SVMVMCB, ctrl, 0x00);
-AssertCompileMemberOffset(SVMVMCB, u8Reserved3, 0x100);
-AssertCompileMemberOffset(SVMVMCB, guest, 0x400);
+AssertCompileMemberOffset(SVMVMCB, ctrl,         0x00);
+AssertCompileMemberOffset(SVMVMCB, u8Reserved3,  0x100);
+AssertCompileMemberOffset(SVMVMCB, guest,        0x400);
 AssertCompileMemberOffset(SVMVMCB, u8Reserved10, 0x698);
 AssertCompileSize(SVMVMCB, 0x1000);
Index: /trunk/src/VBox/VMM/VMMR0/HMR0A.asm
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/HMR0A.asm	(revision 67915)
+++ /trunk/src/VBox/VMM/VMMR0/HMR0A.asm	(revision 67916)
@@ -805,5 +805,6 @@
 ; load the guest ones when necessary.
 ;
-; @cproto       DECLASM(int) HMR0VMXStartVMhmR0DumpDescriptorM(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu, PFNHMVMXSTARTVM pfnStartVM);
+; @cproto       DECLASM(int) HMR0VMXStartVMhmR0DumpDescriptorM(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM,
+;                                                              PVMCPU pVCpu, PFNHMVMXSTARTVM pfnStartVM);
 ;
 ; @returns      eax
@@ -984,10 +985,11 @@
 ; load the guest ones when necessary.
 ;
-; @cproto       DECLASM(int) hmR0SVMRunWrapXMM(RTHCPHYS pVMCBHostPhys, RTHCPHYS pVMCBPhys, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu, PFNHMSVMVMRUN pfnVMRun);
+; @cproto       DECLASM(int) hmR0SVMRunWrapXMM(RTHCPHYS HCPhysVmcbHost, RTHCPHYS HCPhysVmcb, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu,
+;                                              PFNHMSVMVMRUN pfnVMRun);
 ;
 ; @returns      eax
 ;
-; @param        pVMCBHostPhys   msc:rcx
-; @param        pVMCBPhys       msc:rdx
+; @param        HCPhysVmcbHost  msc:rcx
+; @param        HCPhysVmcb      msc:rdx
 ; @param        pCtx            msc:r8
 ; @param        pVM             msc:r9
@@ -1011,6 +1013,6 @@
 
         ; spill input parameters.
-        mov     [xBP + 010h], rcx       ; pVMCBHostPhys
-        mov     [xBP + 018h], rdx       ; pVMCBPhys
+        mov     [xBP + 010h], rcx       ; HCPhysVmcbHost
+        mov     [xBP + 018h], rdx       ; HCPhysVmcb
         mov     [xBP + 020h], r8        ; pCtx
         mov     [xBP + 028h], r9        ; pVM
@@ -1026,6 +1028,6 @@
         mov     r10, [xBP + 30h]        ; pVCpu
         mov     [xSP + 020h], r10
-        mov     rcx, [xBP + 010h]       ; pVMCBHostPhys
-        mov     rdx, [xBP + 018h]       ; pVMCBPhys
+        mov     rcx, [xBP + 010h]       ; HCPhysVmcbHost
+        mov     rdx, [xBP + 018h]       ; HCPhysVmcb
         mov     r8,  [xBP + 020h]       ; pCtx
         mov     r9,  [xBP + 028h]       ; pVM
@@ -1067,6 +1069,6 @@
         mov     r10, [xBP + 30h]        ; pVCpu
         mov     [xSP + 020h], r10
-        mov     rcx, [xBP + 010h]       ; pVMCBHostPhys
-        mov     rdx, [xBP + 018h]       ; pVMCBPhys
+        mov     rcx, [xBP + 010h]       ; HCPhysVmcbHost
+        mov     rdx, [xBP + 018h]       ; HCPhysVmcb
         mov     r8,  [xBP + 020h]       ; pCtx
         mov     r9,  [xBP + 028h]       ; pVM
@@ -1129,6 +1131,6 @@
         mov     r10, [xBP + 30h]        ; pVCpu
         mov     [xSP + 020h], r10
-        mov     rcx, [xBP + 010h]       ; pVMCBHostPhys
-        mov     rdx, [xBP + 018h]       ; pVMCBPhys
+        mov     rcx, [xBP + 010h]       ; HCPhysVmcbHost
+        mov     rdx, [xBP + 018h]       ; HCPhysVmcb
         mov     r8,  [xBP + 020h]       ; pCtx
         mov     r9,  [xBP + 028h]       ; pVM
@@ -1765,8 +1767,8 @@
 ;
 ; @returns  VBox status code
-; @param    HCPhysVMCB      Physical address of host VMCB.
-; @param    HCPhysVMCB      Physical address of guest VMCB.
-; @param    pCtx            Pointer to the guest CPU-context.
-; @param    pVM             msc:r9, gcc:rcx     The cross context VM structure.
+; @param    HCPhysVmcbHost  msc:rcx,gcc:rdi     Physical address of host VMCB.
+; @param    HCPhysVmcb      msc:rdx,gcc:rsi     Physical address of guest VMCB.
+; @param    pCtx            msc:r8,gcc:rdx      Pointer to the guest CPU-context.
+; @param    pVM             msc:r9,gcc:rcx      The cross context VM structure.
 ; @param    pVCpu           msc:[rsp+28],gcc:r8 The cross context virtual CPU structure of the calling EMT.
 ;
@@ -1775,16 +1777,16 @@
 %ifdef RT_ARCH_AMD64 ; fake a cdecl stack frame
  %ifdef ASM_CALL64_GCC
-    push    r8
-    push    rcx
-    push    rdx
-    push    rsi
-    push    rdi
+    push    r8                ; pVCpu
+    push    rcx               ; pVM
+    push    rdx               ; pCtx
+    push    rsi               ; HCPhysVmcb
+    push    rdi               ; HCPhysVmcbHost
  %else
     mov     rax, [rsp + 28h]
-    push    rax                         ; pVCpu
-    push    r9                          ; pVM
-    push    r8                          ; pCtx
-    push    rdx                         ; HCPHYSGuestVMCB
-    push    rcx                         ; HCPhysHostVMCB
+    push    rax               ; pVCpu
+    push    r9                ; pVM
+    push    r8                ; pCtx
+    push    rdx               ; HCPhysVmcb
+    push    rcx               ; HCPhysVmcbHost
  %endif
     push    0
@@ -1794,17 +1796,11 @@
     pushf
 
-    ;
     ; Save all general purpose host registers.
-    ;
     MYPUSHAD
 
-    ;
     ; Load pCtx into xSI.
-    ;
     mov     xSI, [xBP + xCB * 2 + RTHCPHYS_CB * 2]  ; pCtx
 
-    ;
     ; Save the host XCR0 and load the guest one if necessary.
-    ;
     mov     xAX, [xBP + xCB * 2 + RTHCPHYS_CB * 2 + xCB * 2] ; pVCpu
     test    byte [xAX + VMCPU.hm + HMCPU.fLoadSaveGuestXcr0], 1
@@ -1812,33 +1808,31 @@
 
     xor     ecx, ecx
-    xgetbv                              ; Save the host one on the stack.
+    xgetbv                                  ; Save the host XCR0 on the stack
     push    xDX
     push    xAX
 
     mov     xSI, [xBP + xCB * 2 + RTHCPHYS_CB * 2]  ; pCtx
-    mov     eax, [xSI + CPUMCTX.aXcr]   ; Load the guest one.
+    mov     eax, [xSI + CPUMCTX.aXcr]       ; load the guest XCR0
     mov     edx, [xSI + CPUMCTX.aXcr + 4]
-    xor     ecx, ecx                    ; paranoia
+    xor     ecx, ecx                        ; paranoia
     xsetbv
 
-    push    0                           ; Indicate that we must restore XCR0 (popped into ecx, thus 0).
+    push    0                               ; indicate that we must restore XCR0 (popped into ecx, thus 0)
     jmp     .xcr0_before_done
 
 .xcr0_before_skip:
-    push    3fh                         ; indicate that we need not.
+    push    3fh                             ; indicate that we need not restore XCR0
 .xcr0_before_done:
 
-    ;
     ; Save guest CPU-context pointer for simplifying saving of the GPRs afterwards.
-    ;
     push    xSI
 
     ; Save host fs, gs, sysenter msr etc.
-    mov     xAX, [xBP + xCB * 2]                    ; pVMCBHostPhys (64 bits physical address; x86: take low dword only)
+    mov     xAX, [xBP + xCB * 2]                    ; HCPhysVmcbHost (64 bits physical address; x86: take low dword only)
     push    xAX                                     ; save for the vmload after vmrun
     vmsave
 
     ; Setup xAX for VMLOAD.
-    mov     xAX, [xBP + xCB * 2 + RTHCPHYS_CB]      ; pVMCBPhys (64 bits physical address; take low dword only)
+    mov     xAX, [xBP + xCB * 2 + RTHCPHYS_CB]      ; HCPhysVmcb (64 bits physical address; x86: take low dword only)
 
     ; Load guest general purpose registers.
@@ -1857,14 +1851,13 @@
     ; Load guest fs, gs, sysenter msr etc.
     vmload
+
     ; Run the VM.
     vmrun
 
-    ; eax is in the VMCB already; we can use it here.
-
     ; Save guest fs, gs, sysenter msr etc.
     vmsave
 
     ; Load host fs, gs, sysenter msr etc.
-    pop     xAX                     ; Pushed above
+    pop     rax                             ; load HCPhysVmcbHost (pushed above)
     vmload
 
@@ -1873,7 +1866,5 @@
     stgi
 
-    ;
     ; Pop the context pointer (pushed above) and save the guest GPRs (sans RSP and RAX).
-    ;
     pop     xAX
 
@@ -1885,7 +1876,5 @@
     mov     [ss:xAX + CPUMCTX.ebp], ebp
 
-    ;
     ; Restore the host xcr0 if necessary.
-    ;
     pop     xCX
     test    ecx, ecx
@@ -1893,10 +1882,8 @@
     pop     xAX
     pop     xDX
-    xsetbv                              ; ecx is already zero.
+    xsetbv                              ; ecx is already zero
 .xcr0_after_skip:
 
-    ;
     ; Restore host general purpose registers.
-    ;
     MYPOPAD
 
@@ -1917,8 +1904,8 @@
 ;
 ; @returns  VBox status code
-; @param    HCPhysVMCB      Physical address of host VMCB.
-; @param    HCPhysVMCB      Physical address of guest VMCB.
-; @param    pCtx            Pointer to the guest-CPU context.
-; @param    pVM             msc:r9, gcc:rcx     The cross context VM structure.
+; @param    HCPhysVmcbHost  msc:rcx,gcc:rdi     Physical address of host VMCB.
+; @param    HCPhysVmcb      msc:rdx,gcc:rsi     Physical address of guest VMCB.
+; @param    pCtx            msc:r8,gcc:rdx      Pointer to the guest-CPU context.
+; @param    pVM             msc:r9,gcc:rcx      The cross context VM structure.
 ; @param    pVCpu           msc:[rsp+28],gcc:r8 The cross context virtual CPU structure of the calling EMT.
 ;
@@ -1927,19 +1914,19 @@
     ; Fake a cdecl stack frame
  %ifdef ASM_CALL64_GCC
-    push    r8
-    push    rcx
-    push    rdx
-    push    rsi
-    push    rdi
+    push    r8                ;pVCpu
+    push    rcx               ;pVM
+    push    rdx               ;pCtx
+    push    rsi               ;HCPhysVmcb
+    push    rdi               ;HCPhysVmcbHost
  %else
     mov     rax, [rsp + 28h]
-    push    rax                         ; rbp + 30h pVCpu
-    push    r9                          ; rbp + 28h pVM
-    push    r8                          ; rbp + 20h pCtx
-    push    rdx                         ; rbp + 18h HCPHYSGuestVMCB
-    push    rcx                         ; rbp + 10h HCPhysHostVMCB
- %endif
-    push    0                           ; rbp + 08h "fake ret addr"
-    push    rbp                         ; rbp + 00h
+    push    rax               ; rbp + 30h pVCpu
+    push    r9                ; rbp + 28h pVM
+    push    r8                ; rbp + 20h pCtx
+    push    rdx               ; rbp + 18h HCPhysVmcb
+    push    rcx               ; rbp + 10h HCPhysVmcbHost
+ %endif
+    push    0                 ; rbp + 08h "fake ret addr"
+    push    rbp               ; rbp + 00h
     mov     rbp, rsp
     pushf
@@ -1953,58 +1940,46 @@
     ;  - DRx (presumably not changed at all)
     ;  - DR7 (reset to 0x400)
-    ;
-
-    ;
+
     ; Save all general purpose host registers.
-    ;
     MYPUSHAD
 
-    ;
     ; Load pCtx into xSI.
-    ;
     mov     xSI, [rbp + xCB * 2 + RTHCPHYS_CB * 2]
 
-    ;
     ; Save the host XCR0 and load the guest one if necessary.
-    ;
-    mov     rax, [xBP + 30h]            ; pVCpu
+    mov     rax, [xBP + 30h]                ; pVCpu
     test    byte [xAX + VMCPU.hm + HMCPU.fLoadSaveGuestXcr0], 1
     jz      .xcr0_before_skip
 
     xor     ecx, ecx
-    xgetbv                              ; Save the host one on the stack.
+    xgetbv                                  ; save the host XCR0 on the stack.
     push    xDX
     push    xAX
 
     mov     xSI, [xBP + xCB * 2 + RTHCPHYS_CB * 2]  ; pCtx
-    mov     eax, [xSI + CPUMCTX.aXcr]   ; Load the guest one.
+    mov     eax, [xSI + CPUMCTX.aXcr]       ; load the guest XCR0
     mov     edx, [xSI + CPUMCTX.aXcr + 4]
-    xor     ecx, ecx                    ; paranoia
+    xor     ecx, ecx                        ; paranoia
     xsetbv
 
-    push    0                           ; Indicate that we must restore XCR0 (popped into ecx, thus 0).
+    push    0                               ; indicate that we must restore XCR0 (popped into ecx, thus 0)
     jmp     .xcr0_before_done
 
 .xcr0_before_skip:
-    push    3fh                         ; indicate that we need not.
+    push    3fh                             ; indicate that we need not restore XCR0
 .xcr0_before_done:
 
-    ;
     ; Save guest CPU-context pointer for simplifying saving of the GPRs afterwards.
-    ;
     push    rsi
 
-    ;
     ; Save host fs, gs, sysenter msr etc.
-    ;
-    mov     rax, [rbp + xCB * 2]                    ; pVMCBHostPhys (64 bits physical address; x86: take low dword only)
-    push    rax                                     ; Save for the vmload after vmrun
+    mov     rax, [rbp + xCB * 2]                    ; HCPhysVmcbHost (64 bits physical address; x86: take low dword only)
+    push    rax                                     ; save for the vmload after vmrun
     vmsave
 
     ; Setup rax for VMLOAD.
-    mov     rax, [rbp + xCB * 2 + RTHCPHYS_CB]      ; pVMCBPhys (64 bits physical address; take low dword only)
-
-    ; Load guest general purpose registers.
-    ; rax is loaded from the VMCB by VMRUN.
+    mov     rax, [rbp + xCB * 2 + RTHCPHYS_CB]      ; HCPhysVmcb (64 bits physical address; take low dword only)
+
+    ; Load guest general purpose registers (rax is loaded from the VMCB by VMRUN).
     mov     rbx, qword [xSI + CPUMCTX.ebx]
     mov     rcx, qword [xSI + CPUMCTX.ecx]
@@ -2026,29 +2001,22 @@
     sti
 
-    ; Load guest fs, gs, sysenter msr etc.
+    ; Load guest FS, GS, Sysenter MSRs etc.
     vmload
+
     ; Run the VM.
     vmrun
 
-    ; rax is in the VMCB already; we can use it here.
-
     ; Save guest fs, gs, sysenter msr etc.
     vmsave
 
-    ;
     ; Load host fs, gs, sysenter msr etc.
-    ;
-    pop     rax                     ; pushed above
+    pop     rax                         ; load HCPhysVmcbHost (pushed above)
     vmload
 
-    ;
     ; Set the global interrupt flag again, but execute cli to make sure IF=0.
-    ;
     cli
     stgi
 
-    ;
     ; Pop the context pointer (pushed above) and save the guest GPRs (sans RSP and RAX).
-    ;
     pop     rax
 
@@ -2068,7 +2036,5 @@
     mov     qword [rax + CPUMCTX.r15], r15
 
-    ;
     ; Restore the host xcr0 if necessary.
-    ;
     pop     xCX
     test    ecx, ecx
@@ -2076,10 +2042,8 @@
     pop     xAX
     pop     xDX
-    xsetbv                              ; ecx is already zero.
+    xsetbv                              ; ecx is already zero
 .xcr0_after_skip:
 
-    ;
     ; Restore host general purpose registers.
-    ;
     MYPOPAD
 
