Skip to content

Commit

Permalink
sparc64: Clean up handling of pt_regs trap type encoding.
Browse files Browse the repository at this point in the history
If we use this from more than one place, it's better to
have helpers instead of twiddling magic constants all
over.

Add pt_regs_trap_type(), pt_regs_clear_trap_type(), and
pt_regs_is_syscall().

Use them in do_signal().

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Apr 27, 2008
1 parent 5526b7e commit 9088881
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
7 changes: 3 additions & 4 deletions arch/sparc64/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,10 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
struct k_sigaction ka;
sigset_t *oldset;
siginfo_t info;
int signr, tt;
int signr;

tt = regs->magic & 0x1ff;
if (tt == 0x110 || tt == 0x111 || tt == 0x16d) {
regs->magic &= ~0x1ff;
if (pt_regs_is_syscall(regs)) {
pt_regs_clear_trap_type(regs);
cookie.restart_syscall = 1;
} else
cookie.restart_syscall = 0;
Expand Down
23 changes: 22 additions & 1 deletion include/asm-sparc64/ptrace.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* $Id: ptrace.h,v 1.14 2002/02/09 19:49:32 davem Exp $ */
#ifndef _SPARC64_PTRACE_H
#define _SPARC64_PTRACE_H

Expand All @@ -8,10 +7,15 @@
* stack during a system call and basically all traps.
*/

/* This magic value must have the low 9 bits clear,
* as that is where we encode the %tt value, see below.
*/
#define PT_REGS_MAGIC 0x57ac6c00

#ifndef __ASSEMBLY__

#include <linux/types.h>

struct pt_regs {
unsigned long u_regs[16]; /* globals and ins */
unsigned long tstate;
Expand All @@ -33,6 +37,23 @@ struct pt_regs {
unsigned int magic;
};

static inline int pt_regs_trap_type(struct pt_regs *regs)
{
return regs->magic & 0x1ff;
}

static inline int pt_regs_clear_trap_type(struct pt_regs *regs)
{
return regs->magic &= ~0x1ff;
}

static inline bool pt_regs_is_syscall(struct pt_regs *regs)
{
int tt = pt_regs_trap_type(regs);

return (tt == 0x110 || tt == 0x111 || tt == 0x16d);
}

struct pt_regs32 {
unsigned int psr;
unsigned int pc;
Expand Down

0 comments on commit 9088881

Please sign in to comment.