signal32.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * Copyright (C) 2001 Matthew Wilcox <willy at parisc-linux.org>
  3. * Copyright (C) 2003 Carlos O'Donell <carlos at parisc-linux.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #ifndef _PARISC64_KERNEL_SIGNAL32_H
  20. #define _PARISC64_KERNEL_SIGNAL32_H
  21. #include <linux/compat.h>
  22. typedef compat_uptr_t compat_sighandler_t;
  23. typedef struct compat_sigaltstack {
  24. compat_uptr_t ss_sp;
  25. compat_int_t ss_flags;
  26. compat_size_t ss_size;
  27. } compat_stack_t;
  28. /* Most things should be clean enough to redefine this at will, if care
  29. is taken to make libc match. */
  30. struct compat_sigaction {
  31. compat_sighandler_t sa_handler;
  32. compat_uint_t sa_flags;
  33. compat_sigset_t sa_mask; /* mask last for extensibility */
  34. };
  35. /* 32-bit ucontext as seen from an 64-bit kernel */
  36. struct compat_ucontext {
  37. compat_uint_t uc_flags;
  38. compat_uptr_t uc_link;
  39. compat_stack_t uc_stack; /* struct compat_sigaltstack (12 bytes)*/
  40. /* FIXME: Pad out to get uc_mcontext to start at an 8-byte aligned boundary */
  41. compat_uint_t pad[1];
  42. struct compat_sigcontext uc_mcontext;
  43. compat_sigset_t uc_sigmask; /* mask last for extensibility */
  44. };
  45. /* ELF32 signal handling */
  46. struct k_sigaction32 {
  47. struct compat_sigaction sa;
  48. };
  49. typedef struct compat_siginfo {
  50. int si_signo;
  51. int si_errno;
  52. int si_code;
  53. union {
  54. int _pad[((128/sizeof(int)) - 3)];
  55. /* kill() */
  56. struct {
  57. unsigned int _pid; /* sender's pid */
  58. unsigned int _uid; /* sender's uid */
  59. } _kill;
  60. /* POSIX.1b timers */
  61. struct {
  62. compat_timer_t _tid; /* timer id */
  63. int _overrun; /* overrun count */
  64. char _pad[sizeof(unsigned int) - sizeof(int)];
  65. compat_sigval_t _sigval; /* same as below */
  66. int _sys_private; /* not to be passed to user */
  67. } _timer;
  68. /* POSIX.1b signals */
  69. struct {
  70. unsigned int _pid; /* sender's pid */
  71. unsigned int _uid; /* sender's uid */
  72. compat_sigval_t _sigval;
  73. } _rt;
  74. /* SIGCHLD */
  75. struct {
  76. unsigned int _pid; /* which child */
  77. unsigned int _uid; /* sender's uid */
  78. int _status; /* exit code */
  79. compat_clock_t _utime;
  80. compat_clock_t _stime;
  81. } _sigchld;
  82. /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
  83. struct {
  84. unsigned int _addr; /* faulting insn/memory ref. */
  85. } _sigfault;
  86. /* SIGPOLL */
  87. struct {
  88. int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
  89. int _fd;
  90. } _sigpoll;
  91. } _sifields;
  92. } compat_siginfo_t;
  93. int copy_siginfo_to_user32 (compat_siginfo_t __user *to, siginfo_t *from);
  94. int copy_siginfo_from_user32 (siginfo_t *to, compat_siginfo_t __user *from);
  95. /* In a deft move of uber-hackery, we decide to carry the top half of all
  96. * 64-bit registers in a non-portable, non-ABI, hidden structure.
  97. * Userspace can read the hidden structure if it *wants* but is never
  98. * guaranteed to be in the same place. In fact the uc_sigmask from the
  99. * ucontext_t structure may push the hidden register file downards
  100. */
  101. struct compat_regfile {
  102. /* Upper half of all the 64-bit registers that were truncated
  103. on a copy to a 32-bit userspace */
  104. compat_int_t rf_gr[32];
  105. compat_int_t rf_iasq[2];
  106. compat_int_t rf_iaoq[2];
  107. compat_int_t rf_sar;
  108. };
  109. #define COMPAT_SIGRETURN_TRAMP 4
  110. #define COMPAT_SIGRESTARTBLOCK_TRAMP 5
  111. #define COMPAT_TRAMP_SIZE (COMPAT_SIGRETURN_TRAMP + \
  112. COMPAT_SIGRESTARTBLOCK_TRAMP)
  113. struct compat_rt_sigframe {
  114. /* XXX: Must match trampoline size in arch/parisc/kernel/signal.c
  115. Secondary to that it must protect the ERESTART_RESTARTBLOCK
  116. trampoline we left on the stack (we were bad and didn't
  117. change sp so we could run really fast.) */
  118. compat_uint_t tramp[COMPAT_TRAMP_SIZE];
  119. compat_siginfo_t info;
  120. struct compat_ucontext uc;
  121. /* Hidden location of truncated registers, *must* be last. */
  122. struct compat_regfile regs;
  123. };
  124. /*
  125. * The 32-bit ABI wants at least 48 bytes for a function call frame:
  126. * 16 bytes for arg0-arg3, and 32 bytes for magic (the only part of
  127. * which Linux/parisc uses is sp-20 for the saved return pointer...)
  128. * Then, the stack pointer must be rounded to a cache line (64 bytes).
  129. */
  130. #define SIGFRAME32 64
  131. #define FUNCTIONCALLFRAME32 48
  132. #define PARISC_RT_SIGFRAME_SIZE32 (((sizeof(struct compat_rt_sigframe) + FUNCTIONCALLFRAME32) + SIGFRAME32) & -SIGFRAME32)
  133. void sigset_32to64(sigset_t *s64, compat_sigset_t *s32);
  134. void sigset_64to32(compat_sigset_t *s32, sigset_t *s64);
  135. int do_sigaltstack32 (const compat_stack_t __user *uss32,
  136. compat_stack_t __user *uoss32, unsigned long sp);
  137. long restore_sigcontext32(struct compat_sigcontext __user *sc,
  138. struct compat_regfile __user *rf,
  139. struct pt_regs *regs);
  140. long setup_sigcontext32(struct compat_sigcontext __user *sc,
  141. struct compat_regfile __user *rf,
  142. struct pt_regs *regs, int in_syscall);
  143. #endif