Commit d128ad10 authored by Stephen Rothwell's avatar Stephen Rothwell

Merge commit 'parisc/next'

Conflicts:
	arch/parisc/include/asm/thread_info.h
	arch/parisc/kernel/entry.S
	arch/parisc/kernel/signal.c
parents 963134f7 1e0d061b
......@@ -3919,6 +3919,7 @@ F: drivers/block/paride/
PARISC ARCHITECTURE
M: Kyle McMartin <kyle@mcmartin.ca>
M: Helge Deller <deller@gmx.de>
M: "James E.J. Bottomley" <jejb@parisc-linux.org>
L: linux-parisc@vger.kernel.org
W: http://www.parisc-linux.org/
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kyle/parisc-2.6.git
......
......@@ -18,6 +18,7 @@ config PARISC
select BUG
select HAVE_PERF_COUNTERS
select GENERIC_ATOMIC64 if !64BIT
select HAVE_ARCH_TRACEHOOK
help
The PA-RISC microprocessor is designed by Hewlett-Packard and used
in many of their workstations & servers (HP9000 700 and 800 series,
......
......@@ -329,6 +329,7 @@ struct pt_regs; /* forward declaration... */
#define ELF_PLAT_INIT(_r, load_addr) _r->gr[23] = 0
#define USE_ELF_CORE_DUMP
#define CORE_DUMP_USE_REGSET
#define ELF_EXEC_PAGESIZE 4096
/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
......
/* hardirq.h: PA-RISC hard IRQ support.
*
* Copyright (C) 2001 Matthew Wilcox <matthew@wil.cx>
*
* The locking is really quite interesting. There's a cpu-local
* count of how many interrupts are being handled, and a global
* lock. An interrupt can only be serviced if the global lock
* is free. You can't be sure no more interrupts are being
* serviced until you've acquired the lock and then checked
* all the per-cpu interrupt counts are all zero. It's a specialised
* br_lock, and that's exactly how Sparc does it. We don't because
* it's more locking for us. This way is lock-free in the interrupt path.
*/
#ifndef _PARISC_HARDIRQ_H
#define _PARISC_HARDIRQ_H
#include <linux/threads.h>
#include <linux/irq.h>
typedef struct {
unsigned long __softirq_pending; /* set_bit is used on this */
} ____cacheline_aligned irq_cpustat_t;
#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
void ack_bad_irq(unsigned int irq);
#include <asm-generic/hardirq.h>
#endif /* _PARISC_HARDIRQ_H */
......@@ -33,6 +33,35 @@ struct pt_regs {
unsigned long ipsw; /* CR22 */
};
/* regset as seen by PTRACE_{GET|SET}REGS and coredumps */
struct user_regset_struct {
unsigned long gr[32];
unsigned long sr[ 8];
unsigned long iaoq[2];
unsigned long iasq[2];
unsigned long sar;
unsigned long iir;
unsigned long isr;
unsigned long ior;
unsigned long cr22;
unsigned long cr0;
unsigned long cr24;
unsigned long cr25;
unsigned long cr26;
unsigned long cr27;
unsigned long cr28;
unsigned long cr29;
unsigned long cr30;
unsigned long cr31;
unsigned long cr8;
unsigned long cr9;
unsigned long cr12;
unsigned long cr13;
unsigned long cr10;
unsigned long cr15;
unsigned long __pad0[16]; /* ELF_NGREG is 80, pad it out */
};
/*
* The numbers chosen here are somewhat arbitrary but absolutely MUST
* not overlap with any of the number assigned in <linux/ptrace.h>.
......@@ -42,6 +71,10 @@ struct pt_regs {
* since we have taken branch traps too)
*/
#define PTRACE_SINGLEBLOCK 12 /* resume execution until next branch */
#define PTRACE_GETREGS 13
#define PTRACE_SETREGS 14
#define PTRACE_GETFPREGS 18
#define PTRACE_SETFPREGS 19
#ifdef __KERNEL__
......@@ -59,8 +92,11 @@ void user_enable_block_step(struct task_struct *task);
#define user_mode(regs) (((regs)->iaoq[0] & 3) ? 1 : 0)
#define user_space(regs) (((regs)->iasq[1] != 0) ? 1 : 0)
#define instruction_pointer(regs) ((regs)->iaoq[0] & ~3)
#define user_stack_pointer(regs) ((regs)->gr[30])
unsigned long profile_pc(struct pt_regs *);
extern void show_regs(struct pt_regs *);
#endif
#endif /* __KERNEL__ */
#endif
/* syscall.h */
#ifndef _ASM_PARISC_SYSCALL_H_
#define _ASM_PARISC_SYSCALL_H_
#include <linux/err.h>
#include <asm/ptrace.h>
static inline long syscall_get_nr(struct task_struct *tsk,
struct pt_regs *regs)
{
return regs->gr[20];
}
static inline void syscall_get_arguments(struct task_struct *tsk,
struct pt_regs *regs, unsigned int i,
unsigned int n, unsigned long *args)
{
BUG_ON(i);
switch (n) {
case 6:
args[5] = regs->gr[21];
case 5:
args[4] = regs->gr[22];
case 4:
args[3] = regs->gr[23];
case 3:
args[2] = regs->gr[24];
case 2:
args[1] = regs->gr[25];
case 1:
args[0] = regs->gr[26];
break;
default:
BUG();
}
}
#endif /*_ASM_PARISC_SYSCALL_H_*/
......@@ -59,7 +59,9 @@ struct thread_info {
#define TIF_MEMDIE 5
#define TIF_RESTORE_SIGMASK 6 /* restore saved signal mask */
#define TIF_FREEZE 7 /* is freezing for suspend */
#define TIF_NOTIFY_RESUME 8 /* callback before returning to user */
#define TIF_NOTIFY_RESUME 8 /* tracing notification pending */
#define TIF_SINGLESTEP 9 /* single stepping? */
#define TIF_BLOCKSTEP 10 /* branch stepping? */
#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
......@@ -69,9 +71,11 @@ struct thread_info {
#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
#define _TIF_FREEZE (1 << TIF_FREEZE)
#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
#define _TIF_BLOCKSTEP (1 << TIF_BLOCKSTEP)
#define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | \
_TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
#define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | \
_TIF_NOTIFY_RESUME)
#endif /* __KERNEL__ */
......
......@@ -270,8 +270,8 @@ int main(void)
DEFINE(DTLB_OFF_COUNT, offsetof(struct pdc_cache_info, dt_off_count));
DEFINE(DTLB_LOOP, offsetof(struct pdc_cache_info, dt_loop));
BLANK();
DEFINE(PA_BLOCKSTEP_BIT, 31-PT_BLOCKSTEP_BIT);
DEFINE(PA_SINGLESTEP_BIT, 31-PT_SINGLESTEP_BIT);
DEFINE(TIF_BLOCKSTEP_PA_BIT, 31-TIF_BLOCKSTEP);
DEFINE(TIF_SINGLESTEP_PA_BIT, 31-TIF_SINGLESTEP);
BLANK();
DEFINE(ASM_PMD_SHIFT, PMD_SHIFT);
DEFINE(ASM_PGDIR_SHIFT, PGDIR_SHIFT);
......
......@@ -948,7 +948,7 @@ intr_check_sig:
/* As above */
mfctl %cr30,%r1
LDREG TI_FLAGS(%r1),%r19
ldi (_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK|_TIF_NOTIFY_RESUME), %r20
ldi _TIF_DO_NOTIFY_RESUME_MASK, %r20
and,COND(<>) %r19, %r20, %r0
b,n intr_restore /* skip past if we've nothing to do */
......@@ -2019,7 +2019,7 @@ syscall_check_resched:
.import do_signal,code
syscall_check_sig:
LDREG TI_FLAGS-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r19
ldi (_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK), %r26
ldi _TIF_DO_NOTIFY_RESUME_MASK, %r26
and,COND(<>) %r19, %r26, %r0
b,n syscall_restore /* skip past if we've nothing to do */
......@@ -2047,12 +2047,13 @@ syscall_do_signal:
b,n syscall_check_sig
syscall_restore:
/* Are we being ptraced? */
LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1
ldw TASK_PTRACE(%r1), %r19
bb,< %r19,31,syscall_restore_rfi
nop
/* Are we being ptraced? */
ldw TASK_FLAGS(%r1),%r19
ldi (_TIF_SINGLESTEP|_TIF_BLOCKSTEP),%r2
and,COND(=) %r19,%r2,%r0
b,n syscall_restore_rfi
ldo TASK_PT_FR31(%r1),%r19 /* reload fpregs */
rest_fp %r19
......@@ -2113,16 +2114,16 @@ syscall_restore_rfi:
ldi 0x0b,%r20 /* Create new PSW */
depi -1,13,1,%r20 /* C, Q, D, and I bits */
/* The values of PA_SINGLESTEP_BIT and PA_BLOCKSTEP_BIT are
* set in include/linux/ptrace.h and converted to PA bitmap
* numbers in asm-offsets.c */
/* if ((%r19.PA_SINGLESTEP_BIT)) { %r20.27=1} */
extru,= %r19,PA_SINGLESTEP_BIT,1,%r0
/* The values of SINGLESTEP_BIT and BLOCKSTEP_BIT are
* set in thread_info.h and converted to PA bitmap
* numbers in asm-offsets.c
*/
/* if ((%r19.SINGLESTEP_BIT)) { %r20.27=1} */
extru,= %r19,TIF_SINGLESTEP_PA_BIT,1,%r0
depi -1,27,1,%r20 /* R bit */
/* if ((%r19.PA_BLOCKSTEP_BIT)) { %r20.7=1} */
extru,= %r19,PA_BLOCKSTEP_BIT,1,%r0
/* if ((%r19.BLOCKSTEP_BIT)) { %r20.7=1} */
extru,= %r19,TIF_BLOCKSTEP_PA_BIT,1,%r0
depi -1,7,1,%r20 /* T bit */
STREG %r20,TASK_PT_PSW(%r1)
......
......@@ -423,8 +423,3 @@ void __init init_IRQ(void)
set_eiem(cpu_eiem); /* EIEM : enable all external intr */
}
void ack_bad_irq(unsigned int irq)
{
printk(KERN_WARNING "unexpected IRQ %d\n", irq);
}
......@@ -893,7 +893,7 @@ int module_finalize(const Elf_Ehdr *hdr,
* ourselves */
for (i = 1; i < hdr->e_shnum; i++) {
if(sechdrs[i].sh_type == SHT_SYMTAB
&& (sechdrs[i].sh_type & SHF_ALLOC)) {
&& (sechdrs[i].sh_flags & SHF_ALLOC)) {
int strindex = sechdrs[i].sh_link;
/* FIXME: AWFUL HACK
* The cast is to drop the const from
......
......@@ -5,6 +5,7 @@
* Copyright (C) 2000 Matthew Wilcox <matthew@wil.cx>
* Copyright (C) 2000 David Huggins-Daines <dhd@debian.org>
* Copyright (C) 2008 Helge Deller <deller@gmx.de>
* Copyright (C) 2009 Kyle McMartin <kyle@redhat.com>
*/
#include <linux/kernel.h>
......@@ -13,11 +14,14 @@
#include <linux/smp.h>
#include <linux/errno.h>
#include <linux/ptrace.h>
#include <linux/tracehook.h>
#include <linux/user.h>
#include <linux/personality.h>
#include <linux/security.h>
#include <linux/compat.h>
#include <linux/signal.h>
#include <linux/regset.h>
#include <linux/elf.h>
#include <asm/uaccess.h>
#include <asm/pgtable.h>
......@@ -35,7 +39,7 @@
*/
void ptrace_disable(struct task_struct *task)
{
task->ptrace &= ~(PT_SINGLESTEP|PT_BLOCKSTEP);
clear_tsk_thread_flag(task, TIF_SINGLESTEP|TIF_BLOCKSTEP);
/* make sure the trap bits are not set */
pa_psw(task)->r = 0;
......@@ -55,8 +59,8 @@ void user_disable_single_step(struct task_struct *task)
void user_enable_single_step(struct task_struct *task)
{
task->ptrace &= ~PT_BLOCKSTEP;
task->ptrace |= PT_SINGLESTEP;
clear_tsk_thread_flag(task, TIF_BLOCKSTEP);
set_tsk_thread_flag(task, TIF_SINGLESTEP);
if (pa_psw(task)->n) {
struct siginfo si;
......@@ -98,8 +102,8 @@ void user_enable_single_step(struct task_struct *task)
void user_enable_block_step(struct task_struct *task)
{
task->ptrace &= ~PT_SINGLESTEP;
task->ptrace |= PT_BLOCKSTEP;
clear_tsk_thread_flag(task, TIF_SINGLESTEP);
set_tsk_thread_flag(task, TIF_BLOCKSTEP);
/* Enable taken branch trap. */
pa_psw(task)->r = 0;
......@@ -108,6 +112,393 @@ void user_enable_block_step(struct task_struct *task)
pa_psw(task)->l = 0;
}
/* extra regs not saved in pt_regs, written when ejecting core */
static inline void fill_specials(unsigned long *regs)
{
int i = 0;
#define SAVE_CR(cr) regs[i++] = mfctl(cr)
SAVE_CR(22); SAVE_CR( 0);
SAVE_CR(24); SAVE_CR(25);
SAVE_CR(26); SAVE_CR(27);
SAVE_CR(28); SAVE_CR(29);
SAVE_CR(30); SAVE_CR(31);
SAVE_CR( 8); SAVE_CR( 9);
SAVE_CR(12); SAVE_CR(13);
SAVE_CR(10); SAVE_CR(15);
#undef SAVE_CR
}
/* save thread state in regset. this does extra work compared to the gr_set
* function since we save extra magic in coredumps, that we don't let
* userspace play with. (protection registers and the like.)
*/
static int gr_get(struct task_struct *tsk, const struct user_regset *regset,
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf)
{
const struct pt_regs *regs = task_pt_regs(tsk);
unsigned long cr[16];
unsigned long *kbuf_reg = kbuf, *ubuf_reg = ubuf; /* register view */
int ret;
/* 32 gprs, %r0 ... %r31 */
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &regs->gr[0],
0, 32 * sizeof(unsigned long));
if (ret)
goto out;
/* %sr0 ... %sr7 */
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &regs->sr[0],
0, 8 * sizeof(unsigned long));
if (ret)
goto out;
/* extra magic stuff we need for coredumps
* sadly we can't just chunk through pt_regs... sigh.
*/
#define SAVE_REG(r) ({ \
if (count <= 0) \
goto out; \
if (kbuf) \
*kbuf_reg++ = (r); \
else \
ret = __put_user((r), ubuf_reg++); \
if (ret < 0) \
goto out; \
++pos, --count; \
})
SAVE_REG(regs->iaoq[0]); SAVE_REG(regs->iaoq[1]);
SAVE_REG(regs->iasq[0]); SAVE_REG(regs->iasq[1]);
SAVE_REG(regs->sar); SAVE_REG(regs->iir);
SAVE_REG(regs->isr); SAVE_REG(regs->ior);
#undef SAVE_REG
ubuf = ubuf_reg, kbuf = kbuf_reg;
fill_specials(cr);
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &cr,
0, ARRAY_SIZE(cr));
out:
return ret;
}
/* fill in struct pt_regs from a regset. */
static int gr_set(struct task_struct *tsk, const struct user_regset *regset,
unsigned int pos, unsigned int count,
const void *kbuf, const void __user *ubuf)
{
struct pt_regs *regs = task_pt_regs(tsk);
unsigned long psw;
const unsigned long *ubuf_reg = ubuf, *kbuf_reg = kbuf;
int ret;
/* spirit away our PSW, which is in %r0. and only let the user update
* USER_PSW_BITS.
*/
psw = regs->gr[0];
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &regs->gr[0],
0, 32 * sizeof(long));
if (regs->gr[0] != psw)
regs->gr[0] = (psw & ~USER_PSW_BITS) | (regs->gr[0] & USER_PSW_BITS);
if (ret || count <= 0)
goto out;
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &regs->sr[0],
0, 8 * sizeof(long));
if (ret || count <= 0)
goto out;
/* additional magics (iaoq, iasq, ior, etc.) */
#define RESTORE_REG(r) ({ \
if (count <= 0) \
goto out; \
if (kbuf) \
(r) = *kbuf_reg++; \
else { \
ret = __get_user((r), ubuf_reg++); \
if (ret < 0) \
goto out; \
} \
++pos, --count; \
})
RESTORE_REG(regs->iaoq[0]); RESTORE_REG(regs->iaoq[1]);
RESTORE_REG(regs->iasq[0]); RESTORE_REG(regs->iasq[1]);
RESTORE_REG(regs->sar); RESTORE_REG(regs->iir);
RESTORE_REG(regs->isr); RESTORE_REG(regs->ior);
#undef RESTORE_REG
ubuf = ubuf_reg, kbuf = kbuf_reg;
out:
return ret;
}
/* thankfully our floating point is sensible. */
static int fr_get(struct task_struct *tsk, const struct user_regset *regset,
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf)
{
struct pt_regs *regs = task_pt_regs(tsk);
int ret;
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &regs->fr[0],
0, ELF_NFPREG * sizeof(double));
return ret;
}
static int fr_set(struct task_struct *tsk, const struct user_regset *regset,
unsigned int pos, unsigned int count,
const void *kbuf, const void __user *ubuf)
{
struct pt_regs *regs = task_pt_regs(tsk);
int ret;
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &regs->fr[0],
0, ELF_NFPREG * sizeof(double));
return ret;
}
enum pa_regset {
REGSET_GR,
REGSET_FR,
};
static const struct user_regset pa_regsets[] = {
[REGSET_GR] = {
.core_note_type = NT_PRSTATUS,
.n = ELF_NGREG,
.size = sizeof(long),
.align = sizeof(long),
.get = gr_get,
.set = gr_set,
},
[REGSET_FR] = {
.core_note_type = NT_PRFPREG,
.n = ELF_NFPREG,
.size = sizeof(double),
.align = sizeof(double),
.get = fr_get,
.set = fr_set,
},
};
static const struct user_regset_view user_parisc_native_view = {
.name = "parisc",
.e_machine = EM_PARISC,
.ei_osabi = ELFOSABI_LINUX,
.regsets = pa_regsets,
.n = ARRAY_SIZE(pa_regsets),
};
#ifdef CONFIG_COMPAT
/* unmitigated bullshit abounds */
static int gr_get_compat(struct task_struct *tsk,
const struct user_regset *regset,
unsigned int pos, unsigned int count,
void *_kbuf, void __user *_ubuf)
{
struct pt_regs *regs = task_pt_regs(tsk);
compat_ulong_t *kbuf = _kbuf;
compat_ulong_t __user *ubuf = _ubuf;
compat_ulong_t psw, reg;
unsigned long cr[16];
int i, ret = 0;
pos /= sizeof(reg);
count /= sizeof(reg);
/* gprs, with some evil */
psw = regs->gr[0];
if (kbuf)
for (i = 0; count > 0 && i < 32; count--, pos++)
*kbuf++ = (compat_ulong_t)(regs->gr[i++]);
else
for (i = 0; count > 0 && i < 32; count--, pos++) {
ret = __put_user((compat_ulong_t)regs->gr[i++], ubuf++);
if (ret < 0)
goto out;
}
if (regs->gr[0] != psw)
regs->gr[0] = (psw & ~USER_PSW_BITS) | (regs->gr[0] & USER_PSW_BITS);
/* space registers */
if (kbuf)
for (i = 0; count > 0 && i < 8; count--, pos++)
*kbuf++ = (compat_ulong_t)(regs->sr[i++]);
else
for (i = 0; count > 0 && i < 8; count--, pos++) {
ret = __put_user((compat_ulong_t)regs->sr[i++], ubuf++);
if (ret < 0)
goto out;
}
/* all the other bollocks we need in our coredump */
#define SAVE_REG(r) ({ \
if (count <= 0) \
goto out; \
if (kbuf) \
*kbuf++ = (compat_ulong_t)((r)); \
else \
ret = __put_user((compat_ulong_t)(r), ubuf++); \
if (ret < 0) \
goto out; \
++pos, --count; \
})
SAVE_REG(regs->iaoq[0]); SAVE_REG(regs->iaoq[1]);
SAVE_REG(regs->iasq[0]); SAVE_REG(regs->iasq[1]);
SAVE_REG(regs->sar); SAVE_REG(regs->iir);
SAVE_REG(regs->isr); SAVE_REG(regs->ior);
fill_specials(cr);
for (i = 0; i < 16; count--, pos++)
SAVE_REG(cr[i++]);
#undef SAVE_REG
/* that should bring us up to 64*sizeof(ulong_t || compat_ulong_t) */
_kbuf = kbuf;
_ubuf = ubuf;
pos *= sizeof(reg);
count *= sizeof(reg);
ret = user_regset_copyout_zero(&pos, &count, &_kbuf, &_ubuf,
64 * sizeof(reg), -1);
out:
return ret;
}
/* thankfully we get to avoid the %cr saving we do in _get, since
* ptrace doesn't need to touch it.
*/
static int gr_set_compat(struct task_struct *tsk,
const struct user_regset *regset,
unsigned int pos, unsigned int count,
const void *_kbuf, const void __user *_ubuf)
{
struct pt_regs *regs = task_pt_regs(tsk);
const compat_ulong_t *kbuf = _kbuf;
const compat_ulong_t __user *ubuf = _ubuf;
compat_ulong_t reg;
int ret = 0;
/* if i can't smoke and swear, i'm *fucked* */
pos /= sizeof(reg);
count /= sizeof(reg);
/* 32 gprs @ 4-bytes a piece */
if (kbuf)
for (; count > 0 && pos < 32; --count)
regs->gr[pos++] = *kbuf++;
else
for (; count > 0 && pos < 32; --count) {
ret = __get_user(reg, ubuf++);
if (ret < 0)
goto out;
regs->gr[pos++] = reg;
}
/* 8 space registers */
if (kbuf)
for (; count > 0 && pos < 8; --count)
regs->sr[pos++] = *kbuf++;
else
for (; count > 0 && pos < 8; --count) {
ret = __get_user(reg, ubuf++);
if (ret < 0)
goto out;
regs->sr[pos++] = reg;
}
/* additional magics (iaoq, iasq, ior, etc.) */
#define RESTORE_REG(r) ({ \
if (count <= 0) \
goto out; \
if (kbuf) \
(r) = *kbuf++; \
else { \
ret = __get_user(reg, ubuf++); \
if (ret < 0) \
goto out; \
(r) = reg; \
} \
++pos, --count; \
})
RESTORE_REG(regs->iaoq[0]); RESTORE_REG(regs->iaoq[1]);
RESTORE_REG(regs->iasq[0]); RESTORE_REG(regs->iasq[1]);
RESTORE_REG(regs->sar); RESTORE_REG(regs->iir);
RESTORE_REG(regs->isr); RESTORE_REG(regs->ior);
#undef RESTORE_REG
/* update our position */
_kbuf = kbuf;
_ubuf = ubuf;
out:
return ret;
}
static const struct user_regset pa_regsets_compat[] = {
[REGSET_GR] = {
.core_note_type = NT_PRSTATUS,
.n = ELF_NGREG,
.size = sizeof(compat_long_t),
.align = sizeof(compat_long_t),
.get = gr_get_compat,
.set = gr_set_compat,
},
/* no need, fpr are fortunately always 64-bit */
[REGSET_FR] = {
.core_note_type = NT_PRFPREG,
.n = ELF_NFPREG,
.size = sizeof(double),
.align = sizeof(double),
.get = fr_get,
.set = fr_set,
},
};
static const struct user_regset_view user_parisc_compat_view = {
.name = "parisc",
.e_machine = EM_PARISC,
.ei_osabi = ELFOSABI_LINUX,
.regsets = pa_regsets_compat,
.n = ARRAY_SIZE(pa_regsets_compat),
};
#endif /* CONFIG_COMPAT */
const struct user_regset_view *task_user_regset_view(struct task_struct *t)
{
#ifdef CONFIG_COMPAT
if (__is_compat_task(t))
return &user_parisc_compat_view;
#endif
return &user_parisc_native_view;
}
static inline int regset_size(struct task_struct *t, enum pa_regset r)
{
#ifdef CONFIG_COMPAT
if (__is_compat_task(t))
return user_parisc_compat_view.regsets[r].n *
user_parisc_compat_view.regsets[r].size;
#endif
return user_parisc_native_view.regsets[r].n *
user_parisc_native_view.regsets[r].size;
}
static inline void __user *regset_ptr(struct task_struct *t, long data)
{
#ifdef CONFIG_COMPAT
if (__is_compat_task(t))
return (void __user *)compat_ptr(data);
#endif
return (void *)data;
}
long arch_ptrace(struct task_struct *child, long request, long addr, long data)
{
unsigned long tmp;
......@@ -161,6 +552,26 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
}
break;
case PTRACE_GETREGS:
return copy_regset_to_user(child, task_user_regset_view(child),
REGSET_GR, 0, regset_size(child, REGSET_GR),
regset_ptr(child, data));
case PTRACE_SETREGS:
return copy_regset_from_user(child, task_user_regset_view(child),
REGSET_GR, 0, regset_size(child, REGSET_GR),
(const void __user *)regset_ptr(child, data));
case PTRACE_GETFPREGS:
return copy_regset_to_user(child, task_user_regset_view(child),
REGSET_FR, 0, regset_size(child, REGSET_FR),
regset_ptr(child, data));
case PTRACE_SETFPREGS:
return copy_regset_from_user(child, task_user_regset_view(child),
REGSET_FR, 0, regset_size(child, REGSET_FR),
(const void __user *)regset_ptr(child, data));
default:
ret = ptrace_request(child, request, addr, data);
break;
......@@ -254,6 +665,13 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
}
break;
case PTRACE_GETREGS:
case PTRACE_SETREGS:
case PTRACE_GETFPREGS:
case PTRACE_SETFPREGS:
ret = arch_ptrace(child, request, addr, data);
break;
default:
ret = compat_ptrace_request(child, request, addr, data);
break;
......@@ -263,22 +681,19 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
}
#endif
long do_syscall_trace_enter(struct pt_regs *regs)
{
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
tracehook_report_syscall_entry(regs))
return -1L;
void syscall_trace(void)
return regs->gr[20];
}
void do_syscall_trace_exit(struct pt_regs *regs)
{
if (!test_thread_flag(TIF_SYSCALL_TRACE))
return;
if (!(current->ptrace & PT_PTRACED))
return;
ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
? 0x80 : 0));
/*
* this isn't the same as continuing with a signal, but it will do
* for normal use. strace only continues with a signal if the
* stopping signal is not SIGTRAP. -brl
*/
if (current->exit_code) {
send_sig(current->exit_code, current, 1);
current->exit_code = 0;
}
int stepping = test_thread_flag(TIF_SINGLESTEP|TIF_BLOCKSTEP);
if (stepping || test_thread_flag(TIF_SYSCALL_TRACE))
tracehook_report_syscall_exit(regs, stepping);
}
......@@ -21,6 +21,7 @@
#include <linux/errno.h>
#include <linux/wait.h>
#include <linux/ptrace.h>
#include <linux/tracehook.h>
#include <linux/unistd.h>
#include <linux/stddef.h>
#include <linux/compat.h>
......@@ -468,6 +469,9 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
sigaddset(&current->blocked,sig);
recalc_sigpending();
spin_unlock_irq(&current->sighand->siglock);
tracehook_signal_handler(sig, info, ka, regs, 0);
return 1;
}
......
......@@ -288,18 +288,23 @@ tracesys:
STREG %r18,PT_GR18(%r2)
/* Finished saving things for the debugger */
ldil L%syscall_trace,%r1
copy %r2,%r26
ldil L%do_syscall_trace_enter,%r1
ldil L%tracesys_next,%r2
be R%syscall_trace(%sr7,%r1)
be R%do_syscall_trace_enter(%sr7,%r1)
ldo R%tracesys_next(%r2),%r2
tracesys_next:
tracesys_next:
/* do_syscall_trace_enter either returned the syscallno, or -1L,
* so we skip restoring the PT_GR20 below, since we pulled it from
* task->thread.regs.gr[20] above.
*/
copy %ret0,%r20
ldil L%sys_call_table,%r1
ldo R%sys_call_table(%r1), %r19
ldo -THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1 /* get task ptr */
LDREG TI_TASK(%r1), %r1
LDREG TASK_PT_GR20(%r1), %r20
LDREG TASK_PT_GR26(%r1), %r26 /* Restore the users args */
LDREG TASK_PT_GR25(%r1), %r25
LDREG TASK_PT_GR24(%r1), %r24
......@@ -336,7 +341,8 @@ tracesys_exit:
#ifdef CONFIG_64BIT
ldo -16(%r30),%r29 /* Reference param save area */
#endif
bl syscall_trace, %r2
ldo TASK_REGS(%r1),%r26
bl do_syscall_trace_exit,%r2
STREG %r28,TASK_PT_GR28(%r1) /* save return value now */
ldo -THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1 /* get task ptr */
LDREG TI_TASK(%r1), %r1
......@@ -353,12 +359,12 @@ tracesys_exit:
tracesys_sigexit:
ldo -THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1 /* get task ptr */
LDREG 0(%r1), %r1
LDREG TI_TASK(%r1), %r1
#ifdef CONFIG_64BIT
ldo -16(%r30),%r29 /* Reference param save area */
#endif
bl syscall_trace, %r2
nop
bl do_syscall_trace_exit,%r2
ldo TASK_REGS(%r1),%r26
ldil L%syscall_exit_rfi,%r1
be,n R%syscall_exit_rfi(%sr7,%r1)
......
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