26 #include <linux/module.h>
29 #include <linux/sched.h>
31 #include <linux/types.h>
32 #include <linux/errno.h>
34 #include <asm/uaccess.h>
39 #define DEBUG_COMPAT_SIG 0
40 #define DEBUG_COMPAT_SIG_LEVEL 2
43 #define DBG(LEVEL, ...) \
44 ((DEBUG_COMPAT_SIG_LEVEL >= LEVEL) \
45 ? printk(__VA_ARGS__) : (void) 0)
47 #define DBG(LEVEL, ...)
53 s64->
sig[0] = s32->sig[0] | ((
unsigned long)s32->sig[1] << 32);
59 s32->sig[0] = s64->
sig[0] & 0xffffffff
UL;
60 s32->sig[1] = (s64->
sig[0] >> 32) & 0xffffffffUL;
64 put_sigset32(compat_sigset_t __user *
up,
sigset_t *
set,
size_t sz)
68 if (sz !=
sizeof *
set)
76 get_sigset32(compat_sigset_t __user *up,
sigset_t *
set,
size_t sz)
81 if (sz !=
sizeof *
set)
92 unsigned int sigsetsize)
97 if (
set && get_sigset32(
set, &new_set, sigsetsize))
101 oset ? (
sigset_t __user *)&old_set : NULL, sigsetsize);
103 if (!ret && oset && put_sigset32(oset, &old_set, sigsetsize))
117 if (!ret && put_sigset32(uset, &
set, sigsetsize))
135 new_sa.
sa.sa_flags = new_sa32.
sa.sa_flags;
143 old_sa32.
sa.sa_flags = old_sa.
sa.sa_flags;
144 old_sa32.
sa.sa_handler = (__sighandler_t32)(
unsigned long)old_sa.
sa.sa_handler;
175 if (!ret && uoss32) {
197 DBG(2,
"restore_sigcontext32: PER_LINUX32 process\n");
198 DBG(2,
"restore_sigcontext32: sc = 0x%p, rf = 0x%p, regs = 0x%p\n", sc, rf, regs);
199 DBG(2,
"restore_sigcontext32: compat_sigcontext is %#lx bytes\n",
sizeof(*sc));
200 for(regn=0; regn < 32; regn++){
201 err |=
__get_user(compat_reg,&sc->sc_gr[regn]);
202 regs->
gr[regn] = compat_reg;
204 err |=
__get_user(compat_regt,&rf->rf_gr[regn]);
205 regs->
gr[regn] = ((
u64)compat_regt << 32) | (
u64)compat_reg;
206 DBG(3,
"restore_sigcontext32: gr%02d = %#lx (%#x / %#x)\n",
207 regn, regs->
gr[regn], compat_regt, compat_reg);
209 DBG(2,
"restore_sigcontext32: sc->sc_fr = 0x%p (%#lx)\n",sc->sc_fr,
sizeof(sc->sc_fr));
216 err |=
__get_user(compat_reg, &sc->sc_iaoq[0]);
218 err |=
__get_user(compat_regt, &rf->rf_iaoq[0]);
219 regs->
iaoq[0] = ((
u64)compat_regt << 32) | (
u64)compat_reg;
220 DBG(2,
"restore_sigcontext32: upper half of iaoq[0] = %#lx\n", compat_regt);
221 DBG(2,
"restore_sigcontext32: sc->sc_iaoq[0] = %p => %#x\n",
222 &sc->sc_iaoq[0], compat_reg);
224 err |=
__get_user(compat_reg, &sc->sc_iaoq[1]);
226 err |=
__get_user(compat_regt, &rf->rf_iaoq[1]);
227 regs->
iaoq[1] = ((
u64)compat_regt << 32) | (
u64)compat_reg;
228 DBG(2,
"restore_sigcontext32: upper half of iaoq[1] = %#lx\n", compat_regt);
229 DBG(2,
"restore_sigcontext32: sc->sc_iaoq[1] = %p => %#x\n",
230 &sc->sc_iaoq[1],compat_reg);
231 DBG(2,
"restore_sigcontext32: iaoq is %#lx / %#lx\n",
234 err |=
__get_user(compat_reg, &sc->sc_iasq[0]);
236 err |=
__get_user(compat_regt, &rf->rf_iasq[0]);
237 regs->
iasq[0] = ((
u64)compat_regt << 32) | (
u64)compat_reg;
238 DBG(2,
"restore_sigcontext32: upper half of iasq[0] = %#lx\n", compat_regt);
240 err |=
__get_user(compat_reg, &sc->sc_iasq[1]);
242 err |=
__get_user(compat_regt, &rf->rf_iasq[1]);
243 regs->
iasq[1] = ((
u64)compat_regt << 32) | (
u64)compat_reg;
244 DBG(2,
"restore_sigcontext32: upper half of iasq[1] = %#lx\n", compat_regt);
245 DBG(2,
"restore_sigcontext32: iasq is %#lx / %#lx\n",
251 regs->
sar = ((
u64)compat_regt << 32) | (
u64)compat_reg;
252 DBG(2,
"restore_sigcontext32: upper_half & sar = %#lx\n", compat_regt);
253 DBG(2,
"restore_sigcontext32: sar is %#lx\n", regs->
sar);
254 DBG(2,
"restore_sigcontext32: r28 is %ld\n", regs->
gr[28]);
275 if (on_sig_stack((
unsigned long) sc))
280 DBG(1,
"setup_sigcontext32: in_syscall\n");
286 err |=
__put_user(compat_reg, &sc->sc_iaoq[0]);
287 DBG(2,
"setup_sigcontext32: sc->sc_iaoq[0] = %p <= %#x\n",
288 &sc->sc_iaoq[0], compat_reg);
292 err |=
__put_user(compat_reg, &rf->rf_iaoq[0]);
293 DBG(2,
"setup_sigcontext32: upper half iaoq[0] = %#x\n", compat_reg);
297 err |=
__put_user(compat_reg, &sc->sc_iaoq[1]);
298 DBG(2,
"setup_sigcontext32: sc->sc_iaoq[1] = %p <= %#x\n",
299 &sc->sc_iaoq[1], compat_reg);
302 err |=
__put_user(compat_reg, &rf->rf_iaoq[1]);
303 DBG(2,
"setup_sigcontext32: upper half iaoq[1] = %#x\n", compat_reg);
307 err |=
__put_user(compat_reg, &sc->sc_iasq[0]);
308 err |=
__put_user(compat_reg, &sc->sc_iasq[1]);
312 err |=
__put_user(compat_reg, &rf->rf_iasq[0]);
313 err |=
__put_user(compat_reg, &rf->rf_iasq[1]);
315 DBG(2,
"setup_sigcontext32: upper half iasq[0] = %#x\n", compat_reg);
316 DBG(2,
"setup_sigcontext32: upper half iasq[1] = %#x\n", compat_reg);
317 DBG(1,
"setup_sigcontext32: iaoq %#lx / %#lx\n",
318 regs->
gr[31], regs->
gr[31]+4);
323 err |=
__put_user(compat_reg, &sc->sc_iaoq[0]);
324 DBG(2,
"setup_sigcontext32: sc->sc_iaoq[0] = %p <= %#x\n",
325 &sc->sc_iaoq[0], compat_reg);
328 err |=
__put_user(compat_reg, &rf->rf_iaoq[0]);
329 DBG(2,
"setup_sigcontext32: upper half iaoq[0] = %#x\n", compat_reg);
332 err |=
__put_user(compat_reg, &sc->sc_iaoq[1]);
333 DBG(2,
"setup_sigcontext32: sc->sc_iaoq[1] = %p <= %#x\n",
334 &sc->sc_iaoq[1], compat_reg);
337 err |=
__put_user(compat_reg, &rf->rf_iaoq[1]);
338 DBG(2,
"setup_sigcontext32: upper half iaoq[1] = %#x\n", compat_reg);
342 err |=
__put_user(compat_reg, &sc->sc_iasq[0]);
343 DBG(2,
"setup_sigcontext32: sc->sc_iasq[0] = %p <= %#x\n",
344 &sc->sc_iasq[0], compat_reg);
347 err |=
__put_user(compat_reg, &rf->rf_iasq[0]);
348 DBG(2,
"setup_sigcontext32: upper half iasq[0] = %#x\n", compat_reg);
352 err |=
__put_user(compat_reg, &sc->sc_iasq[1]);
353 DBG(2,
"setup_sigcontext32: sc->sc_iasq[1] = %p <= %#x\n",
354 &sc->sc_iasq[1], compat_reg);
357 err |=
__put_user(compat_reg, &rf->rf_iasq[1]);
358 DBG(2,
"setup_sigcontext32: upper half iasq[1] = %#x\n", compat_reg);
361 DBG(1,
"setup_sigcontext32: ia0q %#lx / %#lx\n",
367 DBG(1,
"setup_sigcontext32: Truncating general registers.\n");
369 for(regn=0; regn < 32; regn++){
372 err |=
__put_user(compat_reg, &sc->sc_gr[regn]);
375 err |=
__put_user(compat_regb, &rf->rf_gr[regn]);
378 DBG(2,
"setup_sigcontext32: gr%02d = %#x / %#x\n", regn,
379 compat_regb, compat_reg);
384 DBG(1,
"setup_sigcontext32: Copying from regs to sc, "
385 "sc->sc_fr size = %#lx, regs->fr size = %#lx\n",
386 sizeof(regs->
fr),
sizeof(sc->sc_fr));
391 DBG(2,
"setup_sigcontext32: sar is %#x\n", compat_reg);
395 DBG(2,
"setup_sigcontext32: upper half sar = %#x\n", compat_reg);
396 DBG(1,
"setup_sigcontext32: r28 is %ld\n", regs->
gr[28]);
419 err |=
__get_user(to->si_utime, &from->si_utime);
420 err |=
__get_user(to->si_stime, &from->si_stime);
421 err |=
__get_user(to->si_status, &from->si_status);
428 to->si_addr = compat_ptr(addr);
431 err |=
__get_user(to->si_band, &from->si_band);
470 err |=
__put_user(from->si_utime, &to->si_utime);
471 err |=
__put_user(from->si_stime, &to->si_stime);
472 err |=
__put_user(from->si_status, &to->si_status);
478 addr = ptr_to_compat(from->si_addr);
482 err |=
__put_user(from->si_band, &to->si_band);
487 err |=
__put_user(from->si_overrun, &to->si_overrun);