Skip to content

Commit 1bb50ca

Browse files
author
Chris Metcalf
committed
arch/tile: move user_exit() to early kernel entry sequence
This ensures that we always notify context tracking that we have exited from user space no matter how we enter the kernel. It is similar to how arm64 handles context tracking, for example. This allows the removal of all the exception_enter() calls that were added in commit 49e4e15 ("tile: support CONTEXT_TRACKING and thus NOHZ_FULL"). Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
1 parent 9ce815e commit 1bb50ca

File tree

7 files changed

+16
-41
lines changed

7 files changed

+16
-41
lines changed

arch/tile/kernel/intvec_32.S

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ intvec_\vecname:
572572
}
573573
wh64 r52
574574

575-
#ifdef CONFIG_TRACE_IRQFLAGS
575+
#if defined(CONFIG_TRACE_IRQFLAGS) || defined(CONFIG_CONTEXT_TRACKING)
576576
.ifnc \function,handle_nmi
577577
/*
578578
* We finally have enough state set up to notify the irq
@@ -588,6 +588,9 @@ intvec_\vecname:
588588
{ move r32, r2; move r33, r3 }
589589
.endif
590590
TRACE_IRQS_OFF
591+
#ifdef CONFIG_CONTEXT_TRACKING
592+
jal context_tracking_user_exit
593+
#endif
591594
.ifnc \function,handle_syscall
592595
{ move r0, r30; move r1, r31 }
593596
{ move r2, r32; move r3, r33 }

arch/tile/kernel/intvec_64.S

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ intvec_\vecname:
753753
}
754754
wh64 r52
755755

756-
#ifdef CONFIG_TRACE_IRQFLAGS
756+
#if defined(CONFIG_TRACE_IRQFLAGS) || defined(CONFIG_CONTEXT_TRACKING)
757757
.ifnc \function,handle_nmi
758758
/*
759759
* We finally have enough state set up to notify the irq
@@ -769,6 +769,9 @@ intvec_\vecname:
769769
{ move r32, r2; move r33, r3 }
770770
.endif
771771
TRACE_IRQS_OFF
772+
#ifdef CONFIG_CONTEXT_TRACKING
773+
jal context_tracking_user_exit
774+
#endif
772775
.ifnc \function,handle_syscall
773776
{ move r0, r30; move r1, r31 }
774777
{ move r2, r32; move r3, r33 }

arch/tile/kernel/ptrace.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,6 @@ int do_syscall_trace_enter(struct pt_regs *regs)
255255
{
256256
u32 work = ACCESS_ONCE(current_thread_info()->flags);
257257

258-
/*
259-
* If TIF_NOHZ is set, we are required to call user_exit() before
260-
* doing anything that could touch RCU.
261-
*/
262-
if (work & _TIF_NOHZ)
263-
user_exit();
264-
265258
if (secure_computing() == -1)
266259
return -1;
267260

@@ -280,12 +273,6 @@ void do_syscall_trace_exit(struct pt_regs *regs)
280273
{
281274
long errno;
282275

283-
/*
284-
* We may come here right after calling schedule_user()
285-
* in which case we can be in RCU user mode.
286-
*/
287-
user_exit();
288-
289276
/*
290277
* The standard tile calling convention returns the value (or negative
291278
* errno) in r0, and zero (or positive errno) in r1.
@@ -322,7 +309,5 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs)
322309
/* Handle synthetic interrupt delivered only by the simulator. */
323310
void __kprobes do_breakpoint(struct pt_regs* regs, int fault_num)
324311
{
325-
enum ctx_state prev_state = exception_enter();
326312
send_sigtrap(current, regs);
327-
exception_exit(prev_state);
328313
}

arch/tile/kernel/single_step.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <linux/types.h>
2424
#include <linux/err.h>
2525
#include <linux/prctl.h>
26-
#include <linux/context_tracking.h>
2726
#include <asm/cacheflush.h>
2827
#include <asm/traps.h>
2928
#include <asm/uaccess.h>
@@ -739,7 +738,6 @@ static DEFINE_PER_CPU(unsigned long, ss_saved_pc);
739738

740739
void gx_singlestep_handle(struct pt_regs *regs, int fault_num)
741740
{
742-
enum ctx_state prev_state = exception_enter();
743741
unsigned long *ss_pc = this_cpu_ptr(&ss_saved_pc);
744742
struct thread_info *info = (void *)current_thread_info();
745743
int is_single_step = test_ti_thread_flag(info, TIF_SINGLESTEP);
@@ -756,7 +754,6 @@ void gx_singlestep_handle(struct pt_regs *regs, int fault_num)
756754
__insn_mtspr(SPR_SINGLE_STEP_CONTROL_K, control);
757755
send_sigtrap(current, regs);
758756
}
759-
exception_exit(prev_state);
760757
}
761758

762759

