From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C0426210DA179 for ; Mon, 6 Aug 2018 02:56:24 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Aug 2018 02:56:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,452,1526367600"; d="scan'208";a="73975777" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.4]) by fmsmga002.fm.intel.com with ESMTP; 06 Aug 2018 02:56:23 -0700 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Star Zeng Date: Mon, 6 Aug 2018 17:56:59 +0800 Message-Id: <20180806095659.250456-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 Subject: [PATCH] IntelFrameworkModulePkg/Csm: Set CSM memory executable X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Aug 2018 09:56:25 -0000 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng --- .../Csm/LegacyBiosDxe/LegacyBios.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c index 8f14687b28..f86d00b53f 100644 --- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c +++ b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c @@ -64,8 +64,9 @@ AllocateLegacyMemory ( OUT EFI_PHYSICAL_ADDRESS *Result ) { - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS MemPage; + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS MemPage; + EFI_GCD_MEMORY_SPACE_DESCRIPTOR MemDesc; // // Allocate Pages of memory less <= StartPageAddress @@ -83,10 +84,21 @@ AllocateLegacyMemory ( // if (!EFI_ERROR (Status)) { *Result = (EFI_PHYSICAL_ADDRESS) (UINTN) MemPage; + if (MemoryType != EfiBootServicesCode) { + // + // Make sure that the buffer can be used to store code. + // + Status = gDS->GetMemorySpaceDescriptor (MemPage, &MemDesc); + if (!EFI_ERROR (Status) && (MemDesc.Attributes & EFI_MEMORY_XP) != 0) { + Status = gDS->SetMemorySpaceAttributes ( + MemPage, + EFI_PAGES_TO_SIZE (Pages), + MemDesc.Attributes & (~EFI_MEMORY_XP) + ); + } + } } - // - // If reach here the status = EFI_SUCCESS - // + return Status; } -- 2.16.1.windows.1