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.115; helo=mga14.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ml01.01.org (Postfix) with ESMTP id 2924F2035A7AD for ; Thu, 16 Nov 2017 08:36:06 -0800 (PST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Nov 2017 23:27:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,402,1505804400"; d="scan'208";a="174145289" Received: from jwang36-mobl2.ccr.corp.intel.com ([10.239.192.64]) by orsmga005.jf.intel.com with ESMTP; 15 Nov 2017 23:27:05 -0800 From: Jian J Wang To: edk2-devel@lists.01.org Cc: Jiewen Yao , Star Zeng , Laszlo Ersek , Ard Biesheuvel Date: Thu, 16 Nov 2017 15:26:59 +0800 Message-Id: <20171116072700.11456-2-jian.j.wang@intel.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20171116072700.11456-1-jian.j.wang@intel.com> References: <20171116072700.11456-1-jian.j.wang@intel.com> Subject: [PATCH v6 1/2] MdeModulePkg/DxeCore: Filter out all paging capabilities X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Nov 2017 16:36:09 -0000 Some OSs will treat EFI_MEMORY_DESCRIPTOR.Attribute as really set attributes and change memory paging attribute accordingly. But current EFI_MEMORY_DESCRIPTOR.Attribute is assigned by value from Capabilities in GCD memory map. This might cause boot problems. Clearing all paging related capabilities can workaround it. The code added in this patch is supposed to be removed once the usage of EFI_MEMORY_DESCRIPTOR.Attribute is clarified in UEFI spec and adopted by both EDK-II Core and all supported OSs. Cc: Jiewen Yao Cc: Star Zeng Cc: Laszlo Ersek Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang --- MdeModulePkg/Core/Dxe/Mem/Page.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/Page.c index c9219cc068..783b576e35 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -1829,6 +1829,23 @@ CoreGetMemoryMap ( // BufferSize = ((UINT8 *)MemoryMap - (UINT8 *)MemoryMapStart); + // + // WORKAROUND: Some OSs will treat EFI_MEMORY_DESCRIPTOR.Attribute as really + // set attributes and change memory paging attribute accordingly. + // But current EFI_MEMORY_DESCRIPTOR.Attribute is assigned by + // value from Capabilities in GCD memory map. This might cause + // boot problems. Clearing all paging related capabilities can + // workaround it. Following code is supposed to be removed once + // the usage of EFI_MEMORY_DESCRIPTOR.Attribute is clarified in + // UEFI spec and adopted by both EDK-II Core and all supported + // OSs. + // + while (MemoryMapStart < MemoryMap) { + MemoryMapStart->Attribute &= ~(UINT64)(EFI_MEMORY_RP | EFI_MEMORY_RO | + EFI_MEMORY_XP); + MemoryMapStart = NEXT_MEMORY_DESCRIPTOR(MemoryMapStart, Size); + } + Status = EFI_SUCCESS; Done: -- 2.14.1.windows.1