Skip to content

Commit e4e9f6d

Browse files
brooniewilldeacon
authored andcommitted
arm64: bti: Fix support for userspace only BTI
When setting PTE_MAYBE_GP we check system_supports_bti() but this is true for systems where only CONFIG_BTI is set causing us to enable BTI on some kernel text. Add an extra check for the kernel mode option, using an ifdef due to line length. Fixes: c802728 ("arm64: Set GP bit in kernel page tables to enable BTI for the kernel") Signed-off-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 3a88d7c commit e4e9f6d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

arch/arm64/include/asm/pgtable-prot.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@ extern bool arm64_use_ng_mappings;
3232
#define PTE_MAYBE_NG (arm64_use_ng_mappings ? PTE_NG : 0)
3333
#define PMD_MAYBE_NG (arm64_use_ng_mappings ? PMD_SECT_NG : 0)
3434

35+
/*
36+
* If we have userspace only BTI we don't want to mark kernel pages
37+
* guarded even if the system does support BTI.
38+
*/
39+
#ifdef CONFIG_ARM64_BTI_KERNEL
3540
#define PTE_MAYBE_GP (system_supports_bti() ? PTE_GP : 0)
41+
#else
42+
#define PTE_MAYBE_GP 0
43+
#endif
3644

3745
#define PROT_DEFAULT (_PROT_DEFAULT | PTE_MAYBE_NG)
3846
#define PROT_SECT_DEFAULT (_PROT_SECT_DEFAULT | PMD_MAYBE_NG)

0 commit comments

Comments
 (0)