diff mbox series

Fix "[v3, 28/32] powerpc/64s: interrupt implement exit logic in C"

Message ID 20200319065934.1021079-1-npiggin@gmail.com (mailing list archive)
State Accepted
Headers show
Series Fix "[v3, 28/32] powerpc/64s: interrupt implement exit logic in C" | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/merge (8a445cbcb9f5090cb07ec6cbb89a8a1fc99a0ff7)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/next (59ed2adf393109c56d383e568f2e57bb5ad6d901)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linus/master (5076190daded2197f62fe92cf69674488be44175)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/fixes (af3d0a68698c7e5df8b72267086b23422a3954bb)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linux-next (47780d7892b77e922bbe19b5dea99cde06b2f0e5)
snowpatch_ozlabs/apply_patch fail Failed to apply to any branch

Commit Message

Nicholas Piggin March 19, 2020, 6:59 a.m. UTC
Accessing thread_info flags can cause an SLB fault, so it must not
be done with MSR[RI]=0, which leads to SLB unrecoverable fault error.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/syscall_64.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/syscall_64.c b/arch/powerpc/kernel/syscall_64.c
index 87d95b455b83..a56ae78f2d1d 100644
--- a/arch/powerpc/kernel/syscall_64.c
+++ b/arch/powerpc/kernel/syscall_64.c
@@ -313,12 +313,18 @@  notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs, unsign
 {
 	unsigned long *ti_flagsp = &current_thread_info()->flags;
 	unsigned long flags;
+	unsigned long ret = 0;
 
 	if (IS_ENABLED(CONFIG_PPC_BOOK3S) && unlikely(!(regs->msr & MSR_RI)))
 		unrecoverable_exception(regs);
 	BUG_ON(regs->msr & MSR_PR);
 	BUG_ON(!FULL_REGS(regs));
 
+	if (unlikely(*ti_flagsp & _TIF_EMULATE_STACK_STORE)) {
+		clear_bits(_TIF_EMULATE_STACK_STORE, ti_flagsp);
+		ret = 1;
+	}
+
 	local_irq_save(flags);
 
 	if (regs->softe == IRQS_ENABLED) {
@@ -370,10 +376,6 @@  notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs, unsign
 	 */
 	kuap_restore_amr(regs);
 
-	if (unlikely(*ti_flagsp & _TIF_EMULATE_STACK_STORE)) {
-		clear_bits(_TIF_EMULATE_STACK_STORE, ti_flagsp);
-		return 1;
-	}
-	return 0;
+	return ret;
 }
 #endif