Commit 26e04120 authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman
Browse files

powerpc/kuap: Use MMU_FTR_KUAP on all and refactor disabling kuap



All but book3s/64 use a static branch key for disabling kuap.
book3s/64 uses an mmu feature.

Refactor all targets to use MMU_FTR_KUAP like book3s/64.

For PPC32 that implies updating mmu features fixups once KUAP
has been initialised.

Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/6b3d7c977bad73378ea368bc6818e9c94ea95ab0.1689091022.git.christophe.leroy@csgroup.eu
parent 4589a2b7
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -9,10 +9,6 @@

#ifndef __ASSEMBLY__

#include <linux/jump_label.h>

extern struct static_key_false disable_kuap_key;

#ifdef CONFIG_PPC_KUAP

#include <linux/sched.h>
@@ -20,11 +16,6 @@ extern struct static_key_false disable_kuap_key;
#define KUAP_NONE	(~0UL)
#define KUAP_ALL	(~1UL)

static __always_inline bool kuap_is_disabled(void)
{
	return static_branch_unlikely(&disable_kuap_key);
}

static inline void kuap_lock_one(unsigned long addr)
{
	mtsr(mfsr(addr) | SR_KS, addr);
+0 −5
Original line number Diff line number Diff line
@@ -230,11 +230,6 @@ static inline u64 current_thread_iamr(void)

#ifdef CONFIG_PPC_KUAP

static __always_inline bool kuap_is_disabled(void)
{
	return !mmu_has_feature(MMU_FTR_KUAP);
}

static inline void kuap_user_restore(struct pt_regs *regs)
{
	bool restore_amr = false, restore_iamr = false;
+11 −0
Original line number Diff line number Diff line
@@ -6,6 +6,12 @@
#define KUAP_WRITE	2
#define KUAP_READ_WRITE	(KUAP_READ | KUAP_WRITE)

#ifndef __ASSEMBLY__
#include <linux/types.h>

static __always_inline bool kuap_is_disabled(void);
#endif

#ifdef CONFIG_PPC_BOOK3S_64
#include <asm/book3s/64/kup.h>
#endif
@@ -41,6 +47,11 @@ void setup_kuep(bool disabled);

#ifdef CONFIG_PPC_KUAP
void setup_kuap(bool disabled);

static __always_inline bool kuap_is_disabled(void)
{
	return !mmu_has_feature(MMU_FTR_KUAP);
}
#else
static inline void setup_kuap(bool disabled) { }

+0 −9
Original line number Diff line number Diff line
@@ -9,17 +9,8 @@

#ifndef __ASSEMBLY__

#include <linux/jump_label.h>

#include <asm/reg.h>

extern struct static_key_false disable_kuap_key;

static __always_inline bool kuap_is_disabled(void)
{
	return static_branch_unlikely(&disable_kuap_key);
}

static inline void __kuap_save_and_lock(struct pt_regs *regs)
{
	regs->kuap = mfspr(SPRN_MD_AP);
+0 −8
Original line number Diff line number Diff line
@@ -13,18 +13,10 @@

#else

#include <linux/jump_label.h>
#include <linux/sched.h>

#include <asm/reg.h>

extern struct static_key_false disable_kuap_key;

static __always_inline bool kuap_is_disabled(void)
{
	return static_branch_unlikely(&disable_kuap_key);
}

static inline void __kuap_lock(void)
{
	mtspr(SPRN_PID, 0);
Loading