Commit 912237ea authored by Nicholas Piggin's avatar Nicholas Piggin Committed by Michael Ellerman

powerpc: trap_is_syscall() helper to hide syscall trap number

A new system call interrupt will be added with a new trap number.
Hide the explicit 0xc00 test behind an accessor to reduce churn
in callers.
Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
[mpe: Make it a static inline]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200507121332.2233629-3-mpe@ellerman.id.au
parent db30144b
...@@ -222,6 +222,11 @@ static inline void set_trap(struct pt_regs *regs, unsigned long val) ...@@ -222,6 +222,11 @@ static inline void set_trap(struct pt_regs *regs, unsigned long val)
regs->trap = (regs->trap & TRAP_FLAGS_MASK) | (val & ~TRAP_FLAGS_MASK); regs->trap = (regs->trap & TRAP_FLAGS_MASK) | (val & ~TRAP_FLAGS_MASK);
} }
static inline bool trap_is_syscall(struct pt_regs *regs)
{
return TRAP(regs) == 0xc00;
}
#define arch_has_single_step() (1) #define arch_has_single_step() (1)
#ifndef CONFIG_BOOK3S_601 #ifndef CONFIG_BOOK3S_601
#define arch_has_block_step() (true) #define arch_has_block_step() (true)
......
...@@ -26,7 +26,10 @@ static inline int syscall_get_nr(struct task_struct *task, struct pt_regs *regs) ...@@ -26,7 +26,10 @@ static inline int syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
* This is important for seccomp so that compat tasks can set r0 = -1 * This is important for seccomp so that compat tasks can set r0 = -1
* to reject the syscall. * to reject the syscall.
*/ */
return TRAP(regs) == 0xc00 ? regs->gpr[0] : -1; if (trap_is_syscall(regs))
return regs->gpr[0];
else
return -1;
} }
static inline void syscall_rollback(struct task_struct *task, static inline void syscall_rollback(struct task_struct *task,
......
...@@ -1413,7 +1413,7 @@ void show_regs(struct pt_regs * regs) ...@@ -1413,7 +1413,7 @@ void show_regs(struct pt_regs * regs)
print_msr_bits(regs->msr); print_msr_bits(regs->msr);
pr_cont(" CR: %08lx XER: %08lx\n", regs->ccr, regs->xer); pr_cont(" CR: %08lx XER: %08lx\n", regs->ccr, regs->xer);
trap = TRAP(regs); trap = TRAP(regs);
if ((TRAP(regs) != 0xc00) && cpu_has_feature(CPU_FTR_CFAR)) if (!trap_is_syscall(regs) && cpu_has_feature(CPU_FTR_CFAR))
pr_cont("CFAR: "REG" ", regs->orig_gpr3); pr_cont("CFAR: "REG" ", regs->orig_gpr3);
if (trap == 0x200 || trap == 0x300 || trap == 0x600) if (trap == 0x200 || trap == 0x300 || trap == 0x600)
#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE) #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
......
...@@ -198,7 +198,7 @@ static void check_syscall_restart(struct pt_regs *regs, struct k_sigaction *ka, ...@@ -198,7 +198,7 @@ static void check_syscall_restart(struct pt_regs *regs, struct k_sigaction *ka,
int restart = 1; int restart = 1;
/* syscall ? */ /* syscall ? */
if (TRAP(regs) != 0x0C00) if (!trap_is_syscall(regs))
return; return;
/* error signalled ? */ /* error signalled ? */
......
...@@ -1776,7 +1776,7 @@ static void prregs(struct pt_regs *fp) ...@@ -1776,7 +1776,7 @@ static void prregs(struct pt_regs *fp)
#endif #endif
printf("pc = "); printf("pc = ");
xmon_print_symbol(fp->nip, " ", "\n"); xmon_print_symbol(fp->nip, " ", "\n");
if (TRAP(fp) != 0xc00 && cpu_has_feature(CPU_FTR_CFAR)) { if (!trap_is_syscall(fp) && cpu_has_feature(CPU_FTR_CFAR)) {
printf("cfar= "); printf("cfar= ");
xmon_print_symbol(fp->orig_gpr3, " ", "\n"); xmon_print_symbol(fp->orig_gpr3, " ", "\n");
} }
......
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