Changeset 105670 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
- Timestamp:
- Aug 14, 2024 1:16:30 PM (4 months ago)
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-159268 /vendor/edk2/current 103735-103757,103769-103776,129194-164365
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
r101291 r105670 6 6 7 7 Copyright (c) 2010 - 2023, Intel Corporation. All rights reserved.<BR> 8 Copyright (c) 2017 - 202 0, AMD Inc. All rights reserved.<BR>8 Copyright (c) 2017 - 2024, AMD Inc. All rights reserved.<BR> 9 9 10 10 SPDX-License-Identifier: BSD-2-Clause-Patent … … 1295 1295 ); 1296 1296 // 1297 // If CPUID.(EAX=0BH, ECX=0H):EBX returns zero and maximum input value for 1298 // basic CPUID information is greater than 0BH, then CPUID.0BH leaf is not 1299 // supported on that processor. 1300 // 1301 if (ExtendedTopologyEbx.Uint32 != 0) { 1297 // Quoting Intel SDM: 1298 // Software must detect the presence of CPUID leaf 0BH by 1299 // verifying (a) the highest leaf index supported by CPUID is >= 1300 // 0BH, and (b) CPUID.0BH:EBX[15:0] reports a non-zero value. 1301 // 1302 if (ExtendedTopologyEbx.Bits.LogicalProcessors != 0) { 1302 1303 TopologyLeafSupported = TRUE; 1303 1304 … … 1397 1398 1398 1399 /** 1400 Get Package ID/Die ID/Module ID/Core ID/Thread ID of a AMD processor family. 1401 1402 The algorithm assumes the target system has symmetry across physical 1403 package boundaries with respect to the number of threads per core, number of 1404 cores per module, number of modules per die, number 1405 of dies per package. 1406 1407 @param[in] InitialApicId Initial APIC ID of the target logical processor. 1408 @param[out] Package Returns the processor package ID. 1409 @param[out] Die Returns the processor die ID. 1410 @param[out] Tile Returns zero. 1411 @param[out] Module Returns the processor module ID. 1412 @param[out] Core Returns the processor core ID. 1413 @param[out] Thread Returns the processor thread ID. 1414 **/ 1415 VOID 1416 AmdGetProcessorLocation2ByApicId ( 1417 IN UINT32 InitialApicId, 1418 OUT UINT32 *Package OPTIONAL, 1419 OUT UINT32 *Die OPTIONAL, 1420 OUT UINT32 *Tile OPTIONAL, 1421 OUT UINT32 *Module OPTIONAL, 1422 OUT UINT32 *Core OPTIONAL, 1423 OUT UINT32 *Thread OPTIONAL 1424 ) 1425 { 1426 CPUID_EXTENDED_TOPOLOGY_EAX ExtendedTopologyEax; 1427 CPUID_EXTENDED_TOPOLOGY_EBX ExtendedTopologyEbx; 1428 CPUID_EXTENDED_TOPOLOGY_ECX ExtendedTopologyEcx; 1429 UINT32 MaxExtendedCpuIdIndex; 1430 UINT32 TopologyLevel; 1431 UINT32 PreviousLevel; 1432 UINT32 Data; 1433 1434 if (Die != NULL) { 1435 *Die = 0; 1436 } 1437 1438 if (Tile != NULL) { 1439 *Tile = 0; 1440 } 1441 1442 if (Module != NULL) { 1443 *Module = 0; 1444 } 1445 1446 PreviousLevel = 0; 1447 TopologyLevel = 0; 1448 1449 /// Check if extended toplogy supported 1450 AsmCpuid (CPUID_EXTENDED_FUNCTION, &MaxExtendedCpuIdIndex, NULL, NULL, NULL); 1451 if (MaxExtendedCpuIdIndex >= AMD_CPUID_EXTENDED_TOPOLOGY) { 1452 do { 1453 AsmCpuidEx ( 1454 AMD_CPUID_EXTENDED_TOPOLOGY, 1455 TopologyLevel, 1456 &ExtendedTopologyEax.Uint32, 1457 &ExtendedTopologyEbx.Uint32, 1458 &ExtendedTopologyEcx.Uint32, 1459 NULL 1460 ); 1461 1462 if (ExtendedTopologyEbx.Bits.LogicalProcessors == CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_INVALID) { 1463 /// if this fails at first level 1464 /// then will fall back to non-extended topology 1465 break; 1466 } 1467 1468 Data = InitialApicId >> PreviousLevel; 1469 Data &= (1 << (ExtendedTopologyEax.Bits.ApicIdShift - PreviousLevel)) - 1; 1470 1471 switch (ExtendedTopologyEcx.Bits.LevelType) { 1472 case CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_SMT: 1473 if (Thread != NULL) { 1474 *Thread = Data; 1475 } 1476 1477 break; 1478 case CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_CORE: 1479 if (Core != NULL) { 1480 *Core = Data; 1481 } 1482 1483 break; 1484 case CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_MODULE: 1485 if (Module != NULL) { 1486 *Module = Data; 1487 } 1488 1489 break; 1490 case CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_TILE: 1491 if (Die != NULL) { 1492 *Die = Data; 1493 } 1494 1495 break; 1496 default: 1497 break; 1498 } 1499 1500 TopologyLevel++; 1501 PreviousLevel = ExtendedTopologyEax.Bits.ApicIdShift; 1502 } while (ExtendedTopologyEbx.Bits.LogicalProcessors != CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_INVALID); 1503 1504 if (Package != NULL) { 1505 *Package = InitialApicId >> PreviousLevel; 1506 } 1507 } 1508 1509 /// If extended topology CPUID is not supported 1510 /// OR, execution of AMD_CPUID_EXTENDED_TOPOLOGY at level 0 fails(return 0). 1511 if (TopologyLevel == 0) { 1512 GetProcessorLocationByApicId (InitialApicId, Package, Core, Thread); 1513 } 1514 1515 return; 1516 } 1517 1518 /** 1399 1519 Get Package ID/Die ID/Tile ID/Module ID/Core ID/Thread ID of a processor. 1400 1520 … … 1425 1545 { 1426 1546 CPUID_EXTENDED_TOPOLOGY_EAX ExtendedTopologyEax; 1547 CPUID_EXTENDED_TOPOLOGY_EBX ExtendedTopologyEbx; 1427 1548 CPUID_EXTENDED_TOPOLOGY_ECX ExtendedTopologyEcx; 1428 1549 UINT32 MaxStandardCpuIdIndex; … … 1432 1553 UINT32 *Location[CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_DIE + 2]; 1433 1554 1555 if (StandardSignatureIsAuthenticAMD ()) { 1556 AmdGetProcessorLocation2ByApicId (InitialApicId, Package, Die, Tile, Module, Core, Thread); 1557 return; 1558 } 1559 1434 1560 for (LevelType = 0; LevelType < ARRAY_SIZE (Bits); LevelType++) { 1435 1561 Bits[LevelType] = 0; … … 1437 1563 1438 1564 // 1439 // Get max index of CPUID 1565 // Quoting Intel SDM: 1566 // Software must detect the presence of CPUID leaf 1FH by verifying 1567 // (a) the highest leaf index supported by CPUID is >= 1FH, and (b) 1568 // CPUID.1FH:EBX[15:0] reports a non-zero value. 1440 1569 // 1441 1570 AsmCpuid (CPUID_SIGNATURE, &MaxStandardCpuIdIndex, NULL, NULL, NULL); 1442 1571 if (MaxStandardCpuIdIndex < CPUID_V2_EXTENDED_TOPOLOGY) { 1572 ExtendedTopologyEbx.Bits.LogicalProcessors = 0; 1573 } else { 1574 AsmCpuidEx (CPUID_V2_EXTENDED_TOPOLOGY, 0, NULL, &ExtendedTopologyEbx.Uint32, NULL, NULL); 1575 } 1576 1577 if (ExtendedTopologyEbx.Bits.LogicalProcessors == 0) { 1443 1578 if (Die != NULL) { 1444 1579 *Die = 0;
Note:
See TracChangeset
for help on using the changeset viewer.