From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0061.outbound.protection.outlook.com [104.47.38.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 63B8521A07AA1 for ; Fri, 16 Jun 2017 17:40:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Dl554rWYCuLKC8+cIT40vEKINhOVwNQKX26JaGpR2G8=; b=rfzpgicw16+giaDGTgxs5fFnElHliqsLA3OfFuq6P+nTewcI/qmVXueoTUNM+VgtxeXSa34T9mIIIKcIh1/cWLBcJnXnHM9D6K9mVw5fGWORCivXkO94QgvrQS3AvDl4WovU9uX1U7I27TLjp9j0nOUQxbVrzNtZSOpJmqCya4k= Authentication-Results: lists.01.org; dkim=none (message not signed) header.d=none;lists.01.org; dmarc=none action=none header.from=amd.com; Received: from leduran-Precision-WorkStation-T5400.amd.com (165.204.77.1) by DM5PR12MB1243.namprd12.prod.outlook.com (10.168.237.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1157.12; Sat, 17 Jun 2017 00:42:02 +0000 From: Leo Duran To: edk2-devel@lists.01.org Cc: Leo Duran , Jordan Justen , Jeff Fan , Liming Gao , Brijesh Singh Date: Fri, 16 Jun 2017 19:41:49 -0500 Message-Id: <1497660109-18243-3-git-send-email-leo.duran@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497660109-18243-1-git-send-email-leo.duran@amd.com> References: <1497660109-18243-1-git-send-email-leo.duran@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR02CA0019.namprd02.prod.outlook.com (10.168.209.157) To DM5PR12MB1243.namprd12.prod.outlook.com (10.168.237.22) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR12MB1243: X-MS-Office365-Filtering-Correlation-Id: e6284132-22c6-464c-4ece-08d4b519abfb X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:DM5PR12MB1243; X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1243; 3:x0L+qXFdJSmGXVKzQfD8hh59OiEjw+QEiVCde6hcqhfYZcOiF98G5AGhiNah25MVwMH/4/NeHqwdm8dqdCJgZMzJZcoLDFKDarHutFRZHduaB7pgGhMFghr4C0bpAgWgfs5HURzK+IgWi1e6ZIvHdqSwwzQTuDXiOR5HhZcX2ElhB/CeNcF+BzGf6hBtkwvS+40JQhos5LXVePF+UdURQiDSUSUvULW82sDmwvjzQ6uofC3tHr9H+HNFCyZ3BWoWVUNhmn0G6wO9Hi5RSshu2CEKe/7DVCCofvZutvu3wTZjJMQCeN160ppxfTsniwKtHkiW2ztaduadHaPLV4sGuHsUzS90GV0mbW1gM23U3+Y=; 25:NpIzPQdMvBfDJzhW1/j1caDlOYphWmvMcnua1KlPixql6UQVeS8Bp404ZUN6DhkHVAwedxH7ImsS1Rq++u4PNwb6ISxesNOWv63uvQTVVIWQ8sGsoxGqF6obZsVp+Gd6Z+QmPmX9xcoVPP6Evg3xIgXSeyqPoE/SHzjYPFiEfCtz6XOHnq/2ozrYeZAyxR3qsHeGlIcitQxEbHMCuAyWT3Y9lcR1s0Nkmy99noEE/URNzI6rXQYibJm3K5uDqaQyNa2LvWeeLLtnn5TzsKUrC5GJ1hCQMc35gAVZ49F0nMGavwCHIJNE2C9HHstmPMuerkAWuFt6/xnlYwAnFdUmfEVl+Tm1WrysKgKpMIgQO7hVtooo1sxVR9snUpO+MNt5CW/WDY+u0qB8xLpCCBmeaT9aucibJhuyRooayD8mAFlsfzbF52A/o6CsSCLw1WwrncyS8XE0X91i6Z3z3EfIKmaJ5ZTQtrTc92MIBY4/9F4= X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1243; 31:2mEqChldrgAaTazkP3wutNrMCjbvSBm/l13ayQQ39q+/jdHp5hEeEgrNM1akJHC97vjng+afagSG8/InZGGnUpXoJvLPpngJprMLUyCDe6gfYQs3qywx0jGBrGOwWTGB4FdhUxOXTha+bX4QAVO7U6aZiPaU9cYwgg6245eGg+2bli5JL88yHv6gwvmczNeiRrOt7BN78qBNaqNLrS1wBwcGBKyl0Qvwk9y2dzzaoic=; 20:GpAFSoPoVGjKDsUKXSAsI5kEUZChW+jvEGwWGrxlkhR+DZwbrrRtII/cIxrHQGNZ9RyI92JbSpg6C2MdyoffYGaaN5TibJgTO/mVnhcyEgA5DpHAqorQ9/+WiAsGsMKH/ZvaTCdYmNWTaG//teqFQjcBadyT7U6/Rx0FTTbwhq31eONDr+OKNHP8Z99Y5GrjsA6cREGlqpBq6IOQI0/X1txGTRdtfYeJA1kKFcGHJMKhubQ8NW+NR342Dm+/f4pwsApZXjn+gm1SrXbqIolpagpiftP08kMOKiDprA9kcXAPrsaLNzReGtka0VDzGe5pU72oNaDHD6igExH7N6LIhFGaeXfiJYb7qtCXgBo1nztl9mUONR8Jib1sHpPpFVVm0JxuzSDishQumBkfUEbz1zCWtQkP1oTMvpahFXLMNyaNpL7rR7yELPNbbtAys/gho9ZTTvJpScMhX5i7ckftFr4il8QVgtEFNa1VzzUcjMYLshhsiCYphkIdvP6fzL2h X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(3002001)(6055026)(6041248)(20161123558100)(20161123564025)(20161123562025)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM5PR12MB1243; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM5PR12MB1243; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR12MB1243; 4:QjLObeX/QA6s38AP35DOeXThDzyTbLBorKK0xclvX/?= =?us-ascii?Q?wxnx5tm4IcP5iOmaP3IzR/ZdHoWRzzonhW47duRRx3Od05m7wohDqkNF0uvO?= =?us-ascii?Q?6sNZLOI4ZsBDsTL0qiMJGku1+rOotE1j7q/T+wqH3wOnuGDIvsj6InosbU8G?= =?us-ascii?Q?NUPze0GpFgKvA1hp4X5nehNj8wFrOVWeIuYU0EdBnKHFVTLkyVaNsZbChzyx?= =?us-ascii?Q?aF9nhpBeA+U1Xuz4zkxkFH60x67Z/sDPPbSDCbsNyp/7jWjlDuZ43+Stpmgh?= =?us-ascii?Q?o9D8Qn68f+j9bqVcIG3wQHSWx73sSycky+qk/zwxbKMrVJTdEnce1zFWyN59?= =?us-ascii?Q?DEqNlABqSeORuMhCjToerl5FStFcf9Fba/08LxBSV3yZTh49Oihmt7g7P6gs?= =?us-ascii?Q?+Ic2mMyVzhlYAbY0DqSOZjV0XkbHiGKvSF6QjOTGqPFHtmugQeEnj/QBQTLU?= =?us-ascii?Q?XFAvhICL0vxlHAOitINPMQyg1AeaSjUH8+3TI+pTkWePoCyuqAR2rKttCeV+?= =?us-ascii?Q?doT4Qq3TfdwD4mxvU6L+5x0yKFKo2+baQVB+QVpf11H6MLui5UBXg9KOON4V?= =?us-ascii?Q?Ql8J0NUH8k1bpCS1RFUyAV8VM4KWDR6VzL7dJ3BOmOFSGWA2YMStZJAOE/0o?= =?us-ascii?Q?SgE6Mr884kXqg8ANYl38OeOZla9pYAfoBknRDflel8HM/p/9WEDd5Ya7Ti90?= =?us-ascii?Q?jyBWwfSSFPaUXlY0l9Su1x8bpdwXE3Hr+dPF8V5xUxaGuqx+ZCST9NIbntK7?= =?us-ascii?Q?35r4cKstucEFJVABAOjEWsLBnD0pHsWlXZk0phevZzmxV4g3hMXLDMok0Vuy?= =?us-ascii?Q?mZrmP9leCCrveFSUpkyz83YCT43JYWmLoaHu+2KOhLFmDxPiV4BxfW5E91Nr?= =?us-ascii?Q?UyB2wuIHMkkO4D1hok93H83qUSoo3ZhBVfD26B/NPCztKhH71vRYYjq7HFWx?= =?us-ascii?Q?dcLguX8HJ/lsF56XNHnvT9QZmw36y7CGUjQmAUJn0dT2SaDvL9sg/UixM6xB?= =?us-ascii?Q?t2goZTY2u8AJ+11gvZqYhOJ0vjyWj2H2qWn/TMz5V6OP33h3hF15a8g9IbFA?= =?us-ascii?Q?/aeVHpcoRE7Lgb8cTcXzvp85ViEoVMYt2dcpJjj3Yhctk9XYTABTr7UrgZuO?= =?us-ascii?Q?N7YinpnGmE+N7ff6QbbBCrvEHi8dPTAvvDzelEN6GbzT0pzH5EGR/zQWWGAg?= =?us-ascii?Q?v1r/tH1kp+Qw621Se+4UuoW+iXghG0rDZG7VLcSOsRi4K0+7QJRpUrxhN4zP?= =?us-ascii?Q?9g+Y9MF38CjuBpkkM=3D?= X-Forefront-PRVS: 034119E4F6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6029001)(39840400002)(39850400002)(39860400002)(39400400002)(39450400003)(39410400002)(6486002)(3846002)(54906002)(33646002)(189998001)(110136004)(36756003)(5003940100001)(38730400002)(53936002)(81166006)(50466002)(47776003)(86362001)(2351001)(6116002)(2361001)(48376002)(66066001)(42186005)(25786009)(4326008)(478600001)(2906002)(53416004)(50986999)(76176999)(7736002)(305945005)(6916009)(5660300001)(8676002)(50226002)(2950100002)(6666003)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1243; H:leduran-Precision-WorkStation-T5400.amd.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR12MB1243; 23:/LaEvNUtLOi3uheIeZmXfR9BScZJPRHVpy5zYhP6r?= =?us-ascii?Q?iJ7W2+EhJVVAT3riFlDCDwcWIBNBMh6kHxJWKERF/IrkKoyuJUPY04RKg6UO?= =?us-ascii?Q?bQQ2U458wVivmaht1TLhNKuJWecPNiWA3ufcfjsL2nM/mYPe4pDjG0yqmcNk?= =?us-ascii?Q?xLMWfa19Rfa/eVPLxiPAoyLFEA50sx6Uh2F5g9LlCOHnCexwrdTwst97LXID?= =?us-ascii?Q?BiHe/dOhJkN0UuGORkdA3bSb8g1IFQy4TgrddDZ6/No6Iwh4vgLjniupNHZ9?= =?us-ascii?Q?MmWBmI3J50av64y6SnVjItmd7rmIiI6WOX9wAEFbTzjqSfVlzdGgIMCYrYnU?= =?us-ascii?Q?3q5Kv/y9Uj2UJ7j+msOeaRwvlJgnYUfV8ssg7Zs6TuHGl1kY3TFkSi7o3juG?= =?us-ascii?Q?jokPKDWBLZqet3Eea2HipCh/It5i44GNoU8vsV7nubW7Aw3EUaZ9B2ucVdKW?= =?us-ascii?Q?wbQuiei+qoDHn3MtnBtmGVzwYARzk8kWhMH7zji4bBO0n/oboSOL0v/eCbFs?= =?us-ascii?Q?ZjnyjEPVmC8tcXVKMH+PYxszmVZL0y+edg32ANy0u6HLN2MXWVKGL5PQXOD5?= =?us-ascii?Q?QWZP8O0n98fDpB0WaxTc2HO5KuHwMQLsgSZNK7QxlIhIW0wjIdAzBZWimt7m?= =?us-ascii?Q?AY+ccca5MWl7OsAX/BXiT4l1lKVKOh//D0Tga261fwu6u0s8Wh5FbpMRBYta?= =?us-ascii?Q?tcZzQnI6bdlfAlZ7H6ftMtNQ+xfQK+eMfx5PgefLP5FKFZymnehdurXAnxJG?= =?us-ascii?Q?YKOehiR/N97xeSu9Jj7HWTX67ZhL+4oFcUkb3N8/eb9y0yydmWr9KHfVhgSw?= =?us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GulY3Z/KX4qNkaXEHQtsxWaBOn1MBwhC8vtlE0Z6vStzMCGvpEussR5bu3w4= X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1243; 20:NUYsDMZncFuYyQR8y5PNWU27FBeurWYvDUNMA1f7iLmCRTHjtaJ9nYE3HZSb+Fn5WQcQEBdj/io5cpkQ/Sq/6CxBEitUT31nYQ+LaIoQnL1QuiGa1rbKcs1CIZh1lfNUcK+bPPm7JE24TWIefFs8o2jDoD4r0yx7arxnYdnCG5MzLKTM6ij22p6QjI/dlgko5CtfsdK1Fpo2KxYlM/VVgR8LwmQZU8nx5S4WXPE1y3v/nncuPFk/eNNIdHEbIIQI X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2017 00:42:02.3234 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1243 Subject: [PATCH v5 2/2] UefiCpuPkg: Modify GetProcessorLocationByApicId() to support AMD. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Jun 2017 00:40:46 -0000 Content-Type: text/plain Cc: Jordan Justen Cc: Jeff Fan Cc: Liming Gao Cc: Brijesh Singh Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Leo Duran --- UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c | 157 ++++++++++++++++----- .../BaseXApicX2ApicLib/BaseXApicX2ApicLib.c | 157 ++++++++++++++++----- 2 files changed, 250 insertions(+), 64 deletions(-) diff --git a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c index f81bbb2..2091e5e 100644 --- a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c +++ b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c @@ -4,6 +4,8 @@ This local APIC library instance supports xAPIC mode only. Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, AMD Inc. All rights reserved.
+ This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -15,6 +17,7 @@ **/ #include +#include #include #include @@ -30,6 +33,28 @@ // /** + Determine if the standard CPU signature is "AuthenticAMD". + + @retval TRUE The CPU signature matches. + @retval FALSE The CPU signature does not match. + +**/ +BOOLEAN +StandardSignatureIsAuthenticAMD ( + VOID + ) +{ + UINT32 RegEbx; + UINT32 RegEcx; + UINT32 RegEdx; + + AsmCpuid(CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx); + return (RegEbx == CPUID_SIGNATURE_AUTHENTIC_AMD_EBX && + RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX && + RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX); +} + +/** Determine if the CPU supports the Local APIC Base Address MSR. @retval TRUE The CPU supports the Local APIC Base Address MSR. @@ -966,20 +991,30 @@ GetProcessorLocationByApicId ( OUT UINT32 *Thread OPTIONAL ) { - BOOLEAN TopologyLeafSupported; - UINTN ThreadBits; - UINTN CoreBits; - CPUID_VERSION_INFO_EBX VersionInfoEbx; - CPUID_VERSION_INFO_EDX VersionInfoEdx; - CPUID_CACHE_PARAMS_EAX CacheParamsEax; - CPUID_EXTENDED_TOPOLOGY_EAX ExtendedTopologyEax; - CPUID_EXTENDED_TOPOLOGY_EBX ExtendedTopologyEbx; - CPUID_EXTENDED_TOPOLOGY_ECX ExtendedTopologyEcx; - UINT32 MaxCpuIdIndex; - UINT32 SubIndex; - UINTN LevelType; - UINT32 MaxLogicProcessorsPerPackage; - UINT32 MaxCoresPerPackage; + BOOLEAN TopologyLeafSupported; + CPUID_VERSION_INFO_EBX VersionInfoEbx; + CPUID_VERSION_INFO_EDX VersionInfoEdx; + CPUID_CACHE_PARAMS_EAX CacheParamsEax; + CPUID_EXTENDED_TOPOLOGY_EAX ExtendedTopologyEax; + CPUID_EXTENDED_TOPOLOGY_EBX ExtendedTopologyEbx; + CPUID_EXTENDED_TOPOLOGY_ECX ExtendedTopologyEcx; + CPUID_AMD_EXTENDED_CPU_SIG_ECX AmdExtendedCpuSigEcx; + CPUID_AMD_PROCESSOR_TOPOLOGY_EBX AmdProcessorTopologyEbx; + CPUID_AMD_PROCESSOR_TOPOLOGY_ECX AmdProcessorTopologyEcx; + CPUID_AMD_VIR_PHY_ADDRESS_SIZE_ECX AmdVirPhyAddressSizeEcx; + UINT32 MaxStandardCpuIdIndex; + UINT32 MaxExtendedCpuIdIndex; + UINT32 SubIndex; + UINTN LevelType; + UINT32 MaxLogicProcessorsPerPackage; + UINT32 MaxCoresPerPackage; + UINT32 MaxThreadPerPackageMask; + UINT32 ActualThreadPerPackageMask; + UINT32 MaxCoresPerNode; + UINT32 CorePerNodeMask; + UINT32 ApicIdShift; + UINTN ThreadBits; + UINTN CoreBits; // // Check if the processor is capable of supporting more than one logical processor. @@ -987,10 +1022,10 @@ GetProcessorLocationByApicId ( AsmCpuid(CPUID_VERSION_INFO, NULL, NULL, NULL, &VersionInfoEdx.Uint32); if (VersionInfoEdx.Bits.HTT == 0) { if (Thread != NULL) { - *Thread = 0; + *Thread = 0; } if (Core != NULL) { - *Core = 0; + *Core = 0; } if (Package != NULL) { *Package = 0; @@ -998,24 +1033,24 @@ GetProcessorLocationByApicId ( return; } + // + // Assume three-level mapping of APIC ID: Package|Core|Thread. + // ThreadBits = 0; CoreBits = 0; // - // Assume three-level mapping of APIC ID: Package:Core:SMT. + // Get max index of CPUID // - TopologyLeafSupported = FALSE; - - // - // Get the max index of basic CPUID - // - AsmCpuid(CPUID_SIGNATURE, &MaxCpuIdIndex, NULL, NULL, NULL); + AsmCpuid(CPUID_SIGNATURE, &MaxStandardCpuIdIndex, NULL, NULL, NULL); + AsmCpuid(CPUID_EXTENDED_FUNCTION, &MaxExtendedCpuIdIndex, NULL, NULL, NULL); // // If the extended topology enumeration leaf is available, it // is the preferred mechanism for enumerating topology. // - if (MaxCpuIdIndex >= CPUID_EXTENDED_TOPOLOGY) { + TopologyLeafSupported = FALSE; + if (MaxStandardCpuIdIndex >= CPUID_EXTENDED_TOPOLOGY) { AsmCpuidEx( CPUID_EXTENDED_TOPOLOGY, 0, @@ -1065,27 +1100,85 @@ GetProcessorLocationByApicId ( } if (!TopologyLeafSupported) { + // + // Get logical processor count + // AsmCpuid(CPUID_VERSION_INFO, NULL, &VersionInfoEbx.Uint32, NULL, NULL); MaxLogicProcessorsPerPackage = VersionInfoEbx.Bits.MaximumAddressableIdsForLogicalProcessors; - if (MaxCpuIdIndex >= CPUID_CACHE_PARAMS) { - AsmCpuidEx(CPUID_CACHE_PARAMS, 0, &CacheParamsEax.Uint32, NULL, NULL, NULL); - MaxCoresPerPackage = CacheParamsEax.Bits.MaximumAddressableIdsForLogicalProcessors + 1; + + // + // Assume single-core processor + // + MaxCoresPerPackage = 1; + + // + // Check for topology extensions on AMD processor + // + if (StandardSignatureIsAuthenticAMD()) { + if (MaxExtendedCpuIdIndex >= CPUID_AMD_PROCESSOR_TOPOLOGY) { + AsmCpuid(CPUID_EXTENDED_CPU_SIG, NULL, NULL, &AmdExtendedCpuSigEcx.Uint32, NULL); + if (AmdExtendedCpuSigEcx.Bits.TopologyExtensions != 0) { + AsmCpuid(CPUID_AMD_PROCESSOR_TOPOLOGY, NULL, &AmdProcessorTopologyEbx.Uint32, + &AmdProcessorTopologyEcx.Uint32, NULL); + // + // Get cores per processor package + // + MaxCoresPerPackage = MaxLogicProcessorsPerPackage / (AmdProcessorTopologyEbx.Bits.ThreadsPerCore + 1); + + // + // Account for actual thread count (e.g., SMT disabled) + // + AsmCpuid(CPUID_VIR_PHY_ADDRESS_SIZE, NULL, NULL, &AmdVirPhyAddressSizeEcx.Uint32, NULL); + MaxThreadPerPackageMask = 1 << AmdVirPhyAddressSizeEcx.Bits.ApicIdCoreIdSize; + ActualThreadPerPackageMask = 1; + while (ActualThreadPerPackageMask < MaxLogicProcessorsPerPackage) { + ActualThreadPerPackageMask <<= 1; + } + + // + // Adjust APIC Id to report concatenation of Package|Core|Thread. + // + if (ActualThreadPerPackageMask < MaxThreadPerPackageMask) { + MaxCoresPerNode = MaxCoresPerPackage / (AmdProcessorTopologyEcx.Bits.NodesPerProcessor + 1); + + CorePerNodeMask = 1; + while (CorePerNodeMask < MaxCoresPerNode) { + CorePerNodeMask <<= 1; + } + CorePerNodeMask -= 1; + + ApicIdShift = 0; + do { + ApicIdShift += 1; + ActualThreadPerPackageMask <<= 1; + } while (ActualThreadPerPackageMask < MaxThreadPerPackageMask); + + InitialApicId = ((InitialApicId & ~CorePerNodeMask) >> ApicIdShift) | (InitialApicId & CorePerNodeMask); + } + } + } } else { // - // Must be a single-core processor. + // Extract core count based on CACHE information // - MaxCoresPerPackage = 1; + if (MaxStandardCpuIdIndex >= CPUID_CACHE_PARAMS) { + AsmCpuidEx(CPUID_CACHE_PARAMS, 0, &CacheParamsEax.Uint32, NULL, NULL, NULL); + if (CacheParamsEax.Uint32 != 0) { + MaxCoresPerPackage = CacheParamsEax.Bits.MaximumAddressableIdsForLogicalProcessors + 1; + } + } } ThreadBits = (UINTN)(HighBitSet32(MaxLogicProcessorsPerPackage / MaxCoresPerPackage - 1) + 1); - CoreBits = (UINTN)(HighBitSet32(MaxCoresPerPackage - 1) + 1); } + CoreBits = (UINTN)(HighBitSet32(MaxCoresPerPackage - 1) + 1); + } if (Thread != NULL) { - *Thread = InitialApicId & ((1 << ThreadBits) - 1); + *Thread = InitialApicId & ((1 << ThreadBits) - 1); } if (Core != NULL) { - *Core = (InitialApicId >> ThreadBits) & ((1 << CoreBits) - 1); + *Core = (InitialApicId >> ThreadBits) & ((1 << CoreBits) - 1); } if (Package != NULL) { *Package = (InitialApicId >> (ThreadBits + CoreBits)); diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c index e690d2a..d5d4efa 100644 --- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c +++ b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c @@ -5,6 +5,8 @@ which have xAPIC and x2APIC modes. Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2017, AMD Inc. All rights reserved.
+ This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -16,6 +18,7 @@ **/ #include +#include #include #include @@ -31,6 +34,28 @@ // /** + Determine if the standard CPU signature is "AuthenticAMD". + + @retval TRUE The CPU signature matches. + @retval FALSE The CPU signature does not match. + +**/ +BOOLEAN +StandardSignatureIsAuthenticAMD ( + VOID + ) +{ + UINT32 RegEbx; + UINT32 RegEcx; + UINT32 RegEdx; + + AsmCpuid(CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx); + return (RegEbx == CPUID_SIGNATURE_AUTHENTIC_AMD_EBX && + RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX && + RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX); +} + +/** Determine if the CPU supports the Local APIC Base Address MSR. @retval TRUE The CPU supports the Local APIC Base Address MSR. @@ -1061,20 +1086,30 @@ GetProcessorLocationByApicId ( OUT UINT32 *Thread OPTIONAL ) { - BOOLEAN TopologyLeafSupported; - UINTN ThreadBits; - UINTN CoreBits; - CPUID_VERSION_INFO_EBX VersionInfoEbx; - CPUID_VERSION_INFO_EDX VersionInfoEdx; - CPUID_CACHE_PARAMS_EAX CacheParamsEax; - CPUID_EXTENDED_TOPOLOGY_EAX ExtendedTopologyEax; - CPUID_EXTENDED_TOPOLOGY_EBX ExtendedTopologyEbx; - CPUID_EXTENDED_TOPOLOGY_ECX ExtendedTopologyEcx; - UINT32 MaxCpuIdIndex; - UINT32 SubIndex; - UINTN LevelType; - UINT32 MaxLogicProcessorsPerPackage; - UINT32 MaxCoresPerPackage; + BOOLEAN TopologyLeafSupported; + CPUID_VERSION_INFO_EBX VersionInfoEbx; + CPUID_VERSION_INFO_EDX VersionInfoEdx; + CPUID_CACHE_PARAMS_EAX CacheParamsEax; + CPUID_EXTENDED_TOPOLOGY_EAX ExtendedTopologyEax; + CPUID_EXTENDED_TOPOLOGY_EBX ExtendedTopologyEbx; + CPUID_EXTENDED_TOPOLOGY_ECX ExtendedTopologyEcx; + CPUID_AMD_EXTENDED_CPU_SIG_ECX AmdExtendedCpuSigEcx; + CPUID_AMD_PROCESSOR_TOPOLOGY_EBX AmdProcessorTopologyEbx; + CPUID_AMD_PROCESSOR_TOPOLOGY_ECX AmdProcessorTopologyEcx; + CPUID_AMD_VIR_PHY_ADDRESS_SIZE_ECX AmdVirPhyAddressSizeEcx; + UINT32 MaxStandardCpuIdIndex; + UINT32 MaxExtendedCpuIdIndex; + UINT32 SubIndex; + UINTN LevelType; + UINT32 MaxLogicProcessorsPerPackage; + UINT32 MaxCoresPerPackage; + UINT32 MaxThreadPerPackageMask; + UINT32 ActualThreadPerPackageMask; + UINT32 MaxCoresPerNode; + UINT32 CorePerNodeMask; + UINT32 ApicIdShift; + UINTN ThreadBits; + UINTN CoreBits; // // Check if the processor is capable of supporting more than one logical processor. @@ -1082,10 +1117,10 @@ GetProcessorLocationByApicId ( AsmCpuid(CPUID_VERSION_INFO, NULL, NULL, NULL, &VersionInfoEdx.Uint32); if (VersionInfoEdx.Bits.HTT == 0) { if (Thread != NULL) { - *Thread = 0; + *Thread = 0; } if (Core != NULL) { - *Core = 0; + *Core = 0; } if (Package != NULL) { *Package = 0; @@ -1093,24 +1128,24 @@ GetProcessorLocationByApicId ( return; } + // + // Assume three-level mapping of APIC ID: Package|Core|Thread. + // ThreadBits = 0; CoreBits = 0; // - // Assume three-level mapping of APIC ID: Package:Core:SMT. + // Get max index of CPUID // - TopologyLeafSupported = FALSE; - - // - // Get the max index of basic CPUID - // - AsmCpuid(CPUID_SIGNATURE, &MaxCpuIdIndex, NULL, NULL, NULL); + AsmCpuid(CPUID_SIGNATURE, &MaxStandardCpuIdIndex, NULL, NULL, NULL); + AsmCpuid(CPUID_EXTENDED_FUNCTION, &MaxExtendedCpuIdIndex, NULL, NULL, NULL); // // If the extended topology enumeration leaf is available, it // is the preferred mechanism for enumerating topology. // - if (MaxCpuIdIndex >= CPUID_EXTENDED_TOPOLOGY) { + TopologyLeafSupported = FALSE; + if (MaxStandardCpuIdIndex >= CPUID_EXTENDED_TOPOLOGY) { AsmCpuidEx( CPUID_EXTENDED_TOPOLOGY, 0, @@ -1160,27 +1195,85 @@ GetProcessorLocationByApicId ( } if (!TopologyLeafSupported) { + // + // Get logical processor count + // AsmCpuid(CPUID_VERSION_INFO, NULL, &VersionInfoEbx.Uint32, NULL, NULL); MaxLogicProcessorsPerPackage = VersionInfoEbx.Bits.MaximumAddressableIdsForLogicalProcessors; - if (MaxCpuIdIndex >= CPUID_CACHE_PARAMS) { - AsmCpuidEx(CPUID_CACHE_PARAMS, 0, &CacheParamsEax.Uint32, NULL, NULL, NULL); - MaxCoresPerPackage = CacheParamsEax.Bits.MaximumAddressableIdsForLogicalProcessors + 1; + + // + // Assume single-core processor + // + MaxCoresPerPackage = 1; + + // + // Check for topology extensions on AMD processor + // + if (StandardSignatureIsAuthenticAMD()) { + if (MaxExtendedCpuIdIndex >= CPUID_AMD_PROCESSOR_TOPOLOGY) { + AsmCpuid(CPUID_EXTENDED_CPU_SIG, NULL, NULL, &AmdExtendedCpuSigEcx.Uint32, NULL); + if (AmdExtendedCpuSigEcx.Bits.TopologyExtensions != 0) { + AsmCpuid(CPUID_AMD_PROCESSOR_TOPOLOGY, NULL, &AmdProcessorTopologyEbx.Uint32, + &AmdProcessorTopologyEcx.Uint32, NULL); + // + // Get cores per processor package + // + MaxCoresPerPackage = MaxLogicProcessorsPerPackage / (AmdProcessorTopologyEbx.Bits.ThreadsPerCore + 1); + + // + // Account for actual thread count (e.g., SMT disabled) + // + AsmCpuid(CPUID_VIR_PHY_ADDRESS_SIZE, NULL, NULL, &AmdVirPhyAddressSizeEcx.Uint32, NULL); + MaxThreadPerPackageMask = 1 << AmdVirPhyAddressSizeEcx.Bits.ApicIdCoreIdSize; + ActualThreadPerPackageMask = 1; + while (ActualThreadPerPackageMask < MaxLogicProcessorsPerPackage) { + ActualThreadPerPackageMask <<= 1; + } + + // + // Adjust APIC Id to report concatenation of Package|Core|Thread. + // + if (ActualThreadPerPackageMask < MaxThreadPerPackageMask) { + MaxCoresPerNode = MaxCoresPerPackage / (AmdProcessorTopologyEcx.Bits.NodesPerProcessor + 1); + + CorePerNodeMask = 1; + while (CorePerNodeMask < MaxCoresPerNode) { + CorePerNodeMask <<= 1; + } + CorePerNodeMask -= 1; + + ApicIdShift = 0; + do { + ApicIdShift += 1; + ActualThreadPerPackageMask <<= 1; + } while (ActualThreadPerPackageMask < MaxThreadPerPackageMask); + + InitialApicId = ((InitialApicId & ~CorePerNodeMask) >> ApicIdShift) | (InitialApicId & CorePerNodeMask); + } + } + } } else { // - // Must be a single-core processor. + // Extract core count based on CACHE information // - MaxCoresPerPackage = 1; + if (MaxStandardCpuIdIndex >= CPUID_CACHE_PARAMS) { + AsmCpuidEx(CPUID_CACHE_PARAMS, 0, &CacheParamsEax.Uint32, NULL, NULL, NULL); + if (CacheParamsEax.Uint32 != 0) { + MaxCoresPerPackage = CacheParamsEax.Bits.MaximumAddressableIdsForLogicalProcessors + 1; + } + } } ThreadBits = (UINTN)(HighBitSet32(MaxLogicProcessorsPerPackage / MaxCoresPerPackage - 1) + 1); - CoreBits = (UINTN)(HighBitSet32(MaxCoresPerPackage - 1) + 1); } + CoreBits = (UINTN)(HighBitSet32(MaxCoresPerPackage - 1) + 1); + } if (Thread != NULL) { - *Thread = InitialApicId & ((1 << ThreadBits) - 1); + *Thread = InitialApicId & ((1 << ThreadBits) - 1); } if (Core != NULL) { - *Core = (InitialApicId >> ThreadBits) & ((1 << CoreBits) - 1); + *Core = (InitialApicId >> ThreadBits) & ((1 << CoreBits) - 1); } if (Package != NULL) { *Package = (InitialApicId >> (ThreadBits + CoreBits)); -- 2.7.4