[PATCH v4 20/41] powerpc/book3s64/kuap/kuep: Make KUAP and KUEP a subfeature of PPC_MEM_KEYS
From: Aneesh Kumar K.V <hidden>
Date: 2020-06-15 06:52:45
Subsystem:
linux for powerpc (32-bit and 64-bit), ptrace support, the rest · Maintainers:
Madhavan Srinivasan, Oleg Nesterov, Linus Torvalds
The next set of patches adds support for kuap with hash translation. Hence make KUAP a BOOK3S_64 feature. Also make it a subfeature of PPC_MEM_KEYS. Hash translation is going to use pkeys to support KUAP/KUEP. Adding this dependency reduces the code complexity and enables us to move some of the initialization code to pkeys.c Signed-off-by: Aneesh Kumar K.V <redacted> --- arch/powerpc/include/asm/book3s/64/kup.h | 33 ++++++++++++++---------- arch/powerpc/include/asm/ptrace.h | 2 +- arch/powerpc/kernel/asm-offsets.c | 2 +- arch/powerpc/platforms/Kconfig.cputype | 4 +-- 4 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/arch/powerpc/include/asm/book3s/64/kup.h b/arch/powerpc/include/asm/book3s/64/kup.h
index 476bcd7b0e8b..aa2787c8b12a 100644
--- a/arch/powerpc/include/asm/book3s/64/kup.h
+++ b/arch/powerpc/include/asm/book3s/64/kup.h@@ -62,7 +62,7 @@ #else /* !__ASSEMBLY__ */ -#ifdef CONFIG_PPC_KUAP +#ifdef CONFIG_PPC_MEM_KEYS #include <asm/mmu.h> #include <asm/ptrace.h>
@@ -97,6 +97,24 @@ static inline void kuap_check_amr(void) WARN_ON_ONCE(mfspr(SPRN_AMR) != AMR_KUAP_BLOCKED); } +#else /* CONFIG_PPC_MEM_KEYS */ + +static inline void kuap_restore_amr(struct pt_regs *regs, unsigned long amr) +{ +} + +static inline void kuap_check_amr(void) +{ +} + +static inline unsigned long kuap_get_and_check_amr(void) +{ + return 0; +} +#endif /* CONFIG_PPC_MEM_KEYS */ + + +#ifdef CONFIG_PPC_KUAP /* * We support individually allowing read or write, but we don't support nesting * because that would require an expensive read/modify write of the AMR.
@@ -166,19 +184,6 @@ bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write) (regs->kuap & (is_write ? AMR_KUAP_BLOCK_WRITE : AMR_KUAP_BLOCK_READ)), "Bug: %s fault blocked by AMR!", is_write ? "Write" : "Read"); } -#else /* CONFIG_PPC_KUAP */ -static inline void kuap_restore_amr(struct pt_regs *regs, unsigned long amr) -{ -} - -static inline void kuap_check_amr(void) -{ -} - -static inline unsigned long kuap_get_and_check_amr(void) -{ - return 0; -} #endif /* CONFIG_PPC_KUAP */ #endif /* __ASSEMBLY__ */
diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
index ac3970fff0d5..1a6cadf63d14 100644
--- a/arch/powerpc/include/asm/ptrace.h
+++ b/arch/powerpc/include/asm/ptrace.h@@ -53,7 +53,7 @@ struct pt_regs #ifdef CONFIG_PPC64 unsigned long ppr; #endif -#ifdef CONFIG_PPC_KUAP +#ifdef CONFIG_PPC_HAVE_KUAP unsigned long kuap; #endif };
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 9b9cde07e396..1694c4f531b9 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c@@ -354,7 +354,7 @@ int main(void) STACK_PT_REGS_OFFSET(_PPR, ppr); #endif /* CONFIG_PPC64 */ -#ifdef CONFIG_PPC_KUAP +#ifdef CONFIG_PPC_HAVE_KUAP STACK_PT_REGS_OFFSET(STACK_REGS_KUAP, kuap); #endif
diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index d349603fb889..053c46aecf80 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype@@ -99,6 +99,8 @@ config PPC_BOOK3S_64 select ARCH_SUPPORTS_NUMA_BALANCING select IRQ_WORK select PPC_MM_SLICES + select PPC_HAVE_KUAP if PPC_MEM_KEYS + select PPC_HAVE_KUEP if PPC_MEM_KEYS config PPC_BOOK3E_64 bool "Embedded processors"
@@ -350,8 +352,6 @@ config PPC_RADIX_MMU bool "Radix MMU Support" depends on PPC_BOOK3S_64 select ARCH_HAS_GIGANTIC_PAGE - select PPC_HAVE_KUEP - select PPC_HAVE_KUAP default y help Enable support for the Power ISA 3.0 Radix style MMU. Currently this
--
2.26.2