Skip to contentSkip to conversation

powerpc/Kconfig: limit the PPC_85xx DATA_SHIFT range to STRICT_KERNEL_RWX

PATCH RESEND In review Julian Braha 1 participant 2 messages Dec 1 – Dec 2 PowerPC

v1 of 2 In review Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 powerpc/Kconfig: limit the PPC_85xx DATA_SHIFT range to STRICT_KERNEL_RWX

On PPC_85xx, enabling DEBUG_PAGEALLOC without STRICT_KERNEL_RWX activates the DATA_SHIFT range of 20..24, but since the PAGE_SHIFT default is outside the range (12), kconfig adjusts it to 20, causing 1mb alignment instead of 4kb. However, the larger alignment is only needed for the separate kernel permissions provided by STRICT_KERNEL_RWX.

Since PPC_85xx uses page poisoning for DEBUG_PAGEALLOC and does not support KFENCE, let's restrict this range to STRICT_KERNEL_RWX.

This out-of-range default was found by kconfirm, a static analysis tool for Kconfig.

---
 arch/powerpc/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/Kconfig +2 -1
index c3b6cd655606..09e6027389b2 100644
@@ -896,7 +896,8 @@ config DATA_SHIFT
 	default 24 if STRICT_KERNEL_RWX && PPC64
 	range 17 28 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC || KFENCE) && PPC_BOOK3S_32
 	range 14 23 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC || KFENCE) && PPC_8xx
-	range 20 24 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC || KFENCE) && PPC_85xx
+	range 20 24 if STRICT_KERNEL_RWX && PPC_85xx
+	range PAGE_SHIFT 24 if !STRICT_KERNEL_RWX && PPC_85xx
 	default 22 if STRICT_KERNEL_RWX && PPC_BOOK3S_32
 	default 18 if (DEBUG_PAGEALLOC || KFENCE) && PPC_BOOK3S_32
 	default 23 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC || KFENCE) && PPC_8xx && \
Signature · 1 line
2.56.0
#1 lore raw
Quoted 23 lines · Julian Braha

On PPC_85xx, enabling DEBUG_PAGEALLOC without STRICT_KERNEL_RWX activates the DATA_SHIFT range of 20..24, but since the PAGE_SHIFT default is outside the range (12), kconfig adjusts it to 20, causing 1mb alignment instead of 4kb. However, the larger alignment is only needed for the separate kernel permissions provided by STRICT_KERNEL_RWX.

Since PPC_85xx uses page poisoning for DEBUG_PAGEALLOC and does not support KFENCE, let's restrict this range to STRICT_KERNEL_RWX.

This out-of-range default was found by kconfirm, a static analysis tool for Kconfig.

---
 arch/powerpc/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/Kconfig +0 -0
index c3b6cd655606..09e6027389b2 100644

arch/powerpc/Kconfig config DATA_SHIFT

Quoted 10 lines
arch/powerpc/Kconfig +2 -2
@@ -896,7 +896,8 @@ config DATA_SHIFT
 	default 24 if STRICT_KERNEL_RWX && PPC64
 	range 17 28 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC || KFENCE) && PPC_BOOK3S_32
 	range 14 23 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC || KFENCE) && PPC_8xx
-	range 20 24 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC || KFENCE) && PPC_85xx
+	range 20 24 if STRICT_KERNEL_RWX && PPC_85xx
+	range PAGE_SHIFT 24 if !STRICT_KERNEL_RWX && PPC_85xx
 	default 22 if STRICT_KERNEL_RWX && PPC_BOOK3S_32
 	default 18 if (DEBUG_PAGEALLOC || KFENCE) && PPC_BOOK3S_32
 	default 23 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC || KFENCE) && PPC_8xx && \
-- 2.56.0

Sorry all, I accidentally resent v1, instead of v2:
https://lore.kernel.org/all/[email protected]/

- Julian Braha