From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.120]) by mx.groups.io with SMTP id smtpd.web12.12041.1582961578501289791 for ; Fri, 28 Feb 2020 23:32:58 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=D8Wh0J4u; spf=pass (domain: redhat.com, ip: 205.139.110.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582961577; 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=Wq8gzJkIx7SWs/p00wHdxHEJgECz3W23oPskO2eBnMw=; b=D8Wh0J4uX/mQtqxzqsGVV9vvJ+bV1sDm50zZ6ZQiJKjuzBhQuxSp3Vv6qxJgPAI/KQX9SZ /IlqSbeujOyA6FvnSlR3MYS37XwvGZferl1DoIchgfzhOKkm7Wg/8a0glyvdTPae1NY1O8 f9ezC4PsIe0OoPfQAbD35KCLNQGZtx4= 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-300-btU03IOLO-6Wm69S7x7F2A-1; Sat, 29 Feb 2020 02:32:50 -0500 X-MC-Unique: btU03IOLO-6Wm69S7x7F2A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 66637800D54; Sat, 29 Feb 2020 07:32:49 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-20.ams2.redhat.com [10.36.116.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id D448187B08; Sat, 29 Feb 2020 07:32:47 +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: <1582916283-29137-1-git-send-email-leo.duran@amd.com> <1582916283-29137-2-git-send-email-leo.duran@amd.com> From: "Laszlo Ersek" Message-ID: <26bfc5b1-3dff-a188-7558-15a84397a059@redhat.com> Date: Sat, 29 Feb 2020 08:32:46 +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: <1582916283-29137-2-git-send-email-leo.duran@amd.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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/28/20 19:58, 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 ++++++++++++++++++++++++++++++++-- > 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, > Reviewed-by: Laszlo Ersek