summaryrefslogtreecommitdiff
path: root/arch/powerpc/kernel/interrupt.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/kernel/interrupt.c')
-rw-r--r--arch/powerpc/kernel/interrupt.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c
index f04978080837..5b88bf72786c 100644
--- a/arch/powerpc/kernel/interrupt.c
+++ b/arch/powerpc/kernel/interrupt.c
@@ -89,15 +89,17 @@ notrace unsigned long syscall_exit_prepare(unsigned long r3,
long scv)
{
unsigned long ti_flags;
+ unsigned long ret = 0;
bool is_not_scv = !IS_ENABLED(CONFIG_PPC_BOOK3S_64) || !scv;
kuap_assert_locked();
regs->result = r3;
- regs->exit_flags = 0;
- ti_flags = read_thread_flags();
+ /* Clear exit_flags so only flags set during this exit are visible */
+ current->thread_info.exit_flags = 0;
+ ti_flags = read_thread_flags();
if (unlikely(r3 >= (unsigned long)-MAX_ERRNO) && is_not_scv) {
if (likely(!(ti_flags & (_TIF_NOERROR | _TIF_RESTOREALL)))) {
r3 = -r3;
@@ -107,7 +109,7 @@ notrace unsigned long syscall_exit_prepare(unsigned long r3,
if (unlikely(ti_flags & _TIF_PERSYSCALL_MASK)) {
if (ti_flags & _TIF_RESTOREALL)
- regs->exit_flags = _TIF_RESTOREALL;
+ ret = _TIF_RESTOREALL;
else
regs->gpr[3] = r3;
clear_bits(_TIF_PERSYSCALL_MASK, &current_thread_info()->flags);
@@ -116,7 +118,7 @@ notrace unsigned long syscall_exit_prepare(unsigned long r3,
}
if (unlikely(ti_flags & _TIF_SYSCALL_DOTRACE)) {
- regs->exit_flags |= _TIF_RESTOREALL;
+ ret |= _TIF_RESTOREALL;
}
syscall_exit_to_user_mode(regs);
@@ -132,17 +134,19 @@ again:
/* Restore user access locks last */
kuap_user_restore(regs);
-
+ ret |= current->thread_info.exit_flags;
#ifdef CONFIG_PPC64
- regs->exit_result = regs->exit_flags;
+ regs->exit_result = ret;
#endif
- return regs->exit_flags;
+ return ret;
}
#ifdef CONFIG_PPC64
notrace unsigned long syscall_exit_restart(unsigned long r3, struct pt_regs *regs)
{
+ unsigned long ret;
+
/*
* This is called when detecting a soft-pending interrupt as well as
* an alternate-return interrupt. So we can't just have the alternate
@@ -167,9 +171,11 @@ again:
}
kuap_user_restore(regs);
- regs->exit_result |= regs->exit_flags;
+ ret = current_thread_info()->exit_flags & _TIF_RESTOREALL;
+ current_thread_info()->exit_flags &= ~_TIF_RESTOREALL;
+ regs->exit_result |= ret;
- return regs->exit_result;
+ return ret;
}
#endif
@@ -186,8 +192,10 @@ notrace unsigned long interrupt_exit_user_prepare(struct pt_regs *regs)
*/
kuap_assert_locked();
+ /* Clear exit_flags so only flags set during this exit are visible */
+ current_thread_info()->exit_flags = 0;
+
local_irq_disable();
- regs->exit_flags = 0;
again:
check_return_regs_valid(regs);
user_enter_irqoff();
@@ -200,9 +208,7 @@ again:
/* Restore user access locks last */
kuap_user_restore(regs);
-
- ret = regs->exit_flags;
-
+ ret = current_thread_info()->exit_flags & _TIF_RESTOREALL;
#ifdef CONFIG_PPC64
regs->exit_result = ret;
#endif