VirtualBox

Changeset 21001 in vbox


Ignore:
Timestamp:
Jun 26, 2009 11:18:11 PM (16 years ago)
Author:
vboxsync
Message:

HWACCM: Untested AMD-V fix for the xmm register corruption on Windows/AMD64.

Location:
trunk/src/VBox/VMM
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/HWACCMInternal.h

    r20997 r21001  
    443443/** VMX StartVM function. */
    444444typedef DECLCALLBACK(int) FNHWACCMVMXSTARTVM(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu);
    445 /** Pointer to an VMX StartVM function. */
     445/** Pointer to a VMX StartVM function. */
    446446typedef R0PTRTYPE(FNHWACCMVMXSTARTVM *) PFNHWACCMVMXSTARTVM;
     447
     448/** SVM VMRun function. */
     449typedef DECLCALLBACK(int) FNHWACCMSVMVMRUN(RTHCPHYS pVMCBHostPhys, RTHCPHYS pVMCBPhys, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu);
     450/** Pointer to a SVM VMRun function. */
     451typedef R0PTRTYPE(FNHWACCMSVMVMRUN *) PFNHWACCMSVMVMRUN;
    447452
    448453/**
     
    554559
    555560        /** Ring 0 handlers for VT-x. */
    556         DECLR0CALLBACKMEMBER(int, pfnVMRun,(RTHCPHYS pVMCBHostPhys, RTHCPHYS pVMCBPhys, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu));
     561        PFNHWACCMSVMVMRUN           pfnVMRun;
    557562
    558563    } svm;
     
    725730
    726731# ifdef VBOX_WITH_KERNEL_USING_XMM
    727 DECLASM(int) hwaccmR0VMXStartVMWrapperXMM(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu, PFNHWACCMVMXSTARTVM pfnStartVM);
     732DECLASM(int)   hwaccmR0VMXStartVMWrapXMM(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu, PFNHWACCMVMXSTARTVM pfnStartVM);
     733DECLASM(int)   hwaccmR0SVMRunWrapXMM(RTHCPHYS pVMCBHostPhys, RTHCPHYS pVMCBPhys, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu, PFNHWACCMSVMVMRUN pfnVMRun);
    728734# endif
    729735
  • trunk/src/VBox/VMM/VMMR0/HWACCMR0A.asm

    r20997 r21001  
    10261026%endif ; VBOX_WITH_HYBRID_32BIT_KERNEL
    10271027
    1028 
    10291028%ifdef VBOX_WITH_KERNEL_USING_XMM
     1029
    10301030;;
    10311031; Wrapper around vmx.pfnStartVM that preserves host XMM registers and
    10321032; load the guest ones when necessary.
    10331033;
    1034 ; @cproto       DECLASM(int) hwaccmR0VMXStartVMWrapperXMM(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu, PFNHWACCMVMXSTARTVM pfnStartVM);
     1034; @cproto       DECLASM(int) hwaccmR0VMXStartVMWrapXMM(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu, PFNHWACCMVMXSTARTVM pfnStartVM);
    10351035;
    10361036; @returns      eax
     
    10431043; @param        pfnStartVM      msc:[rbp+38h]
    10441044;
     1045; @remarks      This is essentially the same code as hwaccmR0SVMRunWrapXMM, only the parameters differ a little bit.
     1046;
    10451047; ASSUMING 64-bit and windows for now.
    10461048ALIGNCODE(16)
    1047 BEGINPROC hwaccmR0VMXStartVMWrapperXMM
     1049BEGINPROC hwaccmR0VMXStartVMWrapXMM
    10481050        push    xBP
    10491051        mov     xBP, xSP
     
    11521154        leave
    11531155        ret
    1154 ENDPROC   hwaccmR0VMXStartVMWrapperXMM
    1155 %endif
     1156ENDPROC   hwaccmR0VMXStartVMWrapXMM
     1157
     1158;;
     1159; Wrapper around svm.pfnVMRun that preserves host XMM registers and
     1160; load the guest ones when necessary.
     1161;
     1162; @cproto       DECLASM(int) hwaccmR0SVMRunWrapXMM(RTHCPHYS pVMCBHostPhys, RTHCPHYS pVMCBPhys, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu, PFNHWACCMSVMVMRUN pfnVMRun);
     1163;
     1164; @returns      eax
     1165;
     1166; @param        pVMCBHostPhys   msc:rcx
     1167; @param        pVMCBPhys       msc:rdx
     1168; @param        pCtx            msc:r8
     1169; @param        pVM             msc:r9
     1170; @param        pVCpu           msc:[rbp+30h]
     1171; @param        pfnVMRun        msc:[rbp+38h]
     1172;
     1173; @remarks      This is essentially the same code as hwaccmR0VMXStartVMWrapXMM, only the parameters differ a little bit.
     1174;
     1175; ASSUMING 64-bit and windows for now.
     1176ALIGNCODE(16)
     1177BEGINPROC hwaccmR0SVMRunWrapXMM
     1178        push    xBP
     1179        mov     xBP, xSP
     1180        sub     xSP, 0a0h + 040h        ; Don't bother optimizing the frame size.
     1181
     1182        ; spill input parameters.
     1183        mov     [xBP + 010h], rcx       ; pVMCBHostPhys
     1184        mov     [xBP + 018h], rdx       ; pVMCBPhys
     1185        mov     [xBP + 020h], r8        ; pCtx
     1186        mov     [xBP + 028h], r9        ; pVM
     1187
     1188        ; Ask CPUM whether we've started using the FPU yet.
     1189        mov     rcx, [xBP + 30h]        ; pVCpu
     1190        call    NAME(CPUMIsGuestFPUStateActive)
     1191        test    al, al
     1192        jnz     .guest_fpu_state_active
     1193
     1194        ; No need to mess with XMM registers just call the start routine and return.
     1195        mov     r11, [xBP + 38h]        ; pfnVMRun
     1196        mov     r10, [xBP + 30h]        ; pVCpu
     1197        mov     [xSP + 020h], r10
     1198        mov     rcx, [xBP + 010h]       ; pVMCBHostPhys
     1199        mov     rdx, [xBP + 018h]       ; pVMCBPhys
     1200        mov     r8,  [xBP + 020h]       ; pCtx
     1201        mov     r9,  [xBP + 028h]       ; pVM
     1202        call    r11
     1203
     1204        leave
     1205        ret
     1206
     1207ALIGNCODE(8)
     1208.guest_fpu_state_active:
     1209        ; Save the host XMM registers.
     1210        movdqa  [rsp + 040h + 000h], xmm6
     1211        movdqa  [rsp + 040h + 010h], xmm7
     1212        movdqa  [rsp + 040h + 020h], xmm8
     1213        movdqa  [rsp + 040h + 030h], xmm9
     1214        movdqa  [rsp + 040h + 040h], xmm10
     1215        movdqa  [rsp + 040h + 050h], xmm11
     1216        movdqa  [rsp + 040h + 060h], xmm12
     1217        movdqa  [rsp + 040h + 070h], xmm13
     1218        movdqa  [rsp + 040h + 080h], xmm14
     1219        movdqa  [rsp + 040h + 090h], xmm15
     1220
     1221        ; Load the full guest XMM register state.
     1222        mov     r10, [xBP + 020h]       ; pCtx
     1223        lea     r10, [r10 + XMM_OFF_IN_X86FXSTATE]
     1224        movdqa  xmm0,  [r10 + 000h]
     1225        movdqa  xmm1,  [r10 + 010h]
     1226        movdqa  xmm2,  [r10 + 020h]
     1227        movdqa  xmm3,  [r10 + 030h]
     1228        movdqa  xmm4,  [r10 + 040h]
     1229        movdqa  xmm5,  [r10 + 050h]
     1230        movdqa  xmm6,  [r10 + 060h]
     1231        movdqa  xmm7,  [r10 + 070h]
     1232        movdqa  xmm8,  [r10 + 080h]
     1233        movdqa  xmm9,  [r10 + 090h]
     1234        movdqa  xmm10, [r10 + 0a0h]
     1235        movdqa  xmm11, [r10 + 0b0h]
     1236        movdqa  xmm12, [r10 + 0c0h]
     1237        movdqa  xmm13, [r10 + 0d0h]
     1238        movdqa  xmm14, [r10 + 0e0h]
     1239        movdqa  xmm15, [r10 + 0f0h]
     1240
     1241        ; Make the call (same as in the other case ).
     1242        mov     r11, [xBP + 38h]        ; pfnVMRun
     1243        mov     r10, [xBP + 30h]        ; pVCpu
     1244        mov     [xSP + 020h], r10
     1245        mov     rcx, [xBP + 010h]       ; pVMCBHostPhys
     1246        mov     rdx, [xBP + 018h]       ; pVMCBPhys
     1247        mov     r8,  [xBP + 020h]       ; pCtx
     1248        mov     r9,  [xBP + 028h]       ; pVM
     1249        call    r11
     1250
     1251        ; Save the guest XMM registers.
     1252        mov     r10, [xBP + 020h]       ; pCtx
     1253        lea     r10, [r10 + XMM_OFF_IN_X86FXSTATE]
     1254        movdqa  [r10 + 000h], xmm0
     1255        movdqa  [r10 + 010h], xmm1
     1256        movdqa  [r10 + 020h], xmm2
     1257        movdqa  [r10 + 030h], xmm3
     1258        movdqa  [r10 + 040h], xmm4
     1259        movdqa  [r10 + 050h], xmm5
     1260        movdqa  [r10 + 060h], xmm6
     1261        movdqa  [r10 + 070h], xmm7
     1262        movdqa  [r10 + 080h], xmm8
     1263        movdqa  [r10 + 090h], xmm9
     1264        movdqa  [r10 + 0a0h], xmm10
     1265        movdqa  [r10 + 0b0h], xmm11
     1266        movdqa  [r10 + 0c0h], xmm12
     1267        movdqa  [r10 + 0d0h], xmm13
     1268        movdqa  [r10 + 0e0h], xmm14
     1269        movdqa  [r10 + 0f0h], xmm15
     1270
     1271        ; Load the host XMM registers.
     1272        movdqa  xmm6,  [rsp + 040h + 000h]
     1273        movdqa  xmm7,  [rsp + 040h + 010h]
     1274        movdqa  xmm8,  [rsp + 040h + 020h]
     1275        movdqa  xmm9,  [rsp + 040h + 030h]
     1276        movdqa  xmm10, [rsp + 040h + 040h]
     1277        movdqa  xmm11, [rsp + 040h + 050h]
     1278        movdqa  xmm12, [rsp + 040h + 060h]
     1279        movdqa  xmm13, [rsp + 040h + 070h]
     1280        movdqa  xmm14, [rsp + 040h + 080h]
     1281        movdqa  xmm15, [rsp + 040h + 090h]
     1282        leave
     1283        ret
     1284ENDPROC   hwaccmR0SVMRunWrapXMM
     1285
     1286%endif ; VBOX_WITH_KERNEL_USING_XMM
    11561287
    11571288;
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r20846 r21001  
    981981
    982982    /* TPR caching using CR8 is only available in 64 bits mode or with 32 bits guests when X86_CPUID_AMD_FEATURE_ECX_CR8L is supported. */
    983     /* Note: we can't do this in LoadGuestState as PDMApicGetTPR can jump back to ring 3 (lock)!!!!!!!! 
     983    /* Note: we can't do this in LoadGuestState as PDMApicGetTPR can jump back to ring 3 (lock)!!!!!!!!
    984984     * @todo query and update the TPR only when it could have been changed (mmio access)
    985985     */
     
    11391139#endif
    11401140    TMNotifyStartOfExecution(pVCpu);
     1141#ifdef VBOX_WITH_KERNEL_USING_XMM
     1142    hwaccmR0SVMRunWrapXMM(pVCpu->hwaccm.s.svm.pVMCBHostPhys, pVCpu->hwaccm.s.svm.pVMCBPhys, pCtx, pVM, pVCpu, pVCpu->hwaccm.s.svm.pfnVMRun);
     1143#else
    11411144    pVCpu->hwaccm.s.svm.pfnVMRun(pVCpu->hwaccm.s.svm.pVMCBHostPhys, pVCpu->hwaccm.s.svm.pVMCBPhys, pCtx, pVM, pVCpu);
     1145#endif
    11421146    TMNotifyEndOfExecution(pVCpu);
    11431147    VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED);
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp

    r20997 r21001  
    23352335    TMNotifyStartOfExecution(pVCpu);
    23362336#ifdef VBOX_WITH_KERNEL_USING_XMM
    2337     rc = hwaccmR0VMXStartVMWrapperXMM(pVCpu->hwaccm.s.fResumeVM, pCtx, &pVCpu->hwaccm.s.vmx.VMCSCache, pVM, pVCpu, pVCpu->hwaccm.s.vmx.pfnStartVM);
     2337    rc = hwaccmR0VMXStartVMWrapXMM(pVCpu->hwaccm.s.fResumeVM, pCtx, &pVCpu->hwaccm.s.vmx.VMCSCache, pVM, pVCpu, pVCpu->hwaccm.s.vmx.pfnStartVM);
    23382338#else
    23392339    rc = pVCpu->hwaccm.s.vmx.pfnStartVM(pVCpu->hwaccm.s.fResumeVM, pCtx, &pVCpu->hwaccm.s.vmx.VMCSCache, pVM, pVCpu);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette