From patchwork Tue Nov 22 20:26:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 83494 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp2299240qge; Tue, 22 Nov 2016 12:26:36 -0800 (PST) X-Received: by 10.99.2.142 with SMTP id 136mr47191197pgc.25.1479846396189; Tue, 22 Nov 2016 12:26:36 -0800 (PST) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id p21si23455925pgh.130.2016.11.22.12.26.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Nov 2016 12:26:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4EB0E81E83; Tue, 22 Nov 2016 12:26:34 -0800 (PST) X-Original-To: edk2-devel@ml01.01.org Delivered-To: edk2-devel@ml01.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8A98881E81 for ; Tue, 22 Nov 2016 12:26:33 -0800 (PST) Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1C752C0567A3; Tue, 22 Nov 2016 20:26:33 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-82.phx2.redhat.com [10.3.116.82]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAMKQN4x021949; Tue, 22 Nov 2016 15:26:31 -0500 From: Laszlo Ersek To: edk2-devel-01 Date: Tue, 22 Nov 2016 21:26:19 +0100 Message-Id: <20161122202619.12594-5-lersek@redhat.com> In-Reply-To: <20161122202619.12594-1-lersek@redhat.com> References: <20161122202619.12594-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 22 Nov 2016 20:26:33 +0000 (UTC) Subject: [edk2] [PATCH 4/4] OvmfPkg/PlatformPei: set PcdCpuKnownLogicalProcessorNumber for MpInitLib X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Igor Mammedov , Jeff Fan , Jordan Justen MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" This setting will allow CpuMpPei and CpuDxe to wait for the initial AP check-ins exactly as long as necessary. It is safe to set PcdCpuKnownLogicalProcessorNumber in OvmfPkg/PlatformPei. OvmfPkg/PlatformPei installs the permanent PEI RAM, producing gEfiPeiMemoryDiscoveredPpiGuid, and UefiCpuPkg/CpuMpPei has a depex on gEfiPeiMemoryDiscoveredPpiGuid. It is safe to read the fw_cfg item QemuFwCfgItemSmpCpuCount (0x0005). It was added to QEMU in 2008 as key FW_CFG_NB_CPUS, in commit 905fdcb5264c ("Add common keys to firmware configuration"). Even if the key is unavailable (or if fw_cfg is entirely unavailable, for example on Xen), QemuFwCfgRead16() will return 0, and then we stick with the current behavior (PcdCpuKnownLogicalProcessorNumber == 0, which is the default in "UefiCpuPkg/UefiCpuPkg.dec".) Cc: Igor Mammedov Cc: Jeff Fan Cc: Jordan Justen Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- OvmfPkg/OvmfPkgIa32.dsc | 2 ++ OvmfPkg/OvmfPkgIa32X64.dsc | 2 ++ OvmfPkg/OvmfPkgX64.dsc | 2 ++ OvmfPkg/PlatformPei/PlatformPei.inf | 1 + OvmfPkg/PlatformPei/Platform.c | 22 ++++++++++++++++++++ 5 files changed, 29 insertions(+) -- 2.9.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index ed43c4514491..4973a5c12719 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -488,6 +488,8 @@ [PcdsDynamicDefault] gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE + gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownLogicalProcessorNumber|0 + ################################################################################ # # Components Section - list of all EDK II Modules needed by this Platform. diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index ccd156d9231a..1a7de33450b2 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -496,6 +496,8 @@ [PcdsDynamicDefault] gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE + gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownLogicalProcessorNumber|0 + ################################################################################ # # Components Section - list of all EDK II Modules needed by this Platform. diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 012ce85462c5..08f1542df158 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -495,6 +495,8 @@ [PcdsDynamicDefault] gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE + gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownLogicalProcessorNumber|0 + ################################################################################ # # Components Section - list of all EDK II Modules needed by this Platform. diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf index 776a4ab11f79..872b3c075421 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -95,6 +95,7 @@ [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber + gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownLogicalProcessorNumber gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize [FixedPcd] diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index c6e1106c9ed0..ce8f38561fbe 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -394,6 +394,7 @@ MiscInitialization ( UINTN AcpiCtlReg; UINT8 AcpiEnBit; RETURN_STATUS PcdStatus; + UINT16 KnownProcessorCount; // // Disable A20 Mask @@ -473,6 +474,27 @@ MiscInitialization ( // PciExBarInitialization (); } + + // + // Fetch the number of boot CPUs from QEMU and expose it to MpInitLib in + // UefiCpuPkg. + // + QemuFwCfgSelectItem (QemuFwCfgItemSmpCpuCount); + KnownProcessorCount = QemuFwCfgRead16 (); + if (KnownProcessorCount > PcdGet32 (PcdCpuMaxLogicalProcessorNumber)) { + DEBUG ((DEBUG_ERROR, + "%a: KnownProcessorCount (%d) > PcdCpuMaxLogicalProcessorNumber (%u)\n", + __FUNCTION__, KnownProcessorCount, + PcdGet32 (PcdCpuMaxLogicalProcessorNumber))); + ASSERT (FALSE); + CpuDeadLoop (); + } else if (KnownProcessorCount > 0) { + PcdStatus = PcdSet32S (PcdCpuKnownLogicalProcessorNumber, + KnownProcessorCount); + ASSERT_RETURN_ERROR (PcdStatus); + DEBUG ((DEBUG_INFO, "%a: QEMU reports %d processors\n", __FUNCTION__, + KnownProcessorCount)); + } }