From nobody Sun May 19 16:27:47 2024 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+99496+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+99496+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1675361057; cv=none; d=zohomail.com; s=zohoarc; b=YXbosLr2ctpnZBZ37z6HS4ZWFLTazd86fGz7RfNhqI10WXA2Fpdu0AVqGLl3Tdb4DGkmZH8ZIxbXljTcX0GOxLP/7c3KKtLlMXSaMSxnGeFtfsF4fenG3Hzq6vxlDJQq1WzjzcIe0SUIq+7rwN1nsC2ItYlTz6zpOn9rvT0Ni/Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675361057; 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=zhrotOX7E/tSgfO5yuRvX85/8/8ZHaOlrPEHjiB7sYI=; b=BhYrHCJ7IxXg5wKDIAAOwzWD6AqurtNg+S9U7M9akqamOk5NKDzUpHHNPYUl4gfJe4PMW8YIRmCfswLW31ONJFXmM0Ugfds6RH+HjFTNEauJrC9aodvOnGRTxaETYsLBgK8CyyBCT2xh1uhsHC/36Sc2u7n+1U0HStRiJtiu0wU= 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+99496+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 1675361057912870.3258418341262; Thu, 2 Feb 2023 10:04:17 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id jHDyYY1788612xTEc9jWWG0k; Thu, 02 Feb 2023 10:04:17 -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.1549.1675361033522015792 for ; Thu, 02 Feb 2023 10:03:53 -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 E66E4B826AB; Thu, 2 Feb 2023 18:03:50 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 652ACC433EF; Thu, 2 Feb 2023 18:03:47 +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 Subject: [edk2-devel] [RFC PATCH 1/3] MdePkg: Update MemoryAttributesTable to v2.10 Date: Thu, 2 Feb 2023 19:03:33 +0100 Message-Id: <20230202180335.2256160-2-ardb@kernel.org> In-Reply-To: <20230202180335.2256160-1-ardb@kernel.org> References: <20230202180335.2256160-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: UJ6r56VyGpnuGaJhVJVCrY79x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1675361057; bh=IxRUEErPX0cT9SB+3YZUoihyiWWRiC1sTXKgMIgMYbs=; h=Cc:Date:From:Reply-To:Subject:To; b=Hv3igRDOb98mwHr3SPpfTwlseU40crXPnIpzAgeHITRpvRy3cZhO2eGR8dQnDhe6I9h cajtk1dww58SjzBQVt1vo42faYnvIwuU+hisULQzx5Jj8r4TScHYWUtoDKQIw9oJuNsGi 6/eRNra3K3+CydDHKgJIYCoZGAkpgdQa9Ng= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1675361059141100002 Content-Type: text/plain; charset="utf-8" UEFI v2.10 introduces a new flag to the memory attributes table to inform the OS whether or not runtime services code regions were emitted by the compiler with guard instructions for forward edge control flow integrity enforcement. So update our definition accordingly. Signed-off-by: Ard Biesheuvel Acked-by: Michael Kubacki Reviewed-by: Michael D Kinney --- MdePkg/Include/Guid/MemoryAttributesTable.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MdePkg/Include/Guid/MemoryAttributesTable.h b/MdePkg/Include/G= uid/MemoryAttributesTable.h index 82f83a67b96d..238c14ff92df 100644 --- a/MdePkg/Include/Guid/MemoryAttributesTable.h +++ b/MdePkg/Include/Guid/MemoryAttributesTable.h @@ -17,11 +17,15 @@ typedef struct { UINT32 Version; UINT32 NumberOfEntries; UINT32 DescriptorSize; - UINT32 Reserved; + UINT32 Flags; // EFI_MEMORY_DESCRIPTOR Entry[1]; } EFI_MEMORY_ATTRIBUTES_TABLE; =20 -#define EFI_MEMORY_ATTRIBUTES_TABLE_VERSION 0x00000001 +#define EFI_MEMORY_ATTRIBUTES_TABLE_VERSION 0x00000002 + +#define EFI_MEMORY_ATTRIBUTES_FLAGS_RT_FORWARD_CONTROL_FLOW_GUARD 0x1 +// BIT0 implies that Runtime code includes the forward control flow guard +// instruction, such as X86 CET-IBT or ARM BTI. =20 extern EFI_GUID gEfiMemoryAttributesTableGuid; =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 (#99496): https://edk2.groups.io/g/devel/message/99496 Mute This Topic: https://groups.io/mt/96705497/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- From nobody Sun May 19 16:27:47 2024 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+99495+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+99495+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1675361034; cv=none; d=zohomail.com; s=zohoarc; b=RlZq6C+6n+RdYCt6D7S0RzXOnvGA877VxT7x1V6p0wnCb1oFxU4x2hak9NM/vt3t4ycZjRH2daSPeelKvhKvic4nErAFzjUXOazHg26AAncn7QmDFNBMVOWKvw7LE5lGAlf5t2YJ2KI10l75QTuh15yjVvYS48clzTvHMj9q1w8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675361034; 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=iAzoLsHj9H3K9kuqXvdtIu/QDTKwfTDRXi4jEElSdqY=; b=aIJBhc4NG5AJQduSutNm8596nGvDBTxB7YQ8P9wQ8dOR0WGnDdZymtb3H6+dv9jHQAli48QogA9mLJY7GLyhEn146YSZyIuw6Ti6jj9c1n7GECI/nNQUi2JA2Vbj3H5VctKM3Li15CoxYqj4XQYoNW/tccJzU0Cxp9TstvZmlXw= 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+99495+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 1675361034425265.4707633204388; Thu, 2 Feb 2023 10:03:54 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id TicVYY1788612x6xL4dvyj6M; Thu, 02 Feb 2023 10:03:54 -0800 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.1548.1675361033357012815 for ; Thu, 02 Feb 2023 10:03:53 -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 D258861C1D; Thu, 2 Feb 2023 18:03:52 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1221AC4339E; Thu, 2 Feb 2023 18:03:49 +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 Subject: [edk2-devel] [RFC PATCH 2/3] MdeModulePkg: Enable forward edge CFI in mem attributes table Date: Thu, 2 Feb 2023 19:03:34 +0100 Message-Id: <20230202180335.2256160-3-ardb@kernel.org> In-Reply-To: <20230202180335.2256160-1-ardb@kernel.org> References: <20230202180335.2256160-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: YOPZ4bvLojjoql2gPAysJkmKx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1675361034; bh=uDn6TWCX09d7+9ujaIf9pRgLaj+bXIxK56IqRY1fEuY=; h=Cc:Date:From:Reply-To:Subject:To; b=RmvjTYOXJCbUM7/bAfY0kst+WsJteAuofr/hF+vXZgpyxP5gyEhOvvax05/RCRLKqpV Xie89eK+VV/8ySiThDEb+MeN/4Qg9tTRvKTp8kYY5CakpTR0mUcDHmfZwq7qb7s2gWA4I zFYcK50+lE4FZj+6TUeUsZBBhJSIc/Uu1BU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1675361034959100001 Content-Type: text/plain; charset="utf-8" The memory attributes table has been extended with a flag that indicates whether or not the OS is permitted to map the EFI runtime code regions with strict enforcement for IBT/BTI landing pad instructions. This is generally a property of the firmware build, and so we can permit a platform to set this property using a PCD, and put the burden on the platform definition to set the toolchain options accordingly. There is one snag, however: PE/COFF does not expose whether or not the code was generated with landing pads, so if any runtime DXE drivers were loaded from storage other than the firmware volumes, we must assume that setting the CFI flag in the memory attributes table is unsafe. Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Core/Dxe/DxeMain.h | 2 ++ MdeModulePkg/Core/Dxe/DxeMain.inf | 1 + MdeModulePkg/Core/Dxe/Image/Image.c | 11 +++++++++++ MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c | 7 ++++++- MdeModulePkg/MdeModulePkg.dec | 8 ++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMai= n.h index 815a6b4bd844..427a5fc78f72 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -280,6 +280,8 @@ extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformat= ion[EfiMaxMemoryType + 1] extern BOOLEAN gDispatcherRunning; extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate; =20 +extern BOOLEAN gMemoryAttributesTableForwardCfi; + extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddress= ConfigurationTable; extern BOOLEAN gLoadFixedAddressCodeMe= moryReady; // diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeM= ain.inf index 35d5bf0dee6f..e6ff67773a69 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.inf +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf @@ -187,6 +187,7 @@ [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask = ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard = ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdFwVolDxeMaxEncapsulationDepth = ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryAttributesTableForwardCfi = ## CONSUMES =20 # [Hob] # RESOURCE_DESCRIPTOR ## CONSUMES diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Im= age/Image.c index 06cc6744b8c6..181fefdb6657 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -1398,6 +1398,17 @@ CoreLoadImageCommon ( CoreNewDebugImageInfoEntry (EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL, &Image->= Info, Image->Handle); } =20 + // + // If we loaded a runtime DXE driver from something other than a FV, it + // was not built as part of the firmware image, and so we cannot assume + // that it was built with IBT/BTI landing pads for forward edge control + // flow integrity. + // + if (!ImageIsFromFv && + (Image->ImageContext.ImageCodeMemoryType =3D=3D EfiRuntimeServicesCo= de)) { + gMemoryAttributesTableForwardCfi =3D FALSE; + } + // // Reinstall loaded image protocol to fire any notifications // diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c b/MdeModule= Pkg/Core/Dxe/Misc/MemoryAttributesTable.c index e07921371187..cdd35ade0a8a 100644 --- a/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c +++ b/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c @@ -89,6 +89,7 @@ BOOLEAN mMemoryAttributesTableEnable= =3D TRUE; BOOLEAN mMemoryAttributesTableEndOfDxe =3D FALSE; EFI_MEMORY_ATTRIBUTES_TABLE *mMemoryAttributesTable =3D NULL; BOOLEAN mMemoryAttributesTableReadyToBoot =3D FALSE; +BOOLEAN gMemoryAttributesTableForwardCfi =3D FixedPc= dGetBool (PcdMemoryAttributesTableForwardCfi); =20 /** Install MemoryAttributesTable. @@ -182,7 +183,11 @@ InstallMemoryAttributesTable ( MemoryAttributesTable->Version =3D EFI_MEMORY_ATTRIBUTES_TABLE_V= ERSION; MemoryAttributesTable->NumberOfEntries =3D RuntimeEntryCount; MemoryAttributesTable->DescriptorSize =3D (UINT32)DescriptorSize; - MemoryAttributesTable->Reserved =3D 0; + if (gMemoryAttributesTableForwardCfi) { + MemoryAttributesTable->Flags =3D EFI_MEMORY_ATTRIBUTES_FLAGS_R= T_FORWARD_CONTROL_FLOW_GUARD; + } else { + MemoryAttributesTable->Flags =3D 0; + } DEBUG ((DEBUG_VERBOSE, "MemoryAttributesTable:\n")); DEBUG ((DEBUG_VERBOSE, " Version - 0x%08x\n", MemoryAttrib= utesTable->Version)); DEBUG ((DEBUG_VERBOSE, " NumberOfEntries - 0x%08x\n", MemoryAttrib= utesTable->NumberOfEntries)); diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 9605c617b7a8..d336a38655a3 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -1093,6 +1093,14 @@ [PcdsFixedAtBuild] # @Prompt Enable UEFI Stack Guard. gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x30001055 =20 + ## Indicates whether the EFI memory attributes table will inform the OS = that + # forward edge control flow guards have been inserted into the runtime = services + # code regions. + # TRUE - Runtime code has forward control flow guards.
+ # FALSE - Runtime code does not have forward control flow guards.
+ # @Prompt Enable forward control flow guards in EFI memory attributes ta= ble + gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryAttributesTableForwardCfi|FALSE|= BOOLEAN|0x30001056 + [PcdsFixedAtBuild, PcdsPatchableInModule] ## Dynamic type PCD can be registered callback function for Pcd setting = action. # PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of= callback function --=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 (#99495): https://edk2.groups.io/g/devel/message/99495 Mute This Topic: https://groups.io/mt/96705496/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- From nobody Sun May 19 16:27:47 2024 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+99497+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+99497+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1675361038; cv=none; d=zohomail.com; s=zohoarc; b=G+lP9F+tbkJNCHFzkla44kK+tIMbOTxVoLShaGNOSJdoktJijXQ0FARpg+5jybaMYsyczmGl24PxGLCKI674AVnl2x6I+7g+XXP+KSwHsUHIly1kvBs839+giiPj6Mu4QcuD7Xqzy1f4patWzV3CnWgDtPg0hfTnf/Gsvrh1UsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675361038; 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=+mVTxut1pKVXxkbV4mg9JPK6/NKaVGYQe9h+P/VxKsY=; b=eQKKxzibiLykADw9rkFKu/fcb3XY3DfgR2SuRxZGS57qpnbIi6RSfDS7AaSvghyWI/0/IS2XFjSlk8zX4n6j9Co3gh4tJR+VovXXFkU4vlVbgrcEvtxUiOUyaDYGu8g4uqf8/Clu040mbCqsyDyaoZqW6f/NVwNjQ1ZFfCU79Ok= 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+99497+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 1675361038854576.3299030501792; Thu, 2 Feb 2023 10:03:58 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id rQINYY1788612xY0XWmK874j; Thu, 02 Feb 2023 10:03:58 -0800 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.1552.1675361035939996971 for ; Thu, 02 Feb 2023 10:03: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 7D1F361C43; Thu, 2 Feb 2023 18:03:55 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B022DC4339C; Thu, 2 Feb 2023 18:03: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 Subject: [edk2-devel] [RFC PATCH 3/3] ArmVirtPkg/ArmVirtQemu: Implement BTI for runtime regions Date: Thu, 2 Feb 2023 19:03:35 +0100 Message-Id: <20230202180335.2256160-4-ardb@kernel.org> In-Reply-To: <20230202180335.2256160-1-ardb@kernel.org> References: <20230202180335.2256160-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: ItQ9O9cwYXu7SZzQIGPYh0Prx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1675361038; bh=y7AzCZ3aq4vlM3ZJK0ao5k6Koeqh+APeRML2slNlEf8=; h=Cc:Date:From:Reply-To:Subject:To; b=SgdrCqLjIh1DUFnbQWxKYjx95696pKfYeh71GA/Y3pgNhqffWcq3gMNk+sYWVhZKNOb WJn0A5q2m7MzzXmjm2QVm2RUMPqqz4ClUkiInImVsXUdC5odE36cyDwTHCtB+fcwalApr nA0Ss6HtB9a2ZKbCm4LetxqC3dHufV0So/0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1675361040965100003 Content-Type: text/plain; charset="utf-8" Add a build option RUNTIM_BTI_ENABLE, and wire it up to the newly added PCD that controls the value of the BTI flag in the memory attributes table, as well as the command line options passed to the compiler to get it to emit BTI landing pads in BASE and DXE_RUNTIME_DRIVER modules. Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/ArmVirtQemu.dsc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index 0f1c6395488a..0a67fe250d86 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -32,6 +32,7 @@ [Defines] DEFINE TPM2_ENABLE =3D FALSE DEFINE TPM2_CONFIG_ENABLE =3D FALSE DEFINE CAVIUM_ERRATUM_27456 =3D FALSE + DEFINE RUNTIME_BTI_ENABLE =3D TRUE =20 # # Network definition @@ -124,6 +125,11 @@ [BuildOptions] GCC:*_*_AARCH64_CC_XIPFLAGS =3D=3D !endif =20 +!if $(RUNTIME_BTI_ENABLE) =3D=3D TRUE +[BuildOptions.common.BASE,BuildOptions.common.DXE_RUNTIME_DRIVER] + GCC:*_*_AARCH64_CC_FLAGS =3D -mbranch-protection=3Dbti +!endif + !include NetworkPkg/NetworkBuildOptions.dsc.inc =20 ##########################################################################= ###### @@ -148,6 +154,8 @@ [PcdsFeatureFlag.common] [PcdsFixedAtBuild.common] !if $(ARCH) =3D=3D AARCH64 gArmTokenSpaceGuid.PcdVFPEnabled|1 + + gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryAttributesTableForwardCfi|$(RUNT= IME_BTI_ENABLE) !endif =20 gArmPlatformTokenSpaceGuid.PcdCPUCoresStackBase|0x4007c000 --=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 (#99497): https://edk2.groups.io/g/devel/message/99497 Mute This Topic: https://groups.io/mt/96705498/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-