From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 7F865780091 for ; Tue, 5 Dec 2023 05:49:30 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=QdjL+KdKujuU4YVSEnUvN8RH6eD72s1jbGpSB7Gd2dA=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1701755369; v=1; b=c7H11todTosgxJz6IgY2/4z09xlcHKm1fjDvA3ZzU02ahdbu/NJKC6l+RRQuIz2aY/z/lIz4 4DgZf88c4+6doq8Nwbn5qyZr6V4uL0/tKVMLw0yO9JAJAqTxXhVxMGesDZavlq1WgqVBJRqGZOV FY+xPzkKr4WBNybxe3bDUGxE= X-Received: by 127.0.0.2 with SMTP id lvO8YY7687511x9zl356ksn4; Mon, 04 Dec 2023 21:49:29 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web11.93095.1701755355027796431 for ; Mon, 04 Dec 2023 21:49:28 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="378875436" X-IronPort-AV: E=Sophos;i="6.04,251,1695711600"; d="scan'208";a="378875436" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2023 21:49:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="720580542" X-IronPort-AV: E=Sophos;i="6.04,251,1695711600"; d="scan'208";a="720580542" X-Received: from shwdeopenlab702.ccr.corp.intel.com ([10.239.55.43]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2023 21:49:26 -0800 From: "duntan" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann Subject: [edk2-devel] [PATCH 5/6] UefiCpuPkg: Cache core type in MpInfo2 HOB Date: Tue, 5 Dec 2023 13:48:59 +0800 Message-Id: <20231205054900.926-6-dun.tan@intel.com> In-Reply-To: <20231205054900.926-1-dun.tan@intel.com> References: <20231205054900.926-1-dun.tan@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,dun.tan@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: JMv3u0EjkDN2bOqhUD9xA9D8x7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=c7H11tod; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Cache core type in MpInfo2 HOB by CpuMpPei module. Signed-off-by: Dun Tan Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann --- UefiCpuPkg/CpuMpPei/CpuMpPei.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- UefiCpuPkg/CpuMpPei/CpuMpPei.h | 2 ++ 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c index 4d80d52799..8f6863f4d9 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c @@ -541,6 +541,30 @@ InitializeMpExceptionStackSwitchHandlers ( FreePages (SwitchStackData, EFI_SIZE_TO_PAGES (NumberOfProcessors * sizeof (EXCEPTION_STACK_SWITCH_CONTEXT))); } +/** + Get CPU core type. + + @param[in, out] Buffer Argument of the procedure. +**/ +VOID +EFIAPI +GetProcessorCoreType ( + IN OUT VOID *Buffer + ) +{ + EFI_STATUS Status; + UINT8 *CoreType; + CPUID_NATIVE_MODEL_ID_AND_CORE_TYPE_EAX NativeModelIdAndCoreTypeEax; + UINTN ProcessorIndex; + + Status = MpInitLibWhoAmI (&ProcessorIndex); + ASSERT_EFI_ERROR (Status); + + CoreType = (UINT8 *)Buffer; + AsmCpuidEx (CPUID_HYBRID_INFORMATION, CPUID_HYBRID_INFORMATION_MAIN_LEAF, &NativeModelIdAndCoreTypeEax.Uint32, NULL, NULL, NULL); + CoreType[ProcessorIndex] = (UINT8)NativeModelIdAndCoreTypeEax.Bits.CoreType; +} + /** Create gMpInformationHobGuid2. **/ @@ -558,13 +582,36 @@ BuildMpInformationHob ( MP_INFORMATION2_HOB_DATA *MpInformation2HobData; MP_INFORMATION2_ENTRY *MpInformation2Entry; UINTN Index; + UINT8 *CoreType; + UINT32 CpuidMaxInput; + UINTN Pages; ProcessorIndex = 0; MpInformation2HobData = NULL; MpInformation2Entry = NULL; + CoreType = NULL; + Pages = 0; Status = MpInitLibGetNumberOfProcessors (&NumberOfProcessors, &NumberOfEnabledProcessors); ASSERT_EFI_ERROR (Status); + + // + // Get Processors CoreType + // + AsmCpuid (CPUID_SIGNATURE, &CpuidMaxInput, NULL, NULL, NULL); + if (CpuidMaxInput >= CPUID_HYBRID_INFORMATION) { + Pages = EFI_SIZE_TO_PAGES (sizeof (UINT8) * NumberOfProcessors); + CoreType = AllocatePages (Pages); + ASSERT (CoreType != NULL); + + Status = MpInitLibStartupAllCPUs ( + GetProcessorCoreType, + 0, + (VOID *)CoreType + ); + ASSERT_EFI_ERROR (Status); + } + MaxProcessorsPerHob = ((MAX_UINT16 & 7) - sizeof (EFI_HOB_GUID_TYPE) - sizeof (MP_INFORMATION2_HOB_DATA)) / sizeof (MP_INFORMATION2_ENTRY); NumberOfProcessorsInHob = MaxProcessorsPerHob; @@ -597,12 +644,16 @@ BuildMpInformationHob ( NULL ); ASSERT_EFI_ERROR (Status); + + MpInformation2Entry->CoreType = (CoreType != NULL) ? CoreType[Index + ProcessorIndex] : 0; + DEBUG (( DEBUG_INFO, - "ProcessorIndex = %x, ProcessorId = %lx, StatusFlag = %x\n", + "ProcessorIndex = %x, ProcessorId = %lx, StatusFlag = %x, CoreType = %x\n", Index + ProcessorIndex, MpInformation2Entry->ProcessorInfo.ProcessorId, - MpInformation2Entry->ProcessorInfo.StatusFlag + MpInformation2Entry->ProcessorInfo.StatusFlag, + MpInformation2Entry->CoreType )); DEBUG (( DEBUG_INFO, @@ -625,6 +676,10 @@ BuildMpInformationHob ( ProcessorIndex += NumberOfProcessorsInHob; } + + if (CoreType != NULL) { + FreePages (CoreType, Pages); + } } /** diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h index a40fd2c077..e7d07ffd64 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h @@ -32,6 +32,8 @@ #include +#include + extern EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc; /** -- 2.31.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112067): https://edk2.groups.io/g/devel/message/112067 Mute This Topic: https://groups.io/mt/102987141/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-