From nobody Sat Feb 7 10:15:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+100096+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+100096+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1676301537; cv=none; d=zohomail.com; s=zohoarc; b=c5ySBEh0XthuQc6ITVzO70MMwB6rxDuAd0yi30RcIcQLUCpOAsZqy5FnhaQ2AFLfiWe5oFVxJ8nq/xMV3NaN7B3OuLlikTNMPQA4tNPtNdlomSsJHVjcfQ0K9fqYbio9VrxnVU50njiE6ReXkF8Sfxk8PjSvzsUPV6jJGDsUJAw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676301537; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=Bb89V+Xkzbwn8WhfhVeZNWX4WkOd08zk2Ac9SSxi/Ag=; b=RqltXcbTTY3RKCb/tLww3naOaYM3GW0ETbioa+lUIDtxF6FAUQbWbfwmVBfR3q1F28U89Bczu5+ny7weS230aUeqyag88pGBv7RRthSjRXRZs6V5j/GgbhMKF7YFt0yGsCJwyJv7Tzj7z7tR37KIwbBiCVWXVnKUxoyY3JBWRas= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+100096+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 167630153749152.827465193381045; Mon, 13 Feb 2023 07:18:57 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id N2goYY1788612x1nzCdqCX4n; Mon, 13 Feb 2023 07:18:57 -0800 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web10.16818.1676301536190477923 for ; Mon, 13 Feb 2023 07:18:56 -0800 X-Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9C20961124; Mon, 13 Feb 2023 15:18:55 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69347C433A0; Mon, 13 Feb 2023 15:18:52 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Michael Kinney , Liming Gao , Jiewen Yao , Michael Kubacki , Sean Brogan , Rebecca Cran , Leif Lindholm , Sami Mujawar , Taylor Beebe , Matthew Garrett , Peter Jones , Kees Cook Subject: [edk2-devel] [RFC 09/13] ArmVirtPkg/ArmVirtQemu: Use XP memory mappings by default Date: Mon, 13 Feb 2023 16:18:06 +0100 Message-Id: <20230213151810.2301480-10-ardb@kernel.org> In-Reply-To: <20230213151810.2301480-1-ardb@kernel.org> References: <20230213151810.2301480-1-ardb@kernel.org> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ardb@kernel.org X-Gm-Message-State: dtJfdvHvZZ8D2hrg8aSUOpz2x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1676301537; bh=bB8PMTWInMNSo8zaZOlCzLEGh/GB6Z/e4iJZtvSgZ8I=; h=Cc:Date:From:Reply-To:Subject:To; b=KsJPvgDw5zO0eY9KbKOiVy5Mte3hD+3Ezjm6Z+i/tj/SpT+kvLK3TXQSMWMFMrpSkCE yqq3FmK0rQ9P2U/zceksobvPKOuiqkwb4bBt5uAc8f/2rzSmEoZo4HTytUUEUERoMNw3D 9IqkfqCxfMm9hV4ZCXx0TUNH/zbmm+oHjcA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1676301539685100015 Content-Type: text/plain; charset="utf-8" Now that all the plumbing is in place, we can switch to a default policy of XP for all memory mappings straight out of reset. This reduces the risk of running with memory ranges mapped as both writable and executable at the same time. Note this this requires the overlay library to be added to the DXE core, as otherwise, it will not be able to dispatch the CPU arch protocol DXE driver (or any other DXE driver for that matter), as it would lack the ability to grant executable permissions to those executables. Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/ArmVirtQemu.dsc | 1 + ArmVirtPkg/ArmVirtQemuKernel.dsc | 1 + ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index 0f1c6395488a..dd4c84ae6eb9 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -372,6 +372,7 @@ [Components.common] # MdeModulePkg/Core/Dxe/DxeMain.inf { + NULL|ArmPkg/Library/ArmSetMemoryOverrideLib/ArmSetMemoryOverrideLib.= inf NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32Gu= idedSectionExtractLib.inf DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf } diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKerne= l.dsc index 807c85d48285..1ea49fd32e9c 100644 --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc @@ -278,6 +278,7 @@ [Components.common] # MdeModulePkg/Core/Dxe/DxeMain.inf { + NULL|ArmPkg/Library/ArmSetMemoryOverrideLib/ArmSetMemoryOverrideLib.= inf NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32Gu= idedSectionExtractLib.inf DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf } diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c b/A= rmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c index 9cf43f06c073..aa083cec2082 100644 --- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c +++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c @@ -91,7 +91,7 @@ ArmVirtGetMemoryMap ( VirtualMemoryTable[0].PhysicalBase =3D PcdGet64 (PcdSystemMemoryBase); VirtualMemoryTable[0].VirtualBase =3D VirtualMemoryTable[0].PhysicalBas= e; VirtualMemoryTable[0].Length =3D *(UINT64 *)GET_GUID_HOB_DATA (Mem= orySizeHob); - VirtualMemoryTable[0].Attributes =3D ARM_MEMORY_REGION_ATTRIBUTE_WRITE= _BACK; + VirtualMemoryTable[0].Attributes =3D ARM_MEMORY_REGION_ATTRIBUTE_WRITE= _BACK_XP; =20 DEBUG (( DEBUG_INFO, --=20 2.39.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#100096): https://edk2.groups.io/g/devel/message/100096 Mute This Topic: https://groups.io/mt/96937488/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-