From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id A20A9AC0CFD for ; Thu, 18 Apr 2024 06:56:31 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=68w9UHxGU+dOtvyVOsBfTjHzC2tShxWuFmn64oNTk0U=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe; s=20240206; t=1713423390; v=1; b=0XEDozTqxrsehTu5o0YfO7+TV6mJqW4g3qR3UnuwkeerL94Yqzroaw+QpLR22yduFi1mM1RP sniE6IEE+KHa/9yFa7N4iEEkPHatDULtaZYI/r9ph6Zs9TAO35DuY1fG/XL1ITCTO4+68R6fW4n dPvNkUA3x6BfbxloYLeXxl/SIPBLSkXqFSBFv2aqWKWrhYqSEdBWQqrop7+bXFrZb0dU33jNzS8 FMpOh7W72x6oCbBztaYSbSbBaWUYjw5j8dJuRFTfEflE7VOspCJAufSZtmrHGW2vZB2H3c/94wg z+huKryZmUzfLRz4PgAGZjz2T1bViOovy6NP33JtmPiZQ== X-Received: by 127.0.0.2 with SMTP id CRNhYY7687511xj6hirxWad7; Wed, 17 Apr 2024 23:56:30 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) by mx.groups.io with SMTP id smtpd.web11.6990.1713423388899924165 for ; Wed, 17 Apr 2024 23:56:29 -0700 X-CSE-ConnectionGUID: Ce2hWOfWS+CAMo9okIWAtw== X-CSE-MsgGUID: fCWedRJrQRWB8lcSiGivIA== X-IronPort-AV: E=McAfee;i="6600,9927,11047"; a="8822313" X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="8822313" X-Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2024 23:56:29 -0700 X-CSE-ConnectionGUID: rEi0Z+qsTF+Vyj6ScH/nkg== X-CSE-MsgGUID: EjBXUneGQm6JJmOZnsA+gA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="22755187" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by orviesa010.jf.intel.com with ESMTP; 17 Apr 2024 23:56:24 -0700 From: "Wu, Jiaxin" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Jiewen Yao , Gerd Hoffmann , Ray Ni Subject: [edk2-devel] [PATCH v3 10/13] OvmfPkg/SmmCpuFeaturesLib: Check Smbase Relocation is done or not Date: Thu, 18 Apr 2024 14:55:53 +0800 Message-Id: <20240418065556.5696-11-jiaxin.wu@intel.com> In-Reply-To: <20240418065556.5696-1-jiaxin.wu@intel.com> References: <20240418065556.5696-1-jiaxin.wu@intel.com> 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 Resent-Date: Wed, 17 Apr 2024 23:56:29 -0700 Resent-From: jiaxin.wu@intel.com Reply-To: devel@edk2.groups.io,jiaxin.wu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: W0Ob0kfYASuQP7dGizSJRq10x7686176AA= X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=0XEDozTq; 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 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io Based on gSmmBaseHobGuid: If gSmmBaseHobGuid found, means SmBase info has been relocated and recorded in the SmBase array. So, this patch check smbase relocation is done or not in SmmCpuFeaturesInitializeProcessor(). With SmmRelocationLib, gSmmBaseHobGuid will be always created. Here this patch just makes the function/logic correct. The SMM Relocation logic can be totally cleaned from the SmmCpuFeaturesLib. But it will happen in the future patch set, this patch does not target to the cleanup work. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Ray Ni Signed-off-by: Jiaxin Wu Reviewed-by: Ray Ni --- .../Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 33 ++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c index 63822b126e..0a6f33c2b1 100644 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c +++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c @@ -26,10 +26,16 @@ // // EFER register LMA bit // #define LMA BIT10 +// +// Indicate SmBase for each Processors has been relocated or not. If TRUE, +// means no need to do the relocation in SmmCpuFeaturesInitializeProcessor(). +// +BOOLEAN mSmmCpuFeaturesSmmRelocated; + /** The constructor function @param[in] ImageHandle The firmware allocated handle for the EFI image. @param[in] SystemTable A pointer to the EFI System Table. @@ -44,13 +50,13 @@ SmmCpuFeaturesLibConstructor ( IN EFI_SYSTEM_TABLE *SystemTable ) { // // If gSmmBaseHobGuid found, means SmBase info has been relocated and recorded - // in the SmBase array. ASSERT it's not supported in OVMF. + // in the SmBase array. // - ASSERT (GetFirstGuidHob (&gSmmBaseHobGuid) == NULL); + mSmmCpuFeaturesSmmRelocated = (BOOLEAN)(GetFirstGuidHob (&gSmmBaseHobGuid) != NULL); // // No need to program SMRRs on our virtual platform. // return EFI_SUCCESS; @@ -90,20 +96,25 @@ SmmCpuFeaturesInitializeProcessor ( ) { AMD_SMRAM_SAVE_STATE_MAP *CpuState; // - // Configure SMBASE. + // No need to configure SMBASE if SmBase relocation has been done. // - CpuState = (AMD_SMRAM_SAVE_STATE_MAP *)(UINTN)( - SMM_DEFAULT_SMBASE + - SMRAM_SAVE_STATE_MAP_OFFSET - ); - if ((CpuState->x86.SMMRevId & 0xFFFF) == 0) { - CpuState->x86.SMBASE = (UINT32)CpuHotPlugData->SmBase[CpuIndex]; - } else { - CpuState->x64.SMBASE = (UINT32)CpuHotPlugData->SmBase[CpuIndex]; + if (!mSmmCpuFeaturesSmmRelocated) { + // + // Configure SMBASE. + // + CpuState = (AMD_SMRAM_SAVE_STATE_MAP *)(UINTN)( + SMM_DEFAULT_SMBASE + + SMRAM_SAVE_STATE_MAP_OFFSET + ); + if ((CpuState->x86.SMMRevId & 0xFFFF) == 0) { + CpuState->x86.SMBASE = (UINT32)CpuHotPlugData->SmBase[CpuIndex]; + } else { + CpuState->x64.SMBASE = (UINT32)CpuHotPlugData->SmBase[CpuIndex]; + } } // // No need to program SMRRs on our virtual platform. // -- 2.16.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117956): https://edk2.groups.io/g/devel/message/117956 Mute This Topic: https://groups.io/mt/105593582/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-