From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by mx.groups.io with SMTP id smtpd.web11.3277.1583005827901115528 for ; Sat, 29 Feb 2020 11:50:28 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ek3GQJ75; spf=pass (domain: redhat.com, ip: 207.211.31.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583005827; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+IA8RqHWbEKVCimvZbHxF/dH+Ks1oFNXFh16S3FPLOs=; b=Ek3GQJ75UPifoIvSL8VFiW+bnIpETuryOIhbirFjhVqqEoctqJMjB8y75iC+XUp45wm99l Bl0uyRwFU2x87Sbvrx4TD+hEWqbtNM5bRoimW7uW0M01etfsOSMj+Km7wWpDq9v0GZ6+YP F1/87/5zGGBOQtGzulmQio05MfYt3I0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-395-JEyyNhjhMwOe-In1Q6JL5w-1; Sat, 29 Feb 2020 14:50:18 -0500 X-MC-Unique: JEyyNhjhMwOe-In1Q6JL5w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33D1C13F5; Sat, 29 Feb 2020 19:50:17 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-53.ams2.redhat.com [10.36.116.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 97BF15C1B5; Sat, 29 Feb 2020 19:50:15 +0000 (UTC) Subject: Re: [PATCH] UefiCpuPkg/MpInitLib: Skip reading PlatformId on AMD processors. To: Leo Duran , devel@edk2.groups.io Cc: Eric Dong , Ray Ni References: <1582988745-1189-1-git-send-email-leo.duran@amd.com> <1582988745-1189-2-git-send-email-leo.duran@amd.com> From: "Laszlo Ersek" Message-ID: <26b476ea-1dfc-6063-5fa0-2d4863df09cc@redhat.com> Date: Sat, 29 Feb 2020 20:50:14 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1582988745-1189-2-git-send-email-leo.duran@amd.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 02/29/20 16:05, Leo Duran wrote: > 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 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 > --- > UefiCpuPkg/Library/MpInitLib/MpLib.c | 34 ++++++++++++++++++++++++++++++++-- > UefiCpuPkg/Library/MpInitLib/MpLib.h | 3 +++ > 2 files changed, 35 insertions(+), 2 deletions(-) > mode change 100644 => 100755 UefiCpuPkg/Library/MpInitLib/MpLib.h > > 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, > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/MpInitLib/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. > > Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.
> + Copyright (c) 2020, AMD Inc. All rights reserved.
> + > SPDX-License-Identifier: BSD-2-Clause-Patent > > **/ > @@ -12,6 +14,7 @@ > #include > > #include > +#include > #include > #include > #include > Reviewed-by: Laszlo Ersek