From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web12.1586.1613767414440993074 for ; Fri, 19 Feb 2021 12:43:34 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HuQldXse; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613767413; 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=2dM2NOzuMccC3TRs8PmGNHdcEeTT3Tq77M1vYc4IfIY=; b=HuQldXsecmyrJKNqDfdWgQkW51+jJigUqDmhQvYfzoEc2RqD6uQ603EeuGCNZpRdwrfiZ1 95/kZs0LS6yLXbDDCuP2vUW3ivPo7SPgoaYGDZ7PeaXfvpkvLMCt4adlCF0rey8ecZxWYG 6d7QAcmuatBPwpoXbPeG0xVOoJt/FvA= 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-4-pJCIsBMCNSux88o-UP-ORQ-1; Fri, 19 Feb 2021 15:43:30 -0500 X-MC-Unique: pJCIsBMCNSux88o-UP-ORQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1428A107ACC7; Fri, 19 Feb 2021 20:43:29 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-87.ams2.redhat.com [10.36.113.87]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F59060BFA; Fri, 19 Feb 2021 20:43:27 +0000 (UTC) Subject: Re: [PATCH v3 4/5] UefiCpuPkg/SmmCpuFeaturesLib: Abstract PcdCpuMaxLogicalProcessorNumber To: mikuback@linux.microsoft.com, devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar References: <20210217213227.1277-1-mikuback@linux.microsoft.com> <20210217213227.1277-5-mikuback@linux.microsoft.com> From: "Laszlo Ersek" Message-ID: Date: Fri, 19 Feb 2021 21:43:26 +0100 MIME-Version: 1.0 In-Reply-To: <20210217213227.1277-5-mikuback@linux.microsoft.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 02/17/21 22:32, mikuback@linux.microsoft.com wrote: > From: Michael Kubacki > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3218 > > Adds a new function called GetCpuMaxLogicalProcessorNumber() to > return the number of maximum CPU logical processors (currently > gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber). > > This allows the the mechanism used to retrieve the CPU maximum > logical processor number to be abstracted from the logic that > needs the value. > > Cc: Eric Dong > Cc: Ray Ni > Cc: Laszlo Ersek > Cc: Rahul Kumar > Signed-off-by: Michael Kubacki > Reviewed-by: Laszlo Ersek > --- > UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c | 2 +- > UefiCpuPkg/Library/SmmCpuFeaturesLib/TraditionalMmCpuFeaturesLib.c | 28 ++++++++++++++++++++ > UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h | 14 ++++++++++ > UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf | 1 + > UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf | 1 + > 5 files changed, 45 insertions(+), 1 deletion(-) Looks good, thanks. Laszlo > > diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c > index 7a919c5ee70f..50379f3aea19 100644 > --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c > +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c > @@ -157,7 +157,7 @@ CpuFeaturesLibInitialization ( > // > // Allocate array for state of SMRR enable on all CPUs > // > - mSmrrEnabled = (BOOLEAN *)AllocatePool (sizeof (BOOLEAN) * PcdGet32 (PcdCpuMaxLogicalProcessorNumber)); > + mSmrrEnabled = (BOOLEAN *)AllocatePool (sizeof (BOOLEAN) * GetCpuMaxLogicalProcessorNumber ()); > ASSERT (mSmrrEnabled != NULL); > } > > diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/TraditionalMmCpuFeaturesLib.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/TraditionalMmCpuFeaturesLib.c > new file mode 100644 > index 000000000000..b7a5c1926e4d > --- /dev/null > +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/TraditionalMmCpuFeaturesLib.c > @@ -0,0 +1,28 @@ > +/** @file > + Traditional MM CPU specific programming. > + > + Copyright (c) Microsoft Corporation.
> + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > +#include "CpuFeaturesLib.h" > + > +/** > + Gets the maximum number of logical processors from the PCD PcdCpuMaxLogicalProcessorNumber. > + > + This access is abstracted from the PCD services to enforce that the PCD be > + FixedAtBuild in the Standalone MM build of this driver. > + > + @return The value of PcdCpuMaxLogicalProcessorNumber. > + > +**/ > +UINT32 > +GetCpuMaxLogicalProcessorNumber ( > + VOID > + ) > +{ > + return PcdGet32 (PcdCpuMaxLogicalProcessorNumber); > +} > diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h b/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h > index f9a758e82558..2b6bfa899a48 100644 > --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h > +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h > @@ -31,4 +31,18 @@ FinishSmmCpuFeaturesInitializeProcessor ( > VOID > ); > > +/** > + Gets the maximum number of logical processors from the PCD PcdCpuMaxLogicalProcessorNumber. > + > + This access is abstracted from the PCD services to enforce that the PCD be > + FixedAtBuild in the Standalone MM build of this driver. > + > + @return The value of PcdCpuMaxLogicalProcessorNumber. > + > +**/ > +UINT32 > +GetCpuMaxLogicalProcessorNumber ( > + VOID > + ); > + > #endif > diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf > index ddd00eeceb84..35292dac31ba 100644 > --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf > +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf > @@ -21,6 +21,7 @@ [Sources] > SmmCpuFeaturesLib.c > SmmCpuFeaturesLibCommon.c > SmmCpuFeaturesLibNoStm.c > + TraditionalMmCpuFeaturesLib.c > > [Packages] > MdePkg/MdePkg.dec > diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf > index 78f8e4b42c44..022351f59320 100644 > --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf > +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf > @@ -22,6 +22,7 @@ [Sources] > SmmCpuFeaturesLibCommon.c > SmmStm.c > SmmStm.h > + TraditionalMmCpuFeaturesLib.c > > [Sources.Ia32] > Ia32/SmmStmSupport.c >