From nobody Tue Feb 10 05:17:34 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+105373+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+105373+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1685355470; cv=none; d=zohomail.com; s=zohoarc; b=Go6rOTg2ITDXAC09gyfKsh9BMfoFv40tvex6Wiru4YT0FAA0Uhdy3r6dt4ubW2sMAEjcKpxvWyxlpy5v0izDrG8zkBlyHNzQxJtrY2dlHjz9mCXxds5asFDqVRhkPTcGrwZVEbC5MM23wRKEOVDQbXH82Od/uxNc9wHWY4hIp1I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685355470; 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=TxNlSL3IauNWwOA6iO3iYqc9V6EqduFQwh+Cx04aKY8=; b=Iub0tlN3IXLKS6X/BVQxM/dCb0//oPz2XXEtiA4GNhG9vvE0oZWATUdKs2vntONb8p7O2uBUHhyfABZAWO7kysLQU1YaYqijBxXjinX2g07XbWS/Iu1RAW8nImMAxz/4SpiZcEYhUpLlx16EIsx4aoHd4UaOSc9NqsYpnIgrOoU= 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+105373+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 1685355470956791.5711636562747; Mon, 29 May 2023 03:17:50 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id qMGJYY1788612xbVo1TVQdVR; Mon, 29 May 2023 03:17:50 -0700 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web10.46517.1685355469926700772 for ; Mon, 29 May 2023 03:17:50 -0700 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 777F061405; Mon, 29 May 2023 10:17:49 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FB4AC4339E; Mon, 29 May 2023 10:17:46 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Ray Ni , Jiewen Yao , Gerd Hoffmann , Taylor Beebe , Oliver Smith-Denny , Dandan Bi , Liming Gao , "Kinney, Michael D" , Leif Lindholm , Michael Kubacki Subject: [edk2-devel] [RFC PATCH 11/11] ArmVirtPkg/ArmVirtQemu: Map all DRAM non-execute by default Date: Mon, 29 May 2023 12:17:05 +0200 Message-Id: <20230529101705.2476949-12-ardb@kernel.org> In-Reply-To: <20230529101705.2476949-1-ardb@kernel.org> References: <20230529101705.2476949-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: C1RGPVkHi72pMdLmnzPczXqQx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1685355470; bh=XhM/Clxmgq81k35lJLIAdeJ4/wCpBX6+hK5OCwZugsw=; h=Cc:Date:From:Reply-To:Subject:To; b=L6Ueqks/54mcp/y/h5S/sTrQVBbGMwdAUVOGOSQing4qWjqmyNOo8GLQlZ/V+D8qtSY Hq7j+svESlME/W656ntUyf24JNFzE8n51XXKnpWcw+kHFJg0MlcYqGAQIbrwrGRtqIAei 6kDnDxxbzts7HBmpJl7pduer/pHiVSBQAOo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1685355471503100005 Content-Type: text/plain; charset="utf-8" Now that both PEI and DXE can deal with memory being mapped non-execute by default, update the early mapping code to create non-execute mappings for all of DRAM. While at it, map the NOR flash read-only as well. Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/ArmVirtQemu.dsc | 1 + ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c | 4 ++-- ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index 449e73b9e1329111..7d159f27cfea8790 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -151,6 +151,7 @@ [PcdsFeatureFlag.common] [PcdsFixedAtBuild.common] !if $(ARCH) =3D=3D AARCH64 gArmTokenSpaceGuid.PcdVFPEnabled|1 + gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy|0xE0000000= 00007FD5 !endif =20 gArmPlatformTokenSpaceGuid.PcdCPUCoresStackBase|0x4007c000 diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c b/A= rmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c index 23bd0fe68ef79d98..1ed5815989594ebd 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, @@ -115,7 +115,7 @@ ArmVirtGetMemoryMap ( VirtualMemoryTable[2].PhysicalBase =3D PcdGet64 (PcdFvBaseAddress); VirtualMemoryTable[2].VirtualBase =3D VirtualMemoryTable[2].PhysicalBas= e; VirtualMemoryTable[2].Length =3D FixedPcdGet32 (PcdFvSize); - VirtualMemoryTable[2].Attributes =3D ARM_MEMORY_REGION_ATTRIBUTE_WRITE= _BACK; + VirtualMemoryTable[2].Attributes =3D ARM_MEMORY_REGION_ATTRIBUTE_WRITE= _BACK_RO; =20 // End of Table ZeroMem (&VirtualMemoryTable[3], sizeof (ARM_MEMORY_REGION_DESCRIPTOR)); diff --git a/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf b/ArmVirtPkg/Memor= yInitPei/MemoryInitPeim.inf index 2039f71a0ebecd5d..6e70bf6eaa245b7a 100644 --- a/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf +++ b/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf @@ -56,4 +56,4 @@ [FixedPcd] gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData =20 [Depex] - TRUE + gEdkiiMemoryAttributePpiGuid --=20 2.39.2 -=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 (#105373): https://edk2.groups.io/g/devel/message/105373 Mute This Topic: https://groups.io/mt/99197146/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-