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 64D36AC0F35 for ; Fri, 26 Apr 2024 12:18:00 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=BbFA/AQj49YqDwh3WJ4wVaPpv05IEBibUKfcgJoru6U=; 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=1714133879; v=1; b=uFkBCxoc44PzVu7SCuxqQl8iZ0vV8EXO9fvHF49KSjHu9avjVVxgjPRgNE6mj8H2ccq1H45t 6mseHDTE/XtwgMfQwa+zpLjadB/9sYcv9KOhC7gdXlHJMCiETgT4EpISIESXZAFssRPGKNS9cMQ SOQyM+wdl7icWW9KX/ZJ2uLfKYGOedz9L25V5AuQp/qTOpGmjNZdHN5hGQJVcWB/f7wPlveA4wt bKcs/kb8BJ4sfgjtt5elCswxjYFSczlrQeOdlrgGozuIgxMSQyoxj4mzr3bl43mc7Mwqgw/TUS3 YSH4UcpdzRLTOE48nPkKQ2PslawIy4DXjoINIZxXRL+wQ== X-Received: by 127.0.0.2 with SMTP id kJrmYY7687511xl2KC1dvlLS; Fri, 26 Apr 2024 05:17:59 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by mx.groups.io with SMTP id smtpd.web11.12554.1714133857432549514 for ; Fri, 26 Apr 2024 05:17:58 -0700 X-CSE-ConnectionGUID: wwW+dpZ9TkaoSXoZxXSmzw== X-CSE-MsgGUID: DY+2P0fjTaCv5n02aUCU+A== X-IronPort-AV: E=McAfee;i="6600,9927,11055"; a="10027165" X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="10027165" X-Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2024 05:17:59 -0700 X-CSE-ConnectionGUID: hygDGMG+SF2B1KYiujbieQ== X-CSE-MsgGUID: tDnRSL+TQIW4rnxJ+0BmJg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="62879160" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by orviesa001.jf.intel.com with ESMTP; 26 Apr 2024 05:17:56 -0700 From: "Wu, Jiaxin" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Jiewen Yao , Gerd Hoffmann , Ray Ni Subject: [edk2-devel] [PATCH v4 11/14] OvmfPkg/SmmCpuFeaturesLib: Check Smbase Relocation is done or not Date: Fri, 26 Apr 2024 20:17:17 +0800 Message-Id: <20240426121720.54308-12-jiaxin.wu@intel.com> In-Reply-To: <20240426121720.54308-1-jiaxin.wu@intel.com> References: <20240426121720.54308-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: Fri, 26 Apr 2024 05:17:58 -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: GvHZrFNnPXHpE9jh67pLdBhTx7686176AA= X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=uFkBCxoc; 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 (#118335): https://edk2.groups.io/g/devel/message/118335 Mute This Topic: https://groups.io/mt/105748925/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-