All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: make is_ttbrX_addr() noinstr-safe
@ 2022-11-14 14:40 Mark Rutland
  2022-11-15 18:32 ` Will Deacon
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Rutland @ 2022-11-14 14:40 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: catalin.marinas, mark.rutland, will

We use is_ttbr0_addr() in noinstr code, but as it's only marked as
inline, it's theoretically possible for the compiler to place it
out-of-line and instrument it, which would be problematic.

Mark is_ttbr0_addr() as __always_inline such that that can safely be
used from noinstr code. For consistency, do the same to is_ttbr1_addr().
Note that while is_ttbr1_addr() calls arch_kasan_reset_tag(), this is a
macro (and its callees are either macros or __always_inline), so there
is not a risk of transient instrumentation.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
---
 arch/arm64/include/asm/processor.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 445aa3af3b76..400f8956328b 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -308,13 +308,13 @@ static inline void compat_start_thread(struct pt_regs *regs, unsigned long pc,
 }
 #endif
 
-static inline bool is_ttbr0_addr(unsigned long addr)
+static __always_inline bool is_ttbr0_addr(unsigned long addr)
 {
 	/* entry assembly clears tags for TTBR0 addrs */
 	return addr < TASK_SIZE;
 }
 
-static inline bool is_ttbr1_addr(unsigned long addr)
+static __always_inline bool is_ttbr1_addr(unsigned long addr)
 {
 	/* TTBR1 addresses may have a tag if KASAN_SW_TAGS is in use */
 	return arch_kasan_reset_tag(addr) >= PAGE_OFFSET;
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] arm64: make is_ttbrX_addr() noinstr-safe
  2022-11-14 14:40 [PATCH] arm64: make is_ttbrX_addr() noinstr-safe Mark Rutland
@ 2022-11-15 18:32 ` Will Deacon
  0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2022-11-15 18:32 UTC (permalink / raw)
  To: linux-arm-kernel, Mark Rutland; +Cc: catalin.marinas, kernel-team, Will Deacon

On Mon, 14 Nov 2022 14:40:42 +0000, Mark Rutland wrote:
> We use is_ttbr0_addr() in noinstr code, but as it's only marked as
> inline, it's theoretically possible for the compiler to place it
> out-of-line and instrument it, which would be problematic.
> 
> Mark is_ttbr0_addr() as __always_inline such that that can safely be
> used from noinstr code. For consistency, do the same to is_ttbr1_addr().
> Note that while is_ttbr1_addr() calls arch_kasan_reset_tag(), this is a
> macro (and its callees are either macros or __always_inline), so there
> is not a risk of transient instrumentation.
> 
> [...]

Applied to arm64 (for-next/trivial), thanks!

[1/1] arm64: make is_ttbrX_addr() noinstr-safe
      https://git.kernel.org/arm64/c/d8c1d798a2e5

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-15 18:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-14 14:40 [PATCH] arm64: make is_ttbrX_addr() noinstr-safe Mark Rutland
2022-11-15 18:32 ` Will Deacon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.