From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web12.36282.1613417722997050454 for ; Mon, 15 Feb 2021 11:35:23 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=J70cL19i; spf=pass (domain: redhat.com, ip: 216.205.24.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613417722; 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=s800pbPC4BxoxW0Yi7dslsL2KEeB9bqW6GUVxgOQgyk=; b=J70cL19ice162km/7o2w7ri7ImVsnqnLdxq97q5S3ZTtgJLDjKNQpt9m0tjUR9k9OUj7aU 2UD0+1o0xYgKF4n4LQvo25YHUCGuUqLqeqlLlPrQ6Obg0/tHEGss4Yh43TZIPQ0xSSql4l AI3s2OmlGACx27BOvV2qji4rer9skv4= 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-581-HR3E9jAMNKmHpdhNYWhTfw-1; Mon, 15 Feb 2021 14:35:18 -0500 X-MC-Unique: HR3E9jAMNKmHpdhNYWhTfw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 53474804023; Mon, 15 Feb 2021 19:35:17 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-65.ams2.redhat.com [10.36.112.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id B9E505B698; Mon, 15 Feb 2021 19:35:15 +0000 (UTC) Subject: Re: [PATCH v2 3/4] UefiCpuPkg/SmmCpuFeaturesLib: Abstract PcdCpuMaxLogicalProcessorNumber To: mikuback@linux.microsoft.com, devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar References: <20210213005806.2927-1-mikuback@linux.microsoft.com> <20210213005806.2927-4-mikuback@linux.microsoft.com> From: "Laszlo Ersek" Message-ID: <756c0bb2-e996-1261-a066-709dfd2af292@redhat.com> Date: Mon, 15 Feb 2021 20:35:14 +0100 MIME-Version: 1.0 In-Reply-To: <20210213005806.2927-4-mikuback@linux.microsoft.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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/13/21 01:58, 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 > --- > UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.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(-) > > diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c > index e74f87f3f266..a494988898b8 100644 > --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c > +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.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..6a4eff755d92 > --- /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. > + > + @retval 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..1a72ba4e2e13 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. > + > + @retval The value of PcdCpuMaxLogicalProcessorNumber. > + > +**/ > +UINT32 > +GetCpuMaxLogicalProcessorNumber ( > + VOID > + ); > + > #endif > diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf > index a6d8467d26aa..b32dbeab9383 100644 > --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf > +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf > @@ -20,6 +20,7 @@ [Sources] > CpuFeaturesLib.h > SmmCpuFeaturesLib.c > SmmCpuFeaturesLibNoStm.c > + TraditionalMmCpuFeaturesLib.c > > [Packages] > MdePkg/MdePkg.dec > diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf > index 89cd252ef44e..f72ef0a88088 100644 > --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf > +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf > @@ -22,6 +22,7 @@ [Sources] > SmmCpuFeaturesLib.c > SmmStm.c > SmmStm.h > + TraditionalMmCpuFeaturesLib.c > > [Sources.Ia32] > Ia32/SmmStmSupport.c > Reviewed-by: Laszlo Ersek