mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-18 03:44:27 +08:00
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: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/c8b6f7b8cd0eeaace96879ed0e0a157faa619451.1689091022.git.christophe.leroy@csgroup.eu
This commit is contained in:
parent
6b289911c8
commit
4589a2b789
@ -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_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)) {
|
||||
if ((pte_pkey == 0) && (flags & HPTE_USE_KERNEL_KEY))
|
||||
return HASH_DEFAULT_KERNEL_KEY;
|
||||
|
@ -31,7 +31,7 @@
|
||||
mfspr \gpr2, SPRN_AMR
|
||||
cmpd \gpr1, \gpr2
|
||||
beq 99f
|
||||
END_MMU_FTR_SECTION_NESTED_IFCLR(MMU_FTR_BOOK3S_KUAP, 68)
|
||||
END_MMU_FTR_SECTION_NESTED_IFCLR(MMU_FTR_KUAP, 68)
|
||||
|
||||
isync
|
||||
mtspr SPRN_AMR, \gpr1
|
||||
@ -78,7 +78,7 @@
|
||||
* No need to restore IAMR when returning to kernel space.
|
||||
*/
|
||||
100:
|
||||
END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_BOOK3S_KUAP, 67)
|
||||
END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_KUAP, 67)
|
||||
#endif
|
||||
.endm
|
||||
|
||||
@ -91,7 +91,7 @@
|
||||
LOAD_REG_IMMEDIATE(\gpr2, AMR_KUAP_BLOCKED)
|
||||
999: tdne \gpr1, \gpr2
|
||||
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
|
||||
.endm
|
||||
#endif
|
||||
@ -130,7 +130,7 @@
|
||||
*/
|
||||
BEGIN_MMU_FTR_SECTION_NESTED(68)
|
||||
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
|
||||
@ -166,7 +166,7 @@
|
||||
mtspr SPRN_AMR, \gpr2
|
||||
isync
|
||||
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
|
||||
@ -232,7 +232,7 @@ static inline u64 current_thread_iamr(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)
|
||||
@ -243,7 +243,7 @@ static inline void kuap_user_restore(struct pt_regs *regs)
|
||||
if (!mmu_has_feature(MMU_FTR_PKEY))
|
||||
return;
|
||||
|
||||
if (!mmu_has_feature(MMU_FTR_BOOK3S_KUAP)) {
|
||||
if (!mmu_has_feature(MMU_FTR_KUAP)) {
|
||||
amr = mfspr(SPRN_AMR);
|
||||
if (amr != regs->amr)
|
||||
restore_amr = true;
|
||||
@ -317,7 +317,7 @@ static inline unsigned long get_kuap(void)
|
||||
* This has no effect in terms of actually blocking things on hash,
|
||||
* 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 mfspr(SPRN_AMR);
|
||||
@ -325,7 +325,7 @@ static inline unsigned long get_kuap(void)
|
||||
|
||||
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;
|
||||
|
||||
/*
|
||||
|
@ -33,7 +33,7 @@
|
||||
* key 0 controlling userspace addresses on radix
|
||||
* Key 3 on hash
|
||||
*/
|
||||
#define MMU_FTR_BOOK3S_KUAP ASM_CONST(0x00000200)
|
||||
#define MMU_FTR_KUAP ASM_CONST(0x00000200)
|
||||
|
||||
/*
|
||||
* Supports KUEP feature
|
||||
@ -188,7 +188,7 @@ enum {
|
||||
#endif /* CONFIG_PPC_RADIX_MMU */
|
||||
#endif
|
||||
#ifdef CONFIG_PPC_KUAP
|
||||
MMU_FTR_BOOK3S_KUAP |
|
||||
MMU_FTR_KUAP |
|
||||
#endif /* CONFIG_PPC_KUAP */
|
||||
#ifdef CONFIG_PPC_MEM_KEYS
|
||||
MMU_FTR_PKEY |
|
||||
|
@ -46,7 +46,7 @@ notrace long system_call_exception(struct pt_regs *regs, unsigned long r0)
|
||||
iamr = mfspr(SPRN_IAMR);
|
||||
regs->amr = amr;
|
||||
regs->iamr = iamr;
|
||||
if (mmu_has_feature(MMU_FTR_BOOK3S_KUAP)) {
|
||||
if (mmu_has_feature(MMU_FTR_KUAP)) {
|
||||
mtspr(SPRN_AMR, AMR_KUAP_BLOCKED);
|
||||
flush_needed = true;
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ void setup_kuap(bool disabled)
|
||||
|
||||
if (smp_processor_id() == boot_cpuid) {
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user