From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web12.8480.1648454962517853012 for ; Mon, 28 Mar 2022 01:10:06 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=f35jx4kh; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648455006; x=1679991006; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pcYWeiM2cp5J5MwlFtPFQfhUKAG/69+XAvIlOKnsOIE=; b=f35jx4khB46wZPVEHtfB3zR1rNwXXDTXAM0BftRY1w5HXZmAIfHHPfKn wPhCHFBm+5t5sD+xCvMhAtHvV0hQe8+wxRX4b54gTn/K8LniK1ZMiqini syeKs0HD+5xwSH9TtlGb4dhHo0Vf/PFzUic+Nf3uZL2Yq3deTa0oLVJg2 GOsdPjlOsiaddYMVdl6wu9MlDgH/8BUbLsj4kHxuDPDUGf7MKfq0r+xqx YtKbZqYLd6vEGcsKvBQpD4yn/3kAHRsHcEzQ7NDODUALAprmFvXO4z3ta 7+YqixURKUhJKOzoO61C5f93802TX3n9GktctIdPjufi6O9GnA95UQQSj A==; X-IronPort-AV: E=McAfee;i="6200,9189,10299"; a="257771148" X-IronPort-AV: E=Sophos;i="5.90,216,1643702400"; d="scan'208";a="257771148" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 01:10:06 -0700 X-IronPort-AV: E=Sophos;i="5.90,216,1643702400"; d="scan'208";a="563427873" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.175.167]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 01:10:03 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Ard Biesheuvel , Jordan Justen , Brijesh Singh , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Gerd Hoffmann , Sebastien Boeuf Subject: [PATCH V11 27/47] OvmfPkg/PlatformPei: Refactor NoexecDxeInitialization Date: Mon, 28 Mar 2022 16:08:06 +0800 Message-Id: X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 NoexecDxeInitialization is split into 2 functions: - PlatformNoexecDxeInitialization is for PlatformInitLib - NoexecDxeInitialization calls PlatformNoexecDxeInitialization and then sets PCD. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Brijesh Singh Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Gerd Hoffmann Cc: Sebastien Boeuf Acked-by: Gerd Hoffmann Signed-off-by: Min Xu --- OvmfPkg/PlatformPei/Platform.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index b83bd7515809..e91acca9f769 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -59,7 +59,6 @@ PlatformMemMapInitialization ( { UINT64 PciIoBase; UINT64 PciIoSize; - RETURN_STATUS PcdStatus; UINT32 TopOfLowRam; UINT64 PciExBarBase; UINT32 PciBase; @@ -199,24 +198,33 @@ MemMapInitialization ( ASSERT_RETURN_ERROR (PcdStatus); } -#define UPDATE_BOOLEAN_PCD_FROM_FW_CFG(TokenName) \ - do { \ - BOOLEAN Setting; \ - RETURN_STATUS PcdStatus; \ - \ - if (!RETURN_ERROR (QemuFwCfgParseBool ( \ - "opt/ovmf/" #TokenName, &Setting))) { \ - PcdStatus = PcdSetBoolS (TokenName, Setting); \ - ASSERT_RETURN_ERROR (PcdStatus); \ - } \ - } while (0) +/** + * Fetch "opt/ovmf/PcdSetNxForStack" from QEMU + * + * @param Setting The pointer to the setting of "/opt/ovmf/PcdSetNxForStack". + * @return EFI_SUCCESS Successfully fetch the settings. + */ +EFI_STATUS +EFIAPI +PlatformNoexecDxeInitialization ( + IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob + ) +{ + return QemuFwCfgParseBool ("opt/ovmf/PcdSetNxForStack", &PlatformInfoHob->PcdSetNxForStack); +} VOID NoexecDxeInitialization ( VOID ) { - UPDATE_BOOLEAN_PCD_FROM_FW_CFG (PcdSetNxForStack); + RETURN_STATUS Status; + + Status = PlatformNoexecDxeInitialization (&mPlatformInfoHob); + if (!RETURN_ERROR (Status)) { + Status = PcdSetBoolS (PcdSetNxForStack, mPlatformInfoHob.PcdSetNxForStack); + ASSERT_RETURN_ERROR (Status); + } } VOID -- 2.29.2.windows.2