From nobody Fri Oct 18 08:34:05 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+101929+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+101929+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1679914908; cv=none; d=zohomail.com; s=zohoarc; b=D45yx2E6fVrGTIvw+s7TlDhC6lB77hlPdoX5U7hF8/w94YQjp8dAoDkGap0NMQUxjNzPC0nSDd5si/gJAcmamwxTTK5CM6C1BYjfxFGnWCNO8b1U8J6/SUhbs78tfLKuKrCDno4fUKReHwqht859F4IB8TN9HvLGBIX21PGrsJ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679914908; 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=K3n77F0dAP/8W+Z4wJbYDyV/ofOWhU5kttbOVtT+dUc=; b=L47QTN9TS38ZOCcnB3YdzQLjJss/iSpPHt/Bco1rSt9LI9o8i/WMLJKMFE8ZDPIh+BE7/lRl/Q7WC0X1bz/9h7JuUzVre87sZUPp9onV/3UYXYAdtseo0G9nf2w2o6pSKJVOORNEKL2tne4kyTJoRk5I/RXdQ3KGyQpsmuN0ixQ= 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+101929+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 1679914908845601.7546154947457; Mon, 27 Mar 2023 04:01:48 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id lszvYY1788612x4gw5kSJ2ue; Mon, 27 Mar 2023 04:01:48 -0700 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.32014.1679914907814396823 for ; Mon, 27 Mar 2023 04:01:47 -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 5DF1C611A9; Mon, 27 Mar 2023 11:01:47 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44983C4339C; Mon, 27 Mar 2023 11:01:44 +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 , =?UTF-8?q?Marvin=20H=C3=A4user?= , Bob Feng Subject: [edk2-devel] [PATCH v2 05/17] MdePkg/BaseLib AARCH64: Make asm files BTI compatible Date: Mon, 27 Mar 2023 13:01:00 +0200 Message-Id: <20230327110112.262503-6-ardb@kernel.org> In-Reply-To: <20230327110112.262503-1-ardb@kernel.org> References: <20230327110112.262503-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: J4fgwfH41q6LReggfHlEYKTAx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679914908; bh=GhIfg2JaLZ4KYbExDISX9/XFmtQX7UnCLJFVpAVpbfE=; h=Cc:Date:From:Reply-To:Subject:To; b=TfHCpiCxJ2yR02yMGoU8CFJaHRmcuktVl903kgTFRuPCMjE0FYu9IkLew36h3eQj7LS P3s586Q7Axb/3LkGd5JW68UdddNf1dsAmYRN0xCOwan9ZUpP2/ic7ELfRfjonhGjRlMQh Z3929pO6fyVOCA5pbiEhcc72wacN0ePWlEI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679914909195100011 Content-Type: text/plain; charset="utf-8" Add the BTI instructions and the associated note to make the AArch64 asm objects compatible with BTI enforcement. Signed-off-by: Ard Biesheuvel --- MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S | 1 + MdePkg/Library/BaseLib/AArch64/DisableInterrupts.S | 1 + MdePkg/Library/BaseLib/AArch64/EnableInterrupts.S | 1 + MdePkg/Library/BaseLib/AArch64/GetInterruptsState.S | 1 + MdePkg/Library/BaseLib/AArch64/MemoryFence.S | 1 + MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S | 2 ++ MdePkg/Library/BaseLib/AArch64/SpeculationBarrier.S | 1 + MdePkg/Library/BaseLib/AArch64/SwitchStack.S | 2 ++ 8 files changed, 10 insertions(+) diff --git a/MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S b/MdePkg/Librar= y/BaseLib/AArch64/CpuBreakpoint.S index 7524fb18820c2fa3..24a1ac371884bb1d 100644 --- a/MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S +++ b/MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S @@ -27,5 +27,6 @@ GCC_ASM_EXPORT(CpuBreakpoint) # ); # ASM_PFX(CpuBreakpoint): + AARCH64_BTI(c) svc 0xdbdb // Superviser exception. Takes 16bit arg -> Armv7 had = 'swi' here. ret diff --git a/MdePkg/Library/BaseLib/AArch64/DisableInterrupts.S b/MdePkg/Li= brary/BaseLib/AArch64/DisableInterrupts.S index f0faf16b06a3fcae..3f562461614ad294 100644 --- a/MdePkg/Library/BaseLib/AArch64/DisableInterrupts.S +++ b/MdePkg/Library/BaseLib/AArch64/DisableInterrupts.S @@ -26,5 +26,6 @@ GCC_ASM_EXPORT(DisableInterrupts) # ); # ASM_PFX(DisableInterrupts): + AARCH64_BTI(c) msr daifset, #DAIF_WR_IRQ_BIT ret diff --git a/MdePkg/Library/BaseLib/AArch64/EnableInterrupts.S b/MdePkg/Lib= rary/BaseLib/AArch64/EnableInterrupts.S index 97eeb13fbe5d2145..0f1377f51c7e88f7 100644 --- a/MdePkg/Library/BaseLib/AArch64/EnableInterrupts.S +++ b/MdePkg/Library/BaseLib/AArch64/EnableInterrupts.S @@ -26,5 +26,6 @@ GCC_ASM_EXPORT(EnableInterrupts) # ); # ASM_PFX(EnableInterrupts): + AARCH64_BTI(c) msr daifclr, #DAIF_WR_IRQ_BIT ret diff --git a/MdePkg/Library/BaseLib/AArch64/GetInterruptsState.S b/MdePkg/L= ibrary/BaseLib/AArch64/GetInterruptsState.S index bf8b829bb2b1749d..26787a5b9bddcd7e 100644 --- a/MdePkg/Library/BaseLib/AArch64/GetInterruptsState.S +++ b/MdePkg/Library/BaseLib/AArch64/GetInterruptsState.S @@ -33,6 +33,7 @@ GCC_ASM_EXPORT(GetInterruptState) # ); # ASM_PFX(GetInterruptState): + AARCH64_BTI(c) mrs x0, daif tst x0, #DAIF_RD_IRQ_BIT // Check IRQ mask; set Z=3D1 if clear/un= masked cset w0, eq // if Z=3D1 (eq) return 1, else 0 diff --git a/MdePkg/Library/BaseLib/AArch64/MemoryFence.S b/MdePkg/Library/= BaseLib/AArch64/MemoryFence.S index e553bd2dc9fcf63f..ad5b92a9a72bd65c 100644 --- a/MdePkg/Library/BaseLib/AArch64/MemoryFence.S +++ b/MdePkg/Library/BaseLib/AArch64/MemoryFence.S @@ -28,6 +28,7 @@ GCC_ASM_EXPORT(MemoryFence) # ); # ASM_PFX(MemoryFence): + AARCH64_BTI(c) // System wide Data Memory Barrier. dmb sy ret diff --git a/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S b/MdePkg/Libr= ary/BaseLib/AArch64/SetJumpLongJump.S index 1d5cfbf64470452f..0d902d94d31c4a35 100644 --- a/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S +++ b/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S @@ -46,6 +46,7 @@ GCC_ASM_EXPORT(InternalLongJump) # ); # ASM_PFX(SetJump): + AARCH64_BTI(c) mov x16, sp // use IP0 so save SP #define REG_PAIR(REG1, REG2, OFFS) stp REG1, REG2, [x0, OFFS] #define REG_ONE(REG1, OFFS) str REG1, [x0, OFFS] @@ -75,6 +76,7 @@ ASM_PFX(SetJump): # ); # ASM_PFX(InternalLongJump): + AARCH64_BTI(c) #define REG_PAIR(REG1, REG2, OFFS) ldp REG1, REG2, [x0, OFFS] #define REG_ONE(REG1, OFFS) ldr REG1, [x0, OFFS] GPR_LAYOUT diff --git a/MdePkg/Library/BaseLib/AArch64/SpeculationBarrier.S b/MdePkg/L= ibrary/BaseLib/AArch64/SpeculationBarrier.S index a20d6aed0cdd5284..248ee01e52c27367 100644 --- a/MdePkg/Library/BaseLib/AArch64/SpeculationBarrier.S +++ b/MdePkg/Library/BaseLib/AArch64/SpeculationBarrier.S @@ -28,6 +28,7 @@ GCC_ASM_EXPORT(SpeculationBarrier) # ); # ASM_PFX(SpeculationBarrier): + AARCH64_BTI(c) dsb sy isb ret diff --git a/MdePkg/Library/BaseLib/AArch64/SwitchStack.S b/MdePkg/Library/= BaseLib/AArch64/SwitchStack.S index f3bce6a09bc2d555..837c65b45e73024e 100644 --- a/MdePkg/Library/BaseLib/AArch64/SwitchStack.S +++ b/MdePkg/Library/BaseLib/AArch64/SwitchStack.S @@ -35,6 +35,7 @@ GCC_ASM_EXPORT(CpuPause) # ); # ASM_PFX(InternalSwitchStackAsm): + AARCH64_BTI(c) mov x29, #0 mov x30, x0 mov sp, x3 @@ -57,6 +58,7 @@ ASM_PFX(InternalSwitchStackAsm): # ) # ASM_PFX(CpuPause): + AARCH64_BTI(c) nop nop nop --=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 (#101929): https://edk2.groups.io/g/devel/message/101929 Mute This Topic: https://groups.io/mt/97879286/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-