From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.52]) by mx.groups.io with SMTP id smtpd.web11.19092.1582915560973933304 for ; Fri, 28 Feb 2020 10:46:01 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=4C5L/JGU; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.94.52, mailfrom: leo.duran@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bg1dgngspNEjxZQIeIzUUP6232m4IMRq1qexOuy9TvqDyG4+9Fk4LGjvAr1VxC/84PkeFPgkd+O/VDjhxP5AAK0mes03xGKp+Te7dUZys9eS3t4MGyohS27aI5dhsUMYLBOexVS8EgfKfyeuxB79RWNGMj0sfQ2XSzmmAYUpW7LOR6w9/wJ1JkQAzZkHWdtRPpQsrS2Wi6mrGdweN/I0M2yAf8btGp6YrchgW/iEGd5o3QhH5XYoT2W0hTwM85F+sgxogxFxsj9PLSyEUhNxwU4eYVICz7Baioix1OdxiIfgFE6t3IZOXyYB7rnywVLdqIkei45gwSNpuNRaPeBcFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hmxd8Y0DKGrhmxQR3MDyvqYGeLh4BCWegTR+ZCJ8BJg=; b=RsjYe/0frlFzDOfB6DX38OGDX8vzYyL11kS98ZFyZ3Vjx1Qa7JyYjQ6I1FKcd9C5KfSiSTDRdD/WburRU37ldp9YdOAUkzGCUoPVzTKNyTXp45euR/wq/A4WvelO1S61QDPBPBBpea1jZJo4evU1+WFOlZQhUmYjZy8EuDNn95Y0bWq8oo5CN9RW1YzSecPiLEUz9LYdftqKVBvrx0+BVZwiFLcIp//Grt6ROpmQbQbD0RzS4FZ/MUdK3HUJE5yjWmQcdoow/R9VW0wFuD4kxU/fndaGrqGrPA9tFkYJw3HR9cjvTXpzLeX+ZMOM2yTaP0P8c6OqRZACsztJSBIQyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hmxd8Y0DKGrhmxQR3MDyvqYGeLh4BCWegTR+ZCJ8BJg=; b=4C5L/JGUpLFHyjxwMgJyjJbezMPywHZdY3mh8AoS3Wpt5OCB6N/GXf3gevgZUFIJyhWQ/sZG0AArk5kSfw3W1xf0MTKtDqDPYg1kEruEGAZfrVlAhiYkofpMdAGab+7l06pHiwEfdsmYcN8UDSvEzuHeLMHJLsOMZA4K4PREk/s= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=leo.duran@amd.com; Received: from BN6PR12MB1922.namprd12.prod.outlook.com (2603:10b6:404:106::14) by BN6PR12MB1778.namprd12.prod.outlook.com (2603:10b6:404:106::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.14; Fri, 28 Feb 2020 18:45:59 +0000 Received: from BN6PR12MB1922.namprd12.prod.outlook.com ([fe80::d931:1942:a6b5:d74c]) by BN6PR12MB1922.namprd12.prod.outlook.com ([fe80::d931:1942:a6b5:d74c%7]) with mapi id 15.20.2772.018; Fri, 28 Feb 2020 18:45:59 +0000 From: Leo Duran To: devel@edk2.groups.io Cc: Leo Duran , Eric Dong , Ray Ni , Laszlo Ersek Subject: [PATCH] UefiCpuPkg/MpInitLib: Skip reading PlatformId on AMD processors. Date: Fri, 28 Feb 2020 12:45:42 -0600 Message-Id: <1582915542-28940-2-git-send-email-leo.duran@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1582915542-28940-1-git-send-email-leo.duran@amd.com> References: <1582915542-28940-1-git-send-email-leo.duran@amd.com> X-ClientProxiedBy: DM5PR22CA0008.namprd22.prod.outlook.com (2603:10b6:3:101::18) To BN6PR12MB1922.namprd12.prod.outlook.com (2603:10b6:404:106::14) Return-Path: leo.duran@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from leduran-Precision-WorkStation-T5400.amd.com (165.204.78.2) by DM5PR22CA0008.namprd22.prod.outlook.com (2603:10b6:3:101::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2772.14 via Frontend Transport; Fri, 28 Feb 2020 18:45:58 +0000 X-Mailer: git-send-email 2.7.4 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4455edd4-e704-4f68-1888-08d7bc7e73fb X-MS-TrafficTypeDiagnostic: BN6PR12MB1778:|BN6PR12MB1778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-Forefront-PRVS: 0327618309 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6029001)(4636009)(366004)(39860400002)(376002)(396003)(136003)(346002)(189003)(199004)(16526019)(186003)(2906002)(26005)(19627235002)(6666004)(44832011)(54906003)(316002)(52116002)(7696005)(66556008)(4326008)(81166006)(5660300002)(2616005)(66476007)(956004)(8936002)(86362001)(66946007)(81156014)(478600001)(6486002)(966005)(6916009)(8676002)(36756003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR12MB1778;H:BN6PR12MB1922.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pzAKeoj+J39H4KosLsXcFoT4LaN8bwvM/FVBl/K6PPtwsXP74cSPX2iQ9eB+vJ8xtKM6ck1jnRGqdc/89n5+p22OkjmYWSJYwfqJNIJq9qHo1tLcBWP+z9Tzr9JsA4p/jmOlKZ4M02SEocsS3L8EcDFyNUNv/xExPShT3hvzvRXT4mMph3FGTnxj2LmMn52anslEufppdtTQMoYHSOjBVmEzSnrt1pdxfCpIMzPGZslsxheElV0RRoxd4aCrp/Zue5WeOzKUqtoEUD4dU/0zoSdFlmBbDYgAyj9F1CoUHiPgsZR9JMx/HMPR6+sb/GPPScVBtCdwUT52lMxktPB4MIi8Dks2qe0g4GUWejvId/DZm8JAdI+eUKPt0EIHpnAxO19W2BE8dETaFSg/OWUD5cQ2xB6VFIj5WDFLLsFKaEw8YlRVFShQ1nsi71F4x16Z1+e1cu/4r65Be8YKVnqQ94lV/dCjBWXQ3yn/Mh9RdXpYhaBhQ4vFPHORV8X/cVePvyNfam3R3UHvr16ZFly0uw== X-MS-Exchange-AntiSpam-MessageData: sROAuFoZHbrakzVfh0iSsX4VCvdEkA0Z9FKiR8Jr5ctP+hUaUBAZquIgGmnZzVNUGqNF/Zf93+NLGxiRGepa/aiI51DlZ3uGrbhUFEoMzXKb/sSVuH2Ik4xzTNmr5vP+x20gEQphfijREF7joLzwQA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4455edd4-e704-4f68-1888-08d7bc7e73fb X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2020 18:45:59.6890 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: u6atBrVW81Fr4Mv9K385yzKzOtV7OvIQKp6stB8YgOZUYEsGE240+pBGTL5nHiQK X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1778 Content-Type: text/plain REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2556 This patch uses CPUID signature check to skip reading the PlatformId MSR, which is not implemented on AMD processors. The PlatformId is used for loading microcode patches, which is also not supported and AMD-based platforms. To mitigate the PlatformId dependency, PcdCpuMicrocodePatchAddress and PcdCpuMMicrodePatchRegionSize must be set to 0 (default value), in order to bypass microcode loading code paths. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Signed-off-by: Leo Duran --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c index d0fbc17..d2200c3 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -2,6 +2,8 @@ CPU MP Initialize Library common functions. Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.
+ Copyright (c) 2020, AMD Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -10,6 +12,29 @@ EFI_GUID mCpuInitMpLibHobGuid = CPU_INIT_MP_LIB_HOB_GUID; + +/** + 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); +} + /** The function will check if BSP Execute Disable is enabled. @@ -564,8 +589,13 @@ InitializeApData ( CpuMpData->CpuData[ProcessorNumber].Waiting = FALSE; CpuMpData->CpuData[ProcessorNumber].CpuHealthy = (BistData == 0) ? TRUE : FALSE; - PlatformIdMsr.Uint64 = AsmReadMsr64 (MSR_IA32_PLATFORM_ID); - CpuMpData->CpuData[ProcessorNumber].PlatformId = (UINT8) PlatformIdMsr.Bits.PlatformId; + // + // NOTE: PlatformId is not relevant on AMD platforms. + // + if (!StandardSignatureIsAuthenticAMD ()) { + PlatformIdMsr.Uint64 = AsmReadMsr64 (MSR_IA32_PLATFORM_ID); + CpuMpData->CpuData[ProcessorNumber].PlatformId = (UINT8)PlatformIdMsr.Bits.PlatformId; + } AsmCpuid ( CPUID_VERSION_INFO, -- 2.7.4