From nobody Sat Feb 7 10:15:25 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+100099+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+100099+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1676301548; cv=none; d=zohomail.com; s=zohoarc; b=gdov4lLkaNlw5/zRT9qOAZbM1aUAiVP1pMmcwxcSjAOIGnaOh2lxE1IZq5AzFVQDmDTUf0t7isOXO5W9SF7Wfe62ojBqljbWIeO+ZWH9ytJSgWqFdoU+aYLXwmvEZxwdwYC+nmTHp0gRxQnOQaNd2FtKGmaHUmWAXcL2BhimUMU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676301548; 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=2WWMuguMkH76yy9fL+l9ONVx1PC2xsOrzV9IH5f21Ig=; b=PcWpMmYMpYFRQOSAw9fF8IU4cZLh10PM01ed6L3rWjjBnlVPqjoXo3eNOYWwHRGM0VP5Bloj3RzRwGPXRf2wE/No3RppFelIr1ta07RWH1OUDLCH60bgQ3b9hmN7lQ11Kmh7UfRLEzP2T6nT1KMvuRhjHu8cSWRjXIi0517c+g4= 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+100099+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 1676301548547722.563362583917; Mon, 13 Feb 2023 07:19:08 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id GzWmYY1788612xzsWsNy3pFH; Mon, 13 Feb 2023 07:19:08 -0800 X-Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web11.16997.1676301546917254394 for ; Mon, 13 Feb 2023 07:19:07 -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 ams.source.kernel.org (Postfix) with ESMTPS id 63992B8122D; Mon, 13 Feb 2023 15:19:05 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DBC7C4339C; Mon, 13 Feb 2023 15:19:01 +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 12/13] BaseTools/GccBase AARCH64: Avoid page sharing between code and data Date: Mon, 13 Feb 2023 16:18:09 +0100 Message-Id: <20230213151810.2301480-13-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: mjSNAeGgDmJ8fDXzQnoI4EsQx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1676301548; bh=6z0z7kLBBeqe5ECiEcOlWlh8OJRUHMnBpkCal12AhxM=; h=Cc:Date:From:Reply-To:Subject:To; b=ft/dKzh0uu4a+UfD8ued6SmhmRQCmon6AXvtqQMAmyfV0k2158oTpjvJzyQK9CpYYag frgjp0OluxNsx5VIhuNpkItHXAokW1DCVV7gwjhfvpACRQFx2vNU3nOpolQ2vr7lJKlXI fk9zzGL2DaULb6STSWZtkfwTiDKSI7aO75Y= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1676301549855100002 Content-Type: text/plain; charset="utf-8" The AArch64 ARM architecture supports a hardware enforcement mode for mutual exclusion between code and data: any page that is mapped writable is implicitly non-executable as well. This means that remapping part of a runtime image for reapplying relocation fixups may result in any code sharing the same page to lose its executable permissions. Let's avoid this, by moving all quantities that are subject to relocation fixups to a separate page if the build is using 64k section alignment, which is only the case when building a runtime driver for AArch64. Signed-off-by: Ard Biesheuvel --- BaseTools/Scripts/GccBase.lds | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/BaseTools/Scripts/GccBase.lds b/BaseTools/Scripts/GccBase.lds index 83cebd29d599..63e097e0727c 100644 --- a/BaseTools/Scripts/GccBase.lds +++ b/BaseTools/Scripts/GccBase.lds @@ -21,9 +21,8 @@ SECTIONS { . =3D PECOFF_HEADER_SIZE; =20 .text : ALIGN(CONSTANT(COMMONPAGESIZE)) { - *(.text .text.* .stub .gnu.linkonce.t.*) + *(.text .text.* .stub .gnu.linkonce.t.* .plt) *(.rodata .rodata.* .gnu.linkonce.r.*) - *(.got .got.*) =20 /* * The contents of AutoGen.c files are mostly constant from the POV of= the @@ -34,6 +33,16 @@ SECTIONS { * emitted GUIDs here. */ *:AutoGen.obj(.data.g*Guid) + + /* + * AArch64 runtime drivers use 64k alignment, and may run in a mode wh= ere + * mutual exclusion of RO and XP mappings are hardware enforced. In su= ch + * cases, the input sections below, which carry any quantities that are + * subject to relocation fixups at runtime, must not share a 4 KiB page + * with any code content. + */ + . =3D ALIGN(CONSTANT(COMMONPAGESIZE) > 0x1000 ? 0x1000 : 0x20); + *(.got .got.* .data.rel.ro) } =20 /* --=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 (#100099): https://edk2.groups.io/g/devel/message/100099 Mute This Topic: https://groups.io/mt/96937494/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-