From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gqVbAtLh; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) 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) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44983C4339C; Mon, 27 Mar 2023 11:01:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679914906; bh=ia2mE+Jny2PPjVilFDSRGysACmfUcdoqXEOcb2PuKSg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gqVbAtLhaLXX/sICwibWwzo2xm5J0oZ+8F7EiYUoKiGPdEd49UfIR1xPL2GFIFsfP IrgBSowBwgNottv2si6R7kV82lRZhLWR/ZA3JCKr6bsz4/KnLgvBXNxMdd/ugTrrbU AaL2Gbyu/27dQKbdApqrGw888bB3V3LCaI7ofRZ208hLDFR0AGNbFcvvw0E4sUsIUl 7QhTH4DqSCNhzGiYnAcf5NQijOQAlVWnbey/99H65K9P0N9Zinp1/z3TG+GfGWbUGu AXKK5QBJYcmuSAMS+1ACkzx+8Rizdcshx0lb4LMuVMoc3SybPypA7boz6fRcqC7ZYn TUWItwFnPCCLQ== 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: [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> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230327110112.262503-1-ardb@kernel.org> References: <20230327110112.262503-1-ardb@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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) # );=0D #=0D ASM_PFX(CpuBreakpoint):=0D + AARCH64_BTI(c)=0D svc 0xdbdb // Superviser exception. Takes 16bit arg -> Armv7 had = 'swi' here.=0D ret=0D 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) # );=0D #=0D ASM_PFX(DisableInterrupts):=0D + AARCH64_BTI(c)=0D msr daifset, #DAIF_WR_IRQ_BIT=0D ret=0D 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) # );=0D #=0D ASM_PFX(EnableInterrupts):=0D + AARCH64_BTI(c)=0D msr daifclr, #DAIF_WR_IRQ_BIT=0D ret=0D 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) # );=0D #=0D ASM_PFX(GetInterruptState):=0D + AARCH64_BTI(c)=0D mrs x0, daif=0D tst x0, #DAIF_RD_IRQ_BIT // Check IRQ mask; set Z=3D1 if clear/un= masked=0D cset w0, eq // if Z=3D1 (eq) return 1, else 0=0D 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) # );=0D #=0D ASM_PFX(MemoryFence):=0D + AARCH64_BTI(c)=0D // System wide Data Memory Barrier.=0D dmb sy=0D ret=0D 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) # );=0D #=0D ASM_PFX(SetJump):=0D + AARCH64_BTI(c)=0D mov x16, sp // use IP0 so save SP=0D #define REG_PAIR(REG1, REG2, OFFS) stp REG1, REG2, [x0, OFFS]=0D #define REG_ONE(REG1, OFFS) str REG1, [x0, OFFS]=0D @@ -75,6 +76,7 @@ ASM_PFX(SetJump): # );=0D #=0D ASM_PFX(InternalLongJump):=0D + AARCH64_BTI(c)=0D #define REG_PAIR(REG1, REG2, OFFS) ldp REG1, REG2, [x0, OFFS]=0D #define REG_ONE(REG1, OFFS) ldr REG1, [x0, OFFS]=0D GPR_LAYOUT=0D 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) # );=0D #=0D ASM_PFX(SpeculationBarrier):=0D + AARCH64_BTI(c)=0D dsb sy=0D isb=0D ret=0D 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) # );=0D #=0D ASM_PFX(InternalSwitchStackAsm):=0D + AARCH64_BTI(c)=0D mov x29, #0=0D mov x30, x0=0D mov sp, x3=0D @@ -57,6 +58,7 @@ ASM_PFX(InternalSwitchStackAsm): # )=0D #=0D ASM_PFX(CpuPause):=0D + AARCH64_BTI(c)=0D nop=0D nop=0D nop=0D --=20 2.39.2