diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-29 21:12:23 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-29 21:12:23 -0400 |
commit | a591afc01d9e48affbacb365558a31e53c85af45 (patch) | |
tree | 9bb91f4eb94ec69fc4706c4944788ec5f3586063 /arch/x86/kernel/ptrace.c | |
parent | 820d41cf0cd0e94a5661e093821e2e5c6b36a9d8 (diff) | |
parent | 31796ac4e8f0e88f5c10f1ad6dab8f19bebe44a4 (diff) |
Merge branch 'x86-x32-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x32 support for x86-64 from Ingo Molnar:
"This tree introduces the X32 binary format and execution mode for x86:
32-bit data space binaries using 64-bit instructions and 64-bit kernel
syscalls.
This allows applications whose working set fits into a 32 bits address
space to make use of 64-bit instructions while using a 32-bit address
space with shorter pointers, more compressed data structures, etc."
Fix up trivial context conflicts in arch/x86/{Kconfig,vdso/vma.c}
* 'x86-x32-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (71 commits)
x32: Fix alignment fail in struct compat_siginfo
x32: Fix stupid ia32/x32 inversion in the siginfo format
x32: Add ptrace for x32
x32: Switch to a 64-bit clock_t
x32: Provide separate is_ia32_task() and is_x32_task() predicates
x86, mtrr: Use explicit sizing and padding for the 64-bit ioctls
x86/x32: Fix the binutils auto-detect
x32: Warn and disable rather than error if binutils too old
x32: Only clear TIF_X32 flag once
x32: Make sure TS_COMPAT is cleared for x32 tasks
fs: Remove missed ->fds_bits from cessation use of fd_set structs internally
fs: Fix close_on_exec pointer in alloc_fdtable
x32: Drop non-__vdso weak symbols from the x32 VDSO
x32: Fix coding style violations in the x32 VDSO code
x32: Add x32 VDSO support
x32: Allow x32 to be configured
x32: If configured, add x32 system calls to system call tables
x32: Handle process creation
x32: Signal-related system calls
x86: Add #ifdef CONFIG_COMPAT to <asm/sys_ia32.h>
...
Diffstat (limited to 'arch/x86/kernel/ptrace.c')
-rw-r--r-- | arch/x86/kernel/ptrace.c | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c index 8a634c887652..284c35ae60e4 100644 --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c | |||
@@ -1130,6 +1130,100 @@ static int genregs32_set(struct task_struct *target, | |||
1130 | return ret; | 1130 | return ret; |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | #ifdef CONFIG_X86_X32_ABI | ||
1134 | static long x32_arch_ptrace(struct task_struct *child, | ||
1135 | compat_long_t request, compat_ulong_t caddr, | ||
1136 | compat_ulong_t cdata) | ||
1137 | { | ||
1138 | unsigned long addr = caddr; | ||
1139 | unsigned long data = cdata; | ||
1140 | void __user *datap = compat_ptr(data); | ||
1141 | int ret; | ||
1142 | |||
1143 | switch (request) { | ||
1144 | /* Read 32bits at location addr in the USER area. Only allow | ||
1145 | to return the lower 32bits of segment and debug registers. */ | ||
1146 | case PTRACE_PEEKUSR: { | ||
1147 | u32 tmp; | ||
1148 | |||
1149 | ret = -EIO; | ||
1150 | if ((addr & (sizeof(data) - 1)) || addr >= sizeof(struct user) || | ||
1151 | addr < offsetof(struct user_regs_struct, cs)) | ||
1152 | break; | ||
1153 | |||
1154 | tmp = 0; /* Default return condition */ | ||
1155 | if (addr < sizeof(struct user_regs_struct)) | ||
1156 | tmp = getreg(child, addr); | ||
1157 | else if (addr >= offsetof(struct user, u_debugreg[0]) && | ||
1158 | addr <= offsetof(struct user, u_debugreg[7])) { | ||
1159 | addr -= offsetof(struct user, u_debugreg[0]); | ||
1160 | tmp = ptrace_get_debugreg(child, addr / sizeof(data)); | ||
1161 | } | ||
1162 | ret = put_user(tmp, (__u32 __user *)datap); | ||
1163 | break; | ||
1164 | } | ||
1165 | |||
1166 | /* Write the word at location addr in the USER area. Only allow | ||
1167 | to update segment and debug registers with the upper 32bits | ||
1168 | zero-extended. */ | ||
1169 | case PTRACE_POKEUSR: | ||
1170 | ret = -EIO; | ||
1171 | if ((addr & (sizeof(data) - 1)) || addr >= sizeof(struct user) || | ||
1172 | addr < offsetof(struct user_regs_struct, cs)) | ||
1173 | break; | ||
1174 | |||
1175 | if (addr < sizeof(struct user_regs_struct)) | ||
1176 | ret = putreg(child, addr, data); | ||
1177 | else if (addr >= offsetof(struct user, u_debugreg[0]) && | ||
1178 | addr <= offsetof(struct user, u_debugreg[7])) { | ||
1179 | addr -= offsetof(struct user, u_debugreg[0]); | ||
1180 | ret = ptrace_set_debugreg(child, | ||
1181 | addr / sizeof(data), data); | ||
1182 | } | ||
1183 | break; | ||
1184 | |||
1185 | case PTRACE_GETREGS: /* Get all gp regs from the child. */ | ||
1186 | return copy_regset_to_user(child, | ||
1187 | task_user_regset_view(current), | ||
1188 | REGSET_GENERAL, | ||
1189 | 0, sizeof(struct user_regs_struct), | ||
1190 | datap); | ||
1191 | |||
1192 | case PTRACE_SETREGS: /* Set all gp regs in the child. */ | ||
1193 | return copy_regset_from_user(child, | ||
1194 | task_user_regset_view(current), | ||
1195 | REGSET_GENERAL, | ||
1196 | 0, sizeof(struct user_regs_struct), | ||
1197 | datap); | ||
1198 | |||
1199 | case PTRACE_GETFPREGS: /* Get the child FPU state. */ | ||
1200 | return copy_regset_to_user(child, | ||
1201 | task_user_regset_view(current), | ||
1202 | REGSET_FP, | ||
1203 | 0, sizeof(struct user_i387_struct), | ||
1204 | datap); | ||
1205 | |||
1206 | case PTRACE_SETFPREGS: /* Set the child FPU state. */ | ||
1207 | return copy_regset_from_user(child, | ||
1208 | task_user_regset_view(current), | ||
1209 | REGSET_FP, | ||
1210 | 0, sizeof(struct user_i387_struct), | ||
1211 | datap); | ||
1212 | |||
1213 | /* normal 64bit interface to access TLS data. | ||
1214 | Works just like arch_prctl, except that the arguments | ||
1215 | are reversed. */ | ||
1216 | case PTRACE_ARCH_PRCTL: | ||
1217 | return do_arch_prctl(child, data, addr); | ||
1218 | |||
1219 | default: | ||
1220 | return compat_ptrace_request(child, request, addr, data); | ||
1221 | } | ||
1222 | |||
1223 | return ret; | ||
1224 | } | ||
1225 | #endif | ||
1226 | |||
1133 | long compat_arch_ptrace(struct task_struct *child, compat_long_t request, | 1227 | long compat_arch_ptrace(struct task_struct *child, compat_long_t request, |
1134 | compat_ulong_t caddr, compat_ulong_t cdata) | 1228 | compat_ulong_t caddr, compat_ulong_t cdata) |
1135 | { | 1229 | { |
@@ -1139,6 +1233,11 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request, | |||
1139 | int ret; | 1233 | int ret; |
1140 | __u32 val; | 1234 | __u32 val; |
1141 | 1235 | ||
1236 | #ifdef CONFIG_X86_X32_ABI | ||
1237 | if (!is_ia32_task()) | ||
1238 | return x32_arch_ptrace(child, request, caddr, cdata); | ||
1239 | #endif | ||
1240 | |||
1142 | switch (request) { | 1241 | switch (request) { |
1143 | case PTRACE_PEEKUSR: | 1242 | case PTRACE_PEEKUSR: |
1144 | ret = getreg32(child, addr, &val); | 1243 | ret = getreg32(child, addr, &val); |