powerpc/32s: Move KUEP locking/unlocking in C
This can be done in C, do it. Unrolling the loop gains approx. 15% performance. From now on, prepare_transfer_to_handler() is only for interrupts from kernel. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/4eadd873927e9a73c3d1dfe2f9497353465514cf.1615552867.git.christophe.leroy@csgroup.eu
This commit is contained in:
parent
a2b3e09ae4
commit
b5efec00b6
9 changed files with 64 additions and 48 deletions
|
|
@ -7,37 +7,6 @@
|
|||
|
||||
#ifdef __ASSEMBLY__
|
||||
|
||||
.macro kuep_update_sr gpr1, gpr2 /* NEVER use r0 as gpr2 due to addis */
|
||||
101: mtsrin \gpr1, \gpr2
|
||||
addi \gpr1, \gpr1, 0x111 /* next VSID */
|
||||
rlwinm \gpr1, \gpr1, 0, 0xf0ffffff /* clear VSID overflow */
|
||||
addis \gpr2, \gpr2, 0x1000 /* address of next segment */
|
||||
bdnz 101b
|
||||
isync
|
||||
.endm
|
||||
|
||||
.macro kuep_lock gpr1, gpr2
|
||||
#ifdef CONFIG_PPC_KUEP
|
||||
li \gpr1, NUM_USER_SEGMENTS
|
||||
li \gpr2, 0
|
||||
mtctr \gpr1
|
||||
mfsrin \gpr1, \gpr2
|
||||
oris \gpr1, \gpr1, SR_NX@h /* set Nx */
|
||||
kuep_update_sr \gpr1, \gpr2
|
||||
#endif
|
||||
.endm
|
||||
|
||||
.macro kuep_unlock gpr1, gpr2
|
||||
#ifdef CONFIG_PPC_KUEP
|
||||
li \gpr1, NUM_USER_SEGMENTS
|
||||
li \gpr2, 0
|
||||
mtctr \gpr1
|
||||
mfsrin \gpr1, \gpr2
|
||||
rlwinm \gpr1, \gpr1, 0, ~SR_NX /* Clear Nx */
|
||||
kuep_update_sr \gpr1, \gpr2
|
||||
#endif
|
||||
.endm
|
||||
|
||||
#ifdef CONFIG_PPC_KUAP
|
||||
|
||||
.macro kuap_update_sr gpr1, gpr2, gpr3 /* NEVER use r0 as gpr2 due to addis */
|
||||
|
|
|
|||
|
|
@ -33,8 +33,10 @@ static inline void interrupt_enter_prepare(struct pt_regs *regs, struct interrup
|
|||
if (!arch_irq_disabled_regs(regs))
|
||||
trace_hardirqs_off();
|
||||
|
||||
if (user_mode(regs))
|
||||
if (user_mode(regs)) {
|
||||
kuep_lock();
|
||||
account_cpu_user_entry();
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Book3E reconciles irq soft mask in asm
|
||||
|
|
@ -89,6 +91,8 @@ static inline void interrupt_exit_prepare(struct pt_regs *regs, struct interrupt
|
|||
exception_exit(state->ctx_state);
|
||||
#endif
|
||||
|
||||
if (user_mode(regs))
|
||||
kuep_unlock();
|
||||
/*
|
||||
* Book3S exits to user via interrupt_exit_user_prepare(), which does
|
||||
* context tracking, which is a cleaner way to handle PREEMPT=y
|
||||
|
|
|
|||
|
|
@ -55,6 +55,14 @@ void setup_kuep(bool disabled);
|
|||
static inline void setup_kuep(bool disabled) { }
|
||||
#endif /* CONFIG_PPC_KUEP */
|
||||
|
||||
#if defined(CONFIG_PPC_KUEP) && defined(CONFIG_PPC_BOOK3S_32)
|
||||
void kuep_lock(void);
|
||||
void kuep_unlock(void);
|
||||
#else
|
||||
static inline void kuep_lock(void) { }
|
||||
static inline void kuep_unlock(void) { }
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PPC_KUAP
|
||||
void setup_kuap(bool disabled);
|
||||
#else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue