]> err.no Git - linux-2.6/blob - arch/um/sys-x86_64/ptrace.c
Merge with master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
[linux-2.6] / arch / um / sys-x86_64 / ptrace.c
1 /*
2  * Copyright 2003 PathScale, Inc.
3  *
4  * Licensed under the GPL
5  */
6
7 #define __FRAME_OFFSETS
8 #include "asm/ptrace.h"
9 #include "linux/sched.h"
10 #include "linux/errno.h"
11 #include "asm/elf.h"
12
13 /* XXX x86_64 */
14 unsigned long not_ss;
15 unsigned long not_ds;
16 unsigned long not_es;
17
18 #define SC_SS(r) (not_ss)
19 #define SC_DS(r) (not_ds)
20 #define SC_ES(r) (not_es)
21
22 /* determines which flags the user has access to. */
23 /* 1 = access 0 = no access */
24 #define FLAG_MASK 0x44dd5UL
25
26 int putreg(struct task_struct *child, int regno, unsigned long value)
27 {
28         unsigned long tmp;
29
30 #ifdef TIF_IA32
31         /* Some code in the 64bit emulation may not be 64bit clean.
32            Don't take any chances. */
33         if (test_tsk_thread_flag(child, TIF_IA32))
34                 value &= 0xffffffff;
35 #endif
36         switch (regno){
37         case FS:
38         case GS:
39         case DS:
40         case ES:
41         case SS:
42         case CS:
43                 if (value && (value & 3) != 3)
44                         return -EIO;
45                 value &= 0xffff;
46                 break;
47
48         case FS_BASE:
49         case GS_BASE:
50                 if (!((value >> 48) == 0 || (value >> 48) == 0xffff))
51                         return -EIO;
52                 break;
53
54         case EFLAGS:
55                 value &= FLAG_MASK;
56                 tmp = PT_REGS_EFLAGS(&child->thread.regs) & ~FLAG_MASK;
57                 value |= tmp;
58                 break;
59         }
60
61         PT_REGS_SET(&child->thread.regs, regno, value);
62         return 0;
63 }
64
65 int poke_user(struct task_struct *child, long addr, long data)
66 {
67         if ((addr & 3) || addr < 0)
68                 return -EIO;
69
70         if (addr < MAX_REG_OFFSET)
71                 return putreg(child, addr, data);
72
73 #if 0 /* Need x86_64 debugregs handling */
74         else if((addr >= offsetof(struct user, u_debugreg[0])) &&
75                 (addr <= offsetof(struct user, u_debugreg[7]))){
76                 addr -= offsetof(struct user, u_debugreg[0]);
77                 addr = addr >> 2;
78                 if((addr == 4) || (addr == 5)) return -EIO;
79                 child->thread.arch.debugregs[addr] = data;
80                 return 0;
81         }
82 #endif
83         return -EIO;
84 }
85
86 unsigned long getreg(struct task_struct *child, int regno)
87 {
88         unsigned long retval = ~0UL;
89         switch (regno) {
90         case FS:
91         case GS:
92         case DS:
93         case ES:
94         case SS:
95         case CS:
96                 retval = 0xffff;
97                 /* fall through */
98         default:
99                 retval &= PT_REG(&child->thread.regs, regno);
100 #ifdef TIF_IA32
101                 if (test_tsk_thread_flag(child, TIF_IA32))
102                         retval &= 0xffffffff;
103 #endif
104         }
105         return retval;
106 }
107
108 int peek_user(struct task_struct *child, long addr, long data)
109 {
110         /* read the word at location addr in the USER area. */
111         unsigned long tmp;
112
113         if ((addr & 3) || addr < 0)
114                 return -EIO;
115
116         tmp = 0;  /* Default return condition */
117         if(addr < MAX_REG_OFFSET){
118                 tmp = getreg(child, addr);
119         }
120 #if 0 /* Need x86_64 debugregs handling */
121         else if((addr >= offsetof(struct user, u_debugreg[0])) &&
122                 (addr <= offsetof(struct user, u_debugreg[7]))){
123                 addr -= offsetof(struct user, u_debugreg[0]);
124                 addr = addr >> 2;
125                 tmp = child->thread.arch.debugregs[addr];
126         }
127 #endif
128         return put_user(tmp, (unsigned long *) data);
129 }
130
131 void arch_switch(void)
132 {
133 /* XXX
134         printk("arch_switch\n");
135 */
136 }
137
138 int is_syscall(unsigned long addr)
139 {
140         panic("is_syscall");
141 }
142
143 int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu )
144 {
145         panic("dump_fpu");
146         return(1);
147 }
148
149 int get_fpregs(unsigned long buf, struct task_struct *child)
150 {
151         panic("get_fpregs");
152         return(0);
153 }
154
155 int set_fpregs(unsigned long buf, struct task_struct *child)
156 {
157         panic("set_fpregs");
158         return(0);
159 }
160
161 int get_fpxregs(unsigned long buf, struct task_struct *tsk)
162 {
163         panic("get_fpxregs");
164         return(0);
165 }
166
167 int set_fpxregs(unsigned long buf, struct task_struct *tsk)
168 {
169         panic("set_fxpregs");
170         return(0);
171 }
172
173 /*
174  * Overrides for Emacs so that we follow Linus's tabbing style.
175  * Emacs will notice this stuff at the end of the file and automatically
176  * adjust the settings for this buffer only.  This must remain at the end
177  * of the file.
178  * ---------------------------------------------------------------------------
179  * Local variables:
180  * c-file-style: "linux"
181  * End:
182  */