From nobody Tue Feb 10 01:31:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+99957+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+99957+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1676009142; cv=none; d=zohomail.com; s=zohoarc; b=f6+d64mAoI3+oejRooWVd5EpGcJfvFweYQmSNvFkm2g5+Anp12kYpJR9frYEY8O5+e4Se2IJksHmsng+HYPkFqtR9DyF9PNWRE1VzBEXqa1VNK3OfwLzQUs81zGEy9ALXgZnFO4jdm2D3Mf7zkLTUxb/WyQ1ucXiHjxRQ3gHYsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676009142; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=jheGGx8KBpqqMsSYJlRGiMZCU1S4yjnwrg1pViG0pI0=; b=JwuXqfN9lr6ROqzu7QquFnbGGWrgxsIOagwr6ZFU7WZ2D8UGVHE5CBZNPBKghPpBqPXWoTettqY9g7kDKIynoVucfI72uJOVXJL1JrgcbKPzNAmDG5wAgkfdwDYb+TgWeN7md3wvfp536KpjpQ387LKJ65tvF7Kbiiu1dwneMiA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+99957+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1676009142982290.57422340240043; Thu, 9 Feb 2023 22:05:42 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id bqViYY1788612xznp57TgIje; Thu, 09 Feb 2023 22:05:42 -0800 X-Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.7855.1676009136640824231 for ; Thu, 09 Feb 2023 22:05:42 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10616"; a="310711758" X-IronPort-AV: E=Sophos;i="5.97,286,1669104000"; d="scan'208";a="310711758" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2023 22:05:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10616"; a="791854723" X-IronPort-AV: E=Sophos;i="5.97,286,1669104000"; d="scan'208";a="791854723" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.79]) by orsmga004.jf.intel.com with ESMTP; 09 Feb 2023 22:05:31 -0800 From: "Wu, Jiaxin" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Zeng Star , Laszlo Ersek , Gerd Hoffmann , Rahul Kumar Subject: [edk2-devel] [PATCH v4 2/5] UefiCpuPkg/SmmBaseHob.h: Add SMM Base HOB Data Date: Fri, 10 Feb 2023 14:05:16 +0800 Message-Id: <20230210060519.11100-3-jiaxin.wu@intel.com> In-Reply-To: <20230210060519.11100-1-jiaxin.wu@intel.com> References: <20230210060519.11100-1-jiaxin.wu@intel.com> Precedence: Bulk List-Unsubscribe: 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,jiaxin.wu@intel.com X-Gm-Message-State: Jv6c2sgHQdihwYD8acpuGwFmx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1676009142; bh=tAoXsnatjthFNdOcg4Kz9+0LcdCHMmTObObRO4WXzAw=; h=Cc:Date:From:Reply-To:Subject:To; b=lEoSLBIdgMY2/lloa6pKWVmXbr8Yk39tJUr1WrDRPVCp8amC+m64zk4uMJSKkpOYWCh I8pEQ7kM/s1VuCVhgXu2Cy/Yz5jTUPFyaXeStKtIJXJtsKmBrRKO9y+qeyoHvt4RxrfKv FJJilqPuN3T5xOWni3W+gbNCArGTBxzwXRs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1676009144932100006 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4337 The default SMBASE for the x86 processor is 0x30000. When SMI happens, CPU runs the SMI handler at SMBASE+0x8000. Also, the SMM save state area is within SMBASE+0x10000. One of the SMM initialization from CPU perspective is to relocate and program the new SMBASE (in TSEG range) for each CPU thread. When the SMBASE relocation happens in a PEI module, the PEI module shall produce the SMM_BASE_HOB in HOB database which tells the PiSmmCpuDxeSmm driver (runs at a later phase) about the new SMBASE for each CPU thread. PiSmmCpuDxeSmm driver installs the SMI handler at the SMM_BASE_HOB.SmBase[Index]+0x8000 for CPU thread Index. When the HOB doesn't exist, PiSmmCpuDxeSmm driver shall relocate and program the new SMBASE itself. This patch adds the SMM Base HOB for any PEI module to do the SmBase relocation ahead of PiSmmCpuDxeSmm driver and store the relocated SmBase address in array for reach Processors. Cc: Eric Dong Cc: Ray Ni Cc: Zeng Star Cc: Laszlo Ersek Cc: Gerd Hoffmann Cc: Rahul Kumar Signed-off-by: Jiaxin Wu --- UefiCpuPkg/Include/Guid/SmmBaseHob.h | 64 ++++++++++++++++++++++++++++++++= ++++ UefiCpuPkg/UefiCpuPkg.dec | 3 ++ 2 files changed, 67 insertions(+) create mode 100644 UefiCpuPkg/Include/Guid/SmmBaseHob.h diff --git a/UefiCpuPkg/Include/Guid/SmmBaseHob.h b/UefiCpuPkg/Include/Guid= /SmmBaseHob.h new file mode 100644 index 0000000000..d22b3b942c --- /dev/null +++ b/UefiCpuPkg/Include/Guid/SmmBaseHob.h @@ -0,0 +1,64 @@ +/** @file + The Smm Base HOB is used to store the information of: + * The relocated SmBase address in array for each Processors. + + The default SMBASE for the x86 processor is 0x30000. When SMI happens, C= PU + runs the SMI handler at SMBASE+0x8000. Also, the SMM save state area is = within + SMBASE+0x10000. + + One of the SMM initialization from CPU perspective is to relocate and pr= ogram + the new SMBASE (in TSEG range) for each CPU thread. When the SMBASE relo= cation + happens in a PEI module, the PEI module shall produce the SMM_BASE_HOB i= n HOB + database which tells the PiSmmCpuDxeSmm driver (which runs at a later ph= ase) + about the new SMBASE for each CPU thread. PiSmmCpuDxeSmm driver installs= the + SMI handler at the SMM_BASE_HOB.SmBase[Index]+0x8000 for CPU thread Inde= x. + When the HOB doesn't exist, PiSmmCpuDxeSmm driver shall relocate and pro= gram + the new SMBASE itself. + + Note: + SMBASE relocation process needs to program the vender specific hardware + interface to set SMBASE, it should be in the thread scope. It's doable to + program the hardware interface using DXE MP service protocol in PiSmmCpu= DxeSmm + entry point. But, considering the standalone MM environment where the Cp= uMm + driver runs in a isolated environment and it cannot invoke any DXE or PE= I MP + service, we recommend to put the hardware interface programming in a sep= arate + PEI module instead of in the PiSmmCpuDxeSmm driver. + + Copyright (c) 2023, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef SMM_BASE_HOB_H_ +#define SMM_BASE_HOB_H_ + +#define SMM_BASE_HOB_DATA_GUID \ + { \ + 0xc2217ba7, 0x03bb, 0x4f63, {0xa6, 0x47, 0x7c, 0x25, 0xc5, 0xfc, 0x9d,= 0x73} \ + } + +#pragma pack(1) +typedef struct { + /// + /// CpuIndex tells which CPU range this specific HOB instance described. + /// If CpuIndex is set to 0, it indicats the HOB describes the CPU from = 0 to + /// NumberOfCpus - 1. The HOB list may contains multiple this HOB instan= ces. + /// Each HOB instances describe the information for CPU from CpuIndex to + /// CpuIndex + NumberOfCpus - 1. The instance order in the HOB list is r= andom + /// so consumer can not assume the CpuIndex of first instance is 0. + /// + UINT32 CpuIndex; + /// + /// Describes the Number of all max supported processors. + /// + UINT32 NumberOfProcessors; + /// + /// Pointer to SmBase address for each Processors. + /// + UINT64 SmBase[1]; +} SMM_BASE_HOB_DATA; +#pragma pack() + +extern EFI_GUID gSmmBaseHobGuid; + +#endif diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec index cff239d528..2afd08cdd2 100644 --- a/UefiCpuPkg/UefiCpuPkg.dec +++ b/UefiCpuPkg/UefiCpuPkg.dec @@ -76,10 +76,13 @@ gEdkiiCpuFeaturesInitDoneGuid =3D { 0xc77c3a41, 0x61ab, 0x4143, { 0x98,= 0x3e, 0x33, 0x39, 0x28, 0x6, 0x28, 0xe5 }} =20 ## Include/Guid/MicrocodePatchHob.h gEdkiiMicrocodePatchHobGuid =3D { 0xd178f11d, 0x8716, 0x418e, { 0xa1,= 0x31, 0x96, 0x7d, 0x2a, 0xc4, 0x28, 0x43 }} =20 + ## Include/Guid/SmmBaseHob.h + gSmmBaseHobGuid =3D { 0xc2217ba7, 0x03bb, 0x4f63, {0xa6, 0x47, 0x7c= , 0x25, 0xc5, 0xfc, 0x9d, 0x73 }} + [Protocols] ## Include/Protocol/SmmCpuService.h gEfiSmmCpuServiceProtocolGuid =3D { 0x1d202cab, 0xc8ab, 0x4d5c, { 0x94= , 0xf7, 0x3c, 0xfc, 0xc0, 0xd3, 0xd3, 0x35 }} gEdkiiSmmCpuRendezvousProtocolGuid =3D { 0xaa00d50b, 0x4911, 0x428f, { 0= xb9, 0x1a, 0xa5, 0x9d, 0xdb, 0x13, 0xe2, 0x4c }} =20 --=20 2.16.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#99957): https://edk2.groups.io/g/devel/message/99957 Mute This Topic: https://groups.io/mt/96871372/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-