From nobody Sat May 4 09:58:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+55123+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1583006303326597.7114704283957; Sat, 29 Feb 2020 11:58:23 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Bt5lYY1788612x9fPSgJhfuI; Sat, 29 Feb 2020 11:58:22 -0800 X-Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.64]) by mx.groups.io with SMTP id smtpd.web11.15667.1582988757692448815 for ; Sat, 29 Feb 2020 07:05:57 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PWTU7zuN3WlsBAYiY6MuoI2EGwIyI9uicIPNBNtP8lLEGipioIh1x0AxmEcEjVG3ttP8m1Kd1gH1L99r0wbrSkiY+mqiz9cDPWPws1nVezUcU5YNE+23aeqp/XzA1MR+TJ3a5lF/FUSPJK/5km+O8BTbNYcBgw1rAZXK/XunOfSz1iM0JKyMTBu5p1zWgBZ6Ep3uR/dbVr/YKKZUGYBE4ObQbjTmZlmAAyXxsmsPJ+rTIhip0fUxEErzz76699ViThKtRI8iPeVbtkOwUz53ZhRkgsqh2RbPL3K1I2fpf0tJWL4J3B8EEFj7k1ZEGSvKTpFH6c6J26YEvrPwToFa3w== 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=Yib0az/87jcjHL6G1452+q2JfUBOVttl7S3Vk5wYAig=; b=O1kvXoUvJiG6sNk1m0g72vEPxPmrveEu9LqVxK2jyfCldKEAAUU30xydrQeMEru+2xIzrSJyri+kPBtjRQk8y2x2dUsYe20gA2eRBsVt1l1X4HthNlYL65QiXCv7eSRSwYkbWFm14RYXJBhfHo9mC3W+NUKFW9NymUpCrCH5V3lU+v93vIo2VDqJx6RfOjbGTkO7Gsotce5TLerfdId6JWR7AVLOBauePPxkK6C1/he/MuVZZBGJ18TqTNOH0PHgQu6lU0zcB0tQQrMuKKdkSmbG4BxZrsPM/a70GZXiDhlXeJ0PwsGnrIeBxESP9tQjhWR7YrFmSOz3XblcxsGXmw== 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 X-Received: from BN6PR12MB1922.namprd12.prod.outlook.com (2603:10b6:404:106::14) by BN6PR12MB1411.namprd12.prod.outlook.com (2603:10b6:404:1f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.14; Sat, 29 Feb 2020 15:05:56 +0000 X-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; Sat, 29 Feb 2020 15:05:56 +0000 From: Leo Duran To: devel@edk2.groups.io Cc: Leo Duran , Eric Dong , Ray Ni , Laszlo Ersek Subject: [edk2-devel] [PATCH] UefiCpuPkg/MpInitLib: Skip reading PlatformId on AMD processors. Date: Sat, 29 Feb 2020 09:05:45 -0600 Message-Id: <1582988745-1189-2-git-send-email-leo.duran@amd.com> In-Reply-To: <1582988745-1189-1-git-send-email-leo.duran@amd.com> References: <1582988745-1189-1-git-send-email-leo.duran@amd.com> X-ClientProxiedBy: DM5PR10CA0023.namprd10.prod.outlook.com (2603:10b6:4:2::33) To BN6PR12MB1922.namprd12.prod.outlook.com (2603:10b6:404:106::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from leduran-Precision-WorkStation-T5400.amd.com (165.204.78.2) by DM5PR10CA0023.namprd10.prod.outlook.com (2603:10b6:4:2::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2772.16 via Frontend Transport; Sat, 29 Feb 2020 15:05:55 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 44ecdfc5-20b3-4c96-f48c-08d7bd28e0a6 X-MS-TrafficTypeDiagnostic: BN6PR12MB1411:|BN6PR12MB1411: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+55123+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: zxYuJVMrukOrAUwg6Fftu3agN1HBTakE9heNJ6XPX6vTy7X9vZVA5Nhjq7orwdK1QrdisMoDCKJunPOxhVlue9VhedliWiSgxI5bADjkOhl9dXT4Vs13mRkbKu4QK35saZ5GBAGDjzD6cpY4FBG848ndRG6G35y4HNWTKnaZ6cBIxXkJWaRG4dk8BoCWSDnh4qZgEcGb1gel/oesO7qIH4x3g/6fl6cbYZbzY587Ao1V/te0nJkNzUT2U8Zbx+VI2tZ1YVd5k2JGipaUNerw3fvg+spen6yovKv/ubIm9Z64xrHiH4jeVLmVYejkaGshPvnZPfhpjQpOHSC8RbXZoxJYnJd92L4w0bkNpYjOH9ruWTTwqy8EKPqoHCUI7ToFdrpo9b1GrIQqttpy8WzkwOhLMt4BDjAHWA7/CInsy3qu+czv/ypvs6EhUXwRr+un4xAW1hpmdCym8MQPehQO3Nbt0Je1j9BHbxjelcZM7n/BG7E0kG8/D9+V42BpOVGPxGwb6p8kpfP4krIIJF00eA== X-MS-Exchange-AntiSpam-MessageData: acnKfY+pzIhlRPxSrj6FwP++UY00GkvsgJJgXYuXGLeUC0UGshv94xx2GZ4yA0pXveqQ13IDJIB+z4jWVrR3V11h0vJB5nUhdDPaVIuN3gVlVj10FY5DFqTKMgXVs64Z60knwSorCSMF+3KQSwEvAw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 44ecdfc5-20b3-4c96-f48c-08d7bd28e0a6 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Feb 2020 15:05:56.3063 (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: FMYYQr0+EkeyRut21jD3AUHvuPIf25hC52DuIHQtgGt/z4q7VQ3hiPOin6H129LS X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1411 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,leo.duran@amd.com X-Gm-Message-State: lZZYbEv9mjKxhUYbFQqNJZnFx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1583006302; bh=QT7ViwXgO/GQ1Gez/QneebPT2nQ0lD/N8GFAwWm5JP0=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=CUmmBUaywAXlqF1F4hnQZkb80O8FbJILesBRW7A6NvluTiIm+F8uwogI+aYmoB14xHi oWJfmhPUs5ptcWqcY63SihWPdT2JpBz4sgEom4fbjukInMpvLWT918BE8nX7VBzcM5yL+ LD+iMr4wufne2BFAgCMXcFpv0css3wFaJHE= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2556 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 PcdCpuMicrodePatchRegionSize 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 Reviewed-by: Laszlo Ersek --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 34 ++++++++++++++++++++++++++++++++= -- UefiCpuPkg/Library/MpInitLib/MpLib.h | 3 +++ 2 files changed, 35 insertions(+), 2 deletions(-) mode change 100644 =3D> 100755 UefiCpuPkg/Library/MpInitLib/MpLib.h diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/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. =20 Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.
+ Copyright (c) 2020, AMD Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -10,6 +12,29 @@ =20 EFI_GUID mCpuInitMpLibHobGuid =3D CPU_INIT_MP_LIB_HOB_GUID; =20 + +/** + 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 =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EBX && + RegEcx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_ECX && + RegEdx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EDX); +} + /** The function will check if BSP Execute Disable is enabled. =20 @@ -564,8 +589,13 @@ InitializeApData ( CpuMpData->CpuData[ProcessorNumber].Waiting =3D FALSE; CpuMpData->CpuData[ProcessorNumber].CpuHealthy =3D (BistData =3D=3D 0) ?= TRUE : FALSE; =20 - PlatformIdMsr.Uint64 =3D AsmReadMsr64 (MSR_IA32_PLATFORM_ID); - CpuMpData->CpuData[ProcessorNumber].PlatformId =3D (UINT8) PlatformIdMsr= .Bits.PlatformId; + // + // NOTE: PlatformId is not relevant on AMD platforms. + // + if (!StandardSignatureIsAuthenticAMD ()) { + PlatformIdMsr.Uint64 =3D AsmReadMsr64 (MSR_IA32_PLATFORM_ID); + CpuMpData->CpuData[ProcessorNumber].PlatformId =3D (UINT8)PlatformIdMs= r.Bits.PlatformId; + } =20 AsmCpuid ( CPUID_VERSION_INFO, diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/MpIn= itLib/MpLib.h old mode 100644 new mode 100755 index 455cb3f..0c89f8a --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h @@ -2,6 +2,8 @@ Common header file for MP Initialize Library. =20 Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.
+ Copyright (c) 2020, AMD Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -12,6 +14,7 @@ #include =20 #include +#include #include #include #include --=20 2.7.4 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#55123): https://edk2.groups.io/g/devel/message/55123 Mute This Topic: https://groups.io/mt/71626798/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-