From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web09.4779.1648080680578717265 for ; Wed, 23 Mar 2022 17:12:09 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=LH8zZFtn; spf=pass (domain: intel.com, ip: 134.134.136.65, 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=1648080729; x=1679616729; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pcYWeiM2cp5J5MwlFtPFQfhUKAG/69+XAvIlOKnsOIE=; b=LH8zZFtn+8N0CMdSiz+v4jGwlbSugZGs/n4sc4Rgh736mbDxts5w9Iui so3/70IX/5MXgSK3IjqWcCaTVv9KyYZCHSJ7ptcps/9Ez8H/yYU/eHFXt Kmm5JEa52mtHFzGZFoacn0UuhGEESpgGj02eQN63aj27eHHWOXJ5Pu/V0 UYUwmQFe1ewLkI493Zzha1fo1L2UocJgE57Vi3Yw0mNaTGV9RD5kWo2bG S7crJ3tND60BAkBAWzzF8NejO04D8Ur++huNbZ59IKknUEGz4I6N02yBs HgxQSeALvTntOPUOMURKjAfx8na9yX6qjuQ5TPOO3UV2RDOgo5lQA8yOi Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10295"; a="258207563" X-IronPort-AV: E=Sophos;i="5.90,205,1643702400"; d="scan'208";a="258207563" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2022 17:12:08 -0700 X-IronPort-AV: E=Sophos;i="5.90,205,1643702400"; d="scan'208";a="649651350" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.31.90]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2022 17:12:06 -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 V10 27/47] OvmfPkg/PlatformPei: Refactor NoexecDxeInitialization Date: Thu, 24 Mar 2022 08:10:13 +0800 Message-Id: <20220324001033.1169-28-min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: <20220324001033.1169-1-min.m.xu@intel.com> References: <20220324001033.1169-1-min.m.xu@intel.com> 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