arch/tile/kernel/traps.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <linux/reboot.h>
2121
#include <linux/uaccess.h>
2222
#include <linux/ptrace.h>
23-
#include <linux/context_tracking.h>
2423
#include <asm/stack.h>
2524
#include <asm/traps.h>
2625
#include <asm/setup.h>
@@ -254,7 +253,6 @@ static int do_bpt(struct pt_regs *regs)
254253
void __kprobes do_trap(struct pt_regs *regs, int fault_num,
255254
unsigned long reason)
256255
{
257-
enum ctx_state prev_state = exception_enter();
258256
siginfo_t info = { 0 };
259257
int signo, code;
260258
unsigned long address = 0;
@@ -263,7 +261,7 @@ void __kprobes do_trap(struct pt_regs *regs, int fault_num,
263261

264262
/* Handle breakpoints, etc. */
265263
if (is_kernel && fault_num == INT_ILL && do_bpt(regs))
266-
goto done;
264+
return;
267265

268266
/* Re-enable interrupts, if they were previously enabled. */
269267
if (!(regs->flags & PT_FLAGS_DISABLE_IRQ))
@@ -277,7 +275,7 @@ void __kprobes do_trap(struct pt_regs *regs, int fault_num,
277275
const char *name;
278276
char buf[100];
279277
if (fixup_exception(regs)) /* ILL_TRANS or UNALIGN_DATA */
280-
goto done;
278+
return;
281279
if (fault_num >= 0 &&
282280
fault_num < ARRAY_SIZE(int_name) &&
283281
int_name[fault_num] != NULL)
@@ -319,7 +317,7 @@ void __kprobes do_trap(struct pt_regs *regs, int fault_num,
319317
case INT_GPV:
320318
#if CHIP_HAS_TILE_DMA()
321319
if (retry_gpv(reason))
322-
goto done;
320+
return;
323321
#endif
324322
/*FALLTHROUGH*/
325323
case INT_UDN_ACCESS:
@@ -346,7 +344,7 @@ void __kprobes do_trap(struct pt_regs *regs, int fault_num,
346344
if (!state ||
347345
(void __user *)(regs->pc) != state->buffer) {
348346
single_step_once(regs);
349-
goto done;
347+
return;
350348
}
351349
}
352350
#endif
@@ -390,9 +388,6 @@ void __kprobes do_trap(struct pt_regs *regs, int fault_num,
390388
if (signo != SIGTRAP)
391389
trace_unhandled_signal("trap", regs, address, signo);
392390
force_sig_info(signo, &info, current);
393-
394-
done:
395-
exception_exit(prev_state);
396391
}
397392

398393
void do_nmi(struct pt_regs *regs, int fault_num, unsigned long reason)

arch/tile/kernel/unaligned.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <linux/module.h>
2626
#include <linux/compat.h>
2727
#include <linux/prctl.h>
28-
#include <linux/context_tracking.h>
2928
#include <asm/cacheflush.h>
3029
#include <asm/traps.h>
3130
#include <asm/uaccess.h>
@@ -1449,7 +1448,6 @@ void jit_bundle_gen(struct pt_regs *regs, tilegx_bundle_bits bundle,
14491448

14501449
void do_unaligned(struct pt_regs *regs, int vecnum)
14511450
{
1452-
enum ctx_state prev_state = exception_enter();
14531451
tilegx_bundle_bits __user *pc;
14541452
tilegx_bundle_bits bundle;
14551453
struct thread_info *info = current_thread_info();
@@ -1503,7 +1501,7 @@ void do_unaligned(struct pt_regs *regs, int vecnum)
15031501
*((tilegx_bundle_bits *)(regs->pc)));
15041502
jit_bundle_gen(regs, bundle, align_ctl);
15051503
}
1506-
goto done;
1504+
return;
15071505
}
15081506

15091507
/*
@@ -1527,7 +1525,7 @@ void do_unaligned(struct pt_regs *regs, int vecnum)
15271525

15281526
trace_unhandled_signal("unaligned fixup trap", regs, 0, SIGBUS);
15291527
force_sig_info(info.si_signo, &info, current);
1530-
goto done;
1528+
return;
15311529
}
15321530

15331531

@@ -1544,7 +1542,7 @@ void do_unaligned(struct pt_regs *regs, int vecnum)
15441542
trace_unhandled_signal("segfault in unalign fixup", regs,
15451543
(unsigned long)info.si_addr, SIGSEGV);
15461544
force_sig_info(info.si_signo, &info, current);
1547-
goto done;
1545+
return;
15481546
}
15491547

15501548
if (!info->unalign_jit_base) {
@@ -1579,7 +1577,7 @@ void do_unaligned(struct pt_regs *regs, int vecnum)
15791577

15801578
if (IS_ERR((void __force *)user_page)) {
15811579
pr_err("Out of kernel pages trying do_mmap\n");
1582-
goto done;
1580+
return;
15831581
}
15841582

15851583
/* Save the address in the thread_info struct */
@@ -1592,9 +1590,6 @@ void do_unaligned(struct pt_regs *regs, int vecnum)
15921590

15931591
/* Generate unalign JIT */
15941592
jit_bundle_gen(regs, GX_INSN_BSWAP(bundle), align_ctl);
1595-
1596-
done:
1597-
exception_exit(prev_state);
15981593
}
15991594

16001595
#endif /* __tilegx__ */

arch/tile/mm/fault.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include <linux/syscalls.h>
3636
#include <linux/uaccess.h>
3737
#include <linux/kdebug.h>
38-
#include <linux/context_tracking.h>
3938

4039
#include <asm/pgalloc.h>
4140
#include <asm/sections.h>
@@ -845,9 +844,7 @@ static inline void __do_page_fault(struct pt_regs *regs, int fault_num,
845844
void do_page_fault(struct pt_regs *regs, int fault_num,
846845
unsigned long address, unsigned long write)
847846
{
848-
enum ctx_state prev_state = exception_enter();
849847
__do_page_fault(regs, fault_num, address, write);
850-
exception_exit(prev_state);
851848
}
852849

853850
#if CHIP_HAS_TILE_DMA()

0 commit comments

Comments
 (0)