Commit 4589a2b7 authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman

powerpc/kuap: MMU_FTR_BOOK3S_KUAP becomes MMU_FTR_KUAP

In order to reuse MMU_FTR_BOOK3S_KUAP for other targets than BOOK3S,
rename it MMU_FTR_KUAP.
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/c8b6f7b8cd0eeaace96879ed0e0a157faa619451.1689091022.git.christophe.leroy@csgroup.eu
parent 6b289911
...@@ -24,7 +24,7 @@ static inline u64 pte_to_hpte_pkey_bits(u64 pteflags, unsigned long flags) ...@@ -24,7 +24,7 @@ static inline u64 pte_to_hpte_pkey_bits(u64 pteflags, unsigned long flags)
((pteflags & H_PTE_PKEY_BIT1) ? HPTE_R_KEY_BIT1 : 0x0UL) | ((pteflags & H_PTE_PKEY_BIT1) ? HPTE_R_KEY_BIT1 : 0x0UL) |
((pteflags & H_PTE_PKEY_BIT0) ? HPTE_R_KEY_BIT0 : 0x0UL)); ((pteflags & H_PTE_PKEY_BIT0) ? HPTE_R_KEY_BIT0 : 0x0UL));
if (mmu_has_feature(MMU_FTR_BOOK3S_KUAP) || if (mmu_has_feature(MMU_FTR_KUAP) ||
mmu_has_feature(MMU_FTR_BOOK3S_KUEP)) { mmu_has_feature(MMU_FTR_BOOK3S_KUEP)) {
if ((pte_pkey == 0) && (flags & HPTE_USE_KERNEL_KEY)) if ((pte_pkey == 0) && (flags & HPTE_USE_KERNEL_KEY))
return HASH_DEFAULT_KERNEL_KEY; return HASH_DEFAULT_KERNEL_KEY;
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
mfspr \gpr2, SPRN_AMR mfspr \gpr2, SPRN_AMR
cmpd \gpr1, \gpr2 cmpd \gpr1, \gpr2
beq 99f beq 99f
END_MMU_FTR_SECTION_NESTED_IFCLR(MMU_FTR_BOOK3S_KUAP, 68) END_MMU_FTR_SECTION_NESTED_IFCLR(MMU_FTR_KUAP, 68)
isync isync
mtspr SPRN_AMR, \gpr1 mtspr SPRN_AMR, \gpr1
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
* No need to restore IAMR when returning to kernel space. * No need to restore IAMR when returning to kernel space.
*/ */
100: 100:
END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_BOOK3S_KUAP, 67) END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_KUAP, 67)
#endif #endif
.endm .endm
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
LOAD_REG_IMMEDIATE(\gpr2, AMR_KUAP_BLOCKED) LOAD_REG_IMMEDIATE(\gpr2, AMR_KUAP_BLOCKED)
999: tdne \gpr1, \gpr2 999: tdne \gpr1, \gpr2
EMIT_WARN_ENTRY 999b, __FILE__, __LINE__, (BUGFLAG_WARNING | BUGFLAG_ONCE) EMIT_WARN_ENTRY 999b, __FILE__, __LINE__, (BUGFLAG_WARNING | BUGFLAG_ONCE)
END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_BOOK3S_KUAP, 67) END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_KUAP, 67)
#endif #endif
.endm .endm
#endif #endif
...@@ -130,7 +130,7 @@ ...@@ -130,7 +130,7 @@
*/ */
BEGIN_MMU_FTR_SECTION_NESTED(68) BEGIN_MMU_FTR_SECTION_NESTED(68)
b 100f // skip_save_amr b 100f // skip_save_amr
END_MMU_FTR_SECTION_NESTED_IFCLR(MMU_FTR_PKEY | MMU_FTR_BOOK3S_KUAP, 68) END_MMU_FTR_SECTION_NESTED_IFCLR(MMU_FTR_PKEY | MMU_FTR_KUAP, 68)
/* /*
* if pkey is disabled and we are entering from userspace * if pkey is disabled and we are entering from userspace
...@@ -166,7 +166,7 @@ ...@@ -166,7 +166,7 @@
mtspr SPRN_AMR, \gpr2 mtspr SPRN_AMR, \gpr2
isync isync
102: 102:
END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_BOOK3S_KUAP, 69) END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_KUAP, 69)
/* /*
* if entering from kernel we don't need save IAMR * if entering from kernel we don't need save IAMR
...@@ -232,7 +232,7 @@ static inline u64 current_thread_iamr(void) ...@@ -232,7 +232,7 @@ static inline u64 current_thread_iamr(void)
static __always_inline bool kuap_is_disabled(void) static __always_inline bool kuap_is_disabled(void)
{ {
return !mmu_has_feature(MMU_FTR_BOOK3S_KUAP); return !mmu_has_feature(MMU_FTR_KUAP);
} }
static inline void kuap_user_restore(struct pt_regs *regs) static inline void kuap_user_restore(struct pt_regs *regs)
...@@ -243,7 +243,7 @@ static inline void kuap_user_restore(struct pt_regs *regs) ...@@ -243,7 +243,7 @@ static inline void kuap_user_restore(struct pt_regs *regs)
if (!mmu_has_feature(MMU_FTR_PKEY)) if (!mmu_has_feature(MMU_FTR_PKEY))
return; return;
if (!mmu_has_feature(MMU_FTR_BOOK3S_KUAP)) { if (!mmu_has_feature(MMU_FTR_KUAP)) {
amr = mfspr(SPRN_AMR); amr = mfspr(SPRN_AMR);
if (amr != regs->amr) if (amr != regs->amr)
restore_amr = true; restore_amr = true;
...@@ -317,7 +317,7 @@ static inline unsigned long get_kuap(void) ...@@ -317,7 +317,7 @@ static inline unsigned long get_kuap(void)
* This has no effect in terms of actually blocking things on hash, * This has no effect in terms of actually blocking things on hash,
* so it doesn't break anything. * so it doesn't break anything.
*/ */
if (!mmu_has_feature(MMU_FTR_BOOK3S_KUAP)) if (!mmu_has_feature(MMU_FTR_KUAP))
return AMR_KUAP_BLOCKED; return AMR_KUAP_BLOCKED;
return mfspr(SPRN_AMR); return mfspr(SPRN_AMR);
...@@ -325,7 +325,7 @@ static inline unsigned long get_kuap(void) ...@@ -325,7 +325,7 @@ static inline unsigned long get_kuap(void)
static __always_inline void set_kuap(unsigned long value) static __always_inline void set_kuap(unsigned long value)
{ {
if (!mmu_has_feature(MMU_FTR_BOOK3S_KUAP)) if (!mmu_has_feature(MMU_FTR_KUAP))
return; return;
/* /*
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
* key 0 controlling userspace addresses on radix * key 0 controlling userspace addresses on radix
* Key 3 on hash * Key 3 on hash
*/ */
#define MMU_FTR_BOOK3S_KUAP ASM_CONST(0x00000200) #define MMU_FTR_KUAP ASM_CONST(0x00000200)
/* /*
* Supports KUEP feature * Supports KUEP feature
...@@ -188,7 +188,7 @@ enum { ...@@ -188,7 +188,7 @@ enum {
#endif /* CONFIG_PPC_RADIX_MMU */ #endif /* CONFIG_PPC_RADIX_MMU */
#endif #endif
#ifdef CONFIG_PPC_KUAP #ifdef CONFIG_PPC_KUAP
MMU_FTR_BOOK3S_KUAP | MMU_FTR_KUAP |
#endif /* CONFIG_PPC_KUAP */ #endif /* CONFIG_PPC_KUAP */
#ifdef CONFIG_PPC_MEM_KEYS #ifdef CONFIG_PPC_MEM_KEYS
MMU_FTR_PKEY | MMU_FTR_PKEY |
......
...@@ -46,7 +46,7 @@ notrace long system_call_exception(struct pt_regs *regs, unsigned long r0) ...@@ -46,7 +46,7 @@ notrace long system_call_exception(struct pt_regs *regs, unsigned long r0)
iamr = mfspr(SPRN_IAMR); iamr = mfspr(SPRN_IAMR);
regs->amr = amr; regs->amr = amr;
regs->iamr = iamr; regs->iamr = iamr;
if (mmu_has_feature(MMU_FTR_BOOK3S_KUAP)) { if (mmu_has_feature(MMU_FTR_KUAP)) {
mtspr(SPRN_AMR, AMR_KUAP_BLOCKED); mtspr(SPRN_AMR, AMR_KUAP_BLOCKED);
flush_needed = true; flush_needed = true;
} }
......
...@@ -291,7 +291,7 @@ void setup_kuap(bool disabled) ...@@ -291,7 +291,7 @@ void setup_kuap(bool disabled)
if (smp_processor_id() == boot_cpuid) { if (smp_processor_id() == boot_cpuid) {
pr_info("Activating Kernel Userspace Access Prevention\n"); pr_info("Activating Kernel Userspace Access Prevention\n");
cur_cpu_spec->mmu_features |= MMU_FTR_BOOK3S_KUAP; cur_cpu_spec->mmu_features |= MMU_FTR_KUAP;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment