Commit f22ab814 authored by Adrian Bunk's avatar Adrian Bunk Committed by Linus Torvalds

include/asm/ptrace.h userspace headers cleanup

This patch contains the following cleanups for the asm/ptrace.h
userspace headers:

- include/asm-generic/Kbuild.asm already lists ptrace.h, remove
  the superfluous listings in the Kbuild files of the following
  architectures:
  - cris
  - frv
  - powerpc
  - x86
- don't expose function prototypes and macros to userspace:
  - arm
  - blackfin
  - cris
  - mn10300
  - parisc
- remove #ifdef CONFIG_'s around #define's:
  - blackfin
  - m68knommu
- sh: AFAIK __SH5__ should work in both kernel and userspace,
      no need to leak CONFIG_SUPERH64 to userspace
- xtensa: cosmetical change to remove empty
            #ifndef __ASSEMBLY__ #else #endif
          from the userspace headers

Not changed by this patch is the fact that the following architectures
have a different struct pt_regs depending on CONFIG_ variables:
- h8300
- m68knommu
- mips

This does not work in userspace.
Signed-off-by: default avatarAdrian Bunk <bunk@kernel.org>
Cc: <linux-arch@vger.kernel.org>
Cc: Roland McGrath <roland@redhat.com>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Acked-by: default avatarGreg Ungerer <gerg@uclinux.org>
Acked-by: default avatarPaul Mundt <lethal@linux-sh.org>
Acked-by: default avatarGrant Grundler <grundler@parisc-linux.org>
Acked-by: default avatarJesper Nilsson <jesper.nilsson@axis.com>
Acked-by: default avatarChris Zankel <chris@zankel.net>
Acked-by: default avatarDavid Howells <dhowells@redhat.com>
Acked-by: default avatarPaul Mackerras <paulus@samba.org>
Acked-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent bc64efd2
...@@ -139,8 +139,6 @@ static inline int valid_user_regs(struct pt_regs *regs) ...@@ -139,8 +139,6 @@ static inline int valid_user_regs(struct pt_regs *regs)
return 0; return 0;
} }
#endif /* __KERNEL__ */
#define pc_pointer(v) \ #define pc_pointer(v) \
((v) & ~PCMASK) ((v) & ~PCMASK)
...@@ -153,10 +151,10 @@ extern unsigned long profile_pc(struct pt_regs *regs); ...@@ -153,10 +151,10 @@ extern unsigned long profile_pc(struct pt_regs *regs);
#define profile_pc(regs) instruction_pointer(regs) #define profile_pc(regs) instruction_pointer(regs)
#endif #endif
#ifdef __KERNEL__
#define predicate(x) ((x) & 0xf0000000) #define predicate(x) ((x) & 0xf0000000)
#define PREDICATE_ALWAYS 0xe0000000 #define PREDICATE_ALWAYS 0xe0000000
#endif
#endif /* __KERNEL__ */
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
......
...@@ -83,14 +83,14 @@ struct pt_regs { ...@@ -83,14 +83,14 @@ struct pt_regs {
#define PTRACE_GETREGS 12 #define PTRACE_GETREGS 12
#define PTRACE_SETREGS 13 /* ptrace signal */ #define PTRACE_SETREGS 13 /* ptrace signal */
#ifdef CONFIG_BINFMT_ELF_FDPIC
#define PTRACE_GETFDPIC 31 #define PTRACE_GETFDPIC 31
#define PTRACE_GETFDPIC_EXEC 0 #define PTRACE_GETFDPIC_EXEC 0
#define PTRACE_GETFDPIC_INTERP 1 #define PTRACE_GETFDPIC_INTERP 1
#endif
#define PS_S (0x0002) #define PS_S (0x0002)
#ifdef __KERNEL__
/* user_mode returns true if only one bit is set in IPEND, other than the /* user_mode returns true if only one bit is set in IPEND, other than the
master interrupt enable. */ master interrupt enable. */
#define user_mode(regs) (!(((regs)->ipend & ~0x10) & (((regs)->ipend & ~0x10) - 1))) #define user_mode(regs) (!(((regs)->ipend & ~0x10) & (((regs)->ipend & ~0x10) - 1)))
...@@ -98,6 +98,8 @@ struct pt_regs { ...@@ -98,6 +98,8 @@ struct pt_regs {
#define profile_pc(regs) instruction_pointer(regs) #define profile_pc(regs) instruction_pointer(regs)
extern void show_regs(struct pt_regs *); extern void show_regs(struct pt_regs *);
#endif /* __KERNEL__ */
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
/* /*
......
header-y += ptrace.h
header-y += user.h header-y += user.h
header-y += svinto.h header-y += svinto.h
header-y += sv_addr_ag.h header-y += sv_addr_ag.h
......
...@@ -106,10 +106,14 @@ struct switch_stack { ...@@ -106,10 +106,14 @@ struct switch_stack {
unsigned long return_ip; /* ip that _resume will return to */ unsigned long return_ip; /* ip that _resume will return to */
}; };
#ifdef __KERNEL__
/* bit 8 is user-mode flag */ /* bit 8 is user-mode flag */
#define user_mode(regs) (((regs)->dccr & 0x100) != 0) #define user_mode(regs) (((regs)->dccr & 0x100) != 0)
#define instruction_pointer(regs) ((regs)->irp) #define instruction_pointer(regs) ((regs)->irp)
#define profile_pc(regs) instruction_pointer(regs) #define profile_pc(regs) instruction_pointer(regs)
extern void show_regs(struct pt_regs *); extern void show_regs(struct pt_regs *);
#endif /* __KERNEL__ */
#endif #endif
header-y += ptrace.h
header-y += user.h header-y += user.h
header-y += cryptocop.h header-y += cryptocop.h
...@@ -106,9 +106,13 @@ struct switch_stack { ...@@ -106,9 +106,13 @@ struct switch_stack {
unsigned long return_ip; /* ip that _resume will return to */ unsigned long return_ip; /* ip that _resume will return to */
}; };
#ifdef __KERNEL__
#define user_mode(regs) (((regs)->ccs & (1 << (U_CCS_BITNR + CCS_SHIFT))) != 0) #define user_mode(regs) (((regs)->ccs & (1 << (U_CCS_BITNR + CCS_SHIFT))) != 0)
#define instruction_pointer(regs) ((regs)->erp) #define instruction_pointer(regs) ((regs)->erp)
extern void show_regs(struct pt_regs *); extern void show_regs(struct pt_regs *);
#define profile_pc(regs) instruction_pointer(regs) #define profile_pc(regs) instruction_pointer(regs)
#endif /* __KERNEL__ */
#endif #endif
...@@ -4,11 +4,13 @@ ...@@ -4,11 +4,13 @@
#include <asm/arch/ptrace.h> #include <asm/arch/ptrace.h>
#ifdef __KERNEL__ #ifdef __KERNEL__
/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */ /* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */
#define PTRACE_GETREGS 12 #define PTRACE_GETREGS 12
#define PTRACE_SETREGS 13 #define PTRACE_SETREGS 13
#endif
#define profile_pc(regs) instruction_pointer(regs) #define profile_pc(regs) instruction_pointer(regs)
#endif /* __KERNEL__ */
#endif /* _CRIS_PTRACE_H */ #endif /* _CRIS_PTRACE_H */
...@@ -3,4 +3,3 @@ include include/asm-generic/Kbuild.asm ...@@ -3,4 +3,3 @@ include include/asm-generic/Kbuild.asm
header-y += registers.h header-y += registers.h
unifdef-y += termios.h unifdef-y += termios.h
unifdef-y += ptrace.h
...@@ -68,10 +68,8 @@ struct switch_stack { ...@@ -68,10 +68,8 @@ struct switch_stack {
/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */ /* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */
#define PTRACE_GETREGS 12 #define PTRACE_GETREGS 12
#define PTRACE_SETREGS 13 #define PTRACE_SETREGS 13
#ifdef CONFIG_FPU
#define PTRACE_GETFPREGS 14 #define PTRACE_GETFPREGS 14
#define PTRACE_SETFPREGS 15 #define PTRACE_SETFPREGS 15
#endif
#ifdef __KERNEL__ #ifdef __KERNEL__
......
...@@ -88,12 +88,16 @@ extern struct pt_regs *__frame; /* current frame pointer */ ...@@ -88,12 +88,16 @@ extern struct pt_regs *__frame; /* current frame pointer */
/* options set using PTRACE_SETOPTIONS */ /* options set using PTRACE_SETOPTIONS */
#define PTRACE_O_TRACESYSGOOD 0x00000001 #define PTRACE_O_TRACESYSGOOD 0x00000001
#if defined(__KERNEL__) && !defined(__ASSEMBLY__) #if defined(__KERNEL__)
#if !defined(__ASSEMBLY__)
#define user_mode(regs) (((regs)->epsw & EPSW_nSL) == EPSW_nSL) #define user_mode(regs) (((regs)->epsw & EPSW_nSL) == EPSW_nSL)
#define instruction_pointer(regs) ((regs)->pc) #define instruction_pointer(regs) ((regs)->pc)
extern void show_regs(struct pt_regs *); extern void show_regs(struct pt_regs *);
#endif #endif /* !__ASSEMBLY */
#define profile_pc(regs) ((regs)->pc) #define profile_pc(regs) ((regs)->pc)
#endif /* __KERNEL__ */
#endif /* _ASM_PTRACE_H */ #endif /* _ASM_PTRACE_H */
...@@ -33,7 +33,6 @@ struct pt_regs { ...@@ -33,7 +33,6 @@ struct pt_regs {
unsigned long ipsw; /* CR22 */ unsigned long ipsw; /* CR22 */
}; };
#define task_regs(task) ((struct pt_regs *) ((char *)(task) + TASK_REGS))
/* /*
* The numbers chosen here are somewhat arbitrary but absolutely MUST * The numbers chosen here are somewhat arbitrary but absolutely MUST
* not overlap with any of the number assigned in <linux/ptrace.h>. * not overlap with any of the number assigned in <linux/ptrace.h>.
...@@ -43,8 +42,11 @@ struct pt_regs { ...@@ -43,8 +42,11 @@ struct pt_regs {
* since we have taken branch traps too) * since we have taken branch traps too)
*/ */
#define PTRACE_SINGLEBLOCK 12 /* resume execution until next branch */ #define PTRACE_SINGLEBLOCK 12 /* resume execution until next branch */
#ifdef __KERNEL__ #ifdef __KERNEL__
#define task_regs(task) ((struct pt_regs *) ((char *)(task) + TASK_REGS))
/* XXX should we use iaoq[1] or iaoq[0] ? */ /* XXX should we use iaoq[1] or iaoq[0] ? */
#define user_mode(regs) (((regs)->iaoq[0] & 3) ? 1 : 0) #define user_mode(regs) (((regs)->iaoq[0] & 3) ? 1 : 0)
#define user_space(regs) (((regs)->iasq[1] != 0) ? 1 : 0) #define user_space(regs) (((regs)->iasq[1] != 0) ? 1 : 0)
......
...@@ -29,7 +29,6 @@ unifdef-y += elf.h ...@@ -29,7 +29,6 @@ unifdef-y += elf.h
unifdef-y += nvram.h unifdef-y += nvram.h
unifdef-y += param.h unifdef-y += param.h
unifdef-y += posix_types.h unifdef-y += posix_types.h
unifdef-y += ptrace.h
unifdef-y += seccomp.h unifdef-y += seccomp.h
unifdef-y += signal.h unifdef-y += signal.h
unifdef-y += spu_info.h unifdef-y += spu_info.h
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Copyright (C) 1999, 2000 Niibe Yutaka * Copyright (C) 1999, 2000 Niibe Yutaka
* *
*/ */
#if defined(__SH5__) || defined(CONFIG_SUPERH64) #if defined(__SH5__)
struct pt_regs { struct pt_regs {
unsigned long long pc; unsigned long long pc;
unsigned long long sr; unsigned long long sr;
......
...@@ -19,7 +19,6 @@ unifdef-y += msr.h ...@@ -19,7 +19,6 @@ unifdef-y += msr.h
unifdef-y += mtrr.h unifdef-y += mtrr.h
unifdef-y += posix_types_32.h unifdef-y += posix_types_32.h
unifdef-y += posix_types_64.h unifdef-y += posix_types_64.h
unifdef-y += ptrace.h
unifdef-y += unistd_32.h unifdef-y += unistd_32.h
unifdef-y += unistd_64.h unifdef-y += unistd_64.h
unifdef-y += vm86.h unifdef-y += vm86.h
......
...@@ -73,10 +73,10 @@ ...@@ -73,10 +73,10 @@
#define PTRACE_GETXTREGS 18 #define PTRACE_GETXTREGS 18
#define PTRACE_SETXTREGS 19 #define PTRACE_SETXTREGS 19
#ifndef __ASSEMBLY__
#ifdef __KERNEL__ #ifdef __KERNEL__
#ifndef __ASSEMBLY__
/* /*
* This struct defines the way the registers are stored on the * This struct defines the way the registers are stored on the
* kernel stack during a system call or other kernel entry. * kernel stack during a system call or other kernel entry.
...@@ -122,14 +122,14 @@ extern void show_regs(struct pt_regs *); ...@@ -122,14 +122,14 @@ extern void show_regs(struct pt_regs *);
# ifndef CONFIG_SMP # ifndef CONFIG_SMP
# define profile_pc(regs) instruction_pointer(regs) # define profile_pc(regs) instruction_pointer(regs)
# endif # endif
#endif /* __KERNEL__ */
#else /* __ASSEMBLY__ */ #else /* __ASSEMBLY__ */
#ifdef __KERNEL__
# include <asm/asm-offsets.h> # include <asm/asm-offsets.h>
#define PT_REGS_OFFSET (KERNEL_STACK_SIZE - PT_USER_SIZE) #define PT_REGS_OFFSET (KERNEL_STACK_SIZE - PT_USER_SIZE)
#endif
#endif /* !__ASSEMBLY__ */ #endif /* !__ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif /* _XTENSA_PTRACE_H */ #endif /* _XTENSA_PTRACE_H */
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