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 C4D7BD80056 for ; Thu, 7 Dec 2023 07:33:14 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=eUhnhtdgVXeSbUcGIQzT/g7JjJPjYYLbsZkcI+EMxwY=; 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=1701934393; v=1; b=ApjXiujdyjITMzfYIvGGzzRXnrJF9UBJ/0xTf3auO8ylTxn4QNQ0NUDeybzUlxJuK0ooJq7J 1yJEtA9krgR7i3ukqcUIHN9iJX9ZoMACemDVFfUMj9dcx30SUs6Y9fhRL+1KtyaaPUObpsUFQbk MvuyGGqf5Mo04pWgoyFqOzT8= X-Received: by 127.0.0.2 with SMTP id PbMdYY7687511xOfXIXMlsWG; Wed, 06 Dec 2023 23:33:13 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.78844.1701934386136088650 for ; Wed, 06 Dec 2023 23:33:13 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10916"; a="393061679" X-IronPort-AV: E=Sophos;i="6.04,256,1695711600"; d="scan'208";a="393061679" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Dec 2023 23:32:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10916"; a="800643996" X-IronPort-AV: E=Sophos;i="6.04,256,1695711600"; d="scan'208";a="800643996" X-Received: from shwdeopenlab702.ccr.corp.intel.com ([10.239.55.43]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Dec 2023 23:32:54 -0800 From: "duntan" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann Subject: [edk2-devel] [Patch V2 5/6] UefiCpuPkg: Cache core type in MpInfo2 HOB Date: Thu, 7 Dec 2023 15:32:29 +0800 Message-Id: <20231207073230.264-5-dun.tan@intel.com> In-Reply-To: <20231207073230.264-1-dun.tan@intel.com> References: <20231207073230.264-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: 933nvplFf7AqpBpMrgzey2Byx7686176AA= 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=ApjXiujd; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none) 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 8cacf4ddf5..7e2d7efb6b 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 *CoreTypes; + CPUID_NATIVE_MODEL_ID_AND_CORE_TYPE_EAX NativeModelIdAndCoreTypeEax; + UINTN ProcessorIndex; + + Status = MpInitLibWhoAmI (&ProcessorIndex); + ASSERT_EFI_ERROR (Status); + + CoreTypes = (UINT8 *)Buffer; + AsmCpuidEx (CPUID_HYBRID_INFORMATION, CPUID_HYBRID_INFORMATION_MAIN_LEAF, &NativeModelIdAndCoreTypeEax.Uint32, NULL, NULL, NULL); + CoreTypes[ProcessorIndex] = (UINT8)NativeModelIdAndCoreTypeEax.Bits.CoreType; +} + /** Create gMpInformationHobGuid2. **/ @@ -558,13 +582,36 @@ BuildMpInformationHob ( MP_INFORMATION2_HOB_DATA *MpInformation2HobData; MP_INFORMATION2_ENTRY *MpInformation2Entry; UINTN Index; + UINT8 *CoreTypes; + UINT32 CpuidMaxInput; + UINTN CoreTypePages; ProcessorIndex = 0; MpInformation2HobData = NULL; MpInformation2Entry = NULL; + CoreTypes = NULL; + CoreTypePages = 0; Status = MpInitLibGetNumberOfProcessors (&NumberOfProcessors, &NumberOfEnabledProcessors); ASSERT_EFI_ERROR (Status); + + // + // Get Processors CoreType + // + AsmCpuid (CPUID_SIGNATURE, &CpuidMaxInput, NULL, NULL, NULL); + if (CpuidMaxInput >= CPUID_HYBRID_INFORMATION) { + CoreTypePages = EFI_SIZE_TO_PAGES (sizeof (UINT8) * NumberOfProcessors); + CoreTypes = AllocatePages (CoreTypePages); + ASSERT (CoreTypes != NULL); + + Status = MpInitLibStartupAllCPUs ( + GetProcessorCoreType, + 0, + (VOID *)CoreTypes + ); + 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 = (CoreTypes != NULL) ? CoreTypes[Index + ProcessorIndex] : 0; + DEBUG (( DEBUG_INFO, - " Processor[%04d]: ProcessorId = 0x%lx, StatusFlag = 0x%x\n", + " Processor[%04d]: ProcessorId = 0x%lx, StatusFlag = 0x%x, CoreType = 0x%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 (CoreTypes != NULL) { + FreePages (CoreTypes, CoreTypePages); + } } /** 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 (#112163): https://edk2.groups.io/g/devel/message/112163 Mute This Topic: https://groups.io/mt/103030295/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-