儲存庫 vbox 的更動 13960
- 時間撮記:
- 2008-11-7 下午01:04:45 (16 年 以前)
- 位置:
- trunk
- 檔案:
-
- 修改 20 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/include/VBox/cpum.h
r13832 r13960 891 891 VMMDECL(void) CPUMHyperSetCtxCore(PVM pVM, PCPUMCTXCORE pCtxCore); 892 892 VMMDECL(PCPUMCTX) CPUMQueryGuestCtxPtr(PVM pVM); 893 VMMDECL(PCPUMCTX) CPUMQueryGuestCtxPtrEx(PVM pVM, PVMCPU pVCpu); 893 894 VMMDECL(int) CPUMQueryHyperCtxPtr(PVM pVM, PCPUMCTX *ppCtx); 894 895 VMMDECL(PCCPUMCTXCORE) CPUMGetGuestCtxCore(PVM pVM); … … 899 900 VMMDECL(uint32_t) CPUMRawGetEFlags(PVM pVM, PCPUMCTXCORE pCtxCore); 900 901 VMMDECL(void) CPUMRawSetEFlags(PVM pVM, PCPUMCTXCORE pCtxCore, uint32_t eflags); 901 VMMDECL(int) CPUMHandleLazyFPU(PVM pVM );902 VMMDECL(int) CPUMRestoreHostFPUState(PVM pVM );902 VMMDECL(int) CPUMHandleLazyFPU(PVM pVM, PVMCPU pVCpu); 903 VMMDECL(int) CPUMRestoreHostFPUState(PVM pVM, PVMCPU pVCpu); 903 904 904 905 /** @name Changed flags … … 928 929 VMMDECL(bool) CPUMIsHostUsingSysEnter(PVM pVM); 929 930 VMMDECL(bool) CPUMIsHostUsingSysCall(PVM pVM); 930 VMMDECL(bool) CPUMIsGuestFPUStateActive(PVM pVM);931 VMMDECL(bool) CPUMIsGuestFPUStateActive(PVMCPU pVCPU); 931 932 VMMDECL(void) CPUMDeactivateGuestFPUState(PVM pVM); 932 933 VMMDECL(bool) CPUMIsGuestDebugStateActive(PVM pVM); … … 966 967 VMMR3DECL(int) CPUMR3TermCPU(PVM pVM); 967 968 VMMR3DECL(void) CPUMR3Reset(PVM pVM); 968 VMMR3DECL(int) CPUMR3QueryGuestCtxRCPtr(PVM pVM, RCPTRTYPE(PCPUMCTX) *ppCtx);969 969 # ifdef DEBUG 970 970 VMMR3DECL(void) CPUMR3SaveEntryCtx(PVM pVM); … … 1006 1006 */ 1007 1007 VMMR0DECL(int) CPUMR0Init(PVM pVM); 1008 VMMR0DECL(int) CPUMR0LoadGuestFPU(PVM pVM, P CPUMCTX pCtx);1009 VMMR0DECL(int) CPUMR0SaveGuestFPU(PVM pVM, P CPUMCTX pCtx);1010 VMMR0DECL(int) CPUMR0SaveGuestDebugState(PVM pVM, P CPUMCTX pCtx, bool fDR6);1011 VMMR0DECL(int) CPUMR0LoadGuestDebugState(PVM pVM, P CPUMCTX pCtx, bool fDR6);1008 VMMR0DECL(int) CPUMR0LoadGuestFPU(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx); 1009 VMMR0DECL(int) CPUMR0SaveGuestFPU(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx); 1010 VMMR0DECL(int) CPUMR0SaveGuestDebugState(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, bool fDR6); 1011 VMMR0DECL(int) CPUMR0LoadGuestDebugState(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, bool fDR6); 1012 1012 1013 1013 /** @} */ -
trunk/include/VBox/vm.h
r13898 r13960 107 107 struct CPUMCPU s; 108 108 #endif 109 char padding[ 4096]; /* multiple of 32 */109 char padding[2048]; /* multiple of 32 */ 110 110 } cpum; 111 111 /** VMM part. */ … … 570 570 STAMPROFILEADV StatSwitcherTSS; 571 571 572 /** @todo Realign everything on 64 byte bound raries to better match the572 /** @todo Realign everything on 64 byte boundaries to better match the 573 573 * cache-line size. */ 574 574 /* padding - the unions must be aligned on 32 bytes boundraries. */ … … 581 581 struct CPUM s; 582 582 #endif 583 char padding[4 416]; /* multiple of 32 */583 char padding[4096]; /* multiple of 32 */ 584 584 } cpum; 585 585 -
trunk/include/VBox/vm.mac
r13831 r13960 95 95 96 96 alignb 64 97 .cpum resb 4 41697 .cpum resb 4096 98 98 .vmm resb 1024 99 99 100 100 endstruc 101 101 102 ;; 103 ; This is part of the VMCPU structure. 104 struc VMCPU 105 .fForcedActions resd 1 106 .enmState resd 1 107 .pVMR3 RTR3PTR_RES 1 108 .pVMR0 RTR0PTR_RES 1 109 .pVMRC RTRCPTR_RES 1 110 .idCpu resd 1 111 112 .hNativeThread RTR0PTR_RES 1 113 114 alignb 64 115 116 .cpum resb 2048 117 endstruc 118 102 119 103 120 %endif -
trunk/src/VBox/VMM/CPUM.cpp
r13840 r13960 129 129 /* Hidden selector registers are invalid by default. */ 130 130 pVM->cpum.s.fValidHiddenSelRegs = false; 131 132 /* Calculate the offset from CPUM to CPUMCPU for the first CPU. */ 133 pVM->cpum.s.ulOffCPUMCPU = RT_OFFSETOF(VM, aCpus[0].cpum) - RT_OFFSETOF(VM, cpum); 134 Assert((uintptr_t)&pVM->cpum + pVM->cpum.s.ulOffCPUMCPU == (uintptr_t)&pVM->aCpus[0].cpum); 135 136 /* Calculate the offset from CPUMCPU to CPUM. */ 137 for (unsigned i=0;i<pVM->cCPUs;i++) 138 { 139 pVM->aCpus[i].cpum.s.ulOffCPUM = RT_OFFSETOF(VM, aCpus[i].cpum) - RT_OFFSETOF(VM, cpum); 140 Assert((uintptr_t)&pVM->aCpus[i].cpum - pVM->aCpus[i].cpum.s.ulOffCPUM == (uintptr_t)&pVM->cpum); 141 } 131 142 132 143 /* … … 628 639 629 640 /** 630 * Queries the pointer to the internal CPUMCTX structure631 *632 * @returns VBox status code.633 * @param pVM Handle to the virtual machine.634 * @param ppCtx Receives the CPUMCTX GC pointer when successful.635 */636 VMMR3DECL(int) CPUMR3QueryGuestCtxRCPtr(PVM pVM, RCPTRTYPE(PCPUMCTX) *ppCtx)637 {638 LogFlow(("CPUMR3QueryGuestCtxRCPtr\n"));639 /*640 * Store the address. (Later we might check how's calling, thus the RC.)641 */642 *ppCtx = VM_RC_ADDR(pVM, &pVM->cpum.s.Guest);643 return VINF_SUCCESS;644 }645 646 647 /**648 641 * Terminates the CPUM. 649 642 * … … 684 677 VMMR3DECL(void) CPUMR3Reset(PVM pVM) 685 678 { 686 PCPUMCTX pCtx = &pVM->cpum.s.Guest; 687 688 /* 689 * Initialize everything to ZERO first. 690 */ 691 uint32_t fUseFlags = pVM->cpum.s.fUseFlags & ~CPUM_USED_FPU_SINCE_REM; 692 memset(pCtx, 0, sizeof(*pCtx)); 693 pVM->cpum.s.fUseFlags = fUseFlags; 694 695 pCtx->cr0 = X86_CR0_CD | X86_CR0_NW | X86_CR0_ET; //0x60000010 696 pCtx->eip = 0x0000fff0; 697 pCtx->edx = 0x00000600; /* P6 processor */ 698 pCtx->eflags.Bits.u1Reserved0 = 1; 699 700 pCtx->cs = 0xf000; 701 pCtx->csHid.u64Base = UINT64_C(0xffff0000); 702 pCtx->csHid.u32Limit = 0x0000ffff; 703 pCtx->csHid.Attr.n.u1DescType = 1; /* code/data segment */ 704 pCtx->csHid.Attr.n.u1Present = 1; 705 pCtx->csHid.Attr.n.u4Type = X86_SEL_TYPE_READ | X86_SEL_TYPE_CODE; 706 707 pCtx->dsHid.u32Limit = 0x0000ffff; 708 pCtx->dsHid.Attr.n.u1DescType = 1; /* code/data segment */ 709 pCtx->dsHid.Attr.n.u1Present = 1; 710 pCtx->dsHid.Attr.n.u4Type = X86_SEL_TYPE_RW; 711 712 pCtx->esHid.u32Limit = 0x0000ffff; 713 pCtx->esHid.Attr.n.u1DescType = 1; /* code/data segment */ 714 pCtx->esHid.Attr.n.u1Present = 1; 715 pCtx->esHid.Attr.n.u4Type = X86_SEL_TYPE_RW; 716 717 pCtx->fsHid.u32Limit = 0x0000ffff; 718 pCtx->fsHid.Attr.n.u1DescType = 1; /* code/data segment */ 719 pCtx->fsHid.Attr.n.u1Present = 1; 720 pCtx->fsHid.Attr.n.u4Type = X86_SEL_TYPE_RW; 721 722 pCtx->gsHid.u32Limit = 0x0000ffff; 723 pCtx->gsHid.Attr.n.u1DescType = 1; /* code/data segment */ 724 pCtx->gsHid.Attr.n.u1Present = 1; 725 pCtx->gsHid.Attr.n.u4Type = X86_SEL_TYPE_RW; 726 727 pCtx->ssHid.u32Limit = 0x0000ffff; 728 pCtx->ssHid.Attr.n.u1Present = 1; 729 pCtx->ssHid.Attr.n.u1DescType = 1; /* code/data segment */ 730 pCtx->ssHid.Attr.n.u4Type = X86_SEL_TYPE_RW; 731 732 pCtx->idtr.cbIdt = 0xffff; 733 pCtx->gdtr.cbGdt = 0xffff; 734 735 pCtx->ldtrHid.u32Limit = 0xffff; 736 pCtx->ldtrHid.Attr.n.u1Present = 1; 737 pCtx->ldtrHid.Attr.n.u4Type = X86_SEL_TYPE_SYS_LDT; 738 739 pCtx->trHid.u32Limit = 0xffff; 740 pCtx->trHid.Attr.n.u1Present = 1; 741 pCtx->trHid.Attr.n.u4Type = X86_SEL_TYPE_SYS_386_TSS_BUSY; 742 743 pCtx->dr[6] = X86_DR6_INIT_VAL; 744 pCtx->dr[7] = X86_DR7_INIT_VAL; 745 746 pCtx->fpu.FTW = 0xff; /* All tags are set, i.e. the regs are empty. */ 747 pCtx->fpu.FCW = 0x37f; 748 749 /* Intel 64 and IA-32 Architectures Software Developer's Manual Volume 3A, Table 8-1. IA-32 Processor States Following Power-up, Reset, or INIT */ 750 pCtx->fpu.MXCSR = 0x1F80; 751 752 /* Init PAT MSR */ 753 pCtx->msrPAT = UINT64_C(0x0007040600070406); /** @todo correct? */ 754 755 /* Reset EFER; see AMD64 Architecture Programmer's Manual Volume 2: Table 14-1. Initial Processor State 756 * The Intel docs don't mention it. 757 */ 758 pCtx->msrEFER = 0; 679 /* @todo anything different for VCPU > 0? */ 680 for (unsigned i=0;i<pVM->cCPUs;i++) 681 { 682 PCPUMCTX pCtx = CPUMQueryGuestCtxPtrEx(pVM, &pVM->aCpus[i]); 683 684 /* 685 * Initialize everything to ZERO first. 686 */ 687 uint32_t fUseFlags = pVM->aCpus[i].cpum.s.fUseFlags & ~CPUM_USED_FPU_SINCE_REM; 688 memset(pCtx, 0, sizeof(*pCtx)); 689 pVM->aCpus[i].cpum.s.fUseFlags = fUseFlags; 690 691 pCtx->cr0 = X86_CR0_CD | X86_CR0_NW | X86_CR0_ET; //0x60000010 692 pCtx->eip = 0x0000fff0; 693 pCtx->edx = 0x00000600; /* P6 processor */ 694 pCtx->eflags.Bits.u1Reserved0 = 1; 695 696 pCtx->cs = 0xf000; 697 pCtx->csHid.u64Base = UINT64_C(0xffff0000); 698 pCtx->csHid.u32Limit = 0x0000ffff; 699 pCtx->csHid.Attr.n.u1DescType = 1; /* code/data segment */ 700 pCtx->csHid.Attr.n.u1Present = 1; 701 pCtx->csHid.Attr.n.u4Type = X86_SEL_TYPE_READ | X86_SEL_TYPE_CODE; 702 703 pCtx->dsHid.u32Limit = 0x0000ffff; 704 pCtx->dsHid.Attr.n.u1DescType = 1; /* code/data segment */ 705 pCtx->dsHid.Attr.n.u1Present = 1; 706 pCtx->dsHid.Attr.n.u4Type = X86_SEL_TYPE_RW; 707 708 pCtx->esHid.u32Limit = 0x0000ffff; 709 pCtx->esHid.Attr.n.u1DescType = 1; /* code/data segment */ 710 pCtx->esHid.Attr.n.u1Present = 1; 711 pCtx->esHid.Attr.n.u4Type = X86_SEL_TYPE_RW; 712 713 pCtx->fsHid.u32Limit = 0x0000ffff; 714 pCtx->fsHid.Attr.n.u1DescType = 1; /* code/data segment */ 715 pCtx->fsHid.Attr.n.u1Present = 1; 716 pCtx->fsHid.Attr.n.u4Type = X86_SEL_TYPE_RW; 717 718 pCtx->gsHid.u32Limit = 0x0000ffff; 719 pCtx->gsHid.Attr.n.u1DescType = 1; /* code/data segment */ 720 pCtx->gsHid.Attr.n.u1Present = 1; 721 pCtx->gsHid.Attr.n.u4Type = X86_SEL_TYPE_RW; 722 723 pCtx->ssHid.u32Limit = 0x0000ffff; 724 pCtx->ssHid.Attr.n.u1Present = 1; 725 pCtx->ssHid.Attr.n.u1DescType = 1; /* code/data segment */ 726 pCtx->ssHid.Attr.n.u4Type = X86_SEL_TYPE_RW; 727 728 pCtx->idtr.cbIdt = 0xffff; 729 pCtx->gdtr.cbGdt = 0xffff; 730 731 pCtx->ldtrHid.u32Limit = 0xffff; 732 pCtx->ldtrHid.Attr.n.u1Present = 1; 733 pCtx->ldtrHid.Attr.n.u4Type = X86_SEL_TYPE_SYS_LDT; 734 735 pCtx->trHid.u32Limit = 0xffff; 736 pCtx->trHid.Attr.n.u1Present = 1; 737 pCtx->trHid.Attr.n.u4Type = X86_SEL_TYPE_SYS_386_TSS_BUSY; 738 739 pCtx->dr[6] = X86_DR6_INIT_VAL; 740 pCtx->dr[7] = X86_DR7_INIT_VAL; 741 742 pCtx->fpu.FTW = 0xff; /* All tags are set, i.e. the regs are empty. */ 743 pCtx->fpu.FCW = 0x37f; 744 745 /* Intel 64 and IA-32 Architectures Software Developer's Manual Volume 3A, Table 8-1. IA-32 Processor States Following Power-up, Reset, or INIT */ 746 pCtx->fpu.MXCSR = 0x1F80; 747 748 /* Init PAT MSR */ 749 pCtx->msrPAT = UINT64_C(0x0007040600070406); /** @todo correct? */ 750 751 /* Reset EFER; see AMD64 Architecture Programmer's Manual Volume 2: Table 14-1. Initial Processor State 752 * The Intel docs don't mention it. 753 */ 754 pCtx->msrEFER = 0; 755 } 759 756 } 760 757 … … 776 773 */ 777 774 SSMR3PutMem(pSSM, &pVM->cpum.s.Hyper, sizeof(pVM->cpum.s.Hyper)); 778 SSMR3PutMem(pSSM, &pVM->cpum.s.Guest, sizeof(pVM->cpum.s.Guest)); 779 SSMR3PutU32(pSSM, pVM->cpum.s.fUseFlags); 780 SSMR3PutU32(pSSM, pVM->cpum.s.fChanged); 775 776 for (unsigned i=0;i<pVM->cCPUs;i++) 777 { 778 SSMR3PutMem(pSSM, &pVM->aCpus[i].cpum.s.Guest, sizeof(pVM->aCpus[i].cpum.s.Guest)); 779 SSMR3PutU32(pSSM, pVM->aCpus[i].cpum.s.fUseFlags); 780 SSMR3PutU32(pSSM, pVM->aCpus[i].cpum.s.fChanged); 781 } 781 782 782 783 SSMR3PutU32(pSSM, RT_ELEMENTS(pVM->cpum.s.aGuestCpuIdStd)); … … 809 810 { 810 811 #define CPUMCTX16_LOADREG(RegName) \ 811 pVM-> cpum.s.Guest.RegName = pCpumctx16->RegName;812 pVM->aCpus[0].cpum.s.Guest.RegName = pCpumctx16->RegName; 812 813 813 814 #define CPUMCTX16_LOADDRXREG(RegName) \ 814 pVM-> cpum.s.Guest.dr[RegName] = pCpumctx16->dr##RegName;815 pVM->aCpus[0].cpum.s.Guest.dr[RegName] = pCpumctx16->dr##RegName; 815 816 816 817 #define CPUMCTX16_LOADHIDREG(RegName) \ 817 pVM-> cpum.s.Guest.RegName##Hid.u64Base = pCpumctx16->RegName##Hid.u32Base; \818 pVM-> cpum.s.Guest.RegName##Hid.u32Limit = pCpumctx16->RegName##Hid.u32Limit; \819 pVM-> cpum.s.Guest.RegName##Hid.Attr = pCpumctx16->RegName##Hid.Attr;818 pVM->aCpus[0].cpum.s.Guest.RegName##Hid.u64Base = pCpumctx16->RegName##Hid.u32Base; \ 819 pVM->aCpus[0].cpum.s.Guest.RegName##Hid.u32Limit = pCpumctx16->RegName##Hid.u32Limit; \ 820 pVM->aCpus[0].cpum.s.Guest.RegName##Hid.Attr = pCpumctx16->RegName##Hid.Attr; 820 821 821 822 #define CPUMCTX16_LOADSEGREG(RegName) \ 822 pVM-> cpum.s.Guest.RegName = pCpumctx16->RegName; \823 pVM->aCpus[0].cpum.s.Guest.RegName = pCpumctx16->RegName; \ 823 824 CPUMCTX16_LOADHIDREG(RegName); 824 825 825 pVM-> cpum.s.Guest.fpu = pCpumctx16->fpu;826 pVM->aCpus[0].cpum.s.Guest.fpu = pCpumctx16->fpu; 826 827 827 828 CPUMCTX16_LOADREG(rax); … … 866 867 CPUMCTX16_LOADDRXREG(7); 867 868 868 pVM-> cpum.s.Guest.gdtr.cbGdt = pCpumctx16->gdtr.cbGdt;869 pVM-> cpum.s.Guest.gdtr.pGdt = pCpumctx16->gdtr.pGdt;870 pVM-> cpum.s.Guest.idtr.cbIdt = pCpumctx16->idtr.cbIdt;871 pVM-> cpum.s.Guest.idtr.pIdt = pCpumctx16->idtr.pIdt;869 pVM->aCpus[0].cpum.s.Guest.gdtr.cbGdt = pCpumctx16->gdtr.cbGdt; 870 pVM->aCpus[0].cpum.s.Guest.gdtr.pGdt = pCpumctx16->gdtr.pGdt; 871 pVM->aCpus[0].cpum.s.Guest.idtr.cbIdt = pCpumctx16->idtr.cbIdt; 872 pVM->aCpus[0].cpum.s.Guest.idtr.pIdt = pCpumctx16->idtr.pIdt; 872 873 873 874 CPUMCTX16_LOADREG(ldtr); 874 875 CPUMCTX16_LOADREG(tr); 875 876 876 pVM-> cpum.s.Guest.SysEnter = pCpumctx16->SysEnter;877 pVM->aCpus[0].cpum.s.Guest.SysEnter = pCpumctx16->SysEnter; 877 878 878 879 CPUMCTX16_LOADREG(msrEFER); … … 931 932 { 932 933 CPUMCTX_VER1_6 cpumctx16; 933 memset(&pVM-> cpum.s.Guest, 0, sizeof(pVM->cpum.s.Guest));934 memset(&pVM->aCpus[0].cpum.s.Guest, 0, sizeof(pVM->aCpus[0].cpum.s.Guest)); 934 935 SSMR3GetMem(pSSM, &cpumctx16, sizeof(cpumctx16)); 935 936 936 937 /* Save the old cpumctx state into the new one. */ 937 938 cpumR3LoadCPUM1_6(pVM, &cpumctx16); 939 940 SSMR3GetU32(pSSM, &pVM->aCpus[0].cpum.s.fUseFlags); 941 SSMR3GetU32(pSSM, &pVM->aCpus[0].cpum.s.fChanged); 938 942 } 939 943 else 940 SSMR3GetMem(pSSM, &pVM->cpum.s.Guest, sizeof(pVM->cpum.s.Guest)); 941 942 SSMR3GetU32(pSSM, &pVM->cpum.s.fUseFlags); 943 SSMR3GetU32(pSSM, &pVM->cpum.s.fChanged); 944 { 945 for (unsigned i=0;i<pVM->cCPUs;i++) 946 { 947 SSMR3GetMem(pSSM, &pVM->aCpus[i].cpum.s.Guest, sizeof(pVM->aCpus[i].cpum.s.Guest)); 948 SSMR3GetU32(pSSM, &pVM->aCpus[i].cpum.s.fUseFlags); 949 SSMR3GetU32(pSSM, &pVM->aCpus[i].cpum.s.fChanged); 950 } 951 } 952 944 953 945 954 uint32_t cElements; … … 1304 1313 cpumR3InfoParseArg(pszArgs, &enmType, &pszComment); 1305 1314 pHlp->pfnPrintf(pHlp, "Guest CPUM state: %s\n", pszComment); 1306 cpumR3InfoOne(pVM, &pVM->cpum.s.Guest, CPUMCTX2CORE(&pVM->cpum.s.Guest), pHlp, enmType, ""); 1315 /* @todo SMP */ 1316 PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(pVM); 1317 cpumR3InfoOne(pVM, pCtx, CPUMCTX2CORE(pCtx), pHlp, enmType, ""); 1307 1318 } 1308 1319 … … 1359 1370 * Format the EFLAGS. 1360 1371 */ 1361 PCPUMHOSTCTX pCtx = &pVM->cpum.s.Host; 1372 /* @todo SMP */ 1373 PCPUMHOSTCTX pCtx = &pVM->aCpus[0].cpum.s.Host; 1362 1374 #if HC_ARCH_BITS == 32 1363 1375 uint32_t efl = pCtx->eflags.u32; … … 2333 2345 VMMR3DECL(void) CPUMR3SaveEntryCtx(PVM pVM) 2334 2346 { 2335 pVM->cpum.s.GuestEntry = pVM->cpum.s.Guest; 2347 /* @todo SMP */ 2348 pVM->cpum.s.GuestEntry = *CPUMQueryGuestCtxPtr(pVM); 2336 2349 } 2337 2350 -
trunk/src/VBox/VMM/CPUMInternal.h
r13742 r13960 251 251 { 252 252 /** 253 * Saved host context. Only valid while inside GC.254 * Aligned on a 64-byte boundrary.255 */256 CPUMHOSTCTX Host;257 258 /**259 253 * Hypervisor context. 260 254 * Aligned on a 64-byte boundrary. 261 255 */ 262 256 CPUMCTX Hyper; 263 264 /**265 * Guest context.266 * Aligned on a 64-byte boundrary.267 */268 CPUMCTX Guest;269 257 270 258 /** Pointer to the current hypervisor core context - R3Ptr. */ … … 275 263 RCPTRTYPE(PCPUMCTXCORE) pHyperCoreRC; 276 264 277 /** Use flags. 278 * These flags indicates both what is to be used and what have been used. 279 */ 280 uint32_t fUseFlags; 281 282 /** Changed flags. 283 * These flags indicates to REM (and others) which important guest 284 * registers which has been changed since last time the flags were cleared. 285 * See the CPUM_CHANGED_* defines for what we keep track of. 286 */ 287 uint32_t fChanged; 265 /* Offset from CPUM to CPUMCPU for the first CPU. */ 266 uint32_t ulOffCPUMCPU; 288 267 289 268 /** Hidden selector registers state. … … 333 312 334 313 /** Align the next member, and thereby the structure, on a 64-byte boundrary. */ 335 uint8_t abPadding2[HC_ARCH_BITS == 32 ? 56 : 44];314 uint8_t abPadding2[HC_ARCH_BITS == 32 ? 60 : 48]; 336 315 337 316 /** … … 350 329 { 351 330 /** 331 * Saved host context. Only valid while inside GC. 332 * Aligned on a 64-byte boundrary. 333 */ 334 CPUMHOSTCTX Host; 335 336 /** 352 337 * Guest context. 353 338 * Aligned on a 64-byte boundrary. 354 339 */ 355 340 CPUMCTX Guest; 356 } CPUMCPU; 341 342 /** Use flags. 343 * These flags indicates both what is to be used and what has been used. 344 */ 345 uint32_t fUseFlags; 346 347 /** Changed flags. 348 * These flags indicates to REM (and others) which important guest 349 * registers which has been changed since last time the flags were cleared. 350 * See the CPUM_CHANGED_* defines for what we keep track of. 351 */ 352 uint32_t fChanged; 353 354 /* Offset to CPUM. (subtract from the pointer to get to CPUM) */ 355 uint32_t ulOffCPUM; 356 357 /* Round to 16 byte size. */ 358 uint32_t uPadding; 359 } CPUMCPU, *PCPUMCPU; 357 360 /** Pointer to the CPUMCPU instance data residing in the shared VMCPU structure. */ 358 361 typedef CPUMCPU *PCPUMCPU; … … 360 363 __BEGIN_DECLS 361 364 362 DECLASM(int) CPUMHandleLazyFPUAsm(PCPUM pCPUM);363 DECLASM(int) CPUMRestoreHostFPUStateAsm(PCPUM pCPUM);365 DECLASM(int) CPUMHandleLazyFPUAsm(PCPUMCPU pCPUM); 366 DECLASM(int) CPUMRestoreHostFPUStateAsm(PCPUMCPU pCPUM); 364 367 DECLASM(void) CPUMLoadFPUAsm(PCPUMCTX pCtx); 365 368 DECLASM(void) CPUMSaveFPUAsm(PCPUMCTX pCtx); -
trunk/src/VBox/VMM/CPUMInternal.mac
r12657 r13960 50 50 51 51 struc CPUM 52 ; 53 ; Hypervisor Context. 54 ; 55 alignb 64 ; the padding 56 .Hyper.fpu resb FPUSTATE_SIZE 57 58 .Hyper.edi resq 1 59 .Hyper.esi resq 1 60 .Hyper.ebp resq 1 61 .Hyper.eax resq 1 62 .Hyper.ebx resq 1 63 .Hyper.edx resq 1 64 .Hyper.ecx resq 1 65 .Hyper.esp resq 1 66 .Hyper.lss_esp resd 1 67 .Hyper.ss resw 1 68 .Hyper.ssPadding resw 1 69 .Hyper.gs resw 1 70 .Hyper.gsPadding resw 1 71 .Hyper.fs resw 1 72 .Hyper.fsPadding resw 1 73 .Hyper.es resw 1 74 .Hyper.esPadding resw 1 75 .Hyper.ds resw 1 76 .Hyper.dsPadding resw 1 77 .Hyper.cs resw 1 78 .Hyper.csPadding resw 3 79 .Hyper.eflags resq 1 80 .Hyper.eip resq 1 81 .Hyper.r8 resq 1 82 .Hyper.r9 resq 1 83 .Hyper.r10 resq 1 84 .Hyper.r11 resq 1 85 .Hyper.r12 resq 1 86 .Hyper.r13 resq 1 87 .Hyper.r14 resq 1 88 .Hyper.r15 resq 1 89 90 .Hyper.esHid.u64Base resq 1 91 .Hyper.esHid.u32Limit resd 1 92 .Hyper.esHid.Attr resd 1 93 94 .Hyper.csHid.u64Base resq 1 95 .Hyper.csHid.u32Limit resd 1 96 .Hyper.csHid.Attr resd 1 97 98 .Hyper.ssHid.u64Base resq 1 99 .Hyper.ssHid.u32Limit resd 1 100 .Hyper.ssHid.Attr resd 1 101 102 .Hyper.dsHid.u64Base resq 1 103 .Hyper.dsHid.u32Limit resd 1 104 .Hyper.dsHid.Attr resd 1 105 106 .Hyper.fsHid.u64Base resq 1 107 .Hyper.fsHid.u32Limit resd 1 108 .Hyper.fsHid.Attr resd 1 109 110 .Hyper.gsHid.u64Base resq 1 111 .Hyper.gsHid.u32Limit resd 1 112 .Hyper.gsHid.Attr resd 1 113 114 .Hyper.cr0 resq 1 115 .Hyper.cr2 resq 1 116 .Hyper.cr3 resq 1 117 .Hyper.cr4 resq 1 118 119 .Hyper.dr resq 8 120 121 .Hyper.gdtr resb 10 ; GDT limit + linear address 122 .Hyper.gdtrPadding resw 1 123 .Hyper.idtr resb 10 ; IDT limit + linear address 124 .Hyper.idtrPadding resw 1 125 .Hyper.ldtr resw 1 126 .Hyper.ldtrPadding resw 1 127 .Hyper.tr resw 1 128 .Hyper.trPadding resw 1 129 130 .Hyper.SysEnter.cs resb 8 131 .Hyper.SysEnter.eip resb 8 132 .Hyper.SysEnter.esp resb 8 133 134 .Hyper.msrEFER resb 8 135 .Hyper.msrSTAR resb 8 136 .Hyper.msrPAT resb 8 137 .Hyper.msrLSTAR resb 8 138 .Hyper.msrCSTAR resb 8 139 .Hyper.msrSFMASK resb 8 140 .Hyper.msrKERNELGSBASE resb 8 141 142 .Hyper.ldtrHid.u64Base resq 1 143 .Hyper.ldtrHid.u32Limit resd 1 144 .Hyper.ldtrHid.Attr resd 1 145 146 .Hyper.trHid.u64Base resq 1 147 .Hyper.trHid.u32Limit resd 1 148 .Hyper.trHid.Attr resd 1 149 150 ; 151 ; Other stuff. 152 ; 153 alignb 64 154 ; hypervisor core context. 155 .pHyperCoreR3 RTR3PTR_RES 1 156 .pHyperCoreR0 RTR0PTR_RES 1 157 .pHyperCoreRC RTRCPTR_RES 1 158 ;... 159 .ulOffCPUMCPU resd 1 160 .fValidHiddenSelRegs resd 1 161 162 ; CPUID eax=1 163 .CPUFeatures.edx resd 1 164 .CPUFeatures.ecx resd 1 165 166 ; CPUID eax=0x80000001 167 .CPUFeaturesExt.edx resd 1 168 .CPUFeaturesExt.ecx resd 1 169 170 .enmCPUVendor resd 1 171 172 ; CR4 masks 173 .CR4.AndMask resd 1 174 .CR4.OrMask resd 1 175 ; entered rawmode? 176 .fRawEntered resb 1 177 %if RTHCPTR_CB == 8 178 .abPadding resb 7 179 %else 180 .abPadding resb 3 181 %endif 182 183 ; CPUID leafs 184 .aGuestCpuIdStd resb 16*6 185 .aGuestCpuIdExt resb 16*10 186 .aGuestCpuIdCentaur resb 16*4 187 .GuestCpuIdDef resb 16 188 189 alignb 64 190 ; CPUMCTX debug stuff... 191 .GuestEntry resb 1024 192 endstruc 193 194 struc CPUMCPU 52 195 ; 53 196 ; Host context state … … 160 303 %endif ; 64-bit 161 304 162 163 ;164 ; Hypervisor Context.165 ;166 alignb 64 ; the padding167 .Hyper.fpu resb FPUSTATE_SIZE168 169 .Hyper.edi resq 1170 .Hyper.esi resq 1171 .Hyper.ebp resq 1172 .Hyper.eax resq 1173 .Hyper.ebx resq 1174 .Hyper.edx resq 1175 .Hyper.ecx resq 1176 .Hyper.esp resq 1177 .Hyper.lss_esp resd 1178 .Hyper.ss resw 1179 .Hyper.ssPadding resw 1180 .Hyper.gs resw 1181 .Hyper.gsPadding resw 1182 .Hyper.fs resw 1183 .Hyper.fsPadding resw 1184 .Hyper.es resw 1185 .Hyper.esPadding resw 1186 .Hyper.ds resw 1187 .Hyper.dsPadding resw 1188 .Hyper.cs resw 1189 .Hyper.csPadding resw 3190 .Hyper.eflags resq 1191 .Hyper.eip resq 1192 .Hyper.r8 resq 1193 .Hyper.r9 resq 1194 .Hyper.r10 resq 1195 .Hyper.r11 resq 1196 .Hyper.r12 resq 1197 .Hyper.r13 resq 1198 .Hyper.r14 resq 1199 .Hyper.r15 resq 1200 201 .Hyper.esHid.u64Base resq 1202 .Hyper.esHid.u32Limit resd 1203 .Hyper.esHid.Attr resd 1204 205 .Hyper.csHid.u64Base resq 1206 .Hyper.csHid.u32Limit resd 1207 .Hyper.csHid.Attr resd 1208 209 .Hyper.ssHid.u64Base resq 1210 .Hyper.ssHid.u32Limit resd 1211 .Hyper.ssHid.Attr resd 1212 213 .Hyper.dsHid.u64Base resq 1214 .Hyper.dsHid.u32Limit resd 1215 .Hyper.dsHid.Attr resd 1216 217 .Hyper.fsHid.u64Base resq 1218 .Hyper.fsHid.u32Limit resd 1219 .Hyper.fsHid.Attr resd 1220 221 .Hyper.gsHid.u64Base resq 1222 .Hyper.gsHid.u32Limit resd 1223 .Hyper.gsHid.Attr resd 1224 225 .Hyper.cr0 resq 1226 .Hyper.cr2 resq 1227 .Hyper.cr3 resq 1228 .Hyper.cr4 resq 1229 230 .Hyper.dr resq 8231 232 .Hyper.gdtr resb 10 ; GDT limit + linear address233 .Hyper.gdtrPadding resw 1234 .Hyper.idtr resb 10 ; IDT limit + linear address235 .Hyper.idtrPadding resw 1236 .Hyper.ldtr resw 1237 .Hyper.ldtrPadding resw 1238 .Hyper.tr resw 1239 .Hyper.trPadding resw 1240 241 .Hyper.SysEnter.cs resb 8242 .Hyper.SysEnter.eip resb 8243 .Hyper.SysEnter.esp resb 8244 245 .Hyper.msrEFER resb 8246 .Hyper.msrSTAR resb 8247 .Hyper.msrPAT resb 8248 .Hyper.msrLSTAR resb 8249 .Hyper.msrCSTAR resb 8250 .Hyper.msrSFMASK resb 8251 .Hyper.msrKERNELGSBASE resb 8252 253 .Hyper.ldtrHid.u64Base resq 1254 .Hyper.ldtrHid.u32Limit resd 1255 .Hyper.ldtrHid.Attr resd 1256 257 .Hyper.trHid.u64Base resq 1258 .Hyper.trHid.u32Limit resd 1259 .Hyper.trHid.Attr resd 1260 261 262 305 ; 263 306 ; Guest context state … … 359 402 .Guest.trHid.Attr resd 1 360 403 361 362 ;363 ; Other stuff.364 ;365 alignb 64366 ; hypervisor core context.367 .pHyperCoreR3 RTR3PTR_RES 1368 .pHyperCoreR0 RTR0PTR_RES 1369 .pHyperCoreRC RTRCPTR_RES 1370 ;...371 404 .fUseFlags resd 1 372 405 .fChanged resd 1 373 .fValidHiddenSelRegs resd 1 374 375 ; CPUID eax=1 376 .CPUFeatures.edx resd 1 377 .CPUFeatures.ecx resd 1 378 379 ; CPUID eax=0x80000001 380 .CPUFeaturesExt.edx resd 1 381 .CPUFeaturesExt.ecx resd 1 382 383 .enmCPUVendor resd 1 384 385 ; CR4 masks 386 .CR4.AndMask resd 1 387 .CR4.OrMask resd 1 388 ; entered rawmode? 389 .fRawEntered resb 1 390 %if RTHCPTR_CB == 8 391 .abPadding resb 7 392 %else 393 .abPadding resb 3 394 %endif 395 396 ; CPUID leafs 397 .aGuestCpuIdStd resb 16*6 398 .aGuestCpuIdExt resb 16*10 399 .aGuestCpuIdCentaur resb 16*4 400 .GuestCpuIdDef resb 16 401 402 alignb 64 403 ; CPUMCTX debug stuff... 404 .GuestEntry resb 1024 406 .ulOffCPUM resd 1 407 .uPadding resd 1 405 408 endstruc 406 409 410 411 ;; 412 ; Converts the CPUM pointer to CPUMCPU (for the first VMCPU) 413 ; @param %1 register name 414 %macro CPUMCPU_FROM_CPUM 1 415 add %1, [%1 + CPUM.ulOffCPUMCPU] 416 %endmacro 417 418 ;; 419 ; Converts the CPUMCPU pointer to CPUM (for the first VMCPU) 420 ; @param %1 register name 421 %macro CPUM_FROM_CPUMCPU 1 422 sub %1, [%1 + CPUMCPU.ulOffCPUM] 423 %endmacro -
trunk/src/VBox/VMM/PATM/PATM.cpp
r13834 r13960 346 346 347 347 /* Needed for future patching of sldt/sgdt/sidt/str etc. */ 348 rc = CPUMR3QueryGuestCtxRCPtr(pVM, &pVM->patm.s.pCPUMCtxGC); 349 AssertRCReturn(rc, rc); 348 pVM->patm.s.pCPUMCtxGC = VM_RC_ADDR(pVM, CPUMQueryGuestCtxPtr(pVM)); 350 349 351 350 Assert(pVM->patm.s.PatchLookupTreeHC); -
trunk/src/VBox/VMM/VMMAll/CPUMAllA.asm
r13832 r13960 41 41 %define ENABLE_WRITE_PROTECTION 1 42 42 43 ;; @def CPUM_REG44 ; The register which we load the CPUM pointer into.45 %ifdef RT_ARCH_AMD6446 %define CPUM_REG rdx47 %else48 %define CPUM_REG edx49 %endif50 51 43 BEGINCODE 52 44 … … 64 56 ; @returns 0 if caller should continue execution. 65 57 ; @returns VINF_EM_RAW_GUEST_TRAP if a guest trap should be generated. 66 ; @param pCPUM x86:[esp+4] GCC:rdi MSC:rcx CPUMpointer58 ; @param pCPUMCPU x86:[esp+4] GCC:rdi MSC:rcx CPUMCPU pointer 67 59 ; 68 60 align 16 … … 107 99 mov xDX, dword [esp + 4] 108 100 %endif 109 test dword [xDX + CPUM .fUseFlags], CPUM_USED_FPU101 test dword [xDX + CPUMCPU.fUseFlags], CPUM_USED_FPU 110 102 jz hlfpua_not_loaded 111 103 jmp hlfpua_to_host … … 116 108 align 16 117 109 hlfpua_not_loaded: 118 mov eax, [xDX + CPUM .Guest.cr0]110 mov eax, [xDX + CPUMCPU.Guest.cr0] 119 111 and eax, X86_CR0_MP | X86_CR0_EM | X86_CR0_TS 120 112 %ifdef RT_ARCH_AMD64 … … 164 156 %endif 165 157 %ifndef RT_ARCH_AMD64 166 test dword [xDX + CPUM.CPUFeatures.edx], X86_CPUID_FEATURE_EDX_FXSR 158 mov eax, edx 159 ; Calculate the PCPUM pointer 160 sub eax, [edx + CPUMCPU.ulOffCPUM] 161 test dword [eax + CPUM.CPUFeatures.edx], X86_CPUID_FEATURE_EDX_FXSR 167 162 jz short hlfpua_no_fxsave 168 163 %endif 169 164 170 fxsave [xDX + CPUM .Host.fpu]171 or dword [xDX + CPUM .fUseFlags], (CPUM_USED_FPU | CPUM_USED_FPU_SINCE_REM)172 fxrstor [xDX + CPUM .Guest.fpu]165 fxsave [xDX + CPUMCPU.Host.fpu] 166 or dword [xDX + CPUMCPU.fUseFlags], (CPUM_USED_FPU | CPUM_USED_FPU_SINCE_REM) 167 fxrstor [xDX + CPUMCPU.Guest.fpu] 173 168 hlfpua_finished_switch: 174 169 %ifdef IN_RC … … 182 177 ; legacy support. 183 178 hlfpua_no_fxsave: 184 fnsave [xDX + CPUM .Host.fpu]185 or dword [xDX + CPUM .fUseFlags], dword (CPUM_USED_FPU | CPUM_USED_FPU_SINCE_REM) ; yasm / nasm186 mov eax, [xDX + CPUM .Guest.fpu] ; control word179 fnsave [xDX + CPUMCPU.Host.fpu] 180 or dword [xDX + CPUMCPU.fUseFlags], dword (CPUM_USED_FPU | CPUM_USED_FPU_SINCE_REM) ; yasm / nasm 181 mov eax, [xDX + CPUMCPU.Guest.fpu] ; control word 187 182 not eax ; 1 means exception ignored (6 LS bits) 188 183 and eax, byte 03Fh ; 6 LS bits only 189 test eax, [xDX + CPUM .Guest.fpu + 4]; status word184 test eax, [xDX + CPUMCPU.Guest.fpu + 4]; status word 190 185 jz short hlfpua_no_exceptions_pending 191 186 ; technically incorrect, but we certainly don't want any exceptions now!! 192 and dword [xDX + CPUM .Guest.fpu + 4], ~03Fh187 and dword [xDX + CPUMCPU.Guest.fpu + 4], ~03Fh 193 188 hlfpua_no_exceptions_pending: 194 frstor [xDX + CPUM .Guest.fpu]189 frstor [xDX + CPUMCPU.Guest.fpu] 195 190 jmp near hlfpua_finished_switch 196 191 %endif ; !RT_ARCH_AMD64 … … 211 206 ; 212 207 ; @returns 0 213 ; @param pCPUM x86:[esp+4] GCC:rdi MSC:rcx CPUMpointer208 ; @param pCPUMCPU x86:[esp+4] GCC:rdi MSC:rcx CPUMCPU pointer 214 209 ; 215 210 align 16 … … 227 222 ; Restore FPU if guest has used it. 228 223 ; Using fxrstor should ensure that we're not causing unwanted exception on the host. 229 test dword [xDX + CPUM .fUseFlags], CPUM_USED_FPU224 test dword [xDX + CPUMCPU.fUseFlags], CPUM_USED_FPU 230 225 jz short gth_fpu_no 231 226 … … 235 230 mov cr0, xAX 236 231 237 fxsave [xDX + CPUM .Guest.fpu]238 fxrstor [xDX + CPUM .Host.fpu]232 fxsave [xDX + CPUMCPU.Guest.fpu] 233 fxrstor [xDX + CPUMCPU.Host.fpu] 239 234 240 235 mov cr0, xCX ; and restore old CR0 again 241 and dword [xDX + CPUM .fUseFlags], ~CPUM_USED_FPU236 and dword [xDX + CPUMCPU.fUseFlags], ~CPUM_USED_FPU 242 237 gth_fpu_no: 243 238 xor eax, eax -
trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp
r13832 r13960 36 36 #include <iprt/assert.h> 37 37 #include <iprt/asm.h> 38 38 #ifdef IN_RING3 39 #include <iprt/thread.h> 40 #endif 39 41 40 42 /** Disable stack frame pointer generation here. */ … … 404 406 VMMDECL(PCCPUMCTXCORE) CPUMGetGuestCtxCore(PVM pVM) 405 407 { 406 return CPUMCTX2CORE(&pVM->cpum.s.Guest); 408 VM_ASSERT_EMT(pVM); 409 return CPUMCTX2CORE(&pVM->aCpus[VMMGetCpuId(pVM)].cpum.s.Guest); 407 410 } 408 411 … … 418 421 /** @todo #1410 requires selectors to be checked. (huh? 1410?) */ 419 422 420 PCPUMCTXCORE pCtxCoreDst = CPUMCTX2CORE(&pVM-> cpum.s.Guest);423 PCPUMCTXCORE pCtxCoreDst = CPUMCTX2CORE(&pVM->aCpus[VMMGetCpuId(pVM)].cpum.s.Guest); 421 424 *pCtxCoreDst = *pCtxCore; 422 425 … … 457 460 VMMDECL(PCPUMCTX) CPUMQueryGuestCtxPtr(PVM pVM) 458 461 { 459 return &pVM->cpum.s.Guest; 460 } 461 462 return &pVM->aCpus[VMMGetCpuId(pVM)].cpum.s.Guest; 463 } 464 465 static PCPUMCPU cpumGetCpumCpu(PVM pVM) 466 { 467 RTCPUID idCpu = VMMGetCpuId(pVM); 468 469 return &pVM->aCpus[idCpu].cpum.s; 470 } 471 472 VMMDECL(PCPUMCTX) CPUMQueryGuestCtxPtrEx(PVM pVM, PVMCPU pVCpu) 473 { 474 Assert(pVCpu->idCpu < pVM->cCPUs); 475 return &pVCpu->cpum.s.Guest; 476 } 462 477 463 478 VMMDECL(int) CPUMSetGuestGDTR(PVM pVM, uint32_t addr, uint16_t limit) 464 479 { 465 pVM->cpum.s.Guest.gdtr.cbGdt = limit; 466 pVM->cpum.s.Guest.gdtr.pGdt = addr; 467 pVM->cpum.s.fChanged |= CPUM_CHANGED_GDTR; 480 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 481 482 pCpumCpu->Guest.gdtr.cbGdt = limit; 483 pCpumCpu->Guest.gdtr.pGdt = addr; 484 pCpumCpu->fChanged |= CPUM_CHANGED_GDTR; 468 485 return VINF_SUCCESS; 469 486 } … … 471 488 VMMDECL(int) CPUMSetGuestIDTR(PVM pVM, uint32_t addr, uint16_t limit) 472 489 { 473 pVM->cpum.s.Guest.idtr.cbIdt = limit; 474 pVM->cpum.s.Guest.idtr.pIdt = addr; 475 pVM->cpum.s.fChanged |= CPUM_CHANGED_IDTR; 490 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 491 492 pCpumCpu->Guest.idtr.cbIdt = limit; 493 pCpumCpu->Guest.idtr.pIdt = addr; 494 pCpumCpu->fChanged |= CPUM_CHANGED_IDTR; 476 495 return VINF_SUCCESS; 477 496 } … … 479 498 VMMDECL(int) CPUMSetGuestTR(PVM pVM, uint16_t tr) 480 499 { 481 pVM->cpum.s.Guest.tr = tr; 482 pVM->cpum.s.fChanged |= CPUM_CHANGED_TR; 500 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 501 502 pCpumCpu->Guest.tr = tr; 503 pCpumCpu->fChanged |= CPUM_CHANGED_TR; 483 504 return VINF_SUCCESS; 484 505 } … … 486 507 VMMDECL(int) CPUMSetGuestLDTR(PVM pVM, uint16_t ldtr) 487 508 { 488 pVM->cpum.s.Guest.ldtr = ldtr; 489 pVM->cpum.s.fChanged |= CPUM_CHANGED_LDTR; 509 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 510 511 pCpumCpu->Guest.ldtr = ldtr; 512 pCpumCpu->fChanged |= CPUM_CHANGED_LDTR; 490 513 return VINF_SUCCESS; 491 514 } … … 505 528 VMMDECL(int) CPUMSetGuestCR0(PVM pVM, uint64_t cr0) 506 529 { 530 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 531 507 532 #ifdef IN_RC 508 533 /* … … 510 535 * of math stuff. 511 536 */ 512 if ( (cr0 513 != (p VM->cpum.s.Guest.cr0 & (X86_CR0_TS | X86_CR0_EM | X86_CR0_MP)))537 if ( (cr0 & (X86_CR0_TS | X86_CR0_EM | X86_CR0_MP)) 538 != (pCpumCpu->Guest.cr0 & (X86_CR0_TS | X86_CR0_EM | X86_CR0_MP))) 514 539 { 515 if (!(p VM->cpum.s.fUseFlags & CPUM_USED_FPU))540 if (!(pCpumCpu->fUseFlags & CPUM_USED_FPU)) 516 541 { 517 542 /* … … 519 544 * and EM should be reflecting the guest EM (it always does this). 520 545 */ 521 if ((cr0 & X86_CR0_EM) != (p VM->cpum.s.Guest.cr0 & X86_CR0_EM))546 if ((cr0 & X86_CR0_EM) != (pCpumCpu->Guest.cr0 & X86_CR0_EM)) 522 547 { 523 548 uint32_t HyperCR0 = ASMGetCR0(); 524 549 AssertMsg((HyperCR0 & (X86_CR0_TS | X86_CR0_MP)) == (X86_CR0_TS | X86_CR0_MP), ("%#x\n", HyperCR0)); 525 AssertMsg((HyperCR0 & X86_CR0_EM) == (p VM->cpum.s.Guest.cr0 & X86_CR0_EM), ("%#x\n", HyperCR0));550 AssertMsg((HyperCR0 & X86_CR0_EM) == (pCpumCpu->Guest.cr0 & X86_CR0_EM), ("%#x\n", HyperCR0)); 526 551 HyperCR0 &= ~X86_CR0_EM; 527 552 HyperCR0 |= cr0 & X86_CR0_EM; … … 534 559 uint32_t HyperCR0 = ASMGetCR0(); 535 560 AssertMsg((HyperCR0 & (X86_CR0_TS | X86_CR0_MP)) == (X86_CR0_TS | X86_CR0_MP), ("%#x\n", HyperCR0)); 536 AssertMsg((HyperCR0 & X86_CR0_EM) == (p VM->cpum.s.Guest.cr0 & X86_CR0_EM), ("%#x\n", HyperCR0));561 AssertMsg((HyperCR0 & X86_CR0_EM) == (pCpumCpu->Guest.cr0 & X86_CR0_EM), ("%#x\n", HyperCR0)); 537 562 } 538 563 # endif … … 545 570 */ 546 571 uint32_t HyperCR0 = ASMGetCR0(); 547 AssertMsg( (HyperCR0 548 == (p VM->cpum.s.Guest.cr0 & (X86_CR0_TS | X86_CR0_EM | X86_CR0_MP)),549 ("%#x %#x\n", HyperCR0, p VM->cpum.s.Guest.cr0));572 AssertMsg( (HyperCR0 & (X86_CR0_TS | X86_CR0_EM | X86_CR0_MP)) 573 == (pCpumCpu->Guest.cr0 & (X86_CR0_TS | X86_CR0_EM | X86_CR0_MP)), 574 ("%#x %#x\n", HyperCR0, pCpumCpu->Guest.cr0)); 550 575 HyperCR0 &= ~(X86_CR0_TS | X86_CR0_EM | X86_CR0_MP); 551 576 HyperCR0 |= cr0 & (X86_CR0_TS | X86_CR0_EM | X86_CR0_MP); … … 560 585 * The caller is responsible for calling PGM when appropriate. 561 586 */ 562 if ( (cr0 563 != (p VM->cpum.s.Guest.cr0 & (X86_CR0_PG | X86_CR0_WP | X86_CR0_PE)))564 p VM->cpum.s.fChanged |= CPUM_CHANGED_GLOBAL_TLB_FLUSH;565 p VM->cpum.s.fChanged |= CPUM_CHANGED_CR0;566 567 p VM->cpum.s.Guest.cr0 = cr0 | X86_CR0_ET;587 if ( (cr0 & (X86_CR0_PG | X86_CR0_WP | X86_CR0_PE)) 588 != (pCpumCpu->Guest.cr0 & (X86_CR0_PG | X86_CR0_WP | X86_CR0_PE))) 589 pCpumCpu->fChanged |= CPUM_CHANGED_GLOBAL_TLB_FLUSH; 590 pCpumCpu->fChanged |= CPUM_CHANGED_CR0; 591 592 pCpumCpu->Guest.cr0 = cr0 | X86_CR0_ET; 568 593 return VINF_SUCCESS; 569 594 } … … 572 597 VMMDECL(int) CPUMSetGuestCR2(PVM pVM, uint64_t cr2) 573 598 { 574 pVM->cpum.s.Guest.cr2 = cr2; 599 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 600 601 pCpumCpu->Guest.cr2 = cr2; 575 602 return VINF_SUCCESS; 576 603 } … … 579 606 VMMDECL(int) CPUMSetGuestCR3(PVM pVM, uint64_t cr3) 580 607 { 581 pVM->cpum.s.Guest.cr3 = cr3; 582 pVM->cpum.s.fChanged |= CPUM_CHANGED_CR3; 608 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 609 610 pCpumCpu->Guest.cr3 = cr3; 611 pCpumCpu->fChanged |= CPUM_CHANGED_CR3; 583 612 return VINF_SUCCESS; 584 613 } … … 587 616 VMMDECL(int) CPUMSetGuestCR4(PVM pVM, uint64_t cr4) 588 617 { 618 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 619 589 620 if ( (cr4 & (X86_CR4_PGE | X86_CR4_PAE | X86_CR4_PSE)) 590 != (p VM->cpum.s.Guest.cr4 & (X86_CR4_PGE | X86_CR4_PAE | X86_CR4_PSE)))591 p VM->cpum.s.fChanged |= CPUM_CHANGED_GLOBAL_TLB_FLUSH;592 p VM->cpum.s.fChanged |= CPUM_CHANGED_CR4;621 != (pCpumCpu->Guest.cr4 & (X86_CR4_PGE | X86_CR4_PAE | X86_CR4_PSE))) 622 pCpumCpu->fChanged |= CPUM_CHANGED_GLOBAL_TLB_FLUSH; 623 pCpumCpu->fChanged |= CPUM_CHANGED_CR4; 593 624 if (!CPUMSupportsFXSR(pVM)) 594 625 cr4 &= ~X86_CR4_OSFSXR; 595 p VM->cpum.s.Guest.cr4 = cr4;626 pCpumCpu->Guest.cr4 = cr4; 596 627 return VINF_SUCCESS; 597 628 } … … 600 631 VMMDECL(int) CPUMSetGuestEFlags(PVM pVM, uint32_t eflags) 601 632 { 602 pVM->cpum.s.Guest.eflags.u32 = eflags; 633 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 634 635 pCpumCpu->Guest.eflags.u32 = eflags; 603 636 return VINF_SUCCESS; 604 637 } … … 607 640 VMMDECL(int) CPUMSetGuestEIP(PVM pVM, uint32_t eip) 608 641 { 609 pVM->cpum.s.Guest.eip = eip; 642 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 643 644 pCpumCpu->Guest.eip = eip; 610 645 return VINF_SUCCESS; 611 646 } … … 614 649 VMMDECL(int) CPUMSetGuestEAX(PVM pVM, uint32_t eax) 615 650 { 616 pVM->cpum.s.Guest.eax = eax; 651 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 652 653 pCpumCpu->Guest.eax = eax; 617 654 return VINF_SUCCESS; 618 655 } … … 621 658 VMMDECL(int) CPUMSetGuestEBX(PVM pVM, uint32_t ebx) 622 659 { 623 pVM->cpum.s.Guest.ebx = ebx; 660 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 661 662 pCpumCpu->Guest.ebx = ebx; 624 663 return VINF_SUCCESS; 625 664 } … … 628 667 VMMDECL(int) CPUMSetGuestECX(PVM pVM, uint32_t ecx) 629 668 { 630 pVM->cpum.s.Guest.ecx = ecx; 669 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 670 671 pCpumCpu->Guest.ecx = ecx; 631 672 return VINF_SUCCESS; 632 673 } … … 635 676 VMMDECL(int) CPUMSetGuestEDX(PVM pVM, uint32_t edx) 636 677 { 637 pVM->cpum.s.Guest.edx = edx; 678 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 679 680 pCpumCpu->Guest.edx = edx; 638 681 return VINF_SUCCESS; 639 682 } … … 642 685 VMMDECL(int) CPUMSetGuestESP(PVM pVM, uint32_t esp) 643 686 { 644 pVM->cpum.s.Guest.esp = esp; 687 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 688 689 pCpumCpu->Guest.esp = esp; 645 690 return VINF_SUCCESS; 646 691 } … … 649 694 VMMDECL(int) CPUMSetGuestEBP(PVM pVM, uint32_t ebp) 650 695 { 651 pVM->cpum.s.Guest.ebp = ebp; 696 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 697 698 pCpumCpu->Guest.ebp = ebp; 652 699 return VINF_SUCCESS; 653 700 } … … 656 703 VMMDECL(int) CPUMSetGuestESI(PVM pVM, uint32_t esi) 657 704 { 658 pVM->cpum.s.Guest.esi = esi; 705 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 706 707 pCpumCpu->Guest.esi = esi; 659 708 return VINF_SUCCESS; 660 709 } … … 663 712 VMMDECL(int) CPUMSetGuestEDI(PVM pVM, uint32_t edi) 664 713 { 665 pVM->cpum.s.Guest.edi = edi; 714 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 715 716 pCpumCpu->Guest.edi = edi; 666 717 return VINF_SUCCESS; 667 718 } … … 670 721 VMMDECL(int) CPUMSetGuestSS(PVM pVM, uint16_t ss) 671 722 { 672 pVM->cpum.s.Guest.ss = ss; 723 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 724 725 pCpumCpu->Guest.ss = ss; 673 726 return VINF_SUCCESS; 674 727 } … … 677 730 VMMDECL(int) CPUMSetGuestCS(PVM pVM, uint16_t cs) 678 731 { 679 pVM->cpum.s.Guest.cs = cs; 732 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 733 734 pCpumCpu->Guest.cs = cs; 680 735 return VINF_SUCCESS; 681 736 } … … 684 739 VMMDECL(int) CPUMSetGuestDS(PVM pVM, uint16_t ds) 685 740 { 686 pVM->cpum.s.Guest.ds = ds; 741 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 742 743 pCpumCpu->Guest.ds = ds; 687 744 return VINF_SUCCESS; 688 745 } … … 691 748 VMMDECL(int) CPUMSetGuestES(PVM pVM, uint16_t es) 692 749 { 693 pVM->cpum.s.Guest.es = es; 750 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 751 752 pCpumCpu->Guest.es = es; 694 753 return VINF_SUCCESS; 695 754 } … … 698 757 VMMDECL(int) CPUMSetGuestFS(PVM pVM, uint16_t fs) 699 758 { 700 pVM->cpum.s.Guest.fs = fs; 759 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 760 761 pCpumCpu->Guest.fs = fs; 701 762 return VINF_SUCCESS; 702 763 } … … 705 766 VMMDECL(int) CPUMSetGuestGS(PVM pVM, uint16_t gs) 706 767 { 707 pVM->cpum.s.Guest.gs = gs; 768 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 769 770 pCpumCpu->Guest.gs = gs; 708 771 return VINF_SUCCESS; 709 772 } … … 712 775 VMMDECL(void) CPUMSetGuestEFER(PVM pVM, uint64_t val) 713 776 { 714 pVM->cpum.s.Guest.msrEFER = val; 777 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 778 779 pCpumCpu->Guest.msrEFER = val; 715 780 } 716 781 … … 718 783 VMMDECL(uint64_t) CPUMGetGuestMsr(PVM pVM, unsigned idMsr) 719 784 { 785 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 720 786 uint64_t u64 = 0; 721 787 … … 723 789 { 724 790 case MSR_IA32_CR_PAT: 725 u64 = p VM->cpum.s.Guest.msrPAT;791 u64 = pCpumCpu->Guest.msrPAT; 726 792 break; 727 793 728 794 case MSR_IA32_SYSENTER_CS: 729 u64 = p VM->cpum.s.Guest.SysEnter.cs;795 u64 = pCpumCpu->Guest.SysEnter.cs; 730 796 break; 731 797 732 798 case MSR_IA32_SYSENTER_EIP: 733 u64 = p VM->cpum.s.Guest.SysEnter.eip;799 u64 = pCpumCpu->Guest.SysEnter.eip; 734 800 break; 735 801 736 802 case MSR_IA32_SYSENTER_ESP: 737 u64 = p VM->cpum.s.Guest.SysEnter.esp;803 u64 = pCpumCpu->Guest.SysEnter.esp; 738 804 break; 739 805 740 806 case MSR_K6_EFER: 741 u64 = p VM->cpum.s.Guest.msrEFER;807 u64 = pCpumCpu->Guest.msrEFER; 742 808 break; 743 809 744 810 case MSR_K8_SF_MASK: 745 u64 = p VM->cpum.s.Guest.msrSFMASK;811 u64 = pCpumCpu->Guest.msrSFMASK; 746 812 break; 747 813 748 814 case MSR_K6_STAR: 749 u64 = p VM->cpum.s.Guest.msrSTAR;815 u64 = pCpumCpu->Guest.msrSTAR; 750 816 break; 751 817 752 818 case MSR_K8_LSTAR: 753 u64 = p VM->cpum.s.Guest.msrLSTAR;819 u64 = pCpumCpu->Guest.msrLSTAR; 754 820 break; 755 821 756 822 case MSR_K8_CSTAR: 757 u64 = p VM->cpum.s.Guest.msrCSTAR;823 u64 = pCpumCpu->Guest.msrCSTAR; 758 824 break; 759 825 760 826 case MSR_K8_KERNEL_GS_BASE: 761 u64 = p VM->cpum.s.Guest.msrKERNELGSBASE;827 u64 = pCpumCpu->Guest.msrKERNELGSBASE; 762 828 break; 763 829 … … 773 839 VMMDECL(RTGCPTR) CPUMGetGuestIDTR(PVM pVM, uint16_t *pcbLimit) 774 840 { 841 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 842 775 843 if (pcbLimit) 776 *pcbLimit = p VM->cpum.s.Guest.idtr.cbIdt;777 return p VM->cpum.s.Guest.idtr.pIdt;844 *pcbLimit = pCpumCpu->Guest.idtr.cbIdt; 845 return pCpumCpu->Guest.idtr.pIdt; 778 846 } 779 847 … … 781 849 VMMDECL(RTSEL) CPUMGetGuestTR(PVM pVM) 782 850 { 783 return pVM->cpum.s.Guest.tr; 851 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 852 853 return pCpumCpu->Guest.tr; 784 854 } 785 855 … … 787 857 VMMDECL(RTSEL) CPUMGetGuestCS(PVM pVM) 788 858 { 789 return pVM->cpum.s.Guest.cs; 859 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 860 861 return pCpumCpu->Guest.cs; 790 862 } 791 863 … … 793 865 VMMDECL(RTSEL) CPUMGetGuestDS(PVM pVM) 794 866 { 795 return pVM->cpum.s.Guest.ds; 867 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 868 869 return pCpumCpu->Guest.ds; 796 870 } 797 871 … … 799 873 VMMDECL(RTSEL) CPUMGetGuestES(PVM pVM) 800 874 { 801 return pVM->cpum.s.Guest.es; 875 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 876 877 return pCpumCpu->Guest.es; 802 878 } 803 879 … … 805 881 VMMDECL(RTSEL) CPUMGetGuestFS(PVM pVM) 806 882 { 807 return pVM->cpum.s.Guest.fs; 883 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 884 885 return pCpumCpu->Guest.fs; 808 886 } 809 887 … … 811 889 VMMDECL(RTSEL) CPUMGetGuestGS(PVM pVM) 812 890 { 813 return pVM->cpum.s.Guest.gs; 891 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 892 893 return pCpumCpu->Guest.gs; 814 894 } 815 895 … … 817 897 VMMDECL(RTSEL) CPUMGetGuestSS(PVM pVM) 818 898 { 819 return pVM->cpum.s.Guest.ss; 899 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 900 901 return pCpumCpu->Guest.ss; 820 902 } 821 903 … … 823 905 VMMDECL(RTSEL) CPUMGetGuestLDTR(PVM pVM) 824 906 { 825 return pVM->cpum.s.Guest.ldtr; 907 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 908 909 return pCpumCpu->Guest.ldtr; 826 910 } 827 911 … … 829 913 VMMDECL(uint64_t) CPUMGetGuestCR0(PVM pVM) 830 914 { 831 return pVM->cpum.s.Guest.cr0; 915 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 916 917 return pCpumCpu->Guest.cr0; 832 918 } 833 919 … … 835 921 VMMDECL(uint64_t) CPUMGetGuestCR2(PVM pVM) 836 922 { 837 return pVM->cpum.s.Guest.cr2; 923 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 924 925 return pCpumCpu->Guest.cr2; 838 926 } 839 927 … … 841 929 VMMDECL(uint64_t) CPUMGetGuestCR3(PVM pVM) 842 930 { 843 return pVM->cpum.s.Guest.cr3; 931 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 932 933 return pCpumCpu->Guest.cr3; 844 934 } 845 935 … … 847 937 VMMDECL(uint64_t) CPUMGetGuestCR4(PVM pVM) 848 938 { 849 return pVM->cpum.s.Guest.cr4; 939 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 940 941 return pCpumCpu->Guest.cr4; 850 942 } 851 943 … … 853 945 VMMDECL(void) CPUMGetGuestGDTR(PVM pVM, PVBOXGDTR pGDTR) 854 946 { 855 *pGDTR = pVM->cpum.s.Guest.gdtr; 947 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 948 949 *pGDTR = pCpumCpu->Guest.gdtr; 856 950 } 857 951 … … 859 953 VMMDECL(uint32_t) CPUMGetGuestEIP(PVM pVM) 860 954 { 861 return pVM->cpum.s.Guest.eip; 955 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 956 957 return pCpumCpu->Guest.eip; 862 958 } 863 959 … … 865 961 VMMDECL(uint64_t) CPUMGetGuestRIP(PVM pVM) 866 962 { 867 return pVM->cpum.s.Guest.rip; 963 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 964 965 return pCpumCpu->Guest.rip; 868 966 } 869 967 … … 871 969 VMMDECL(uint32_t) CPUMGetGuestEAX(PVM pVM) 872 970 { 873 return pVM->cpum.s.Guest.eax; 971 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 972 973 return pCpumCpu->Guest.eax; 874 974 } 875 975 … … 877 977 VMMDECL(uint32_t) CPUMGetGuestEBX(PVM pVM) 878 978 { 879 return pVM->cpum.s.Guest.ebx; 979 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 980 981 return pCpumCpu->Guest.ebx; 880 982 } 881 983 … … 883 985 VMMDECL(uint32_t) CPUMGetGuestECX(PVM pVM) 884 986 { 885 return pVM->cpum.s.Guest.ecx; 987 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 988 989 return pCpumCpu->Guest.ecx; 886 990 } 887 991 … … 889 993 VMMDECL(uint32_t) CPUMGetGuestEDX(PVM pVM) 890 994 { 891 return pVM->cpum.s.Guest.edx; 995 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 996 997 return pCpumCpu->Guest.edx; 892 998 } 893 999 … … 895 1001 VMMDECL(uint32_t) CPUMGetGuestESI(PVM pVM) 896 1002 { 897 return pVM->cpum.s.Guest.esi; 1003 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1004 1005 return pCpumCpu->Guest.esi; 898 1006 } 899 1007 … … 901 1009 VMMDECL(uint32_t) CPUMGetGuestEDI(PVM pVM) 902 1010 { 903 return pVM->cpum.s.Guest.edi; 1011 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1012 1013 return pCpumCpu->Guest.edi; 904 1014 } 905 1015 … … 907 1017 VMMDECL(uint32_t) CPUMGetGuestESP(PVM pVM) 908 1018 { 909 return pVM->cpum.s.Guest.esp; 1019 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1020 1021 return pCpumCpu->Guest.esp; 910 1022 } 911 1023 … … 913 1025 VMMDECL(uint32_t) CPUMGetGuestEBP(PVM pVM) 914 1026 { 915 return pVM->cpum.s.Guest.ebp; 1027 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1028 1029 return pCpumCpu->Guest.ebp; 916 1030 } 917 1031 … … 919 1033 VMMDECL(uint32_t) CPUMGetGuestEFlags(PVM pVM) 920 1034 { 921 return pVM->cpum.s.Guest.eflags.u32; 1035 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1036 1037 return pCpumCpu->Guest.eflags.u32; 922 1038 } 923 1039 … … 925 1041 VMMDECL(CPUMSELREGHID *) CPUMGetGuestTRHid(PVM pVM) 926 1042 { 927 return &pVM->cpum.s.Guest.trHid; 1043 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1044 1045 return &pCpumCpu->Guest.trHid; 928 1046 } 929 1047 … … 932 1050 VMMDECL(int) CPUMGetGuestCRx(PVM pVM, unsigned iReg, uint64_t *pValue) 933 1051 { 1052 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1053 934 1054 switch (iReg) 935 1055 { 936 1056 case USE_REG_CR0: 937 *pValue = p VM->cpum.s.Guest.cr0;1057 *pValue = pCpumCpu->Guest.cr0; 938 1058 break; 939 1059 case USE_REG_CR2: 940 *pValue = p VM->cpum.s.Guest.cr2;1060 *pValue = pCpumCpu->Guest.cr2; 941 1061 break; 942 1062 case USE_REG_CR3: 943 *pValue = p VM->cpum.s.Guest.cr3;1063 *pValue = pCpumCpu->Guest.cr3; 944 1064 break; 945 1065 case USE_REG_CR4: 946 *pValue = p VM->cpum.s.Guest.cr4;1066 *pValue = pCpumCpu->Guest.cr4; 947 1067 break; 948 1068 default: … … 955 1075 VMMDECL(uint64_t) CPUMGetGuestDR0(PVM pVM) 956 1076 { 957 return pVM->cpum.s.Guest.dr[0]; 1077 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1078 1079 return pCpumCpu->Guest.dr[0]; 958 1080 } 959 1081 … … 961 1083 VMMDECL(uint64_t) CPUMGetGuestDR1(PVM pVM) 962 1084 { 963 return pVM->cpum.s.Guest.dr[1]; 1085 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1086 1087 return pCpumCpu->Guest.dr[1]; 964 1088 } 965 1089 … … 967 1091 VMMDECL(uint64_t) CPUMGetGuestDR2(PVM pVM) 968 1092 { 969 return pVM->cpum.s.Guest.dr[2]; 1093 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1094 1095 return pCpumCpu->Guest.dr[2]; 970 1096 } 971 1097 … … 973 1099 VMMDECL(uint64_t) CPUMGetGuestDR3(PVM pVM) 974 1100 { 975 return pVM->cpum.s.Guest.dr[3]; 1101 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1102 1103 return pCpumCpu->Guest.dr[3]; 976 1104 } 977 1105 … … 979 1107 VMMDECL(uint64_t) CPUMGetGuestDR6(PVM pVM) 980 1108 { 981 return pVM->cpum.s.Guest.dr[6]; 1109 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1110 1111 return pCpumCpu->Guest.dr[6]; 982 1112 } 983 1113 … … 985 1115 VMMDECL(uint64_t) CPUMGetGuestDR7(PVM pVM) 986 1116 { 987 return pVM->cpum.s.Guest.dr[7]; 1117 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1118 1119 return pCpumCpu->Guest.dr[7]; 988 1120 } 989 1121 … … 991 1123 VMMDECL(int) CPUMGetGuestDRx(PVM pVM, uint32_t iReg, uint64_t *pValue) 992 1124 { 1125 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1126 993 1127 AssertReturn(iReg <= USE_REG_DR7, VERR_INVALID_PARAMETER); 994 1128 /* DR4 is an alias for DR6, and DR5 is an alias for DR7. */ 995 1129 if (iReg == 4 || iReg == 5) 996 1130 iReg += 2; 997 *pValue = p VM->cpum.s.Guest.dr[iReg];1131 *pValue = pCpumCpu->Guest.dr[iReg]; 998 1132 return VINF_SUCCESS; 999 1133 } … … 1002 1136 VMMDECL(uint64_t) CPUMGetGuestEFER(PVM pVM) 1003 1137 { 1004 return pVM->cpum.s.Guest.msrEFER; 1138 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1139 1140 return pCpumCpu->Guest.msrEFER; 1005 1141 } 1006 1142 … … 1288 1424 break; 1289 1425 } 1290 pVM->cpum.s.fChanged |= CPUM_CHANGED_CPUID; 1426 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1427 1428 pCpumCpu->fChanged |= CPUM_CHANGED_CPUID; 1291 1429 } 1292 1430 … … 1375 1513 break; 1376 1514 } 1377 pVM->cpum.s.fChanged |= CPUM_CHANGED_CPUID; 1515 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1516 pCpumCpu->fChanged |= CPUM_CHANGED_CPUID; 1378 1517 } 1379 1518 … … 1393 1532 VMMDECL(int) CPUMSetGuestDR0(PVM pVM, uint64_t uDr0) 1394 1533 { 1395 pVM->cpum.s.Guest.dr[0] = uDr0; 1534 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1535 1536 pCpumCpu->Guest.dr[0] = uDr0; 1396 1537 return CPUMRecalcHyperDRx(pVM); 1397 1538 } … … 1400 1541 VMMDECL(int) CPUMSetGuestDR1(PVM pVM, uint64_t uDr1) 1401 1542 { 1402 pVM->cpum.s.Guest.dr[1] = uDr1; 1543 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1544 1545 pCpumCpu->Guest.dr[1] = uDr1; 1403 1546 return CPUMRecalcHyperDRx(pVM); 1404 1547 } … … 1407 1550 VMMDECL(int) CPUMSetGuestDR2(PVM pVM, uint64_t uDr2) 1408 1551 { 1409 pVM->cpum.s.Guest.dr[2] = uDr2; 1552 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1553 1554 pCpumCpu->Guest.dr[2] = uDr2; 1410 1555 return CPUMRecalcHyperDRx(pVM); 1411 1556 } … … 1414 1559 VMMDECL(int) CPUMSetGuestDR3(PVM pVM, uint64_t uDr3) 1415 1560 { 1416 pVM->cpum.s.Guest.dr[3] = uDr3; 1561 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1562 1563 pCpumCpu->Guest.dr[3] = uDr3; 1417 1564 return CPUMRecalcHyperDRx(pVM); 1418 1565 } … … 1421 1568 VMMDECL(int) CPUMSetGuestDR6(PVM pVM, uint64_t uDr6) 1422 1569 { 1423 pVM->cpum.s.Guest.dr[6] = uDr6; 1570 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1571 1572 pCpumCpu->Guest.dr[6] = uDr6; 1424 1573 return CPUMRecalcHyperDRx(pVM); 1425 1574 } … … 1428 1577 VMMDECL(int) CPUMSetGuestDR7(PVM pVM, uint64_t uDr7) 1429 1578 { 1430 pVM->cpum.s.Guest.dr[7] = uDr7; 1579 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1580 1581 pCpumCpu->Guest.dr[7] = uDr7; 1431 1582 return CPUMRecalcHyperDRx(pVM); 1432 1583 } … … 1435 1586 VMMDECL(int) CPUMSetGuestDRx(PVM pVM, uint32_t iReg, uint64_t Value) 1436 1587 { 1588 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1589 1437 1590 AssertReturn(iReg <= USE_REG_DR7, VERR_INVALID_PARAMETER); 1438 1591 /* DR4 is an alias for DR6, and DR5 is an alias for DR7. */ 1439 1592 if (iReg == 4 || iReg == 5) 1440 1593 iReg += 2; 1441 p VM->cpum.s.Guest.dr[iReg] = Value;1594 pCpumCpu->Guest.dr[iReg] = Value; 1442 1595 return CPUMRecalcHyperDRx(pVM); 1443 1596 } … … 1457 1610 VMMDECL(int) CPUMRecalcHyperDRx(PVM pVM) 1458 1611 { 1612 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1459 1613 /* 1460 1614 * Compare the DR7s first. … … 1542 1696 */ 1543 1697 #ifdef IN_RC 1544 if (!(p VM->cpum.s.fUseFlags & CPUM_USE_DEBUG_REGS))1698 if (!(pCpumCpu->fUseFlags & CPUM_USE_DEBUG_REGS)) 1545 1699 { 1546 1700 /** @todo save host DBx registers. */ 1547 1701 } 1548 1702 #endif 1549 p VM->cpum.s.fUseFlags |= CPUM_USE_DEBUG_REGS;1703 pCpumCpu->fUseFlags |= CPUM_USE_DEBUG_REGS; 1550 1704 if (uNewDr3 != pVM->cpum.s.Hyper.dr[3]) 1551 1705 CPUMSetHyperDR3(pVM, uNewDr3); … … 1562 1716 { 1563 1717 #ifdef IN_RC 1564 if (p VM->cpum.s.fUseFlags & CPUM_USE_DEBUG_REGS)1718 if (pCpumCpu->fUseFlags & CPUM_USE_DEBUG_REGS) 1565 1719 { 1566 1720 /** @todo restore host DBx registers. */ 1567 1721 } 1568 1722 #endif 1569 p VM->cpum.s.fUseFlags &= ~CPUM_USE_DEBUG_REGS;1723 pCpumCpu->fUseFlags &= ~CPUM_USE_DEBUG_REGS; 1570 1724 } 1571 1725 Log2(("CPUMRecalcHyperDRx: fUseFlags=%#x %RGr %RGr %RGr %RGr %RGr %RGr\n", 1572 p VM->cpum.s.fUseFlags, pVM->cpum.s.Hyper.dr[0], pVM->cpum.s.Hyper.dr[1],1726 pCpumCpu->fUseFlags, pVM->cpum.s.Hyper.dr[0], pVM->cpum.s.Hyper.dr[1], 1573 1727 pVM->cpum.s.Hyper.dr[2], pVM->cpum.s.Hyper.dr[3], pVM->cpum.s.Hyper.dr[6], 1574 1728 pVM->cpum.s.Hyper.dr[7])); … … 1591 1745 VMMDECL(int) CPUMRawEnter(PVM pVM, PCPUMCTXCORE pCtxCore) 1592 1746 { 1747 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1748 1593 1749 Assert(!pVM->cpum.s.fRawEntered); 1594 1750 if (!pCtxCore) 1595 pCtxCore = CPUMCTX2CORE(&p VM->cpum.s.Guest);1751 pCtxCore = CPUMCTX2CORE(&pCpumCpu->Guest); 1596 1752 1597 1753 /* … … 1630 1786 || pCtxCore->eflags.Bits.u1VM, 1631 1787 ("X86_EFL_IOPL=%d CPL=%d\n", pCtxCore->eflags.Bits.u2IOPL, pCtxCore->ss & X86_SEL_RPL)); 1632 Assert((p VM->cpum.s.Guest.cr0 & (X86_CR0_PG | X86_CR0_WP | X86_CR0_PE)) == (X86_CR0_PG | X86_CR0_PE | X86_CR0_WP));1788 Assert((pCpumCpu->Guest.cr0 & (X86_CR0_PG | X86_CR0_WP | X86_CR0_PE)) == (X86_CR0_PG | X86_CR0_PE | X86_CR0_WP)); 1633 1789 pCtxCore->eflags.u32 |= X86_EFL_IF; /* paranoia */ 1634 1790 … … 1651 1807 VMMDECL(int) CPUMRawLeave(PVM pVM, PCPUMCTXCORE pCtxCore, int rc) 1652 1808 { 1809 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1810 1653 1811 /* 1654 1812 * Don't leave if we've already left (in GC). … … 1659 1817 pVM->cpum.s.fRawEntered = false; 1660 1818 1661 PCPUMCTX pCtx = &p VM->cpum.s.Guest;1819 PCPUMCTX pCtx = &pCpumCpu->Guest; 1662 1820 if (!pCtxCore) 1663 1821 pCtxCore = CPUMCTX2CORE(pCtx); … … 1764 1922 VMMDECL(unsigned) CPUMGetAndClearChangedFlagsREM(PVM pVM) 1765 1923 { 1766 unsigned fFlags = pVM->cpum.s.fChanged; 1767 pVM->cpum.s.fChanged = 0; 1924 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1925 1926 unsigned fFlags = pCpumCpu->fChanged; 1927 pCpumCpu->fChanged = 0; 1768 1928 /** @todo change the switcher to use the fChanged flags. */ 1769 if (p VM->cpum.s.fUseFlags & CPUM_USED_FPU_SINCE_REM)1929 if (pCpumCpu->fUseFlags & CPUM_USED_FPU_SINCE_REM) 1770 1930 { 1771 1931 fFlags |= CPUM_CHANGED_FPU_REM; 1772 p VM->cpum.s.fUseFlags &= ~CPUM_USED_FPU_SINCE_REM;1932 pCpumCpu->fUseFlags &= ~CPUM_USED_FPU_SINCE_REM; 1773 1933 } 1774 1934 return fFlags; … … 1783 1943 VMMDECL(void) CPUMSetChangedFlags(PVM pVM, uint32_t fChangedFlags) 1784 1944 { 1785 pVM->cpum.s.fChanged |= fChangedFlags; 1945 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1946 1947 pCpumCpu->fChanged |= fChangedFlags; 1786 1948 } 1787 1949 … … 1807 1969 VMMDECL(bool) CPUMIsHostUsingSysEnter(PVM pVM) 1808 1970 { 1809 return (pVM->cpum.s.fUseFlags & CPUM_USE_SYSENTER) != 0; 1971 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1972 1973 return (pCpumCpu->fUseFlags & CPUM_USE_SYSENTER) != 0; 1810 1974 } 1811 1975 … … 1819 1983 VMMDECL(bool) CPUMIsHostUsingSysCall(PVM pVM) 1820 1984 { 1821 return (pVM->cpum.s.fUseFlags & CPUM_USE_SYSCALL) != 0; 1985 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1986 1987 return (pCpumCpu->fUseFlags & CPUM_USE_SYSCALL) != 0; 1822 1988 } 1823 1989 … … 1829 1995 * @returns VBox status code. 1830 1996 * @param pVM VM handle. 1831 */ 1832 VMMDECL(int) CPUMHandleLazyFPU(PVM pVM) 1833 { 1834 return CPUMHandleLazyFPUAsm(&pVM->cpum.s); 1997 * @param pVCpu VMCPU handle 1998 */ 1999 VMMDECL(int) CPUMHandleLazyFPU(PVM pVM, PVMCPU pVCpu) 2000 { 2001 return CPUMHandleLazyFPUAsm(&pVCpu->cpum.s); 1835 2002 } 1836 2003 … … 1841 2008 * @returns VBox status code. 1842 2009 * @param pVM VM handle. 1843 */ 1844 VMMDECL(int) CPUMRestoreHostFPUState(PVM pVM) 2010 * @param pVCpu VMCPU handle 2011 */ 2012 VMMDECL(int) CPUMRestoreHostFPUState(PVM pVM, PVMCPU pVCpu) 1845 2013 { 1846 2014 Assert(pVM->cpum.s.CPUFeatures.edx.u1FXSR); 1847 return CPUMRestoreHostFPUStateAsm(&pV M->cpum.s);2015 return CPUMRestoreHostFPUStateAsm(&pVCpu->cpum.s); 1848 2016 } 1849 2017 … … 1854 2022 * @returns true if we did. 1855 2023 * @returns false if not. 1856 * @param pV M The VMhandle.1857 */ 1858 VMMDECL(bool) CPUMIsGuestFPUStateActive(PVM pVM)1859 { 1860 return (pV M->cpum.s.fUseFlags & CPUM_USED_FPU) != 0;2024 * @param pVCpu The VMCPU handle. 2025 */ 2026 VMMDECL(bool) CPUMIsGuestFPUStateActive(PVMCPU pVCpu) 2027 { 2028 return (pVCpu->cpum.s.fUseFlags & CPUM_USED_FPU) != 0; 1861 2029 } 1862 2030 … … 1868 2036 VMMDECL(void) CPUMDeactivateGuestFPUState(PVM pVM) 1869 2037 { 1870 pVM->cpum.s.fUseFlags &= ~CPUM_USED_FPU; 2038 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 2039 2040 pCpumCpu->fUseFlags &= ~CPUM_USED_FPU; 1871 2041 } 1872 2042 … … 1880 2050 VMMDECL(bool) CPUMIsGuestDebugStateActive(PVM pVM) 1881 2051 { 1882 return (pVM->cpum.s.fUseFlags & CPUM_USE_DEBUG_REGS) != 0; 2052 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 2053 2054 return (pCpumCpu->fUseFlags & CPUM_USE_DEBUG_REGS) != 0; 1883 2055 } 1884 2056 … … 1892 2064 VMMDECL(void) CPUMDeactivateGuestDebugState(PVM pVM) 1893 2065 { 1894 pVM->cpum.s.fUseFlags &= ~CPUM_USE_DEBUG_REGS; 2066 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 2067 2068 pCpumCpu->fUseFlags &= ~CPUM_USE_DEBUG_REGS; 1895 2069 } 1896 2070 … … 1928 2102 VMMDECL(uint32_t) CPUMGetGuestCPL(PVM pVM, PCPUMCTXCORE pCtxCore) 1929 2103 { 2104 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 1930 2105 uint32_t cpl; 1931 2106 … … 1939 2114 * at SS. (ACP2 regression during install after a far call to ring 2) 1940 2115 */ 1941 if (RT_LIKELY(p VM->cpum.s.Guest.cr0 & X86_CR0_PE))2116 if (RT_LIKELY(pCpumCpu->Guest.cr0 & X86_CR0_PE)) 1942 2117 cpl = pCtxCore->ssHid.Attr.n.u2Dpl; 1943 2118 else 1944 2119 cpl = 0; /* CPL set to 3 for VT-x real-mode emulation. */ 1945 2120 } 1946 else if (RT_LIKELY(p VM->cpum.s.Guest.cr0 & X86_CR0_PE))2121 else if (RT_LIKELY(pCpumCpu->Guest.cr0 & X86_CR0_PE)) 1947 2122 { 1948 2123 if (RT_LIKELY(!pCtxCore->eflags.Bits.u1VM)) … … 1979 2154 VMMDECL(CPUMMODE) CPUMGetGuestMode(PVM pVM) 1980 2155 { 2156 PCPUMCPU pCpumCpu = cpumGetCpumCpu(pVM); 2157 1981 2158 CPUMMODE enmMode; 1982 if (!(p VM->cpum.s.Guest.cr0 & X86_CR0_PE))2159 if (!(pCpumCpu->Guest.cr0 & X86_CR0_PE)) 1983 2160 enmMode = CPUMMODE_REAL; 1984 else if (!(p VM->cpum.s.Guest.msrEFER & MSR_K6_EFER_LMA))2161 else if (!(pCpumCpu->Guest.msrEFER & MSR_K6_EFER_LMA)) 1985 2162 enmMode = CPUMMODE_PROTECTED; 1986 2163 else -
trunk/src/VBox/VMM/VMMGC/CPUMGC.cpp
r8155 r13960 64 64 if (uUser & CPUM_HANDLER_CTXCORE_IN_EBP) 65 65 { 66 PCPUMCTXCORE pGstCtxCore = CPUMCTX2CORE(&pVM->cpum.s.Guest);66 PCPUMCTXCORE pGstCtxCore = (PCPUMCTXCORE)CPUMGetGuestCtxCore(pVM); 67 67 PCCPUMCTXCORE pGstCtxCoreSrc = (PCPUMCTXCORE)pRegFrame->ebp; 68 68 *pGstCtxCore = *pGstCtxCoreSrc; … … 90 90 case CPUM_HANDLER_IRET: 91 91 { 92 PCPUMCTXCORE pGstCtxCore = CPUMCTX2CORE(&pVM->cpum.s.Guest);92 PCPUMCTXCORE pGstCtxCore = (PCPUMCTXCORE)CPUMGetGuestCtxCore(pVM); 93 93 uint32_t *pEsp = (uint32_t *)pRegFrame->esp; 94 94 -
trunk/src/VBox/VMM/VMMGC/CPUMGCA.asm
r12989 r13960 73 73 mov eax, [esp + 4] ; get argument 74 74 mov edx, IMP(g_CPUM) 75 76 mov ecx, [edx + CPUM.Guest.eip] 75 ; Convert to CPUMCPU pointer 76 add edx, [edx + CPUM.ulOffCPUMCPU] 77 78 mov ecx, [edx + CPUMCPU.Guest.eip] 77 79 mov [eax + 0h], ecx 78 mov ecx, [edx + CPUM .Guest.cs]80 mov ecx, [edx + CPUMCPU.Guest.cs] 79 81 mov [eax + 4h], ecx 80 mov ecx, [edx + CPUM .Guest.eflags]82 mov ecx, [edx + CPUMCPU.Guest.eflags] 81 83 mov [eax + 8h], ecx 82 mov ecx, [edx + CPUM .Guest.esp]84 mov ecx, [edx + CPUMCPU.Guest.esp] 83 85 mov [eax + 0ch], ecx 84 mov ecx, [edx + CPUM .Guest.ss]86 mov ecx, [edx + CPUMCPU.Guest.ss] 85 87 mov [eax + 10h], ecx 86 88 87 test dword [edx + CPUM .Guest.eflags], X86_EFL_VM89 test dword [edx + CPUMCPU.Guest.eflags], X86_EFL_VM 88 90 jnz short CPUMGCRestoreInt_V86 89 91 … … 93 95 ; todo: potential trouble loading invalid es,fs,gs,ds because 94 96 ; of a VMM imposed exception? 95 mov es, [edx + CPUM .Guest.es]96 mov fs, [edx + CPUM .Guest.fs]97 mov gs, [edx + CPUM .Guest.gs]98 mov esi, [edx + CPUM .Guest.esi]99 mov edi, [edx + CPUM .Guest.edi]100 mov ebp, [edx + CPUM .Guest.ebp]101 mov ebx, [edx + CPUM .Guest.ebx]102 mov ecx, [edx + CPUM .Guest.ecx]103 mov eax, [edx + CPUM .Guest.eax]104 push dword [edx + CPUM .Guest.ds]105 mov edx, [edx + CPUM .Guest.edx]97 mov es, [edx + CPUMCPU.Guest.es] 98 mov fs, [edx + CPUMCPU.Guest.fs] 99 mov gs, [edx + CPUMCPU.Guest.gs] 100 mov esi, [edx + CPUMCPU.Guest.esi] 101 mov edi, [edx + CPUMCPU.Guest.edi] 102 mov ebp, [edx + CPUMCPU.Guest.ebp] 103 mov ebx, [edx + CPUMCPU.Guest.ebx] 104 mov ecx, [edx + CPUMCPU.Guest.ecx] 105 mov eax, [edx + CPUMCPU.Guest.eax] 106 push dword [edx + CPUMCPU.Guest.ds] 107 mov edx, [edx + CPUMCPU.Guest.edx] 106 108 pop ds 107 109 … … 110 112 CPUMGCRestoreInt_V86: 111 113 ; iret restores ds, es, fs & gs 112 mov ecx, [edx + CPUM .Guest.es]114 mov ecx, [edx + CPUMCPU.Guest.es] 113 115 mov [eax + 14h], ecx 114 mov ecx, [edx + CPUM .Guest.ds]116 mov ecx, [edx + CPUMCPU.Guest.ds] 115 117 mov [eax + 18h], ecx 116 mov ecx, [edx + CPUM .Guest.fs]118 mov ecx, [edx + CPUMCPU.Guest.fs] 117 119 mov [eax + 1Ch], ecx 118 mov ecx, [edx + CPUM .Guest.gs]120 mov ecx, [edx + CPUMCPU.Guest.gs] 119 121 mov [eax + 20h], ecx 120 mov esi, [edx + CPUM .Guest.esi]121 mov edi, [edx + CPUM .Guest.edi]122 mov ebp, [edx + CPUM .Guest.ebp]123 mov ebx, [edx + CPUM .Guest.ebx]124 mov ecx, [edx + CPUM .Guest.ecx]125 mov eax, [edx + CPUM .Guest.eax]126 mov edx, [edx + CPUM .Guest.edx]122 mov esi, [edx + CPUMCPU.Guest.esi] 123 mov edi, [edx + CPUMCPU.Guest.edi] 124 mov ebp, [edx + CPUMCPU.Guest.ebp] 125 mov ebx, [edx + CPUMCPU.Guest.ebx] 126 mov ecx, [edx + CPUMCPU.Guest.ecx] 127 mov eax, [edx + CPUMCPU.Guest.eax] 128 mov edx, [edx + CPUMCPU.Guest.edx] 127 129 ret 128 130 … … 250 252 align 16 251 253 BEGINPROC_EXPORTED CPUMGCResumeGuest 254 ; Convert to CPUMCPU pointer 255 add edx, [edx + CPUM.ulOffCPUMCPU] 252 256 ; 253 257 ; Setup iretd 254 258 ; 255 push dword [edx + CPUM .Guest.ss]256 push dword [edx + CPUM .Guest.esp]257 push dword [edx + CPUM .Guest.eflags]258 push dword [edx + CPUM .Guest.cs]259 push dword [edx + CPUM .Guest.eip]259 push dword [edx + CPUMCPU.Guest.ss] 260 push dword [edx + CPUMCPU.Guest.esp] 261 push dword [edx + CPUMCPU.Guest.eflags] 262 push dword [edx + CPUMCPU.Guest.cs] 263 push dword [edx + CPUMCPU.Guest.eip] 260 264 261 265 ; … … 263 267 ; 264 268 TRPM_NP_GP_HANDLER NAME(cpumGCHandleNPAndGP), CPUM_HANDLER_ES 265 mov es, [edx + CPUM .Guest.es]269 mov es, [edx + CPUMCPU.Guest.es] 266 270 TRPM_NP_GP_HANDLER NAME(cpumGCHandleNPAndGP), CPUM_HANDLER_FS 267 mov fs, [edx + CPUM .Guest.fs]271 mov fs, [edx + CPUMCPU.Guest.fs] 268 272 TRPM_NP_GP_HANDLER NAME(cpumGCHandleNPAndGP), CPUM_HANDLER_GS 269 mov gs, [edx + CPUM .Guest.gs]273 mov gs, [edx + CPUMCPU.Guest.gs] 270 274 271 275 %ifdef VBOX_WITH_STATISTICS … … 296 300 ; Continue restore. 297 301 ; 298 mov esi, [edx + CPUM .Guest.esi]299 mov edi, [edx + CPUM .Guest.edi]300 mov ebp, [edx + CPUM .Guest.ebp]301 mov ebx, [edx + CPUM .Guest.ebx]302 mov ecx, [edx + CPUM .Guest.ecx]303 mov eax, [edx + CPUM .Guest.eax]304 push dword [edx + CPUM .Guest.ds]305 mov edx, [edx + CPUM .Guest.edx]302 mov esi, [edx + CPUMCPU.Guest.esi] 303 mov edi, [edx + CPUMCPU.Guest.edi] 304 mov ebp, [edx + CPUMCPU.Guest.ebp] 305 mov ebx, [edx + CPUMCPU.Guest.ebx] 306 mov ecx, [edx + CPUMCPU.Guest.ecx] 307 mov eax, [edx + CPUMCPU.Guest.eax] 308 push dword [edx + CPUMCPU.Guest.ds] 309 mov edx, [edx + CPUMCPU.Guest.edx] 306 310 TRPM_NP_GP_HANDLER NAME(cpumGCHandleNPAndGP), CPUM_HANDLER_DS 307 311 pop ds … … 326 330 align 16 327 331 BEGINPROC_EXPORTED CPUMGCResumeGuestV86 332 ; Convert to CPUMCPU pointer 333 add edx, [edx + CPUM.ulOffCPUMCPU] 328 334 ; 329 335 ; Setup iretd 330 336 ; 331 push dword [edx + CPUM .Guest.gs]332 push dword [edx + CPUM .Guest.fs]333 push dword [edx + CPUM .Guest.ds]334 push dword [edx + CPUM .Guest.es]335 336 push dword [edx + CPUM .Guest.ss]337 push dword [edx + CPUM .Guest.esp]338 339 push dword [edx + CPUM .Guest.eflags]340 push dword [edx + CPUM .Guest.cs]341 push dword [edx + CPUM .Guest.eip]337 push dword [edx + CPUMCPU.Guest.gs] 338 push dword [edx + CPUMCPU.Guest.fs] 339 push dword [edx + CPUMCPU.Guest.ds] 340 push dword [edx + CPUMCPU.Guest.es] 341 342 push dword [edx + CPUMCPU.Guest.ss] 343 push dword [edx + CPUMCPU.Guest.esp] 344 345 push dword [edx + CPUMCPU.Guest.eflags] 346 push dword [edx + CPUMCPU.Guest.cs] 347 push dword [edx + CPUMCPU.Guest.eip] 342 348 343 349 ; … … 372 378 ; Continue restore. 373 379 ; 374 mov esi, [edx + CPUM .Guest.esi]375 mov edi, [edx + CPUM .Guest.edi]376 mov ebp, [edx + CPUM .Guest.ebp]377 mov ecx, [edx + CPUM .Guest.ecx]378 mov ebx, [edx + CPUM .Guest.ebx]379 mov eax, [edx + CPUM .Guest.eax]380 mov edx, [edx + CPUM .Guest.edx]380 mov esi, [edx + CPUMCPU.Guest.esi] 381 mov edi, [edx + CPUMCPU.Guest.edi] 382 mov ebp, [edx + CPUMCPU.Guest.ebp] 383 mov ecx, [edx + CPUMCPU.Guest.ecx] 384 mov ebx, [edx + CPUMCPU.Guest.ebx] 385 mov eax, [edx + CPUMCPU.Guest.eax] 386 mov edx, [edx + CPUMCPU.Guest.edx] 381 387 382 388 ; restart execution. -
trunk/src/VBox/VMM/VMMGC/TRPMGCHandlers.cpp
r13823 r13960 441 441 442 442 LogFlow(("TRPMTrap07HandlerGC: eip=%08RX32\n", pRegFrame->eip)); 443 return CPUMHandleLazyFPU(pVM );443 return CPUMHandleLazyFPU(pVM, VMMGetCpu(pVM)); 444 444 } 445 445 -
trunk/src/VBox/VMM/VMMR0/CPUMR0.cpp
r12989 r13960 82 82 * Read the MSR and see if it's in use or not. 83 83 */ 84 uint32_t 84 uint32_t u32 = ASMRdMsr_Low(MSR_IA32_SYSENTER_CS); 85 85 if (u32) 86 86 { 87 pVM->cpum.s.fUseFlags |= CPUM_USE_SYSENTER; 87 for (unsigned i=0;i<pVM->cCPUs;i++) 88 pVM->aCpus[i].cpum.s.fUseFlags |= CPUM_USE_SYSENTER; 89 88 90 Log(("CPUMR0Init: host uses sysenter cs=%08x%08x\n", ASMRdMsr_High(MSR_IA32_SYSENTER_CS), u32)); 89 91 } … … 101 103 if (u32DR7 & X86_DR7_ENABLED_MASK) 102 104 { 103 pVM->cpum.s.fUseFlags |= CPUM_USE_DEBUG_REGS_HOST; 105 for (unsigned i=0;i<pVM->cCPUs;i++) 106 pVM->aCpus[i].cpum.s.fUseFlags |= CPUM_USE_DEBUG_REGS_HOST; 104 107 Log(("CPUMR0Init: host uses debug registers (dr7=%x)\n", u32DR7)); 105 108 } … … 114 117 * @returns VBox status code. 115 118 * @param pVM VM handle. 119 * @param pVCpu VMCPU handle. 116 120 * @param pCtx CPU context 117 121 */ 118 VMMR0DECL(int) CPUMR0LoadGuestFPU(PVM pVM, P CPUMCTX pCtx)122 VMMR0DECL(int) CPUMR0LoadGuestFPU(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx) 119 123 { 120 124 Assert(pVM->cpum.s.CPUFeatures.edx.u1FXSR); … … 122 126 123 127 /* If the FPU state has already been loaded, then it's a guest trap. */ 124 if (pV M->cpum.s.fUseFlags & CPUM_USED_FPU)128 if (pVCpu->cpum.s.fUseFlags & CPUM_USED_FPU) 125 129 { 126 130 Assert( ((pCtx->cr0 & (X86_CR0_MP | X86_CR0_EM | X86_CR0_TS)) == (X86_CR0_MP | X86_CR0_EM | X86_CR0_TS)) … … 177 181 { 178 182 ASMWrMsr(MSR_K6_EFER, oldMsrEFERHost & ~MSR_K6_EFER_FFXSR); 179 pV M->cpum.s.fUseFlags |= CPUM_MANUAL_XMM_RESTORE;183 pVCpu->cpum.s.fUseFlags |= CPUM_MANUAL_XMM_RESTORE; 180 184 } 181 185 } 182 186 183 187 /* If we sync the FPU/XMM state on-demand, then we can continue execution as if nothing has happened. */ 184 int rc = CPUMHandleLazyFPU(pVM );188 int rc = CPUMHandleLazyFPU(pVM, pVCpu); 185 189 AssertRC(rc); 186 Assert(CPUMIsGuestFPUStateActive(pV M));190 Assert(CPUMIsGuestFPUStateActive(pVCpu)); 187 191 188 192 /* Restore EFER MSR */ 189 if (pV M->cpum.s.fUseFlags & CPUM_MANUAL_XMM_RESTORE)193 if (pVCpu->cpum.s.fUseFlags & CPUM_MANUAL_XMM_RESTORE) 190 194 ASMWrMsr(MSR_K6_EFER, oldMsrEFERHost); 191 195 … … 199 203 * We don't want the guest to be able to trigger floating point/SSE exceptions on the host. 200 204 */ 201 pV M->cpum.s.Host.fpu.FCW = CPUMGetFCW();205 pVCpu->cpum.s.Host.fpu.FCW = CPUMGetFCW(); 202 206 if (pVM->cpum.s.CPUFeatures.edx.u1SSE) 203 pV M->cpum.s.Host.fpu.MXCSR = CPUMGetMXCSR();207 pVCpu->cpum.s.Host.fpu.MXCSR = CPUMGetMXCSR(); 204 208 205 209 CPUMLoadFPUAsm(pCtx); … … 219 223 /* fxrstor doesn't restore the XMM state! */ 220 224 CPUMLoadXMMAsm(pCtx); 221 pV M->cpum.s.fUseFlags |= CPUM_MANUAL_XMM_RESTORE;225 pVCpu->cpum.s.fUseFlags |= CPUM_MANUAL_XMM_RESTORE; 222 226 } 223 227 } 224 228 #endif /* CPUM_CAN_HANDLE_NM_TRAPS_IN_KERNEL_MODE */ 225 229 226 pV M->cpum.s.fUseFlags |= CPUM_USED_FPU;230 pVCpu->cpum.s.fUseFlags |= CPUM_USED_FPU; 227 231 return VINF_SUCCESS; 228 232 } … … 234 238 * @returns VBox status code. 235 239 * @param pVM VM handle. 240 * @param pVCpu VMCPU handle. 236 241 * @param pCtx CPU context 237 242 */ 238 VMMR0DECL(int) CPUMR0SaveGuestFPU(PVM pVM, P CPUMCTX pCtx)243 VMMR0DECL(int) CPUMR0SaveGuestFPU(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx) 239 244 { 240 245 Assert(pVM->cpum.s.CPUFeatures.edx.u1FXSR); 241 246 Assert(ASMGetCR4() & X86_CR4_OSFSXR); 242 AssertReturn((pV M->cpum.s.fUseFlags & CPUM_USED_FPU), VINF_SUCCESS);247 AssertReturn((pVCpu->cpum.s.fUseFlags & CPUM_USED_FPU), VINF_SUCCESS); 243 248 244 249 #ifndef CPUM_CAN_HANDLE_NM_TRAPS_IN_KERNEL_MODE … … 246 251 247 252 /* Clear MSR_K6_EFER_FFXSR or else we'll be unable to save/restore the XMM state with fxsave/fxrstor. */ 248 if (pV M->cpum.s.fUseFlags & CPUM_MANUAL_XMM_RESTORE)253 if (pVCpu->cpum.s.fUseFlags & CPUM_MANUAL_XMM_RESTORE) 249 254 { 250 255 oldMsrEFERHost = ASMRdMsr(MSR_K6_EFER); 251 256 ASMWrMsr(MSR_K6_EFER, oldMsrEFERHost & ~MSR_K6_EFER_FFXSR); 252 257 } 253 CPUMRestoreHostFPUState(pVM );258 CPUMRestoreHostFPUState(pVM, pVCpu); 254 259 255 260 /* Restore EFER MSR */ 256 if (pV M->cpum.s.fUseFlags & CPUM_MANUAL_XMM_RESTORE)261 if (pVCpu->cpum.s.fUseFlags & CPUM_MANUAL_XMM_RESTORE) 257 262 ASMWrMsr(MSR_K6_EFER, oldMsrEFERHost | MSR_K6_EFER_FFXSR); 258 263 259 264 #else /* CPUM_CAN_HANDLE_NM_TRAPS_IN_KERNEL_MODE */ 260 265 CPUMSaveFPUAsm(pCtx); 261 if (pV M->cpum.s.fUseFlags & CPUM_MANUAL_XMM_RESTORE)266 if (pVCpu->cpum.s.fUseFlags & CPUM_MANUAL_XMM_RESTORE) 262 267 { 263 268 /* fxsave doesn't save the XMM state! */ … … 269 274 * We don't want the guest to be able to trigger floating point/SSE exceptions on the host. 270 275 */ 271 CPUMSetFCW(pV M->cpum.s.Host.fpu.FCW);276 CPUMSetFCW(pVCpu->cpum.s.Host.fpu.FCW); 272 277 if (pVM->cpum.s.CPUFeatures.edx.u1SSE) 273 CPUMSetMXCSR(pV M->cpum.s.Host.fpu.MXCSR);278 CPUMSetMXCSR(pVCpu->cpum.s.Host.fpu.MXCSR); 274 279 #endif /* CPUM_CAN_HANDLE_NM_TRAPS_IN_KERNEL_MODE */ 275 280 276 pV M->cpum.s.fUseFlags &= ~(CPUM_USED_FPU | CPUM_MANUAL_XMM_RESTORE);281 pVCpu->cpum.s.fUseFlags &= ~(CPUM_USED_FPU | CPUM_MANUAL_XMM_RESTORE); 277 282 return VINF_SUCCESS; 278 283 } … … 284 289 * @returns VBox status code. 285 290 * @param pVM VM handle. 291 * @param pVCpu VMCPU handle. 286 292 * @param pCtx CPU context 287 293 * @param fDR6 Include DR6 or not 288 294 */ 289 VMMR0DECL(int) CPUMR0SaveGuestDebugState(PVM pVM, P CPUMCTX pCtx, bool fDR6)290 { 291 Assert(pV M->cpum.s.fUseFlags & CPUM_USE_DEBUG_REGS);295 VMMR0DECL(int) CPUMR0SaveGuestDebugState(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, bool fDR6) 296 { 297 Assert(pVCpu->cpum.s.fUseFlags & CPUM_USE_DEBUG_REGS); 292 298 293 299 /* Save the guest's debug state. The caller is responsible for DR7. */ … … 303 309 * DR7 contains 0x400 right now. 304 310 */ 305 ASMSetDR0(pV M->cpum.s.Host.dr0);306 ASMSetDR1(pV M->cpum.s.Host.dr1);307 ASMSetDR2(pV M->cpum.s.Host.dr2);308 ASMSetDR3(pV M->cpum.s.Host.dr3);309 ASMSetDR6(pV M->cpum.s.Host.dr6);310 ASMSetDR7(pV M->cpum.s.Host.dr7);311 312 pV M->cpum.s.fUseFlags &= ~CPUM_USE_DEBUG_REGS;311 ASMSetDR0(pVCpu->cpum.s.Host.dr0); 312 ASMSetDR1(pVCpu->cpum.s.Host.dr1); 313 ASMSetDR2(pVCpu->cpum.s.Host.dr2); 314 ASMSetDR3(pVCpu->cpum.s.Host.dr3); 315 ASMSetDR6(pVCpu->cpum.s.Host.dr6); 316 ASMSetDR7(pVCpu->cpum.s.Host.dr7); 317 318 pVCpu->cpum.s.fUseFlags &= ~CPUM_USE_DEBUG_REGS; 313 319 return VINF_SUCCESS; 314 320 } … … 320 326 * @returns VBox status code. 321 327 * @param pVM VM handle. 328 * @param pVCpu VMCPU handle. 322 329 * @param pCtx CPU context 323 330 * @param fDR6 Include DR6 or not 324 331 */ 325 VMMR0DECL(int) CPUMR0LoadGuestDebugState(PVM pVM, P CPUMCTX pCtx, bool fDR6)332 VMMR0DECL(int) CPUMR0LoadGuestDebugState(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, bool fDR6) 326 333 { 327 334 /* Save the host state. */ 328 pV M->cpum.s.Host.dr0 = ASMGetDR0();329 pV M->cpum.s.Host.dr1 = ASMGetDR1();330 pV M->cpum.s.Host.dr2 = ASMGetDR2();331 pV M->cpum.s.Host.dr3 = ASMGetDR3();332 pV M->cpum.s.Host.dr6 = ASMGetDR6();335 pVCpu->cpum.s.Host.dr0 = ASMGetDR0(); 336 pVCpu->cpum.s.Host.dr1 = ASMGetDR1(); 337 pVCpu->cpum.s.Host.dr2 = ASMGetDR2(); 338 pVCpu->cpum.s.Host.dr3 = ASMGetDR3(); 339 pVCpu->cpum.s.Host.dr6 = ASMGetDR6(); 333 340 /** @todo dr7 might already have been changed to 0x400; don't care right now as it's harmless. */ 334 pV M->cpum.s.Host.dr7 = ASMGetDR7();341 pVCpu->cpum.s.Host.dr7 = ASMGetDR7(); 335 342 /* Make sure DR7 is harmless or else we could trigger breakpoints when restoring dr0-3 (!) */ 336 343 ASMSetDR7(X86_DR7_INIT_VAL); … … 344 351 ASMSetDR6(pCtx->dr[6]); 345 352 346 pV M->cpum.s.fUseFlags |= CPUM_USE_DEBUG_REGS;347 return VINF_SUCCESS; 348 } 349 353 pVCpu->cpum.s.fUseFlags |= CPUM_USE_DEBUG_REGS; 354 return VINF_SUCCESS; 355 } 356 -
trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp
r13898 r13960 889 889 ASMAtomicWriteBool(&pCpu->fInUse, true); 890 890 891 pCtx = CPUMQueryGuestCtxPtr (pVM);891 pCtx = CPUMQueryGuestCtxPtrEx(pVM, pVCpu); 892 892 893 893 /* Always load the guest's FPU/XMM state on-demand. */ … … 942 942 AssertReturn(!ASMAtomicReadBool(&HWACCMR0Globals.fSuspended), VERR_HWACCM_SUSPEND_PENDING); 943 943 944 pCtx = CPUMQueryGuestCtxPtr (pVM);944 pCtx = CPUMQueryGuestCtxPtrEx(pVM, pVCpu); 945 945 946 946 /* Note: It's rather tricky with longjmps done by e.g. Log statements or the page fault handler. … … 949 949 */ 950 950 /* Save the guest FPU and XMM state if necessary. */ 951 if (CPUMIsGuestFPUStateActive(pV M))951 if (CPUMIsGuestFPUStateActive(pVCpu)) 952 952 { 953 953 Log2(("CPUMR0SaveGuestFPU\n")); 954 CPUMR0SaveGuestFPU(pVM, p Ctx);954 CPUMR0SaveGuestFPU(pVM, pVCpu, pCtx); 955 955 956 956 pVCpu->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_CR0; … … 989 989 Assert(ASMAtomicReadBool(&pCpu->fInUse) == true); 990 990 991 pCtx = CPUMQueryGuestCtxPtr (pVM);991 pCtx = CPUMQueryGuestCtxPtrEx(pVM, pVCpu); 992 992 993 993 return HWACCMR0Globals.pfnRunGuestCode(pVM, pVCpu, pCtx); -
trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp
r13905 r13960 608 608 { 609 609 val = pCtx->cr0; 610 if (!CPUMIsGuestFPUStateActive(pV M))610 if (!CPUMIsGuestFPUStateActive(pVCpu)) 611 611 { 612 612 /* Always use #NM exceptions to load the FPU/XMM state on demand. */ … … 723 723 724 724 /* Save the host and load the guest debug state. */ 725 int rc = CPUMR0LoadGuestDebugState(pVM, p Ctx, false /* exclude DR6 */);725 int rc = CPUMR0LoadGuestDebugState(pVM, pVCpu, pCtx, false /* exclude DR6 */); 726 726 AssertRC(rc); 727 727 } … … 1329 1329 /** @todo don't intercept #NM exceptions anymore when we've activated the guest FPU state. */ 1330 1330 /* If we sync the FPU/XMM state on-demand, then we can continue execution as if nothing has happened. */ 1331 rc = CPUMR0LoadGuestFPU(pVM, p Ctx);1331 rc = CPUMR0LoadGuestFPU(pVM, pVCpu, pCtx); 1332 1332 if (rc == VINF_SUCCESS) 1333 1333 { 1334 Assert(CPUMIsGuestFPUStateActive(pV M));1334 Assert(CPUMIsGuestFPUStateActive(pVCpu)); 1335 1335 STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitShadowNM); 1336 1336 … … 1723 1723 1724 1724 /* Save the host and load the guest debug state. */ 1725 rc = CPUMR0LoadGuestDebugState(pVM, p Ctx, false /* exclude DR6 */);1725 rc = CPUMR0LoadGuestDebugState(pVM, pVCpu, pCtx, false /* exclude DR6 */); 1726 1726 AssertRC(rc); 1727 1727 … … 1763 1763 1764 1764 /* Save the host and load the guest debug state. */ 1765 rc = CPUMR0LoadGuestDebugState(pVM, p Ctx, false /* exclude DR6 */);1765 rc = CPUMR0LoadGuestDebugState(pVM, pVCpu, pCtx, false /* exclude DR6 */); 1766 1766 AssertRC(rc); 1767 1767 … … 2094 2094 if (CPUMIsGuestDebugStateActive(pVM)) 2095 2095 { 2096 CPUMR0SaveGuestDebugState(pVM, p Ctx, false /* skip DR6 */);2096 CPUMR0SaveGuestDebugState(pVM, pVCpu, pCtx, false /* skip DR6 */); 2097 2097 2098 2098 /* Intercept all DRx reads and writes again. Changed later on. */ -
trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp
r13909 r13960 921 921 922 922 /* Also catch floating point exceptions as we need to report them to the guest in a different way. */ 923 if ( CPUMIsGuestFPUStateActive(pV M) == true923 if ( CPUMIsGuestFPUStateActive(pVCpu) == true 924 924 && !(pCtx->cr0 & X86_CR0_NE) 925 925 && !pVCpu->hwaccm.s.fFPUOldStyleOverride) … … 1130 1130 rc = VMXWriteVMCS(VMX_VMCS_CTRL_CR0_READ_SHADOW, val); 1131 1131 Log2(("Guest CR0-shadow %08x\n", val)); 1132 if (CPUMIsGuestFPUStateActive(pV M) == false)1132 if (CPUMIsGuestFPUStateActive(pVCpu) == false) 1133 1133 { 1134 1134 /* Always use #NM exceptions to load the FPU/XMM state on demand. */ … … 1339 1339 1340 1340 /* Save the host and load the guest debug state. */ 1341 rc = CPUMR0LoadGuestDebugState(pVM, p Ctx, true /* include DR6 */);1341 rc = CPUMR0LoadGuestDebugState(pVM, pVCpu, pCtx, true /* include DR6 */); 1342 1342 AssertRC(rc); 1343 1343 } … … 2081 2081 /** @todo don't intercept #NM exceptions anymore when we've activated the guest FPU state. */ 2082 2082 /* If we sync the FPU/XMM state on-demand, then we can continue execution as if nothing has happened. */ 2083 rc = CPUMR0LoadGuestFPU(pVM, p Ctx);2083 rc = CPUMR0LoadGuestFPU(pVM, pVCpu, pCtx); 2084 2084 if (rc == VINF_SUCCESS) 2085 2085 { 2086 Assert(CPUMIsGuestFPUStateActive(pV M));2086 Assert(CPUMIsGuestFPUStateActive(pVCpu)); 2087 2087 2088 2088 STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitShadowNM); … … 2592 2592 2593 2593 /* Save the host and load the guest debug state. */ 2594 rc = CPUMR0LoadGuestDebugState(pVM, p Ctx, true /* include DR6 */);2594 rc = CPUMR0LoadGuestDebugState(pVM, pVCpu, pCtx, true /* include DR6 */); 2595 2595 AssertRC(rc); 2596 2596 … … 3028 3028 if (CPUMIsGuestDebugStateActive(pVM)) 3029 3029 { 3030 CPUMR0SaveGuestDebugState(pVM, p Ctx, true /* save DR6 */);3030 CPUMR0SaveGuestDebugState(pVM, pVCpu, pCtx, true /* save DR6 */); 3031 3031 3032 3032 /* Enable drx move intercepts again. */ -
trunk/src/VBox/VMM/VMMSwitcher/AMD64ToPAE.asm
r12602 r13960 198 198 ; 199 199 ; USES/DESTROYS: 200 ; - eax, ecx, edx 200 ; - eax, ecx, edx, r8 201 201 ; 202 202 ; ASSUMPTION: … … 206 206 ALIGNCODE(16) 207 207 BEGINPROC vmmR0HostToGuestAsm 208 ;; Store the offset from CPUM to CPUMCPU in r8 209 mov r8, [rdx + CPUM.ulOffCPUMCPU] 210 208 211 ;; 209 212 ;; Save CPU host context … … 211 214 ;; 212 215 ; general registers. 213 ; mov [rdx + CPUM.Host.rax], rax - scratch214 mov [rdx + CPUM.Host.rbx], rbx215 ; mov [rdx + CPUM.Host.rcx], rcx - scratch216 ; mov [rdx + CPUM.Host.rdx], rdx - scratch217 mov [rdx + CPUM.Host.rdi], rdi218 mov [rdx + CPUM.Host.rsi], rsi219 mov [rdx + CPUM.Host.rsp], rsp220 mov [rdx + CPUM.Host.rbp], rbp221 ; mov [rdx + CPUM.Host.r8 ], r8 - scratch222 ; mov [rdx + CPUM.Host.r9 ], r9 - scratch223 mov [rdx + CPUM.Host.r10], r10224 mov [rdx + CPUM.Host.r11], r11225 mov [rdx + CPUM.Host.r12], r12226 mov [rdx + CPUM.Host.r13], r13227 mov [rdx + CPUM.Host.r14], r14228 mov [rdx + CPUM.Host.r15], r15216 ; mov [rdx + r8 + CPUMCPU.Host.rax], rax - scratch 217 mov [rdx + r8 + CPUMCPU.Host.rbx], rbx 218 ; mov [rdx + r8 + CPUMCPU.Host.rcx], rcx - scratch 219 ; mov [rdx + r8 + CPUMCPU.Host.rdx], rdx - scratch 220 mov [rdx + r8 + CPUMCPU.Host.rdi], rdi 221 mov [rdx + r8 + CPUMCPU.Host.rsi], rsi 222 mov [rdx + r8 + CPUMCPU.Host.rsp], rsp 223 mov [rdx + r8 + CPUMCPU.Host.rbp], rbp 224 ; mov [rdx + r8 + CPUMCPU.Host.r8 ], r8 - scratch 225 ; mov [rdx + r8 + CPUMCPU.Host.r9 ], r9 - scratch 226 mov [rdx + r8 + CPUMCPU.Host.r10], r10 227 mov [rdx + r8 + CPUMCPU.Host.r11], r11 228 mov [rdx + r8 + CPUMCPU.Host.r12], r12 229 mov [rdx + r8 + CPUMCPU.Host.r13], r13 230 mov [rdx + r8 + CPUMCPU.Host.r14], r14 231 mov [rdx + r8 + CPUMCPU.Host.r15], r15 229 232 ; selectors. 230 mov [rdx + CPUM.Host.ds], ds231 mov [rdx + CPUM.Host.es], es232 mov [rdx + CPUM.Host.fs], fs233 mov [rdx + CPUM.Host.gs], gs234 mov [rdx + CPUM.Host.ss], ss233 mov [rdx + r8 + CPUMCPU.Host.ds], ds 234 mov [rdx + r8 + CPUMCPU.Host.es], es 235 mov [rdx + r8 + CPUMCPU.Host.fs], fs 236 mov [rdx + r8 + CPUMCPU.Host.gs], gs 237 mov [rdx + r8 + CPUMCPU.Host.ss], ss 235 238 ; MSRs 236 239 mov rbx, rdx 237 240 mov ecx, MSR_K8_FS_BASE 238 241 rdmsr 239 mov [rbx + CPUM.Host.FSbase], eax240 mov [rbx + CPUM.Host.FSbase + 4], edx242 mov [rbx + r8 + CPUMCPU.Host.FSbase], eax 243 mov [rbx + r8 + CPUMCPU.Host.FSbase + 4], edx 241 244 mov ecx, MSR_K8_GS_BASE 242 245 rdmsr 243 mov [rbx + CPUM.Host.GSbase], eax244 mov [rbx + CPUM.Host.GSbase + 4], edx246 mov [rbx + r8 + CPUMCPU.Host.GSbase], eax 247 mov [rbx + r8 + CPUMCPU.Host.GSbase + 4], edx 245 248 mov ecx, MSR_K6_EFER 246 249 rdmsr 247 mov [rbx + CPUM.Host.efer], eax248 mov [rbx + CPUM.Host.efer + 4], edx250 mov [rbx + r8 + CPUMCPU.Host.efer], eax 251 mov [rbx + r8 + CPUMCPU.Host.efer + 4], edx 249 252 mov ecx, MSR_K6_EFER 250 253 mov rdx, rbx 251 254 ; special registers. 252 sldt [rdx + CPUM.Host.ldtr]253 sidt [rdx + CPUM.Host.idtr]254 sgdt [rdx + CPUM.Host.gdtr]255 str [rdx + CPUM.Host.tr] ; yasm BUG, generates sldt. YASMCHECK!255 sldt [rdx + r8 + CPUMCPU.Host.ldtr] 256 sidt [rdx + r8 + CPUMCPU.Host.idtr] 257 sgdt [rdx + r8 + CPUMCPU.Host.gdtr] 258 str [rdx + r8 + CPUMCPU.Host.tr] ; yasm BUG, generates sldt. YASMCHECK! 256 259 ; flags 257 260 pushf 258 pop qword [rdx + CPUM.Host.rflags]261 pop qword [rdx + r8 + CPUMCPU.Host.rflags] 259 262 260 263 FIXUP FIX_NO_SYSENTER_JMP, 0, htg_no_sysenter - NAME(Start) ; this will insert a jmp htg_no_sysenter if host doesn't use sysenter. … … 263 266 mov rbx, rdx ; save edx 264 267 rdmsr ; edx:eax <- MSR[ecx] 265 mov [rbx + CPUM.Host.SysEnter.cs], rax266 mov [rbx + CPUM.Host.SysEnter.cs + 4], rdx268 mov [rbx + r8 + CPUMCPU.Host.SysEnter.cs], rax 269 mov [rbx + r8 + CPUMCPU.Host.SysEnter.cs + 4], rdx 267 270 xor rax, rax ; load 0:0 to cause #GP upon sysenter 268 271 xor rdx, rdx … … 275 278 276 279 ;; handle use flags. 277 mov esi, [rdx + CPUM.fUseFlags] ; esi == use flags.280 mov esi, [rdx + r8 + CPUMCPU.fUseFlags] ; esi == use flags. 278 281 and esi, ~CPUM_USED_FPU ; Clear CPUM_USED_* flags. ;;@todo FPU check can be optimized to use cr0 flags! 279 mov [rdx + CPUM.fUseFlags], esi282 mov [rdx + r8 + CPUMCPU.fUseFlags], esi 280 283 281 284 ; debug registers. … … 288 291 ; control registers. 289 292 mov rax, cr0 290 mov [rdx + CPUM.Host.cr0], rax291 ;mov rax, cr2 ; assume host os don't s uff things in cr2. (safe)292 ;mov [rdx + CPUM.Host.cr2], rax293 mov [rdx + r8 + CPUMCPU.Host.cr0], rax 294 ;mov rax, cr2 ; assume host os don't stuff things in cr2. (safe) 295 ;mov [rdx + r8 + CPUMCPU.Host.cr2], rax 293 296 mov rax, cr3 294 mov [rdx + CPUM.Host.cr3], rax297 mov [rdx + r8 + CPUMCPU.Host.cr3], rax 295 298 mov rax, cr4 296 mov [rdx + CPUM.Host.cr4], rax299 mov [rdx + r8 + CPUMCPU.Host.cr4], rax 297 300 298 301 ;; … … 306 309 ; 307 310 and rax, X86_CR4_MCE | X86_CR4_PSE | X86_CR4_PAE 308 mov ecx, [rdx + CPUM.Guest.cr4]311 mov ecx, [rdx + r8 + CPUMCPU.Guest.cr4] 309 312 DEBUG_CHAR('b') ; trashes esi 310 ;; @todo Switcher cleanup: Determin base CR4 during CPUMR0Init / VMMR3SelectSwitcher putting it313 ;; @todo Switcher cleanup: Determine base CR4 during CPUMR0Init / VMMR3SelectSwitcher putting it 311 314 ; in CPUM.Hyper.cr4 (which isn't currently being used). That should 312 315 ; simplify this operation a bit (and improve locality of the data). … … 322 325 DEBUG_CHAR('c') ; trashes esi 323 326 324 mov eax, [rdx + CPUM.Guest.cr0]327 mov eax, [rdx + r8 + CPUMCPU.Guest.cr0] 325 328 and eax, X86_CR0_EM 326 329 or eax, X86_CR0_PE | X86_CR0_PG | X86_CR0_TS | X86_CR0_ET | X86_CR0_NE | X86_CR0_MP … … 360 363 DEBUG_S_CHAR('s'); 361 364 mov rax, dr7 ; not sure, but if I read the docs right this will trap if GD is set. FIXME!!! 362 mov [rdx + CPUM.Host.dr7], rax365 mov [rdx + r8 + CPUMCPU.Host.dr7], rax 363 366 xor eax, eax ; clear everything. (bit 12? is read as 1...) 364 367 mov dr7, rax 365 368 mov rax, dr6 ; just in case we save the state register too. 366 mov [rdx + CPUM.Host.dr6], rax369 mov [rdx + r8 + CPUMCPU.Host.dr6], rax 367 370 ; save host DR0-3? 368 371 test esi, CPUM_USE_DEBUG_REGS … … 370 373 DEBUG_S_CHAR('S'); 371 374 mov rax, dr0 372 mov [rdx + CPUM.Host.dr0], rax375 mov [rdx + r8 + CPUMCPU.Host.dr0], rax 373 376 mov rbx, dr1 374 mov [rdx + CPUM.Host.dr1], rbx377 mov [rdx + r8 + CPUMCPU.Host.dr1], rbx 375 378 mov rcx, dr2 376 mov [rdx + CPUM.Host.dr2], rcx379 mov [rdx + r8 + CPUMCPU.Host.dr2], rcx 377 380 mov rax, dr3 378 mov [rdx + CPUM.Host.dr3], rax381 mov [rdx + r8 + CPUMCPU.Host.dr3], rax 379 382 jmp htg_debug_regs_no 380 383 … … 472 475 473 476 ;; use flags. 474 mov esi, [edx + CPUM.fUseFlags] 477 mov esi, [edx + CPUM.ulOffCPUMCPU] 478 mov esi, [edx + esi + CPUMCPU.fUseFlags] 475 479 476 480 ; debug registers … … 632 636 FIXUP FIX_GC_CPUM_OFF, 1, 0 633 637 mov edx, 0ffffffffh 634 638 ; Convert to CPUMCPU pointer 639 add edx, [edx + CPUM.ulOffCPUMCPU] 640 635 641 ; Skip return address (assumes called!) 636 642 lea esp, [esp + 4] … … 642 648 push eax ; save return code. 643 649 mov eax, [esp + 4 + CPUMCTXCORE.edi] 644 mov [edx + CPUM .Guest.edi], eax650 mov [edx + CPUMCPU.Guest.edi], eax 645 651 mov eax, [esp + 4 + CPUMCTXCORE.esi] 646 mov [edx + CPUM .Guest.esi], eax652 mov [edx + CPUMCPU.Guest.esi], eax 647 653 mov eax, [esp + 4 + CPUMCTXCORE.ebp] 648 mov [edx + CPUM .Guest.ebp], eax654 mov [edx + CPUMCPU.Guest.ebp], eax 649 655 mov eax, [esp + 4 + CPUMCTXCORE.eax] 650 mov [edx + CPUM .Guest.eax], eax656 mov [edx + CPUMCPU.Guest.eax], eax 651 657 mov eax, [esp + 4 + CPUMCTXCORE.ebx] 652 mov [edx + CPUM .Guest.ebx], eax658 mov [edx + CPUMCPU.Guest.ebx], eax 653 659 mov eax, [esp + 4 + CPUMCTXCORE.edx] 654 mov [edx + CPUM .Guest.edx], eax660 mov [edx + CPUMCPU.Guest.edx], eax 655 661 mov eax, [esp + 4 + CPUMCTXCORE.ecx] 656 mov [edx + CPUM .Guest.ecx], eax662 mov [edx + CPUMCPU.Guest.ecx], eax 657 663 mov eax, [esp + 4 + CPUMCTXCORE.esp] 658 mov [edx + CPUM .Guest.esp], eax664 mov [edx + CPUMCPU.Guest.esp], eax 659 665 ; selectors 660 666 mov eax, [esp + 4 + CPUMCTXCORE.ss] 661 mov [edx + CPUM .Guest.ss], eax667 mov [edx + CPUMCPU.Guest.ss], eax 662 668 mov eax, [esp + 4 + CPUMCTXCORE.gs] 663 mov [edx + CPUM .Guest.gs], eax669 mov [edx + CPUMCPU.Guest.gs], eax 664 670 mov eax, [esp + 4 + CPUMCTXCORE.fs] 665 mov [edx + CPUM .Guest.fs], eax671 mov [edx + CPUMCPU.Guest.fs], eax 666 672 mov eax, [esp + 4 + CPUMCTXCORE.es] 667 mov [edx + CPUM .Guest.es], eax673 mov [edx + CPUMCPU.Guest.es], eax 668 674 mov eax, [esp + 4 + CPUMCTXCORE.ds] 669 mov [edx + CPUM .Guest.ds], eax675 mov [edx + CPUMCPU.Guest.ds], eax 670 676 mov eax, [esp + 4 + CPUMCTXCORE.cs] 671 mov [edx + CPUM .Guest.cs], eax677 mov [edx + CPUMCPU.Guest.cs], eax 672 678 ; flags 673 679 mov eax, [esp + 4 + CPUMCTXCORE.eflags] 674 mov [edx + CPUM .Guest.eflags], eax680 mov [edx + CPUMCPU.Guest.eflags], eax 675 681 ; eip 676 682 mov eax, [esp + 4 + CPUMCTXCORE.eip] 677 mov [edx + CPUM .Guest.eip], eax683 mov [edx + CPUMCPU.Guest.eip], eax 678 684 ; jump to common worker code. 679 685 pop eax ; restore return code. 686 ; Load CPUM into edx again 687 sub edx, [edx + CPUMCPU.ulOffCPUM] 680 688 681 689 add esp, CPUMCTXCORE_size ; skip CPUMCTXCORE structure … … 913 921 914 922 ; load final cr3 915 mov rsi, [rdx + CPUM.Host.cr3]923 mov rsi, [rdx + r8 + CPUMCPU.Host.cr3] 916 924 mov cr3, rsi 917 925 DEBUG_CHAR('@') … … 922 930 ; Load CPUM pointer into edx 923 931 mov rdx, [NAME(pCpumHC) wrt rip] 932 ; Load the CPUMCPU offset. 933 mov r8, [rdx + CPUM.ulOffCPUMCPU] 934 924 935 ; activate host gdt and idt 925 lgdt [rdx + CPUM.Host.gdtr]936 lgdt [rdx + r8 + CPUMCPU.Host.gdtr] 926 937 DEBUG_CHAR('0') 927 lidt [rdx + CPUM.Host.idtr]938 lidt [rdx + r8 + CPUMCPU.Host.idtr] 928 939 DEBUG_CHAR('1') 929 940 ; Restore TSS selector; must mark it as not busy before using ltr (!) 930 941 %if 1 ; ASSUME that this is supposed to be 'BUSY'. (saves 20-30 ticks on the T42p) 931 movzx eax, word [rdx + CPUM.Host.tr] ; eax <- TR942 movzx eax, word [rdx + r8 + CPUMCPU.Host.tr] ; eax <- TR 932 943 and al, 0F8h ; mask away TI and RPL bits, get descriptor offset. 933 add rax, [rdx + CPUM.Host.gdtr + 2] ; eax <- GDTR.address + descriptor offset.944 add rax, [rdx + r8 + CPUMCPU.Host.gdtr + 2] ; eax <- GDTR.address + descriptor offset. 934 945 and dword [rax + 4], ~0200h ; clear busy flag (2nd type2 bit) 935 ltr word [rdx + CPUM.Host.tr]946 ltr word [rdx + r8 + CPUMCPU.Host.tr] 936 947 %else 937 movzx eax, word [rdx + CPUM.Host.tr] ; eax <- TR948 movzx eax, word [rdx + r8 + CPUMCPU.Host.tr] ; eax <- TR 938 949 and al, 0F8h ; mask away TI and RPL bits, get descriptor offset. 939 add rax, [rdx + CPUM.Host.gdtr + 2] ; eax <- GDTR.address + descriptor offset.950 add rax, [rdx + r8 + CPUMCPU.Host.gdtr + 2] ; eax <- GDTR.address + descriptor offset. 940 951 mov ecx, [rax + 4] ; ecx <- 2nd descriptor dword 941 952 mov ebx, ecx ; save orginal value 942 953 and ecx, ~0200h ; clear busy flag (2nd type2 bit) 943 954 mov [rax + 4], ccx ; not using xchg here is paranoia.. 944 ltr word [rdx + CPUM.Host.tr]955 ltr word [rdx + r8 + CPUMCPU.Host.tr] 945 956 xchg [rax + 4], ebx ; using xchg is paranoia too... 946 957 %endif 947 958 ; activate ldt 948 959 DEBUG_CHAR('2') 949 lldt [rdx + CPUM.Host.ldtr]960 lldt [rdx + r8 + CPUMCPU.Host.ldtr] 950 961 ; Restore segment registers 951 mov eax, [rdx + CPUM.Host.ds]962 mov eax, [rdx + r8 + CPUMCPU.Host.ds] 952 963 mov ds, eax 953 mov eax, [rdx + CPUM.Host.es]964 mov eax, [rdx + r8 + CPUMCPU.Host.es] 954 965 mov es, eax 955 mov eax, [rdx + CPUM.Host.fs]966 mov eax, [rdx + r8 + CPUMCPU.Host.fs] 956 967 mov fs, eax 957 mov eax, [rdx + CPUM.Host.gs]968 mov eax, [rdx + r8 + CPUMCPU.Host.gs] 958 969 mov gs, eax 959 970 ; restore stack 960 mov eax, [rdx + CPUM.Host.ss]971 mov eax, [rdx + r8 + CPUMCPU.Host.ss] 961 972 mov ss, eax 962 mov rsp, [rdx + CPUM.Host.rsp]973 mov rsp, [rdx + r8 + CPUMCPU.Host.rsp] 963 974 964 975 FIXUP FIX_NO_SYSENTER_JMP, 0, gth_sysenter_no - NAME(Start) ; this will insert a jmp gth_sysenter_no if host doesn't use sysenter. 965 976 ; restore MSR_IA32_SYSENTER_CS register. 966 977 mov ecx, MSR_IA32_SYSENTER_CS 967 mov eax, [rdx + CPUM.Host.SysEnter.cs]968 mov ebx, [rdx + CPUM.Host.SysEnter.cs + 4]978 mov eax, [rdx + r8 + CPUMCPU.Host.SysEnter.cs] 979 mov ebx, [rdx + r8 + CPUMCPU.Host.SysEnter.cs + 4] 969 980 mov rbx, rdx ; save/load edx 970 981 wrmsr ; MSR[ecx] <- edx:eax … … 979 990 ; Restore FPU if guest has used it. 980 991 ; Using fxrstor should ensure that we're not causing unwanted exception on the host. 981 mov esi, [rdx + CPUM.fUseFlags] ; esi == use flags.992 mov esi, [rdx + r8 + CPUMCPU.fUseFlags] ; esi == use flags. 982 993 test esi, CPUM_USED_FPU 983 994 jz short gth_fpu_no … … 986 997 mov cr0, rcx 987 998 988 fxsave [rdx + CPUM.Guest.fpu]989 fxrstor [rdx + CPUM.Host.fpu]999 fxsave [rdx + r8 + CPUMCPU.Guest.fpu] 1000 fxrstor [rdx + r8 + CPUMCPU.Host.fpu] 990 1001 jmp short gth_fpu_no 991 1002 … … 996 1007 ; Would've liked to have these highere up in case of crashes, but 997 1008 ; the fpu stuff must be done before we restore cr0. 998 mov rcx, [rdx + CPUM.Host.cr4]1009 mov rcx, [rdx + r8 + CPUMCPU.Host.cr4] 999 1010 mov cr4, rcx 1000 mov rcx, [rdx + CPUM.Host.cr0]1011 mov rcx, [rdx + r8 + CPUMCPU.Host.cr0] 1001 1012 mov cr0, rcx 1002 ;mov rcx, [rdx + CPUM.Host.cr2] ; assumes this is waste of time.1013 ;mov rcx, [rdx + r8 + CPUMCPU.Host.cr2] ; assumes this is waste of time. 1003 1014 ;mov cr2, rcx 1004 1015 … … 1013 1024 mov rbx, rdx 1014 1025 mov ecx, MSR_K8_FS_BASE 1015 mov eax, [rbx + CPUM.Host.FSbase]1016 mov edx, [rbx + CPUM.Host.FSbase + 4]1026 mov eax, [rbx + r8 + CPUMCPU.Host.FSbase] 1027 mov edx, [rbx + r8 + CPUMCPU.Host.FSbase + 4] 1017 1028 wrmsr 1018 1029 mov ecx, MSR_K8_GS_BASE 1019 mov eax, [rbx + CPUM.Host.GSbase]1020 mov edx, [rbx + CPUM.Host.GSbase + 4]1030 mov eax, [rbx + r8 + CPUMCPU.Host.GSbase] 1031 mov edx, [rbx + r8 + CPUMCPU.Host.GSbase + 4] 1021 1032 wrmsr 1022 1033 mov ecx, MSR_K6_EFER 1023 mov eax, [rbx + CPUM.Host.efer]1024 mov edx, [rbx + CPUM.Host.efer + 4]1034 mov eax, [rbx + r8 + CPUMCPU.Host.efer] 1035 mov edx, [rbx + r8 + CPUMCPU.Host.efer + 4] 1025 1036 wrmsr 1026 1037 mov rdx, rbx … … 1029 1040 ; restore general registers. 1030 1041 mov eax, edi ; restore return code. eax = return code !! 1031 ; mov rax, [rdx + CPUM.Host.rax] - scratch + return code1032 mov rbx, [rdx + CPUM.Host.rbx]1033 ; mov rcx, [rdx + CPUM.Host.rcx] - scratch1034 ; mov rdx, [rdx + CPUM.Host.rdx] - scratch1035 mov rdi, [rdx + CPUM.Host.rdi]1036 mov rsi, [rdx + CPUM.Host.rsi]1037 mov rsp, [rdx + CPUM.Host.rsp]1038 mov rbp, [rdx + CPUM.Host.rbp]1039 ; mov r8, [rdx + CPUM.Host.r8 ] - scratch1040 ; mov r9, [rdx + CPUM.Host.r9 ] - scratch1041 mov r10, [rdx + CPUM.Host.r10]1042 mov r11, [rdx + CPUM.Host.r11]1043 mov r12, [rdx + CPUM.Host.r12]1044 mov r13, [rdx + CPUM.Host.r13]1045 mov r14, [rdx + CPUM.Host.r14]1046 mov r15, [rdx + CPUM.Host.r15]1042 ; mov rax, [rdx + r8 + CPUMCPU.Host.rax] - scratch + return code 1043 mov rbx, [rdx + r8 + CPUMCPU.Host.rbx] 1044 ; mov rcx, [rdx + r8 + CPUMCPU.Host.rcx] - scratch 1045 ; mov rdx, [rdx + r8 + CPUMCPU.Host.rdx] - scratch 1046 mov rdi, [rdx + r8 + CPUMCPU.Host.rdi] 1047 mov rsi, [rdx + r8 + CPUMCPU.Host.rsi] 1048 mov rsp, [rdx + r8 + CPUMCPU.Host.rsp] 1049 mov rbp, [rdx + r8 + CPUMCPU.Host.rbp] 1050 ; mov r8, [rdx + r8 + CPUMCPU.Host.r8 ] - scratch 1051 ; mov r9, [rdx + r8 + CPUMCPU.Host.r9 ] - scratch 1052 mov r10, [rdx + r8 + CPUMCPU.Host.r10] 1053 mov r11, [rdx + r8 + CPUMCPU.Host.r11] 1054 mov r12, [rdx + r8 + CPUMCPU.Host.r12] 1055 mov r13, [rdx + r8 + CPUMCPU.Host.r13] 1056 mov r14, [rdx + r8 + CPUMCPU.Host.r14] 1057 mov r15, [rdx + r8 + CPUMCPU.Host.r15] 1047 1058 1048 1059 ; finally restore flags. (probably not required) 1049 push qword [rdx + CPUM.Host.rflags]1060 push qword [rdx + r8 + CPUMCPU.Host.rflags] 1050 1061 popf 1051 1062 … … 1067 1078 jz short gth_debug_regs_dr7 1068 1079 DEBUG_S_CHAR('r') 1069 mov rax, [rdx + CPUM.Host.dr0]1080 mov rax, [rdx + r8 + CPUMCPU.Host.dr0] 1070 1081 mov dr0, rax 1071 mov rbx, [rdx + CPUM.Host.dr1]1082 mov rbx, [rdx + r8 + CPUMCPU.Host.dr1] 1072 1083 mov dr1, rbx 1073 mov rcx, [rdx + CPUM.Host.dr2]1084 mov rcx, [rdx + r8 + CPUMCPU.Host.dr2] 1074 1085 mov dr2, rcx 1075 mov rax, [rdx + CPUM.Host.dr3]1086 mov rax, [rdx + r8 + CPUMCPU.Host.dr3] 1076 1087 mov dr3, rax 1077 1088 gth_debug_regs_dr7: 1078 mov rbx, [rdx + CPUM.Host.dr6]1089 mov rbx, [rdx + r8 + CPUMCPU.Host.dr6] 1079 1090 mov dr6, rbx 1080 mov rcx, [rdx + CPUM.Host.dr7]1091 mov rcx, [rdx + r8 + CPUMCPU.Host.dr7] 1081 1092 mov dr7, rcx 1082 1093 jmp gth_debug_regs_no -
trunk/src/VBox/VMM/VMMSwitcher/PAEand32Bit.mac
r12602 r13960 119 119 ;; Skip eax, edx and ecx as these are not preserved over calls. 120 120 ;; 121 CPUMCPU_FROM_CPUM(edx) 121 122 ; general registers. 122 mov [edx + CPUM .Host.ebx], ebx123 mov [edx + CPUM .Host.edi], edi124 mov [edx + CPUM .Host.esi], esi125 mov [edx + CPUM .Host.esp], esp126 mov [edx + CPUM .Host.ebp], ebp123 mov [edx + CPUMCPU.Host.ebx], ebx 124 mov [edx + CPUMCPU.Host.edi], edi 125 mov [edx + CPUMCPU.Host.esi], esi 126 mov [edx + CPUMCPU.Host.esp], esp 127 mov [edx + CPUMCPU.Host.ebp], ebp 127 128 ; selectors. 128 mov [edx + CPUM .Host.ds], ds129 mov [edx + CPUM .Host.es], es130 mov [edx + CPUM .Host.fs], fs131 mov [edx + CPUM .Host.gs], gs132 mov [edx + CPUM .Host.ss], ss129 mov [edx + CPUMCPU.Host.ds], ds 130 mov [edx + CPUMCPU.Host.es], es 131 mov [edx + CPUMCPU.Host.fs], fs 132 mov [edx + CPUMCPU.Host.gs], gs 133 mov [edx + CPUMCPU.Host.ss], ss 133 134 ; special registers. 134 sldt [edx + CPUM .Host.ldtr]135 sidt [edx + CPUM .Host.idtr]136 sgdt [edx + CPUM .Host.gdtr]137 str [edx + CPUM .Host.tr]135 sldt [edx + CPUMCPU.Host.ldtr] 136 sidt [edx + CPUMCPU.Host.idtr] 137 sgdt [edx + CPUMCPU.Host.gdtr] 138 str [edx + CPUMCPU.Host.tr] 138 139 ; flags 139 140 pushfd 140 pop dword [edx + CPUM .Host.eflags]141 pop dword [edx + CPUMCPU.Host.eflags] 141 142 142 143 FIXUP FIX_NO_SYSENTER_JMP, 0, htg_no_sysenter - NAME(Start) ; this will insert a jmp htg_no_sysenter if host doesn't use sysenter. … … 145 146 mov ebx, edx ; save edx 146 147 rdmsr ; edx:eax <- MSR[ecx] 147 mov [ebx + CPUM .Host.SysEnter.cs], eax148 mov [ebx + CPUM .Host.SysEnter.cs + 4], edx148 mov [ebx + CPUMCPU.Host.SysEnter.cs], eax 149 mov [ebx + CPUMCPU.Host.SysEnter.cs + 4], edx 149 150 xor eax, eax ; load 0:0 to cause #GP upon sysenter 150 151 xor edx, edx … … 157 158 158 159 ;; handle use flags. 159 mov esi, [edx + CPUM .fUseFlags] ; esi == use flags.160 mov esi, [edx + CPUMCPU.fUseFlags] ; esi == use flags. 160 161 and esi, ~CPUM_USED_FPU ; Clear CPUM_USED_* flags. ;;@todo FPU check can be optimized to use cr0 flags! 161 mov [edx + CPUM .fUseFlags], esi162 mov [edx + CPUMCPU.fUseFlags], esi 162 163 163 164 ; debug registers. … … 169 170 ; control registers. 170 171 mov eax, cr0 171 mov [edx + CPUM .Host.cr0], eax172 mov [edx + CPUMCPU.Host.cr0], eax 172 173 ;mov eax, cr2 ; assume host os don't suff things in cr2. (safe) 173 ;mov [edx + CPUM .Host.cr2], eax174 ;mov [edx + CPUMCPU.Host.cr2], eax 174 175 mov eax, cr3 175 mov [edx + CPUM .Host.cr3], eax176 mov [edx + CPUMCPU.Host.cr3], eax 176 177 mov eax, cr4 177 mov [edx + CPUM .Host.cr4], eax178 mov [edx + CPUMCPU.Host.cr4], eax 178 179 179 180 ;; … … 188 189 ; 189 190 and eax, X86_CR4_MCE | X86_CR4_PSE | X86_CR4_PAE | X86_CR4_VMXE 190 mov ecx, [edx + CPUM .Guest.cr4]191 mov ecx, [edx + CPUMCPU.Guest.cr4] 191 192 ;; @todo Switcher cleanup: Determin base CR4 during CPUMR0Init / VMMR3SelectSwitcher putting it 192 193 ; in CPUM.Hyper.cr4 (which isn't currently being used). That should … … 197 198 ; FXSAVE support on the host CPU 198 199 ; 200 CPUM_FROM_CPUMCPU(edx) 199 201 and ecx, [edx + CPUM.CR4.AndMask] 200 202 or eax, ecx … … 202 204 mov cr4, eax 203 205 204 mov eax, [edx + CPUM.Guest.cr0] 206 CPUMCPU_FROM_CPUM(edx) 207 mov eax, [edx + CPUMCPU.Guest.cr0] 205 208 and eax, X86_CR0_EM 206 209 or eax, X86_CR0_PE | X86_CR0_PG | X86_CR0_TS | X86_CR0_ET | X86_CR0_NE | X86_CR0_MP 207 210 mov cr0, eax 208 211 212 CPUM_FROM_CPUMCPU(edx) 209 213 ; Load new gdt so we can do far jump to guest code after cr3 reload. 210 214 lgdt [edx + CPUM.Hyper.gdtr] … … 307 311 DEBUG_CHAR('7') 308 312 313 CPUMCPU_FROM_CPUM(edx) 309 314 ;; use flags. 310 mov esi, [edx + CPUM.fUseFlags] 315 mov esi, [edx + CPUMCPU.fUseFlags] 316 CPUM_FROM_CPUMCPU(edx) 311 317 312 318 ; debug registers … … 389 395 htg_debug_regs_save_dr7and6: 390 396 DEBUG_S_CHAR('s'); 397 CPUMCPU_FROM_CPUM(edx) 391 398 mov eax, dr7 ; not sure, but if I read the docs right this will trap if GD is set. FIXME!!! 392 mov [edx + CPUM .Host.dr7], eax399 mov [edx + CPUMCPU.Host.dr7], eax 393 400 xor eax, eax ; clear everything. (bit 12? is read as 1...) 394 401 mov dr7, eax 395 402 mov eax, dr6 ; just in case we save the state register too. 396 mov [edx + CPUM.Host.dr6], eax 403 mov [edx + CPUMCPU.Host.dr6], eax 404 CPUM_FROM_CPUMCPU(edx) 397 405 jmp htg_debug_regs_no 398 406 … … 404 412 DEBUG_S_CHAR('R') 405 413 DEBUG_S_CHAR('x') 414 CPUMCPU_FROM_CPUM(edx) 406 415 ; save host DR0-3. 407 416 mov eax, dr0 408 mov [edx + CPUM .Host.dr0], eax417 mov [edx + CPUMCPU.Host.dr0], eax 409 418 mov ebx, dr1 410 mov [edx + CPUM .Host.dr1], ebx419 mov [edx + CPUMCPU.Host.dr1], ebx 411 420 mov ecx, dr2 412 mov [edx + CPUM .Host.dr2], ecx421 mov [edx + CPUMCPU.Host.dr2], ecx 413 422 mov eax, dr3 414 mov [edx + CPUM.Host.dr3], eax 423 mov [edx + CPUMCPU.Host.dr3], eax 424 CPUM_FROM_CPUMCPU(edx) 425 415 426 ; load hyper DR0-7 416 427 mov ebx, [edx + CPUM.Hyper.dr] … … 538 549 push eax 539 550 551 CPUMCPU_FROM_CPUM(edx) 540 552 mov eax, [esp + 4 + CPUMCTXCORE.eax] 541 mov [edx + CPUM .Guest.eax], eax553 mov [edx + CPUMCPU.Guest.eax], eax 542 554 mov eax, [esp + 4 + CPUMCTXCORE.ecx] 543 mov [edx + CPUM .Guest.ecx], eax555 mov [edx + CPUMCPU.Guest.ecx], eax 544 556 mov eax, [esp + 4 + CPUMCTXCORE.edx] 545 mov [edx + CPUM .Guest.edx], eax557 mov [edx + CPUMCPU.Guest.edx], eax 546 558 mov eax, [esp + 4 + CPUMCTXCORE.ebx] 547 mov [edx + CPUM .Guest.ebx], eax559 mov [edx + CPUMCPU.Guest.ebx], eax 548 560 mov eax, [esp + 4 + CPUMCTXCORE.esp] 549 mov [edx + CPUM .Guest.esp], eax561 mov [edx + CPUMCPU.Guest.esp], eax 550 562 mov eax, [esp + 4 + CPUMCTXCORE.ebp] 551 mov [edx + CPUM .Guest.ebp], eax563 mov [edx + CPUMCPU.Guest.ebp], eax 552 564 mov eax, [esp + 4 + CPUMCTXCORE.esi] 553 mov [edx + CPUM .Guest.esi], eax565 mov [edx + CPUMCPU.Guest.esi], eax 554 566 mov eax, [esp + 4 + CPUMCTXCORE.edi] 555 mov [edx + CPUM .Guest.edi], eax567 mov [edx + CPUMCPU.Guest.edi], eax 556 568 mov eax, dword [esp + 4 + CPUMCTXCORE.es] 557 mov dword [edx + CPUM .Guest.es], eax569 mov dword [edx + CPUMCPU.Guest.es], eax 558 570 mov eax, dword [esp + 4 + CPUMCTXCORE.cs] 559 mov dword [edx + CPUM .Guest.cs], eax571 mov dword [edx + CPUMCPU.Guest.cs], eax 560 572 mov eax, dword [esp + 4 + CPUMCTXCORE.ss] 561 mov dword [edx + CPUM .Guest.ss], eax573 mov dword [edx + CPUMCPU.Guest.ss], eax 562 574 mov eax, dword [esp + 4 + CPUMCTXCORE.ds] 563 mov dword [edx + CPUM .Guest.ds], eax575 mov dword [edx + CPUMCPU.Guest.ds], eax 564 576 mov eax, dword [esp + 4 + CPUMCTXCORE.fs] 565 mov dword [edx + CPUM .Guest.fs], eax577 mov dword [edx + CPUMCPU.Guest.fs], eax 566 578 mov eax, dword [esp + 4 + CPUMCTXCORE.gs] 567 mov dword [edx + CPUM .Guest.gs], eax579 mov dword [edx + CPUMCPU.Guest.gs], eax 568 580 mov eax, [esp + 4 + CPUMCTXCORE.eflags] 569 mov dword [edx + CPUM .Guest.eflags], eax581 mov dword [edx + CPUMCPU.Guest.eflags], eax 570 582 mov eax, [esp + 4 + CPUMCTXCORE.eip] 571 mov dword [edx + CPUM .Guest.eip], eax583 mov dword [edx + CPUMCPU.Guest.eip], eax 572 584 pop eax 585 CPUM_FROM_CPUMCPU(edx) 573 586 574 587 add esp, CPUMCTXCORE_size ; skip CPUMCTXCORE structure … … 734 747 ;; 735 748 mov edi, eax ; save return code in EDI (careful with COM_DWORD_REG from here on!) 736 mov ecx, [edx + CPUM.Host.cr3] 749 CPUMCPU_FROM_CPUM(edx) 750 mov ecx, [edx + CPUMCPU.Host.cr3] 751 CPUM_FROM_CPUMCPU(edx) 737 752 FIXUP SWITCHER_FIX_INTER_CR3_GC, 1 738 753 mov eax, 0ffffffffh … … 803 818 FIXUP FIX_HC_CPUM_OFF, 1, 0 804 819 mov edx, 0ffffffffh 820 CPUMCPU_FROM_CPUM(edx) 805 821 ; activate host gdt and idt 806 lgdt [edx + CPUM .Host.gdtr]822 lgdt [edx + CPUMCPU.Host.gdtr] 807 823 DEBUG_CHAR('0') 808 lidt [edx + CPUM .Host.idtr]824 lidt [edx + CPUMCPU.Host.idtr] 809 825 DEBUG_CHAR('1') 810 826 ; Restore TSS selector; must mark it as not busy before using ltr (!) 811 827 %if 1 ; ASSUME that this is supposed to be 'BUSY'. (saves 20-30 ticks on the T42p) 812 movzx eax, word [edx + CPUM .Host.tr] ; eax <- TR828 movzx eax, word [edx + CPUMCPU.Host.tr] ; eax <- TR 813 829 and al, 0F8h ; mask away TI and RPL bits, get descriptor offset. 814 add eax, [edx + CPUM .Host.gdtr + 2] ; eax <- GDTR.address + descriptor offset.830 add eax, [edx + CPUMCPU.Host.gdtr + 2] ; eax <- GDTR.address + descriptor offset. 815 831 and dword [eax + 4], ~0200h ; clear busy flag (2nd type2 bit) 816 ltr word [edx + CPUM .Host.tr]832 ltr word [edx + CPUMCPU.Host.tr] 817 833 %else 818 movzx eax, word [edx + CPUM .Host.tr] ; eax <- TR834 movzx eax, word [edx + CPUMCPU.Host.tr] ; eax <- TR 819 835 and al, 0F8h ; mask away TI and RPL bits, get descriptor offset. 820 add eax, [edx + CPUM .Host.gdtr + 2] ; eax <- GDTR.address + descriptor offset.836 add eax, [edx + CPUMCPU.Host.gdtr + 2] ; eax <- GDTR.address + descriptor offset. 821 837 mov ecx, [eax + 4] ; ecx <- 2nd descriptor dword 822 838 mov ebx, ecx ; save orginal value 823 839 and ecx, ~0200h ; clear busy flag (2nd type2 bit) 824 840 mov [eax + 4], ecx ; not using xchg here is paranoia.. 825 ltr word [edx + CPUM .Host.tr]841 ltr word [edx + CPUMCPU.Host.tr] 826 842 xchg [eax + 4], ebx ; using xchg is paranoia too... 827 843 %endif 828 844 ; activate ldt 829 845 DEBUG_CHAR('2') 830 lldt [edx + CPUM .Host.ldtr]846 lldt [edx + CPUMCPU.Host.ldtr] 831 847 ; Restore segment registers 832 mov eax, [edx + CPUM .Host.ds]848 mov eax, [edx + CPUMCPU.Host.ds] 833 849 mov ds, eax 834 mov eax, [edx + CPUM .Host.es]850 mov eax, [edx + CPUMCPU.Host.es] 835 851 mov es, eax 836 mov eax, [edx + CPUM .Host.fs]852 mov eax, [edx + CPUMCPU.Host.fs] 837 853 mov fs, eax 838 mov eax, [edx + CPUM .Host.gs]854 mov eax, [edx + CPUMCPU.Host.gs] 839 855 mov gs, eax 840 856 ; restore stack 841 lss esp, [edx + CPUM .Host.esp]857 lss esp, [edx + CPUMCPU.Host.esp] 842 858 843 859 … … 845 861 ; restore MSR_IA32_SYSENTER_CS register. 846 862 mov ecx, MSR_IA32_SYSENTER_CS 847 mov eax, [edx + CPUM .Host.SysEnter.cs]848 mov ebx, [edx + CPUM .Host.SysEnter.cs + 4]863 mov eax, [edx + CPUMCPU.Host.SysEnter.cs] 864 mov ebx, [edx + CPUMCPU.Host.SysEnter.cs + 4] 849 865 xchg edx, ebx ; save/load edx 850 866 wrmsr ; MSR[ecx] <- edx:eax … … 859 875 ; Restore FPU if guest has used it. 860 876 ; Using fxrstor should ensure that we're not causing unwanted exception on the host. 861 mov esi, [edx + CPUM .fUseFlags] ; esi == use flags.877 mov esi, [edx + CPUMCPU.fUseFlags] ; esi == use flags. 862 878 test esi, CPUM_USED_FPU 863 879 jz near gth_fpu_no … … 867 883 868 884 FIXUP FIX_NO_FXSAVE_JMP, 0, gth_no_fxsave - NAME(Start) ; this will insert a jmp gth_no_fxsave if fxsave isn't supported. 869 fxsave [edx + CPUM .Guest.fpu]870 fxrstor [edx + CPUM .Host.fpu]885 fxsave [edx + CPUMCPU.Guest.fpu] 886 fxrstor [edx + CPUMCPU.Host.fpu] 871 887 jmp near gth_fpu_no 872 888 873 889 gth_no_fxsave: 874 fnsave [edx + CPUM .Guest.fpu]875 mov eax, [edx + CPUM .Host.fpu] ; control word890 fnsave [edx + CPUMCPU.Guest.fpu] 891 mov eax, [edx + CPUMCPU.Host.fpu] ; control word 876 892 not eax ; 1 means exception ignored (6 LS bits) 877 893 and eax, byte 03Fh ; 6 LS bits only 878 test eax, [edx + CPUM .Host.fpu + 4] ; status word894 test eax, [edx + CPUMCPU.Host.fpu + 4] ; status word 879 895 jz gth_no_exceptions_pending 880 896 881 897 ; technically incorrect, but we certainly don't want any exceptions now!! 882 and dword [edx + CPUM .Host.fpu + 4], ~03Fh898 and dword [edx + CPUMCPU.Host.fpu + 4], ~03Fh 883 899 884 900 gth_no_exceptions_pending: 885 frstor [edx + CPUM .Host.fpu]901 frstor [edx + CPUMCPU.Host.fpu] 886 902 jmp short gth_fpu_no 887 903 … … 892 908 ; Would've liked to have these highere up in case of crashes, but 893 909 ; the fpu stuff must be done before we restore cr0. 894 mov ecx, [edx + CPUM .Host.cr4]910 mov ecx, [edx + CPUMCPU.Host.cr4] 895 911 mov cr4, ecx 896 mov ecx, [edx + CPUM .Host.cr0]912 mov ecx, [edx + CPUMCPU.Host.cr0] 897 913 mov cr0, ecx 898 ;mov ecx, [edx + CPUM .Host.cr2] ; assumes this is waste of time.914 ;mov ecx, [edx + CPUMCPU.Host.cr2] ; assumes this is waste of time. 899 915 ;mov cr2, ecx 900 916 … … 908 924 ; restore general registers. 909 925 mov eax, edi ; restore return code. eax = return code !! 910 mov edi, [edx + CPUM .Host.edi]911 mov esi, [edx + CPUM .Host.esi]912 mov ebx, [edx + CPUM .Host.ebx]913 mov ebp, [edx + CPUM .Host.ebp]914 push dword [edx + CPUM .Host.eflags]926 mov edi, [edx + CPUMCPU.Host.edi] 927 mov esi, [edx + CPUMCPU.Host.esi] 928 mov ebx, [edx + CPUMCPU.Host.ebx] 929 mov ebp, [edx + CPUMCPU.Host.ebp] 930 push dword [edx + CPUMCPU.Host.eflags] 915 931 popfd 916 932 … … 930 946 jz short gth_debug_regs_dr7 931 947 DEBUG_S_CHAR('r') 932 mov eax, [edx + CPUM .Host.dr0]948 mov eax, [edx + CPUMCPU.Host.dr0] 933 949 mov dr0, eax 934 mov ebx, [edx + CPUM .Host.dr1]950 mov ebx, [edx + CPUMCPU.Host.dr1] 935 951 mov dr1, ebx 936 mov ecx, [edx + CPUM .Host.dr2]952 mov ecx, [edx + CPUMCPU.Host.dr2] 937 953 mov dr2, ecx 938 mov eax, [edx + CPUM .Host.dr3]954 mov eax, [edx + CPUMCPU.Host.dr3] 939 955 mov dr3, eax 940 956 gth_debug_regs_dr7: 941 mov ebx, [edx + CPUM .Host.dr6]957 mov ebx, [edx + CPUMCPU.Host.dr6] 942 958 mov dr6, ebx 943 mov ecx, [edx + CPUM .Host.dr7]959 mov ecx, [edx + CPUMCPU.Host.dr7] 944 960 mov dr7, ecx 945 961 jmp gth_debug_regs_no -
trunk/src/VBox/VMM/testcase/Makefile.kmk
r13699 r13960 301 301 -e '/00[0-9a-fA-F]* [aA] [^_.]*\./!d' -e 's/\(00[0-9a-fA-F]*\) [aA] \([^.]*\)\.\(.*$$\)/ CHECK_OFF(\2, 0x0\1, \3);/' \ 302 302 --output [email protected] [email protected] 303 $(QUIET)$(SED) -e '/VM_size$$/d' \303 $(QUIET)$(SED) -e '/VM_size$$/d' -e '/VMCPU_size$$/d' \ 304 304 -e '/00[0-9a-fA-F]* [aA] [^_.]*_size$$/!d' -e 's/\(00[0-9a-fA-F]*\) [aA] \([^_.]*\)_size/ CHECK_SIZE(\2, 0x0\1);/' \ 305 305 --append [email protected] [email protected] -
trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp
r13921 r13960 164 164 CHECK_MEMBER_ALIGNMENT(VM, trpm.s.aIdt, 16); 165 165 CHECK_MEMBER_ALIGNMENT(VM, cpum, 64); 166 CHECK_MEMBER_ALIGNMENT(VM, cpum.s.Host, 64);167 CHECK_MEMBER_ALIGNMENT(VM, cpum.s.Guest, 64);166 CHECK_MEMBER_ALIGNMENT(VM, aCpus[0].cpum.s.Host, 64); 167 CHECK_MEMBER_ALIGNMENT(VM, aCpus[0].cpum.s.Guest, 64); 168 168 CHECK_MEMBER_ALIGNMENT(VM, cpum.s.Hyper, 64); 169 169 CHECK_MEMBER_ALIGNMENT(VM, cpum.s.GuestEntry, 64);
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器