vbox的更動 13577 路徑 trunk/src/VBox/VMM/VMMAll/SELMAll.cpp
- 時間撮記:
- 2008-10-27 下午01:53:04 (16 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/VMM/VMMAll/SELMAll.cpp
r13144 r13577 39 39 40 40 41 #ifndef IN_RING0 42 41 43 /** 42 44 * Converts a GC selector based address to a flat address. … … 58 60 X86DESC Desc; 59 61 if (!(Sel & X86_SEL_LDT)) 60 Desc = pVM->selm.s.CTX SUFF(paGdt)[Sel >> X86_SEL_SHIFT];62 Desc = pVM->selm.s.CTX_SUFF(paGdt)[Sel >> X86_SEL_SHIFT]; 61 63 else 62 64 { 63 65 /** @todo handle LDT pages not present! */ 64 #ifdef IN_GC 65 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.GCPtrLdt + pVM->selm.s.offLdtHyper); 66 #else 67 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.HCPtrLdt + pVM->selm.s.offLdtHyper); 68 #endif 66 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.CTX_SUFF(pvLdt) + pVM->selm.s.offLdtHyper); 69 67 Desc = paLDT[Sel >> X86_SEL_SHIFT]; 70 68 } … … 72 70 return (RTGCPTR)((RTGCUINTPTR)Addr + X86DESC_BASE(Desc)); 73 71 } 72 #endif /* !IN_RING0 */ 74 73 75 74 … … 101 100 { 102 101 RTGCUINTPTR uFlat = (RTGCUINTPTR)Addr & 0xffff; 103 104 102 if (CPUMAreHiddenSelRegsValid(pVM)) 105 103 uFlat += pHiddenSel->u64Base; … … 109 107 } 110 108 109 #ifdef IN_RING0 110 Assert(CPUMAreHiddenSelRegsValid(pVM)); 111 #else 111 112 /** @todo when we're in 16 bits mode, we should cut off the address as well.. */ 112 113 if (!CPUMAreHiddenSelRegsValid(pVM)) 113 114 return SELMToFlatBySel(pVM, Sel, Addr); 115 #endif 114 116 115 117 /* 64 bits mode: CS, DS, ES and SS are treated as if each segment base is 0 (Intel® 64 and IA-32 Architectures Software Developer's Manual: 3.4.2.1). */ … … 119 121 switch (SelReg) 120 122 { 121 case DIS_SELREG_FS: 122 case DIS_SELREG_GS: 123 return (RTGCPTR)(pHiddenSel->u64Base + Addr); 124 125 default: 126 return Addr; /* base 0 */ 127 } 128 } 123 case DIS_SELREG_FS: 124 case DIS_SELREG_GS: 125 return (RTGCPTR)(pHiddenSel->u64Base + Addr); 126 127 default: 128 return Addr; /* base 0 */ 129 } 130 } 131 129 132 /* AMD64 manual: compatibility mode ignores the high 32 bits when calculating an effective address. */ 130 133 Assert(pHiddenSel->u64Base <= 0xffffffff); … … 149 152 VMMDECL(int) SELMToFlatEx(PVM pVM, DIS_SELREG SelReg, PCCPUMCTXCORE pCtxCore, RTGCPTR Addr, unsigned fFlags, PRTGCPTR ppvGC) 150 153 { 154 /* 155 * Fetch the selector first. 156 */ 151 157 PCPUMSELREGHID pHiddenSel; 152 158 RTSEL Sel; 153 int rc; 154 155 rc = DISFetchRegSegEx(pCtxCore, SelReg, &Sel, &pHiddenSel); AssertRC(rc); 159 int rc = DISFetchRegSegEx(pCtxCore, SelReg, &Sel, &pHiddenSel); 160 AssertRC(rc); 156 161 157 162 /* … … 189 194 u1DescType = pHiddenSel->Attr.n.u1DescType; 190 195 u4Type = pHiddenSel->Attr.n.u4Type; 191 192 196 u32Limit = pHiddenSel->u32Limit; 193 197 … … 199 203 switch (SelReg) 200 204 { 201 case DIS_SELREG_FS:202 case DIS_SELREG_GS:203 pvFlat = (pHiddenSel->u64Base + Addr);204 break;205 206 default:207 pvFlat = Addr;208 break;205 case DIS_SELREG_FS: 206 case DIS_SELREG_GS: 207 pvFlat = (pHiddenSel->u64Base + Addr); 208 break; 209 210 default: 211 pvFlat = Addr; 212 break; 209 213 } 210 214 } … … 304 308 && (unsigned)(Sel & X86_SEL_MASK) >= pVM->selm.s.GuestGdtr.cbGdt) 305 309 return VERR_INVALID_SELECTOR; 306 Desc = pVM->selm.s.CTX SUFF(paGdt)[Sel >> X86_SEL_SHIFT];310 Desc = pVM->selm.s.CTX_SUFF(paGdt)[Sel >> X86_SEL_SHIFT]; 307 311 } 308 312 else … … 312 316 313 317 /** @todo handle LDT page(s) not present! */ 314 #ifdef IN_GC 315 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.GCPtrLdt + pVM->selm.s.offLdtHyper); 316 #else 317 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.HCPtrLdt + pVM->selm.s.offLdtHyper); 318 #endif 318 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.CTX_SUFF(pvLdt) + pVM->selm.s.offLdtHyper); 319 319 Desc = paLDT[Sel >> X86_SEL_SHIFT]; 320 320 } … … 341 341 * Type check. 342 342 */ 343 # define BOTH(a, b) ((a << 16) | b)343 # define BOTH(a, b) ((a << 16) | b) 344 344 switch (BOTH(u1DescType, u4Type)) 345 345 { … … 429 429 430 430 } 431 # undef BOTH431 # undef BOTH 432 432 } 433 433 } … … 435 435 return VERR_SELECTOR_NOT_PRESENT; 436 436 } 437 437 438 438 439 #ifndef IN_RING0 … … 512 513 && (unsigned)(Sel & X86_SEL_MASK) >= pVM->selm.s.GuestGdtr.cbGdt) 513 514 return VERR_INVALID_SELECTOR; 514 Desc = pVM->selm.s.CTX SUFF(paGdt)[Sel >> X86_SEL_SHIFT];515 Desc = pVM->selm.s.CTX_SUFF(paGdt)[Sel >> X86_SEL_SHIFT]; 515 516 } 516 517 else … … 520 521 521 522 /** @todo handle LDT page(s) not present! */ 522 #ifdef IN_GC 523 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.GCPtrLdt + pVM->selm.s.offLdtHyper); 524 #else 525 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.HCPtrLdt + pVM->selm.s.offLdtHyper); 526 #endif 523 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.CTX_SUFF(pvLdt) + pVM->selm.s.offLdtHyper); 527 524 Desc = paLDT[Sel >> X86_SEL_SHIFT]; 528 525 } … … 652 649 #endif /* !IN_RING0 */ 653 650 651 654 652 /** 655 653 * Validates and converts a GC selector based code address to a flat … … 675 673 676 674 675 #ifndef IN_RING0 677 676 /** 678 677 * Validates and converts a GC selector based code address to a flat … … 695 694 X86DESC Desc; 696 695 if (!(SelCS & X86_SEL_LDT)) 697 Desc = pVM->selm.s.CTX SUFF(paGdt)[SelCS >> X86_SEL_SHIFT];696 Desc = pVM->selm.s.CTX_SUFF(paGdt)[SelCS >> X86_SEL_SHIFT]; 698 697 else 699 698 { 700 699 /** @todo handle LDT page(s) not present! */ 701 #ifdef IN_GC 702 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.GCPtrLdt + pVM->selm.s.offLdtHyper); 703 #else 704 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.HCPtrLdt + pVM->selm.s.offLdtHyper); 705 #endif 700 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.CTX_SUFF(pvLdt) + pVM->selm.s.offLdtHyper); 706 701 Desc = paLDT[SelCS >> X86_SEL_SHIFT]; 707 702 } … … 748 743 return VERR_SELECTOR_NOT_PRESENT; 749 744 } 745 #endif /* !IN_RING0 */ 750 746 751 747 … … 813 809 814 810 811 #ifdef IN_GC 815 812 /** 816 813 * Validates and converts a GC selector based code address to a flat address. … … 840 837 return selmValidateAndConvertCSAddrStd(pVM, SelCPL, SelCS, Addr, ppvFlat, pcBits); 841 838 } 839 #endif /* IN_GC */ 842 840 843 841 … … 861 859 return selmValidateAndConvertCSAddrRealMode(pVM, SelCS, pHiddenCSSel, Addr, ppvFlat); 862 860 861 #ifdef IN_RING0 862 Assert(CPUMAreHiddenSelRegsValid(pVM)); 863 #else 863 864 /** @todo when we're in 16 bits mode, we should cut off the address as well? (like in selmValidateAndConvertCSAddrRealMode) */ 864 865 if (!CPUMAreHiddenSelRegsValid(pVM)) 865 866 return selmValidateAndConvertCSAddrStd(pVM, SelCPL, SelCS, Addr, ppvFlat, NULL); 867 #endif 866 868 return selmValidateAndConvertCSAddrHidden(pVM, SelCPL, SelCS, pHiddenCSSel, Addr, ppvFlat); 867 869 } 868 870 869 871 872 #ifndef IN_RING0 870 873 /** 871 874 * Return the cpu mode corresponding to the (CS) selector … … 882 885 X86DESC Desc; 883 886 if (!(Sel & X86_SEL_LDT)) 884 Desc = pVM->selm.s.CTX SUFF(paGdt)[Sel >> X86_SEL_SHIFT];887 Desc = pVM->selm.s.CTX_SUFF(paGdt)[Sel >> X86_SEL_SHIFT]; 885 888 else 886 889 { 887 890 /** @todo handle LDT page(s) not present! */ 888 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.CTX MID(,PtrLdt) + pVM->selm.s.offLdtHyper);891 PX86DESC paLDT = (PX86DESC)((char *)pVM->selm.s.CTX_SUFF(pvLdt) + pVM->selm.s.offLdtHyper); 889 892 Desc = paLDT[Sel >> X86_SEL_SHIFT]; 890 893 } 891 894 return (Desc.Gen.u1DefBig) ? CPUMODE_32BIT : CPUMODE_16BIT; 892 895 } 896 #endif /* !IN_RING0 */ 893 897 894 898 … … 904 908 VMMDECL(DISCPUMODE) SELMGetCpuModeFromSelector(PVM pVM, X86EFLAGS eflags, RTSEL Sel, CPUMSELREGHID *pHiddenSel) 905 909 { 910 #ifdef IN_RING0 911 Assert(CPUMAreHiddenSelRegsValid(pVM)); 912 #else /* !IN_RING0 */ 906 913 if (!CPUMAreHiddenSelRegsValid(pVM)) 907 914 { … … 915 922 return selmGetCpuModeFromSelector(pVM, Sel); 916 923 } 924 #endif /* !IN_RING0 */ 917 925 if ( CPUMIsGuestInLongMode(pVM) 918 926 && pHiddenSel->Attr.n.u1Long) … … 924 932 } 925 933 934 926 935 /** 927 936 * Returns Hypervisor's Trap 08 (\#DF) selector. … … 960 969 pVM->selm.s.Tss.esp1 = (uint32_t)esp; 961 970 } 971 962 972 963 973 #ifndef IN_RING0 … … 969 979 * @param pSS Ring1 SS register value. 970 980 * @param pEsp Ring1 ESP register value. 981 * 982 * @todo Merge in the GC version of this, eliminating it - or move this to 983 * SELM.cpp, making it SELMR3GetRing1Stack. 971 984 */ 972 985 VMMDECL(int) SELMGetRing1Stack(PVM pVM, uint32_t *pSS, PRTGCPTR32 pEsp) … … 980 993 Assert(pVM->selm.s.GCPtrGuestTss && pVM->selm.s.cbMonitoredGuestTss); 981 994 982 # ifdef IN_GC995 # ifdef IN_GC 983 996 bool fTriedAlready = false; 984 997 … … 986 999 rc = MMGCRamRead(pVM, &tss.ss0, (RCPTRTYPE(void *))(GCPtrTss + RT_OFFSETOF(VBOXTSS, ss0)), sizeof(tss.ss0)); 987 1000 rc |= MMGCRamRead(pVM, &tss.esp0, (RCPTRTYPE(void *))(GCPtrTss + RT_OFFSETOF(VBOXTSS, esp0)), sizeof(tss.esp0)); 988 #ifdef DEBUG1001 # ifdef DEBUG 989 1002 rc |= MMGCRamRead(pVM, &tss.offIoBitmap, (RCPTRTYPE(void *))(GCPtrTss + RT_OFFSETOF(VBOXTSS, offIoBitmap)), sizeof(tss.offIoBitmap)); 990 #endif1003 # endif 991 1004 992 1005 if (VBOX_FAILURE(rc)) … … 1006 1019 } 1007 1020 1008 # else /* !IN_GC */1021 # else /* !IN_GC */ 1009 1022 /* Reading too much. Could be cheaper than two seperate calls though. */ 1010 1023 rc = PGMPhysSimpleReadGCPtr(pVM, &tss, GCPtrTss, sizeof(VBOXTSS)); … … 1014 1027 return rc; 1015 1028 } 1016 # endif /* !IN_GC */1017 1018 # ifdef LOG_ENABLED1029 # endif /* !IN_GC */ 1030 1031 # ifdef LOG_ENABLED 1019 1032 uint32_t ssr0 = pVM->selm.s.Tss.ss1; 1020 1033 uint32_t espr0 = pVM->selm.s.Tss.esp1; … … 1025 1038 1026 1039 Log(("offIoBitmap=%#x\n", tss.offIoBitmap)); 1027 # endif1040 # endif 1028 1041 /* Update our TSS structure for the guest's ring 1 stack */ 1029 1042 SELMSetRing1Stack(pVM, tss.ss0 | 1, (RTGCPTR32)tss.esp0); … … 1036 1049 return VINF_SUCCESS; 1037 1050 } 1038 #endif 1051 #endif /* !IN_RING0 */ 1052 1039 1053 1040 1054 /** 1041 1055 * Returns Guest TSS pointer 1042 1056 * 1057 * @returns Pointer to the guest TSS, RTRCPTR_MAX if not being monitored. 1043 1058 * @param pVM VM Handle. 1044 1059 */ … … 1086 1101 1087 1102 #ifndef IN_RING0 1103 1088 1104 /** 1089 1105 * Gets the hypervisor code selector (CS). … … 1148 1164 * switchers. Don't exploit this API! 1149 1165 */ 1150 VMMDECL(RT GCPTR) SELMGetHyperGDT(PVM pVM)1166 VMMDECL(RTRCPTR) SELMGetHyperGDT(PVM pVM) 1151 1167 { 1152 1168 /* 1153 * Always convert this from the HC pointer since . We're can be1169 * Always convert this from the HC pointer since we can be 1154 1170 * called before the first relocation and have to work correctly 1155 1171 * without having dependencies on the relocation order. 1156 1172 */ 1157 return (RTGCPTR)MMHyperHC2GC(pVM, pVM->selm.s.paGdtHC); 1158 } 1159 #endif /* IN_RING0 */ 1173 return (RTRCPTR)MMHyperR3ToRC(pVM, pVM->selm.s.paGdtR3); 1174 } 1175 1176 #endif /* !IN_RING0 */ 1160 1177 1161 1178 /** … … 1178 1195 * Do we have a valid TSS? 1179 1196 */ 1180 if ( pVM->selm.s.GCSelTss == (RTSEL)~01197 if ( pVM->selm.s.GCSelTss == RTSEL_MAX 1181 1198 || !pVM->selm.s.fGuestTss32Bit) 1182 1199 return VERR_SELM_NO_TSS; … … 1205 1222 return VINF_SUCCESS; 1206 1223 } 1224
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器