Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 79879
b: refs/heads/master
c: e4aed6c
h: refs/heads/master
i:
  79877: cd61546
  79875: babf839
  79871: 60968cb
v: v3
  • Loading branch information
Roland McGrath authored and Ingo Molnar committed Jan 30, 2008
1 parent a397be9 commit cf2e2d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 49 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 62a97d447b511bf4f0f0aa8cdccfb9ed1c934c8b
refs/heads/master: e4aed6cc45f06acd35e3dfbbaf632c5d5aa897c0
60 changes: 12 additions & 48 deletions trunk/arch/x86/kernel/ptrace_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,44 +42,6 @@
*/
#define FLAG_MASK 0x54dd5UL

/*
* eflags and offset of eflags on child stack..
*/
#define EFLAGS offsetof(struct pt_regs, eflags)
#define EFL_OFFSET ((int)(EFLAGS-sizeof(struct pt_regs)))

/*
* this routine will get a word off of the processes privileged stack.
* the offset is how far from the base addr as stored in the TSS.
* this routine assumes that all the privileged stacks are in our
* data space.
*/
static inline unsigned long get_stack_long(struct task_struct *task, int offset)
{
unsigned char *stack;

stack = (unsigned char *)task->thread.rsp0;
stack += offset;
return (*((unsigned long *)stack));
}

/*
* this routine will put a word on the processes privileged stack.
* the offset is how far from the base addr as stored in the TSS.
* this routine assumes that all the privileged stacks are in our
* data space.
*/
static inline long put_stack_long(struct task_struct *task, int offset,
unsigned long data)
{
unsigned char * stack;

stack = (unsigned char *) task->thread.rsp0;
stack += offset;
*(unsigned long *) stack = data;
return 0;
}

/*
* Called by kernel/ptrace.c when detaching..
*
Expand All @@ -90,11 +52,16 @@ void ptrace_disable(struct task_struct *child)
user_disable_single_step(child);
}

static unsigned long *pt_regs_access(struct pt_regs *regs, unsigned long offset)
{
BUILD_BUG_ON(offsetof(struct pt_regs, r15) != 0);
return &regs->r15 + (offset / sizeof(regs->r15));
}

static int putreg(struct task_struct *child,
unsigned long regno, unsigned long value)
{
unsigned long tmp;

struct pt_regs *regs = task_pt_regs(child);
switch (regno) {
case offsetof(struct user_regs_struct,fs):
if (value && (value & 3) != 3)
Expand Down Expand Up @@ -152,22 +119,21 @@ static int putreg(struct task_struct *child,
clear_tsk_thread_flag(child, TIF_FORCED_TF);
else if (test_tsk_thread_flag(child, TIF_FORCED_TF))
value |= X86_EFLAGS_TF;
tmp = get_stack_long(child, EFL_OFFSET);
tmp &= ~FLAG_MASK;
value |= tmp;
value |= regs->eflags & ~FLAG_MASK;
break;
case offsetof(struct user_regs_struct,cs):
if ((value & 3) != 3)
return -EIO;
value &= 0xffff;
break;
}
put_stack_long(child, regno - sizeof(struct pt_regs), value);
*pt_regs_access(regs, regno) = value;
return 0;
}

static unsigned long getreg(struct task_struct *child, unsigned long regno)
{
struct pt_regs *regs = task_pt_regs(child);
unsigned long val;
switch (regno) {
case offsetof(struct user_regs_struct, fs):
Expand Down Expand Up @@ -202,16 +168,14 @@ static unsigned long getreg(struct task_struct *child, unsigned long regno)
/*
* If the debugger set TF, hide it from the readout.
*/
regno = regno - sizeof(struct pt_regs);
val = get_stack_long(child, regno);
val = regs->eflags;
if (test_tsk_thread_flag(child, TIF_IA32))
val &= 0xffffffff;
if (test_tsk_thread_flag(child, TIF_FORCED_TF))
val &= ~X86_EFLAGS_TF;
return val;
default:
regno = regno - sizeof(struct pt_regs);
val = get_stack_long(child, regno);
val = *pt_regs_access(regs, regno);
if (test_tsk_thread_flag(child, TIF_IA32))
val &= 0xffffffff;
return val;
Expand Down

0 comments on commit cf2e2d9

Please sign in to comment.