coldfire-sighandler.patch 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. From a95517992a37488c0bc8b629c47c570e580e407d Mon Sep 17 00:00:00 2001
  2. From: Greg Ungerer <gerg@uclinux.org>
  3. Date: Mon, 15 Feb 2016 16:36:29 +1000
  4. Subject: m68k: Use conventional function parameters for do_sigreturn
  5. Create conventional stack parameters for the calls to do_sigreturn and
  6. do_rt_sigreturn. The current C code for do_sigreturn and do_rt_sigreturn
  7. dig into the stack to create local pointers to the saved switch stack
  8. and the pt_regs structs.
  9. The motivation for this change is a problem with non-MMU targets that
  10. have broken signal return paths on newer versions of gcc. It appears as
  11. though gcc has determined that the pointers into the saved stack structs,
  12. and the saved structs themselves, are function parameters and updates to
  13. them will be lost on function return, so they are optimized away. This
  14. results in large parts of restore_sigcontext() and mangle_kernel_stack()
  15. functions being removed. Of course this results in non-functional code
  16. causing kernel oops. This problem has been observed with gcc version
  17. 5.2 and 5.3, and probably exists in earlier versions as well.
  18. Using conventional stack parameter pointers passed to these functions has
  19. the advantage of the code here not needing to know the exact details of
  20. how the underlying entry handler layed these structs out on the stack.
  21. So the rather ugly pointer setup casting and arg referencing can be
  22. removed.
  23. The resulting code after this change is a few bytes larger (due to the
  24. overhead of creating the stack args and their tear down). Not being hot
  25. paths I don't think this is too much of a problem here.
  26. An alternative solution is to put a barrier() in the do_sigreturn() code,
  27. but this doesn't feel quite as clean as this solution.
  28. This change has been compile tested on all defconfigs, and run tested on
  29. Atari (through aranym), ColdFire with MMU (M5407EVB) and ColdFire with
  30. no-MMU (QEMU and M5208EVB).
  31. Signed-off-by: Greg Ungerer <gerg@uclinux.org>
  32. Acked-by: Andreas Schwab <schwab@linux-m68k.org>
  33. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
  34. ---
  35. arch/m68k/kernel/entry.S | 6 ++++++
  36. arch/m68k/kernel/signal.c | 8 ++------
  37. 2 files changed, 8 insertions(+), 6 deletions(-)
  38. diff --git a/arch/m68k/kernel/entry.S b/arch/m68k/kernel/entry.S
  39. index b54ac7a..97cd3ea 100644
  40. --- a/arch/m68k/kernel/entry.S
  41. +++ b/arch/m68k/kernel/entry.S
  42. @@ -71,13 +71,19 @@ ENTRY(__sys_vfork)
  43. ENTRY(sys_sigreturn)
  44. SAVE_SWITCH_STACK
  45. + movel %sp,%sp@- | switch_stack pointer
  46. + pea %sp@(SWITCH_STACK_SIZE+4) | pt_regs pointer
  47. jbsr do_sigreturn
  48. + addql #8,%sp
  49. RESTORE_SWITCH_STACK
  50. rts
  51. ENTRY(sys_rt_sigreturn)
  52. SAVE_SWITCH_STACK
  53. + movel %sp,%sp@- | switch_stack pointer
  54. + pea %sp@(SWITCH_STACK_SIZE+4) | pt_regs pointer
  55. jbsr do_rt_sigreturn
  56. + addql #8,%sp
  57. RESTORE_SWITCH_STACK
  58. rts
  59. diff --git a/arch/m68k/kernel/signal.c b/arch/m68k/kernel/signal.c
  60. index af1c4f3..2dcee3a 100644
  61. --- a/arch/m68k/kernel/signal.c
  62. +++ b/arch/m68k/kernel/signal.c
  63. @@ -737,10 +737,8 @@ badframe:
  64. return 1;
  65. }
  66. -asmlinkage int do_sigreturn(unsigned long __unused)
  67. +asmlinkage int do_sigreturn(struct pt_regs *regs, struct switch_stack *sw)
  68. {
  69. - struct switch_stack *sw = (struct switch_stack *) &__unused;
  70. - struct pt_regs *regs = (struct pt_regs *) (sw + 1);
  71. unsigned long usp = rdusp();
  72. struct sigframe __user *frame = (struct sigframe __user *)(usp - 4);
  73. sigset_t set;
  74. @@ -764,10 +762,8 @@ badframe:
  75. return 0;
  76. }
  77. -asmlinkage int do_rt_sigreturn(unsigned long __unused)
  78. +asmlinkage int do_rt_sigreturn(struct pt_regs *regs, struct switch_stack *sw)
  79. {
  80. - struct switch_stack *sw = (struct switch_stack *) &__unused;
  81. - struct pt_regs *regs = (struct pt_regs *) (sw + 1);
  82. unsigned long usp = rdusp();
  83. struct rt_sigframe __user *frame = (struct rt_sigframe __user *)(usp - 4);
  84. sigset_t set;
  85. --
  86. cgit v0.12