Changeset 25838 in vbox
- Timestamp:
- Jan 14, 2010 4:55:55 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmapi.h
r25825 r25838 407 407 VMMR3DECL(RTNATIVETHREAD) VMR3GetVMCPUNativeThread(PVM pVM); 408 408 VMMR3DECL(RTNATIVETHREAD) VMR3GetVMCPUNativeThreadU(PUVM pUVM); 409 VMMR3DECL(int) VMR3GetC PUCoreAndPackageIdFromCPUId(PVM pVM, VMCPUID idCpu, uint32_t *pidCpuCore, uint32_t *pidCpuPackage);410 VMMR3DECL(int) VMR3Hot unplugCPU(PVM pVM, VMCPUID idCpu);411 VMMR3DECL(int) VMR3Hot plugCPU(PVM pVM, VMCPUID idCpu);409 VMMR3DECL(int) VMR3GetCpuCoreAndPackageIdFromCpuId(PVM pVM, VMCPUID idCpu, uint32_t *pidCpuCore, uint32_t *pidCpuPackage); 410 VMMR3DECL(int) VMR3HotUnplugCpu(PVM pVM, VMCPUID idCpu); 411 VMMR3DECL(int) VMR3HotPlugCpu(PVM pVM, VMCPUID idCpu); 412 412 413 413 /** @} */ -
trunk/src/VBox/Devices/Makefile.kmk
r25825 r25838 471 471 vboxaml.hex:: $$(PATH_DevicesR3)/vboxaml.hex 472 472 473 # CPU hot-plug version474 DevicesR3_CLEAN += $(PATH_DevicesR3)/vboxaml-cpuhotplug.hex $(PATH_DevicesR3)/vboxaml-cpuhotplug.hex.tmp $(PATH_DevicesR3)/vboxaml-cpuhotplug.aml475 PC/ACPI/VBoxAcpi.cpp_DEPS += $(PATH_DevicesR3)/vboxaml-cpuhotplug.hex476 477 $$(PATH_DevicesR3)/vboxaml-cpuhotplug.hex: $(PATH_SUB_CURRENT)/PC/vbox-cpuhotplug.dsl | $$(dir $$@)478 $(call MSG_TOOL,iasl,DevicesR3,$<,$@)479 $(QUIET)$(RM) -f $@ [email protected]480 $(QUIET)$(VBOX_IASLCMD) -tc -vs -p $@ $<481 $(QUIET)$(MV) -f $@ [email protected]482 $(QUIET)$(SED) -e 's/AmlCode/AmlCodeCpuHotplug/' \483 --output $@ [email protected]484 $(QUIET)$(RM) -f [email protected]485 486 487 vboxaml-cpuhotplug.hex:: $$(PATH_DevicesR3)/vboxaml-cpuhotplug.hex488 489 473 endif # !VBOX_WITH_DYNAMIC_DSDT 490 474 PC/ACPI/VBoxAcpi.cpp_INCS = $(PATH_DevicesR3) -
trunk/src/VBox/Devices/PC/ACPI/VBoxAcpi.cpp
r25825 r25838 30 30 #include <VBox/param.h> 31 31 #include <VBox/cfgm.h> 32 #include <VBox/mm.h> 32 33 #include <iprt/assert.h> 33 34 #include <iprt/alloc.h> 34 35 #include <iprt/string.h> 36 #include <iprt/file.h> 35 37 36 38 #ifdef VBOX_WITH_DYNAMIC_DSDT … … 40 42 /* Statically compiled AML */ 41 43 # include <vboxaml.hex> 42 # include <vboxaml-cpuhotplug.hex>43 44 #endif 44 45 … … 142 143 return prepareDynamicDsdt(pDevIns, ppPtr, puDsdtLen); 143 144 #else 144 u nsigned char*pbAmlCode = NULL;145 uint8_t *pbAmlCode = NULL; 145 146 size_t cbAmlCode = 0; 146 bool fCpuHotPlug = false; 147 int rc = CFGMR3QueryBoolDef(pDevIns->pCfgHandle, "CpuHotplug", &fCpuHotPlug, false); /** @todo r=bird: Rename to CpuHotPlug. */ 148 if (RT_FAILURE(rc)) 147 char *pszAmlFilePath = NULL; 148 int rc = CFGMR3QueryStringAlloc(pDevIns->pCfgHandle, "AmlFilePath", &pszAmlFilePath); 149 if (RT_SUCCESS(rc)) 150 { 151 /* Load from file. */ 152 RTFILE FileAml = NIL_RTFILE; 153 154 rc = RTFileOpen(&FileAml, pszAmlFilePath, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE); 155 if (RT_SUCCESS(rc)) 156 { 157 /* 158 * An AML file contains the raw DSDT thus the size of the file 159 * is equal to the size of the DSDT. 160 */ 161 uint64_t cbAmlFile = 0; 162 rc = RTFileGetSize(FileAml, &cbAmlFile); 163 164 cbAmlCode = (size_t)cbAmlFile; 165 166 /* Don't use AML files over 4GB ;) */ 167 if ( RT_SUCCESS(rc) 168 && ((uint64_t)cbAmlCode == cbAmlFile)) 169 { 170 pbAmlCode = (uint8_t *)RTMemAllocZ(cbAmlCode); 171 if (pbAmlCode) 172 { 173 rc = RTFileReadAt(FileAml, 0, pbAmlCode, cbAmlCode, NULL); 174 175 /* 176 * We fail if reading failed or the identifier at the 177 * beginning is wrong. 178 */ 179 if ( RT_FAILURE(rc) 180 || strncmp((const char *)pbAmlCode, "DSDT", 4)) 181 { 182 RTMemFree(pbAmlCode); 183 pbAmlCode = NULL; 184 185 /* Return error if file header check failed */ 186 if (RT_SUCCESS(rc)) 187 rc = VERR_PARSE_ERROR; 188 } 189 } 190 else 191 rc = VERR_NO_MEMORY; 192 } 193 194 RTFileClose(FileAml); 195 } 196 MMR3HeapFree(pszAmlFilePath); 197 } 198 else if (rc == VERR_CFGM_VALUE_NOT_FOUND) 199 { 200 rc = VINF_SUCCESS; 201 202 /* Use the compiled in AML code */ 203 cbAmlCode = sizeof(AmlCode); 204 pbAmlCode = (uint8_t *)RTMemAllocZ(cbAmlCode); 205 if (pbAmlCode) 206 memcpy(pbAmlCode, AmlCode, cbAmlCode); 207 else 208 rc = VERR_NO_MEMORY; 209 } 210 else if (RT_FAILURE(rc)) 149 211 return PDMDEV_SET_ERROR(pDevIns, rc, 150 N_("Configuration error: Failed to read \"CpuHotplug\"")); 151 152 if (fCpuHotPlug) 153 { 154 pbAmlCode = AmlCodeCpuHotplug; 155 cbAmlCode = sizeof(AmlCodeCpuHotplug); 156 } 157 else 158 { 159 pbAmlCode = AmlCode; 160 cbAmlCode = sizeof(AmlCode); 161 } 162 163 patchAml(pDevIns, pbAmlCode, cbAmlCode); 164 *ppPtr = pbAmlCode; 165 *puDsdtLen = cbAmlCode; 166 return 0; 212 N_("Configuration error: Failed to read \"AmlFilePath\"")); 213 214 if (RT_SUCCESS(rc)) 215 { 216 patchAml(pDevIns, pbAmlCode, cbAmlCode); 217 *ppPtr = pbAmlCode; 218 *puDsdtLen = cbAmlCode; 219 } 220 return rc; 167 221 #endif 168 222 } … … 173 227 return cleanupDynamicDsdt(pDevIns, pPtr); 174 228 #else 175 /* Do nothing */ 176 return 0; 177 #endif 178 } 179 229 if (pPtr) 230 RTMemFree(pPtr); 231 return VINF_SUCCESS; 232 #endif 233 } 234 -
trunk/src/VBox/Devices/PC/DevACPI.cpp
r25825 r25838 150 150 SYSTEM_INFO_INDEX_RTC_STATUS = 10, 151 151 SYSTEM_INFO_INDEX_CPU_LOCKED = 11, 152 SYSTEM_INFO_INDEX_MADT_ADDR = 12, 153 SYSTEM_INFO_INDEX_MADT_SIZE = 13, 154 SYSTEM_INFO_INDEX_END = 14, 152 SYSTEM_INFO_INDEX_CPU_LOCK_CHECK = 12, 153 SYSTEM_INFO_INDEX_MADT_ADDR = 13, 154 SYSTEM_INFO_INDEX_MADT_SIZE = 14, 155 SYSTEM_INFO_INDEX_END = 15, 155 156 SYSTEM_INFO_INDEX_INVALID = 0x80, 156 157 SYSTEM_INFO_INDEX_VALID = 0x200 … … 238 239 uint32_t cbMADT; 239 240 /** Array of flags of attached CPUs */ 240 bool afCpuAttached[VMM_MAX_CPU_COUNT]; /**< @todo use VMCPUSET. */ 241 VMCPUSET CpuSetAttached; 242 /** Which CPU to check for the locked status. */ 243 uint32_t idCpuLockCheck; 241 244 /** Mask of locked CPUs (used by the guest) */ 242 uint32_t uCpusLocked; /**< @todo use VMCPUSET. */245 VMCPUSET CpuSetLocked; 243 246 /** Flag whether CPU hot plugging is enabled */ 244 247 bool fCpuHotPlug; … … 847 850 lapic->u8ProcId = i; 848 851 lapic->u8ApicId = i; 849 lapic->u32Flags = s->afCpuAttached[i]? RT_H2LE_U32(LAPIC_ENABLED) : 0;852 lapic->u32Flags = VMCPUSET_IS_PRESENT(&s->CpuSetAttached, i) ? RT_H2LE_U32(LAPIC_ENABLED) : 0; 850 853 lapic++; 851 854 } … … 986 989 { 987 990 ACPIState *s = IACPIPORT_2_ACPISTATE(pInterface); 988 *pfLocked = (s->uCpusLocked & RT_BIT(uCpu)) != 0;991 *pfLocked = VMCPUSET_IS_PRESENT(&s->CpuSetLocked, uCpu); 989 992 return VINF_SUCCESS; 990 993 } … … 1406 1409 *pu32 = s->fShowCpu 1407 1410 && s->uSystemInfoIndex - SYSTEM_INFO_INDEX_CPU0_STATUS < s->cCpus 1408 && s->afCpuAttached[s->uSystemInfoIndex - SYSTEM_INFO_INDEX_CPU0_STATUS]1411 && VMCPUSET_IS_PRESENT(&s->CpuSetAttached, s->uSystemInfoIndex - SYSTEM_INFO_INDEX_CPU0_STATUS) 1409 1412 ? 1410 1413 STA_DEVICE_PRESENT_MASK … … 1424 1427 case SYSTEM_INFO_INDEX_CPU_LOCKED: 1425 1428 { 1426 *pu32 = s->uCpusLocked; 1429 if (s->idCpuLockCheck != UINT32_C(0xffffffff)) 1430 { 1431 *pu32 = VMCPUSET_IS_PRESENT(&s->CpuSetLocked, s->idCpuLockCheck) ? 1 : 0; 1432 s->idCpuLockCheck = UINT32_C(0xffffffff); /* Make the entry invalid */ 1433 } 1434 else 1435 { 1436 AssertMsgFailed(("ACPI: CPU lock check protocol violation\n")); 1437 /* Always return locked status just to be safe */ 1438 *pu32 = 1; 1439 } 1427 1440 break; 1428 1441 } … … 1479 1492 break; 1480 1493 1494 case SYSTEM_INFO_INDEX_CPU_LOCK_CHECK: 1495 if (u32 < s->cCpus) 1496 s->idCpuLockCheck = u32; 1497 else 1498 LogRel(("ACPI: CPU %u does not exist\n", u32)); 1481 1499 case SYSTEM_INFO_INDEX_CPU_LOCKED: 1482 s->uCpusLocked &= ~u32; /* Unlock the CPU */ 1500 if (u32 < s->cCpus) 1501 VMCPUSET_DEL(&s->CpuSetLocked, u32); /* Unlock the CPU */ 1502 else 1503 LogRel(("ACPI: CPU %u does not exist\n", u32)); 1483 1504 break; 1484 1505 … … 2080 2101 2081 2102 /* Check if it was already attached */ 2082 if ( s->afCpuAttached[iLUN])2103 if (VMCPUSET_IS_PRESENT(&s->CpuSetAttached, iLUN)) 2083 2104 return VINF_SUCCESS; 2084 2105 … … 2089 2110 { 2090 2111 /* Enable the CPU */ 2091 s->afCpuAttached[iLUN] = true; 2092 2093 /* Enable the lapic */ 2094 acpiSetupMADT(s, s->GCPhysMADTBase); 2112 VMCPUSET_ADD(&s->CpuSetAttached, iLUN); 2113 2095 2114 /* 2096 2115 * Lock the CPU because we don't know if the guest will use it or not. 2097 2116 * Prevents ejection while the CPU is still used 2098 2117 */ 2099 s->uCpusLocked |= RT_BIT(iLUN); 2118 VMCPUSET_ADD(&s->CpuSetLocked, iLUN); 2119 2120 /* Enable the lapic */ 2121 acpiSetupMADT(s, s->GCPhysMADTBase); 2100 2122 2101 2123 /* Notify the guest */ … … 2119 2141 2120 2142 /* Check if it was already detached */ 2121 if (s->afCpuAttached[iLUN]) 2122 { 2143 if (VMCPUSET_IS_PRESENT(&s->CpuSetAttached, iLUN)) 2144 { 2145 AssertMsgReturnVoid(!(VMCPUSET_IS_PRESENT(&s->CpuSetLocked, iLUN)), ("CPU is still locked by the guest\n")); 2146 2123 2147 /* Disable the CPU */ 2124 s->afCpuAttached[iLUN] = false; 2125 2126 AssertMsg(!(s->uCpusLocked & RT_BIT(iLUN)), ("CPU is still locked by the guest\n")); 2148 VMCPUSET_DEL(&s->CpuSetAttached, iLUN); 2127 2149 2128 2150 /* Update the lapic state */ … … 2195 2217 "ShowRtc\0" 2196 2218 "ShowCpu\0" 2197 "CpuHotplug\0" /** @todo r=bird: Rename to CpuHotPlug. */ 2219 "CpuHotPlug\0" 2220 "AmlFilePath\0" 2198 2221 )) 2199 2222 return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES, … … 2243 2266 2244 2267 /* query whether we are allow CPU hot plugging */ 2245 rc = CFGMR3QueryBoolDef(pCfgHandle, "CpuHot plug", &s->fCpuHotPlug, false); /** @todo r=bird: Rename to CpuHotPlug. */2268 rc = CFGMR3QueryBoolDef(pCfgHandle, "CpuHotPlug", &s->fCpuHotPlug, false); 2246 2269 if (RT_FAILURE(rc)) 2247 2270 return PDMDEV_SET_ERROR(pDevIns, rc, 2248 N_("Configuration error: Failed to read \"CpuHot plug\""));2271 N_("Configuration error: Failed to read \"CpuHotPlug\"")); 2249 2272 2250 2273 rc = CFGMR3QueryBool(pCfgHandle, "GCEnabled", &s->fGCEnabled); … … 2274 2297 s->IACPIPort.pfnGetCpuStatus = acpiGetCpuStatus; 2275 2298 2299 VMCPUSET_EMPTY(&s->CpuSetAttached); 2300 VMCPUSET_EMPTY(&s->CpuSetLocked); 2301 s->idCpuLockCheck = UINT32_C(0xffffffff); 2302 2276 2303 /* The first CPU can't be attached/detached */ 2277 s->afCpuAttached[0] = true;2278 s->uCpusLocked |= RT_BIT(0);2304 VMCPUSET_ADD(&s->CpuSetAttached, 0); 2305 VMCPUSET_ADD(&s->CpuSetLocked, 0); 2279 2306 2280 2307 /* Try to attach the other CPUs */ … … 2288 2315 if (RT_SUCCESS(rc)) 2289 2316 { 2290 s->afCpuAttached[i] = true;2291 s->uCpusLocked |= RT_BIT(i);2317 VMCPUSET_ADD(&s->CpuSetAttached, i); 2318 VMCPUSET_ADD(&s->CpuSetLocked, i); 2292 2319 Log(("acpi: Attached CPU %u\n", i)); 2293 2320 } 2294 2321 else if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 2295 {2296 2322 Log(("acpi: CPU %u not attached yet\n", i)); 2297 s->afCpuAttached[i] = false;2298 }2299 2323 else 2300 2324 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to attach CPU object\n")); … … 2303 2327 { 2304 2328 /* CPU is always attached if hot-plug is not enabled. */ 2305 s->afCpuAttached[i] = true;2306 s->uCpusLocked |= RT_BIT(i);2329 VMCPUSET_ADD(&s->CpuSetAttached, i); 2330 VMCPUSET_ADD(&s->CpuSetLocked, i); 2307 2331 } 2308 2332 } -
trunk/src/VBox/Devices/testcase/tstDeviceStructSizeGC.cpp
r25825 r25838 466 466 GEN_CHECK_OFF(ACPIState, fUseSmc); 467 467 GEN_CHECK_OFF(ACPIState, GCPhysMADTBase); 468 GEN_CHECK_OFF(ACPIState, afCpuAttached); 469 GEN_CHECK_OFF(ACPIState, uCpusLocked); 468 GEN_CHECK_OFF(ACPIState, CpuSetAttached); 469 GEN_CHECK_OFF(ACPIState, idCpuLockCheck); 470 GEN_CHECK_OFF(ACPIState, CpuSetLocked); 470 471 GEN_CHECK_OFF(ACPIState, fCpuHotPlug); 471 472 GEN_CHECK_OFF(ACPIState, IBase); -
trunk/src/VBox/VMM/VM.cpp
r25825 r25838 4052 4052 * @param pidCpuPackage Where to store the package ID of the virtual CPU. 4053 4053 * 4054 * @todo r=bird: Rename to VMR3GetCpuCoreAndPackageIdFromCpuId. We currently 4055 * try avoid holding down the shift key, so 'Cpu' is favored over 'CPU' 4056 * now. 4057 */ 4058 VMMR3DECL(int) VMR3GetCPUCoreAndPackageIdFromCPUId(PVM pVM, VMCPUID idCpu, uint32_t *pidCpuCore, uint32_t *pidCpuPackage) 4054 */ 4055 VMMR3DECL(int) VMR3GetCpuCoreAndPackageIdFromCpuId(PVM pVM, VMCPUID idCpu, uint32_t *pidCpuCore, uint32_t *pidCpuPackage) 4059 4056 { 4060 4057 if (idCpu >= pVM->cCpus) … … 4109 4106 * @param pVM The VM to operate on. 4110 4107 * @param idCpu Virtual CPU to perform the hot unplugging operation on. 4111 * @todo r=bird: Rename to VMR3HotUnplugCpu. 4112 */ 4113 VMMR3DECL(int) VMR3HotunplugCPU(PVM pVM, VMCPUID idCpu) 4108 */ 4109 VMMR3DECL(int) VMR3HotUnplugCpu(PVM pVM, VMCPUID idCpu) 4114 4110 { 4115 4111 AssertReturn(idCpu < pVM->cCpus, VERR_INVALID_CPU_ID); 4116 4112 4117 /** @todo Destroy EMT and not needed resources. */4118 4113 /** @todo r=bird: Don't destroy the EMT, it'll break VMMR3EmtRendezvous and 4119 4114 * broadcast requests. Just note down somewhere that the CPU is … … 4130 4125 * @param pVM The VM to operate on. 4131 4126 * @param idCpu Virtual CPU to perform the hot plugging operation on. 4132 * @todo r=bird: Rename to VMR3HotPlugCpu. 4133 */ 4134 VMMR3DECL(int) VMR3HotplugCPU(PVM pVM, VMCPUID idCpu) 4127 */ 4128 VMMR3DECL(int) VMR3HotPlugCpu(PVM pVM, VMCPUID idCpu) 4135 4129 { 4136 4130 AssertReturn(idCpu < pVM->cCpus, VERR_INVALID_CPU_ID); 4137 4131 4138 /** @todo start EMT and allocate needed resources. */4139 4132 /** @todo r-bird: Just mark it online and make sure it waits on SPIP. */ 4140 4133 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.