From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail04.groups.io (mail04.groups.io [45.79.224.9]) by spool.mail.gandi.net (Postfix) with ESMTPS id 01647AC13EF for ; Mon, 15 Apr 2024 13:30:43 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=LcdeYZUCXHstMGdigoE8ryEps5M1mo4nj8nm+Vf70bM=; 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=1713187842; v=1; b=vuEcsJdUTbVwkGb3uHET/vB0Cs9l4Fh4IlYVfhk8XjqR1APuW3Mdi1SgdSLAId6x/nCE9mp7 QoAj+VgZ0C8WqVVRw10d4VGF1zeT/HJ14AsicJQWldZtHVsY2S9YXkNijXRNbEOc/UyeHqDnMLn YEyfegdNmOm9AOZfuDC+PoGNYCkB8qsOniLpHITHjG8edMkhnjVpriVD4ZRuLVfQMKA30VMGk7y pER3u9SGDxjYPd/1DgA+cFkgtdudKSq11lE2+Jxthxl+wv5MEViyaPneHmTLxY9u8tJduGUmcOg /ZYIcnX6NWsc/WsQtZLTZSGKJWZLstOiMvnZQY+aFbfYA== X-Received: by 127.0.0.2 with SMTP id TU1HYY7687511xQzZw44hvIS; Mon, 15 Apr 2024 06:30:42 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by mx.groups.io with SMTP id smtpd.web10.21064.1713187828784399677 for ; Mon, 15 Apr 2024 06:30:42 -0700 X-CSE-ConnectionGUID: AwITFn37QJ2lklWHZz/BQg== X-CSE-MsgGUID: FgCCBl4ZStK1grpx1RrgCA== X-IronPort-AV: E=McAfee;i="6600,9927,11044"; a="33961819" X-IronPort-AV: E=Sophos;i="6.07,203,1708416000"; d="scan'208";a="33961819" X-Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2024 06:30:42 -0700 X-CSE-ConnectionGUID: m38px+VUTOK5TPSScha55w== X-CSE-MsgGUID: eJgYw2dXTP2CvPHm8P3Abg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,203,1708416000"; d="scan'208";a="22000572" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by fmviesa007.fm.intel.com with ESMTP; 15 Apr 2024 06:30:40 -0700 From: "Wu, Jiaxin" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Jiewen Yao , Gerd Hoffmann , Ray Ni Subject: [edk2-devel] [PATCH v2 07/10] OvmfPkg/SmmCpuFeaturesLib: Check Smbase Relocation is done or not Date: Mon, 15 Apr 2024 21:30:18 +0800 Message-Id: <20240415133021.10516-8-jiaxin.wu@intel.com> In-Reply-To: <20240415133021.10516-1-jiaxin.wu@intel.com> References: <20240415133021.10516-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: Mon, 15 Apr 2024 06:30:42 -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: a4cJ77hrfLnYIQ4w8bcwRuGkx7686176AA= X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=vuEcsJdU; 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.9 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 (#117782): https://edk2.groups.io/g/devel/message/117782 Mute This Topic: https://groups.io/mt/105535813/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-