Commit d4539074 authored by Nicholas Piggin's avatar Nicholas Piggin Committed by Michael Ellerman

powerpc/64s/kuap: Conditionally restore AMR in kuap_restore_amr asm

Similar to the C code change, make the AMR restore conditional on
whether the register has changed.
Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200429065654.1677541-7-npiggin@gmail.com
parent 579940bb
...@@ -12,13 +12,17 @@ ...@@ -12,13 +12,17 @@
#ifdef __ASSEMBLY__ #ifdef __ASSEMBLY__
.macro kuap_restore_amr gpr .macro kuap_restore_amr gpr1, gpr2
#ifdef CONFIG_PPC_KUAP #ifdef CONFIG_PPC_KUAP
BEGIN_MMU_FTR_SECTION_NESTED(67) BEGIN_MMU_FTR_SECTION_NESTED(67)
ld \gpr, STACK_REGS_KUAP(r1) mfspr \gpr1, SPRN_AMR
ld \gpr2, STACK_REGS_KUAP(r1)
cmpd \gpr1, \gpr2
beq 998f
isync isync
mtspr SPRN_AMR, \gpr mtspr SPRN_AMR, \gpr2
/* No isync required, see kuap_restore_amr() */ /* No isync required, see kuap_restore_amr() */
998:
END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_RADIX_KUAP, 67) END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_RADIX_KUAP, 67)
#endif #endif
.endm .endm
......
...@@ -479,11 +479,11 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) ...@@ -479,11 +479,11 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
fast_interrupt_return: fast_interrupt_return:
_ASM_NOKPROBE_SYMBOL(fast_interrupt_return) _ASM_NOKPROBE_SYMBOL(fast_interrupt_return)
kuap_check_amr r3, r4 kuap_check_amr r3, r4
ld r4,_MSR(r1) ld r5,_MSR(r1)
andi. r0,r4,MSR_PR andi. r0,r5,MSR_PR
bne .Lfast_user_interrupt_return bne .Lfast_user_interrupt_return
kuap_restore_amr r3 kuap_restore_amr r3, r4
andi. r0,r4,MSR_RI andi. r0,r5,MSR_RI
li r3,0 /* 0 return value, no EMULATE_STACK_STORE */ li r3,0 /* 0 return value, no EMULATE_STACK_STORE */
bne+ .Lfast_kernel_interrupt_return bne+ .Lfast_kernel_interrupt_return
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
......
...@@ -971,7 +971,7 @@ EXC_COMMON_BEGIN(system_reset_common) ...@@ -971,7 +971,7 @@ EXC_COMMON_BEGIN(system_reset_common)
ld r10,SOFTE(r1) ld r10,SOFTE(r1)
stb r10,PACAIRQSOFTMASK(r13) stb r10,PACAIRQSOFTMASK(r13)
kuap_restore_amr r10 kuap_restore_amr r9, r10
EXCEPTION_RESTORE_REGS EXCEPTION_RESTORE_REGS
RFI_TO_USER_OR_KERNEL RFI_TO_USER_OR_KERNEL
...@@ -2784,7 +2784,7 @@ EXC_COMMON_BEGIN(soft_nmi_common) ...@@ -2784,7 +2784,7 @@ EXC_COMMON_BEGIN(soft_nmi_common)
ld r10,SOFTE(r1) ld r10,SOFTE(r1)
stb r10,PACAIRQSOFTMASK(r13) stb r10,PACAIRQSOFTMASK(r13)
kuap_restore_amr r10 kuap_restore_amr r9, r10
EXCEPTION_RESTORE_REGS hsrr=0 EXCEPTION_RESTORE_REGS hsrr=0
RFI_TO_KERNEL RFI_TO_KERNEL
......
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