- Timestamp:
- Jul 2, 2014 6:09:31 AM (11 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r51764 r51797 1002 1002 } 1003 1003 1004 #if 0 1004 1005 /* Expose extended MWAIT features to Mac OS X guests. */ 1005 1006 if (fOsXGuest) … … 1039 1040 InsertConfigInteger(pCPUM, "MaxIntelFamilyModelStep", uMaxIntelFamilyModelStep); 1040 1041 } 1041 1042 #endif 1042 1043 1043 1044 /* Synthetic CPU */ -
trunk/src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp
r51735 r51797 939 939 940 940 /** 941 * Gets a CPU ID leaf. 942 * 943 * @returns VBox status code. 944 * @param pVM Pointer to the VM. 945 * @param pLeaf Where to store the found leaf. 946 * @param uLeaf The leaf to locate. 947 * @param uSubLeaf The subleaf to locate. Pass 0 if no subleaves. 948 */ 949 VMMR3DECL(int) CPUMR3CpuIdGetLeaf(PVM pVM, PCPUMCPUIDLEAF pLeaf, uint32_t uLeaf, uint32_t uSubLeaf) 950 { 951 PCPUMCPUIDLEAF pcLeaf = cpumR3CpuIdGetLeaf(pVM->cpum.s.GuestInfo.paCpuIdLeavesR3, pVM->cpum.s.GuestInfo.cCpuIdLeaves, 952 uLeaf, uSubLeaf); 953 if (pcLeaf) 954 { 955 memcpy(pLeaf, pcLeaf, sizeof(*pLeaf)); 956 return VINF_SUCCESS; 957 } 958 959 return VERR_NOT_FOUND; 960 } 961 962 963 /** 941 964 * Inserts a CPU ID leaf, replacing any existing ones. 942 965 * -
trunk/src/VBox/VMM/VMMR3/GIM.cpp
r51643 r51797 115 115 AssertLogRelRCReturn(rc, rc); 116 116 117 /** @cfgm{GIM/GuestOsId, uint32_t} 118 * The guest OS identifier. The default is 0, implying an unknown Guest OS. */ 119 GIMOSID GuestOsId = GIMOSID_END; 120 uint32_t uGuestOsId; 121 rc = CFGMR3QueryU32Def(pCfgNode, "GuestOsId", &uGuestOsId, GIMOSID_UNKNOWN); 122 AssertLogRelRCReturn(rc, rc); 123 if (uGuestOsId < GIMOSID_END) 124 GuestOsId = (GIMOSID)uGuestOsId; 125 else 126 { 127 LogRel(("GIM: GuestOsId %u invalid.", uGuestOsId)); 128 return VERR_GIM_INVALID_GUESTOS_ID; 129 } 130 117 131 /* 118 132 * Setup the GIM provider for this VM. … … 131 145 { 132 146 pVM->gim.s.enmProviderId = GIMPROVIDERID_MINIMAL; 133 rc = GIMR3MinimalInit(pVM );147 rc = GIMR3MinimalInit(pVM, GuestOsId); 134 148 } 135 149 else if (!RTStrCmp(szProvider, "HyperV")) … … 587 601 #endif 588 602 603 604 /** 605 * Checks if the given Guest OS identifier implies an OS X family of guests. 606 * 607 * @returns true if it's an OS X guest, false otherwise. 608 * @param enmGuestOs The Guest OS Id. 609 */ 610 VMMR3_INT_DECL(bool) GIMR3IsOSXGuest(GIMOSID enmGuestOs) 611 { 612 switch (enmGuestOs) 613 { 614 case GIMOSID_OSX: 615 case GIMOSID_OSX_64: 616 case GIMOSID_OSX_106: 617 case GIMOSID_OSX_106_64: 618 case GIMOSID_OSX_107: 619 case GIMOSID_OSX_107_64: 620 case GIMOSID_OSX_108: 621 case GIMOSID_OSX_108_64: 622 case GIMOSID_OSX_109: 623 case GIMOSID_OSX_109_64: 624 { 625 return true; 626 } 627 628 default: /* shut up gcc */ 629 break; 630 } 631 return false; 632 } 633 -
trunk/src/VBox/VMM/VMMR3/GIMMinimal.cpp
r51731 r51797 20 20 *******************************************************************************/ 21 21 #define LOG_GROUP LOG_GROUP_GIM 22 #include "GIMMinimalInternal.h"23 22 #include "GIMInternal.h" 24 23 25 24 #include <iprt/assert.h> 26 25 #include <iprt/err.h> 26 #include <iprt/asm-amd64-x86.h> 27 27 28 28 #include <VBox/vmm/cpum.h> … … 33 33 *******************************************************************************/ 34 34 35 VMMR3_INT_DECL(int) GIMR3MinimalInit(PVM pVM )35 VMMR3_INT_DECL(int) GIMR3MinimalInit(PVM pVM, GIMOSID enmGuest) 36 36 { 37 37 AssertReturn(pVM, VERR_INVALID_PARAMETER); … … 39 39 40 40 /* 41 * Enable the Hypervisor Present and MWait Extensions bits.41 * Enable the Hypervisor Present. 42 42 */ 43 43 CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP); 44 CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_MWAIT_EXTS); 44 45 if (GIMR3IsOSXGuest(enmGuest)) 46 { 47 /* 48 * Enable MWAIT Extensions for OS X Guests. 49 */ 50 CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_MWAIT_EXTS); 51 52 /* 53 * Fake the CPU family/model so the guest works. This is partly because older 54 * Mac releases really doesn't work on newer CPUs, and partly because OS X 55 * expects more from systems with newer CPUs (MSRs, power features etc.) 56 */ 57 if (CPUMGetGuestCpuVendor(pVM) == CPUMCPUVENDOR_INTEL) 58 { 59 uint32_t uMaxIntelFamilyModelStep = UINT32_MAX; 60 switch (enmGuest) 61 { 62 case GIMOSID_OSX: 63 case GIMOSID_OSX_64: 64 uMaxIntelFamilyModelStep = RT_MAKE_U32_FROM_U8(1, 23, 6, 7); /* Penryn / X5482. */ 65 break; 66 case GIMOSID_OSX_106: 67 case GIMOSID_OSX_106_64: 68 uMaxIntelFamilyModelStep = RT_MAKE_U32_FROM_U8(1, 23, 6, 7); /* Penryn / X5482 */ 69 break; 70 case GIMOSID_OSX_107: 71 case GIMOSID_OSX_107_64: 72 /** @todo Figure out what is required here. */ 73 uMaxIntelFamilyModelStep = RT_MAKE_U32_FROM_U8(1, 23, 6, 7); /* Penryn / X5482 */ 74 break; 75 case GIMOSID_OSX_108: 76 case GIMOSID_OSX_108_64: 77 /** @todo Figure out what is required here. */ 78 uMaxIntelFamilyModelStep = RT_MAKE_U32_FROM_U8(1, 23, 6, 7); /* Penryn / X5482 */ 79 break; 80 case GIMOSID_OSX_109: 81 case GIMOSID_OSX_109_64: 82 /** @todo Figure out what is required here. */ 83 uMaxIntelFamilyModelStep = RT_MAKE_U32_FROM_U8(1, 23, 6, 7); /* Penryn / X5482 */ 84 break; 85 86 default: /* shut up gcc */ 87 break; 88 } 89 90 if (uMaxIntelFamilyModelStep != UINT32_MAX) 91 { 92 CPUMCPUIDLEAF Leaf; 93 int rc = CPUMR3CpuIdGetLeaf(pVM, &Leaf, 1, 0); 94 if (RT_SUCCESS(rc)) 95 { 96 uint32_t uCurIntelFamilyModelStep = RT_MAKE_U32_FROM_U8(ASMGetCpuStepping(Leaf.uEax), 97 ASMGetCpuModelIntel(Leaf.uEax), 98 ASMGetCpuFamily(Leaf.uEax), 99 0); 100 if (uMaxIntelFamilyModelStep < uCurIntelFamilyModelStep) 101 { 102 uint32_t uNew = Leaf.uEax & UINT32_C(0xf0003000); 103 uNew |= RT_BYTE1(uMaxIntelFamilyModelStep) & 0xf; /* stepping */ 104 uNew |= (RT_BYTE2(uMaxIntelFamilyModelStep) & 0xf) << 4; /* 4 low model bits */ 105 uNew |= (RT_BYTE2(uMaxIntelFamilyModelStep) >> 4) << 16; /* 4 high model bits */ 106 uNew |= (RT_BYTE3(uMaxIntelFamilyModelStep) & 0xf) << 8; /* 4 low family bits */ 107 /* 8 high family bits, Intel's suggested calculation. */ 108 if (RT_BYTE3(uMaxIntelFamilyModelStep) > 0xf) 109 { 110 uNew |= ( (RT_BYTE3(uMaxIntelFamilyModelStep) 111 - (RT_BYTE3(uMaxIntelFamilyModelStep) & 0xf)) & 0xff ) << 20; 112 } 113 114 LogRel(("GIM: Minimal: CPUID(0).EAX %#x -> %#x (uMaxIntelFamilyModelStep=%#x, uCurIntelFamilyModelStep=%#x\n", 115 Leaf.uEax, uNew, uMaxIntelFamilyModelStep, uCurIntelFamilyModelStep)); 116 Leaf.uEax = uNew; 117 } 118 119 rc = CPUMR3CpuIdInsert(pVM, &Leaf); 120 if (RT_FAILURE(rc)) 121 { 122 LogRel(("GIM: Minimal: Failed to insert CPUID leaf for OS X guest. rc=%Rrc\n", rc)); 123 return rc; 124 } 125 } 126 else 127 { 128 LogRel(("GIM: Minimal: Failed to retreive std. CPUID leaf. rc=%Rrc\n", rc)); 129 return rc; 130 } 131 } 132 } 133 } 45 134 46 135 /** @todo Register CPUID leaves, MSR ranges with CPUM. */ 136 /** -XXX_ CPUMGetGuestCpuId CPUMGetGuestCpuVendor CPUMR3CpuIdInsert */ 47 137 return VINF_SUCCESS; 48 138 } -
trunk/src/VBox/VMM/include/GIMInternal.h
r51643 r51797 21 21 #include <VBox/vmm/gim.h> 22 22 #include "GIMHvInternal.h" 23 #include "GIMMinimalInternal.h" 23 24 24 25 RT_C_DECLS_BEGIN … … 96 97 VMMR3_INT_DECL(int) GIMR3Mmio2HandlerPhysicalRegister(PVM pVM, PGIMMMIO2REGION pRegion); 97 98 VMMR3_INT_DECL(int) GIMR3Mmio2HandlerPhysicalDeregister(PVM pVM, PGIMMMIO2REGION pRegion); 99 VMMR3_INT_DECL(bool) GIMR3IsOSXGuest(GIMOSID enmGuestOs); 98 100 #endif /* IN_RING3 */ 99 101 -
trunk/src/VBox/VMM/include/GIMMinimalInternal.h
r50994 r51797 25 25 26 26 #ifdef IN_RING3 27 VMMR3_INT_DECL(int) GIMR3MinimalInit(PVM pVM );27 VMMR3_INT_DECL(int) GIMR3MinimalInit(PVM pVM, GIMOSID enmGuest); 28 28 VMMR3_INT_DECL(void) GIMR3MinimalRelocate(PVM pVM, RTGCINTPTR offDelta); 29 29 #endif /* IN_RING3 */
Note:
See TracChangeset
for help on using the changeset viewer.