From nobody Mon Feb 9 18:19:31 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+98450+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+98450+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1673594273; cv=none; d=zohomail.com; s=zohoarc; b=mHvPeye33WqnaDK6rzD+qkE0myXSqxv5kyUB0OOBVvWsGIBTwElYPNcI3VuFp0QrkfRvm4lbTCr2kfv/M2rcVueAE4wA0Ni02/Xg7jTpT57z3kNIKYkmkJD5P3RQnExbGQtU/J5yz64LwZlSBxQLoDaKkphdhdqGZyqFiMc7N7s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673594273; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=RWqv2UDjZ4f318yVDtNU1XGZ6o3BU4HuPw8z0xEumfE=; b=mjcx7OV/ZzxynrelwEO2vxYJ3+dZoTklulJDuiBegeYtV25V6VbdS4dK0C5BSSJseZlPXQHM/JWSAeKbtCH6xfuhPTRxDBOvRWXbw0j21bMMY2ViQX/DgbSYxMs0GA4aKKNkI5ooeeskXVOVtisyoIpbiNaACRH7BA++L5zqLoM= 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+98450+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 1673594273448929.9713248878213; Thu, 12 Jan 2023 23:17:53 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id aZQjYY1788612xV8FXxvvTo5; Thu, 12 Jan 2023 23:17:53 -0800 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web11.80768.1673594263982383415 for ; Thu, 12 Jan 2023 23:17:52 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="410169797" X-IronPort-AV: E=Sophos;i="5.97,213,1669104000"; d="scan'208";a="410169797" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 23:17:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="688646224" X-IronPort-AV: E=Sophos;i="5.97,213,1669104000"; d="scan'208";a="688646224" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.79]) by orsmga008.jf.intel.com with ESMTP; 12 Jan 2023 23:17:50 -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 v1 4/4] OvmfPkg/SmmCpuFeaturesLib: Skip to configure SMBASE Date: Fri, 13 Jan 2023 15:17:38 +0800 Message-Id: <20230113071738.15868-5-jiaxin.wu@intel.com> In-Reply-To: <20230113071738.15868-1-jiaxin.wu@intel.com> References: <20230113071738.15868-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: zAlPWkR6jtJAg4Fpf8hDfOAcx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1673594273; bh=nMT2FfYQI7PUqZO79wzLSFMCRxSsPmq3bzn+ZDWutQ8=; h=Cc:Date:From:Reply-To:Subject:To; b=M/HjU50RQmx0IkvaK1JW5k1N8QSMrOqyGtpImNH7oButlIMoYiTqPzTd/obEn+HTHT1 MiGcS2E9/uGv3T2uW2Iir78PCZNO0iovgG5rnfskQMDayhAavzi9DDiP7zYVK+gW3/PLO CTEK9IhL6Cjdw9soU5SzAs6jJJml6GBH5fU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1673594274194100021 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch is to aviod configure SMBASE if SmBase relocation has been done. If gSmmBaseHobGuid found, means SmBase info has been relocated and recorded in the SmBase array. No need to do the relocation in SmmCpuFeaturesInitializeProcessor(). Cc: Eric Dong Cc: Ray Ni Cc: Zeng Star Cc: Laszlo Ersek Cc: Gerd Hoffmann Cc: Rahul Kumar Signed-off-by: Jiaxin Wu --- .../Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 39 +++++++++++++++++-= ---- .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf | 4 +++ 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/OvmfPk= g/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c index 6693666d04..00c84877ed 100644 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c +++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c @@ -15,20 +15,28 @@ #include #include #include #include #include +#include #include #include #include #include +#include =20 // // EFER register LMA bit // #define LMA BIT10 =20 +// +// Indicate SmBase for each Processors has been relocated or not. If TRUE, +// means no need to do the relocation in SmmCpuFeaturesInitializeProcessor= (). +// +BOOLEAN mSmBaseRelocated; + /** The constructor function =20 @param[in] ImageHandle The firmware allocated handle for the EFI image. @param[in] SystemTable A pointer to the EFI System Table. @@ -41,10 +49,18 @@ EFIAPI SmmCpuFeaturesLibConstructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { + // + // If gSmmBaseHobGuid found, means SmBase info has been relocated and re= corded + // in the SmBase array. + // + if (GetFirstGuidHob (&gSmmBaseHobGuid) !=3D NULL) { + mSmBaseRelocated =3D TRUE; + } + // // No need to program SMRRs on our virtual platform. // return EFI_SUCCESS; } @@ -83,20 +99,25 @@ SmmCpuFeaturesInitializeProcessor ( ) { QEMU_SMRAM_SAVE_STATE_MAP *CpuState; =20 // - // Configure SMBASE. + // No need to configure SMBASE if SmBase relocation has been done. // - CpuState =3D (QEMU_SMRAM_SAVE_STATE_MAP *)(UINTN)( - SMM_DEFAULT_SMBASE + - SMRAM_SAVE_STATE_MAP_OFF= SET - ); - if ((CpuState->x86.SMMRevId & 0xFFFF) =3D=3D 0) { - CpuState->x86.SMBASE =3D (UINT32)CpuHotPlugData->SmBase[CpuIndex]; - } else { - CpuState->x64.SMBASE =3D (UINT32)CpuHotPlugData->SmBase[CpuIndex]; + if (!mSmBaseRelocated) { + // + // Configure SMBASE. + // + CpuState =3D (QEMU_SMRAM_SAVE_STATE_MAP *)(UINTN)( + SMM_DEFAULT_SMBASE + + SMRAM_SAVE_STATE_MAP_O= FFSET + ); + if ((CpuState->x86.SMMRevId & 0xFFFF) =3D=3D 0) { + CpuState->x86.SMBASE =3D (UINT32)CpuHotPlugData->SmBase[CpuIndex]; + } else { + CpuState->x64.SMBASE =3D (UINT32)CpuHotPlugData->SmBase[CpuIndex]; + } } =20 // // No need to program SMRRs on our virtual platform. // diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b/Ovmf= Pkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf index 8a426a4c10..6a281518f5 100644 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf +++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf @@ -33,10 +33,14 @@ MemoryAllocationLib PcdLib SafeIntLib SmmServicesTableLib UefiBootServicesTableLib + HobLib + +[Guids] + gSmmBaseHobGuid ## CONSUMES =20 [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber gUefiOvmfPkgTokenSpaceGuid.PcdCpuHotEjectDataAddress gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase --=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 (#98450): https://edk2.groups.io/g/devel/message/98450 Mute This Topic: https://groups.io/mt/96241704/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-