~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/um/ptrace_64.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/x86/um/ptrace_64.c (Architecture sparc) and /arch/mips/um/ptrace_64.c (Architecture mips)


  1 /*                                                  1 
  2  * Copyright 2003 PathScale, Inc.                 
  3  * Copyright (C) 2003 - 2007 Jeff Dike (jdike@    
  4  *                                                
  5  * Licensed under the GPL                         
  6  */                                               
  7                                                   
  8 #include <linux/mm.h>                             
  9 #include <linux/sched.h>                          
 10 #include <linux/errno.h>                          
 11 #define __FRAME_OFFSETS                           
 12 #include <asm/ptrace.h>                           
 13 #include <linux/uaccess.h>                        
 14 #include <registers.h>                            
 15 #include <asm/ptrace-abi.h>                       
 16                                                   
 17 /*                                                
 18  * determines which flags the user has access     
 19  * 1 = access 0 = no access                       
 20  */                                               
 21 #define FLAG_MASK 0x44dd5UL                       
 22                                                   
 23 static const int reg_offsets[] =                  
 24 {                                                 
 25         [R8 >> 3] = HOST_R8,                      
 26         [R9 >> 3] = HOST_R9,                      
 27         [R10 >> 3] = HOST_R10,                    
 28         [R11 >> 3] = HOST_R11,                    
 29         [R12 >> 3] = HOST_R12,                    
 30         [R13 >> 3] = HOST_R13,                    
 31         [R14 >> 3] = HOST_R14,                    
 32         [R15 >> 3] = HOST_R15,                    
 33         [RIP >> 3] = HOST_IP,                     
 34         [RSP >> 3] = HOST_SP,                     
 35         [RAX >> 3] = HOST_AX,                     
 36         [RBX >> 3] = HOST_BX,                     
 37         [RCX >> 3] = HOST_CX,                     
 38         [RDX >> 3] = HOST_DX,                     
 39         [RSI >> 3] = HOST_SI,                     
 40         [RDI >> 3] = HOST_DI,                     
 41         [RBP >> 3] = HOST_BP,                     
 42         [CS >> 3] = HOST_CS,                      
 43         [SS >> 3] = HOST_SS,                      
 44         [FS_BASE >> 3] = HOST_FS_BASE,            
 45         [GS_BASE >> 3] = HOST_GS_BASE,            
 46         [DS >> 3] = HOST_DS,                      
 47         [ES >> 3] = HOST_ES,                      
 48         [FS >> 3] = HOST_FS,                      
 49         [GS >> 3] = HOST_GS,                      
 50         [EFLAGS >> 3] = HOST_EFLAGS,              
 51         [ORIG_RAX >> 3] = HOST_ORIG_AX,           
 52 };                                                
 53                                                   
 54 int putreg(struct task_struct *child, int regn    
 55 {                                                 
 56         switch (regno) {                          
 57         case R8:                                  
 58         case R9:                                  
 59         case R10:                                 
 60         case R11:                                 
 61         case R12:                                 
 62         case R13:                                 
 63         case R14:                                 
 64         case R15:                                 
 65         case RIP:                                 
 66         case RSP:                                 
 67         case RAX:                                 
 68         case RBX:                                 
 69         case RCX:                                 
 70         case RDX:                                 
 71         case RSI:                                 
 72         case RDI:                                 
 73         case RBP:                                 
 74                 break;                            
 75                                                   
 76         case ORIG_RAX:                            
 77                 /* Update the syscall number.     
 78                 UPT_SYSCALL_NR(&child->thread.    
 79                 break;                            
 80                                                   
 81         case FS:                                  
 82         case GS:                                  
 83         case DS:                                  
 84         case ES:                                  
 85         case SS:                                  
 86         case CS:                                  
 87                 if (value && (value & 3) != 3)    
 88                         return -EIO;              
 89                 value &= 0xffff;                  
 90                 break;                            
 91                                                   
 92         case FS_BASE:                             
 93         case GS_BASE:                             
 94                 if (!((value >> 48) == 0 || (v    
 95                         return -EIO;              
 96                 break;                            
 97                                                   
 98         case EFLAGS:                              
 99                 value &= FLAG_MASK;               
100                 child->thread.regs.regs.gp[HOS    
101                 return 0;                         
102                                                   
103         default:                                  
104                 panic("Bad register in putreg(    
105         }                                         
106                                                   
107         child->thread.regs.regs.gp[reg_offsets    
108         return 0;                                 
109 }                                                 
110                                                   
111 int poke_user(struct task_struct *child, long     
112 {                                                 
113         if ((addr & 3) || addr < 0)               
114                 return -EIO;                      
115                                                   
116         if (addr < MAX_REG_OFFSET)                
117                 return putreg(child, addr, dat    
118         else if ((addr >= offsetof(struct user    
119                 (addr <= offsetof(struct user,    
120                 addr -= offsetof(struct user,     
121                 addr = addr >> 3;                 
122                 if ((addr == 4) || (addr == 5)    
123                         return -EIO;              
124                 child->thread.arch.debugregs[a    
125                 return 0;                         
126         }                                         
127         return -EIO;                              
128 }                                                 
129                                                   
130 unsigned long getreg(struct task_struct *child    
131 {                                                 
132         unsigned long mask = ~0UL;                
133                                                   
134         switch (regno) {                          
135         case R8:                                  
136         case R9:                                  
137         case R10:                                 
138         case R11:                                 
139         case R12:                                 
140         case R13:                                 
141         case R14:                                 
142         case R15:                                 
143         case RIP:                                 
144         case RSP:                                 
145         case RAX:                                 
146         case RBX:                                 
147         case RCX:                                 
148         case RDX:                                 
149         case RSI:                                 
150         case RDI:                                 
151         case RBP:                                 
152         case ORIG_RAX:                            
153         case EFLAGS:                              
154         case FS_BASE:                             
155         case GS_BASE:                             
156                 break;                            
157         case FS:                                  
158         case GS:                                  
159         case DS:                                  
160         case ES:                                  
161         case SS:                                  
162         case CS:                                  
163                 mask = 0xffff;                    
164                 break;                            
165         default:                                  
166                 panic("Bad register in getreg:    
167         }                                         
168         return mask & child->thread.regs.regs.    
169 }                                                 
170                                                   
171 int peek_user(struct task_struct *child, long     
172 {                                                 
173         /* read the word at location addr in t    
174         unsigned long tmp;                        
175                                                   
176         if ((addr & 3) || addr < 0)               
177                 return -EIO;                      
178                                                   
179         tmp = 0;  /* Default return condition     
180         if (addr < MAX_REG_OFFSET)                
181                 tmp = getreg(child, addr);        
182         else if ((addr >= offsetof(struct user    
183                 (addr <= offsetof(struct user,    
184                 addr -= offsetof(struct user,     
185                 addr = addr >> 2;                 
186                 tmp = child->thread.arch.debug    
187         }                                         
188         return put_user(tmp, (unsigned long *)    
189 }                                                 
190                                                   
191 static int get_fpregs(struct user_i387_struct     
192 {                                                 
193         int err, n, cpu = ((struct thread_info    
194         struct user_i387_struct fpregs;           
195                                                   
196         err = save_i387_registers(userspace_pi    
197                                   (unsigned lo    
198         if (err)                                  
199                 return err;                       
200                                                   
201         n = copy_to_user(buf, &fpregs, sizeof(    
202         if (n > 0)                                
203                 return -EFAULT;                   
204                                                   
205         return n;                                 
206 }                                                 
207                                                   
208 static int set_fpregs(struct user_i387_struct     
209 {                                                 
210         int n, cpu = ((struct thread_info *) c    
211         struct user_i387_struct fpregs;           
212                                                   
213         n = copy_from_user(&fpregs, buf, sizeo    
214         if (n > 0)                                
215                 return -EFAULT;                   
216                                                   
217         return restore_i387_registers(userspac    
218                                       (unsigne    
219 }                                                 
220                                                   
221 long subarch_ptrace(struct task_struct *child,    
222                     unsigned long addr, unsign    
223 {                                                 
224         int ret = -EIO;                           
225         void __user *datap = (void __user *) d    
226                                                   
227         switch (request) {                        
228         case PTRACE_GETFPREGS: /* Get the chil    
229                 ret = get_fpregs(datap, child)    
230                 break;                            
231         case PTRACE_SETFPREGS: /* Set the chil    
232                 ret = set_fpregs(datap, child)    
233                 break;                            
234         case PTRACE_ARCH_PRCTL:                   
235                 /* XXX Calls ptrace on the hos    
236                 ret = arch_prctl(child, data,     
237                 break;                            
238         }                                         
239                                                   
240         return ret;                               
241 }                                                 
242                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php