powerpc: trap_is_syscall() helper to hide syscall trap number
authorNicholas Piggin <npiggin@gmail.com>
Thu, 7 May 2020 12:13:31 +0000 (22:13 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 15 May 2020 01:58:54 +0000 (11:58 +1000)
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: Nicholas Piggin <npiggin@gmail.com>
[mpe: Make it a static inline]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200507121332.2233629-3-mpe@ellerman.id.au
arch/powerpc/include/asm/ptrace.h
arch/powerpc/include/asm/syscall.h
arch/powerpc/kernel/process.c
arch/powerpc/kernel/signal.c
arch/powerpc/xmon/xmon.c

index 7c585bddc06e1c83ccec8960e7098619901433de..5db45790a087faa98e675ff272861cb03f2e95b9 100644 (file)
@@ -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);
 }
 
+static inline bool trap_is_syscall(struct pt_regs *regs)
+{
+       return TRAP(regs) == 0xc00;
+}
+
 #define arch_has_single_step() (1)
 #ifndef CONFIG_BOOK3S_601
 #define arch_has_block_step()  (true)
index 38d62acfdce7acae7a869fbd676db8787beb17ae..fd1b518eed17c2865010f7ed6ebb7a980261c271 100644 (file)
@@ -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
         * 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,
index 8af3583546b78f3f582eb012d66d74c719b5de0c..db766252238fb588dd4a04e47d37c54409325f12 100644 (file)
@@ -1413,7 +1413,7 @@ void show_regs(struct pt_regs * regs)
        print_msr_bits(regs->msr);
        pr_cont("  CR: %08lx  XER: %08lx\n", regs->ccr, regs->xer);
        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);
        if (trap == 0x200 || trap == 0x300 || trap == 0x600)
 #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
index a264989626fd4cf4c070f69f083cf7b111aafe18..f2be9e960c2ef745f49ca4a6d8f5977097215158 100644 (file)
@@ -198,7 +198,7 @@ static void check_syscall_restart(struct pt_regs *regs, struct k_sigaction *ka,
        int restart = 1;
 
        /* syscall ? */
-       if (TRAP(regs) != 0x0C00)
+       if (!trap_is_syscall(regs))
                return;
 
        /* error signalled ? */
index 92761e47fb5cbc0b902fa5b760a203d3d2d94118..a7430632bab4d8cfc94557896b2cc0286b2f37af 100644 (file)
@@ -1776,7 +1776,7 @@ static void prregs(struct pt_regs *fp)
 #endif
        printf("pc  = ");
        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= ");
                xmon_print_symbol(fp->orig_gpr3, " ", "\n");
        }