Skip to content

Commit 96a68b1

Browse files
committed
MIPS: Remove nabi_no_regargs
Our sigreturn functions make use of a macro named nabi_no_regargs to declare 8 dummy arguments to a function, forcing the compiler to expect a pt_regs structure on the stack rather than in argument registers. This is an ugly hack which unnecessarily causes these sigreturn functions to need to care about the calling convention of the ABI the kernel is built for. Although this is abstracted via nabi_no_regargs, it's still ugly & unnecessary. Remove nabi_no_regargs & the struct pt_regs argument from sigreturn functions, and instead use current_pt_regs() to find the struct pt_regs on the stack, which works cleanly regardless of ABI. Signed-off-by: Paul Burton <paul.burton@mips.com> Patchwork: https://patchwork.linux-mips.org/patch/20106/ Cc: James Hogan <jhogan@kernel.org> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: linux-mips@linux-mips.org
1 parent 84a7f56 commit 96a68b1

4 files changed

Lines changed: 35 additions & 37 deletions

File tree

‎arch/mips/include/asm/sim.h‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ __asm__( \
3939
".end\t__" #symbol "\n\t" \
4040
".size\t__" #symbol",. - __" #symbol)
4141

42-
#define nabi_no_regargs
43-
4442
#endif /* CONFIG_32BIT */
4543

4644
#ifdef CONFIG_64BIT
@@ -67,16 +65,6 @@ __asm__( \
6765
".end\t__" #symbol "\n\t" \
6866
".size\t__" #symbol",. - __" #symbol)
6967

70-
#define nabi_no_regargs \
71-
unsigned long __dummy0, \
72-
unsigned long __dummy1, \
73-
unsigned long __dummy2, \
74-
unsigned long __dummy3, \
75-
unsigned long __dummy4, \
76-
unsigned long __dummy5, \
77-
unsigned long __dummy6, \
78-
unsigned long __dummy7,
79-
8068
#endif /* CONFIG_64BIT */
8169

8270
#endif /* _ASM_SIM_H */

‎arch/mips/kernel/signal.c‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -592,21 +592,23 @@ SYSCALL_DEFINE3(sigaction, int, sig, const struct sigaction __user *, act,
592592
#endif
593593

594594
#ifdef CONFIG_TRAD_SIGNALS
595-
asmlinkage void sys_sigreturn(nabi_no_regargs struct pt_regs regs)
595+
asmlinkage void sys_sigreturn(void)
596596
{
597597
struct sigframe __user *frame;
598+
struct pt_regs *regs;
598599
sigset_t blocked;
599600
int sig;
600601

601-
frame = (struct sigframe __user *) regs.regs[29];
602+
regs = current_pt_regs();
603+
frame = (struct sigframe __user *)regs->regs[29];
602604
if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
603605
goto badframe;
604606
if (__copy_from_user(&blocked, &frame->sf_mask, sizeof(blocked)))
605607
goto badframe;
606608

607609
set_current_blocked(&blocked);
608610

609-
sig = restore_sigcontext(&regs, &frame->sf_sc);
611+
sig = restore_sigcontext(regs, &frame->sf_sc);
610612
if (sig < 0)
611613
goto badframe;
612614
else if (sig)
@@ -618,30 +620,32 @@ asmlinkage void sys_sigreturn(nabi_no_regargs struct pt_regs regs)
618620
__asm__ __volatile__(
619621
"move\t$29, %0\n\t"
620622
"j\tsyscall_exit"
621-
:/* no outputs */
622-
:"r" (&regs));
623+
: /* no outputs */
624+
: "r" (regs));
623625
/* Unreached */
624626

625627
badframe:
626628
force_sig(SIGSEGV, current);
627629
}
628630
#endif /* CONFIG_TRAD_SIGNALS */
629631

630-
asmlinkage void sys_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
632+
asmlinkage void sys_rt_sigreturn(void)
631633
{
632634
struct rt_sigframe __user *frame;
635+
struct pt_regs *regs;
633636
sigset_t set;
634637
int sig;
635638

636-
frame = (struct rt_sigframe __user *) regs.regs[29];
639+
regs = current_pt_regs();
640+
frame = (struct rt_sigframe __user *)regs->regs[29];
637641
if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
638642
goto badframe;
639643
if (__copy_from_user(&set, &frame->rs_uc.uc_sigmask, sizeof(set)))
640644
goto badframe;
641645

642646
set_current_blocked(&set);
643647

644-
sig = restore_sigcontext(&regs, &frame->rs_uc.uc_mcontext);
648+
sig = restore_sigcontext(regs, &frame->rs_uc.uc_mcontext);
645649
if (sig < 0)
646650
goto badframe;
647651
else if (sig)
@@ -656,8 +660,8 @@ asmlinkage void sys_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
656660
__asm__ __volatile__(
657661
"move\t$29, %0\n\t"
658662
"j\tsyscall_exit"
659-
:/* no outputs */
660-
:"r" (&regs));
663+
: /* no outputs */
664+
: "r" (regs));
661665
/* Unreached */
662666

663667
badframe:

‎arch/mips/kernel/signal_n32.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,23 @@ struct rt_sigframe_n32 {
6464
struct ucontextn32 rs_uc;
6565
};
6666

67-
asmlinkage void sysn32_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
67+
asmlinkage void sysn32_rt_sigreturn(void)
6868
{
6969
struct rt_sigframe_n32 __user *frame;
70+
struct pt_regs *regs;
7071
sigset_t set;
7172
int sig;
7273

73-
frame = (struct rt_sigframe_n32 __user *) regs.regs[29];
74+
regs = current_pt_regs();
75+
frame = (struct rt_sigframe_n32 __user *)regs->regs[29];
7476
if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
7577
goto badframe;
7678
if (__copy_conv_sigset_from_user(&set, &frame->rs_uc.uc_sigmask))
7779
goto badframe;
7880

7981
set_current_blocked(&set);
8082

81-
sig = restore_sigcontext(&regs, &frame->rs_uc.uc_mcontext);
83+
sig = restore_sigcontext(regs, &frame->rs_uc.uc_mcontext);
8284
if (sig < 0)
8385
goto badframe;
8486
else if (sig)
@@ -93,8 +95,8 @@ asmlinkage void sysn32_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
9395
__asm__ __volatile__(
9496
"move\t$29, %0\n\t"
9597
"j\tsyscall_exit"
96-
:/* no outputs */
97-
:"r" (&regs));
98+
: /* no outputs */
99+
: "r" (regs));
98100
/* Unreached */
99101

100102
badframe:

‎arch/mips/kernel/signal_o32.c‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,23 @@ static int setup_frame_32(void *sig_return, struct ksignal *ksig,
151151
return 0;
152152
}
153153

154-
asmlinkage void sys32_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
154+
asmlinkage void sys32_rt_sigreturn(void)
155155
{
156156
struct rt_sigframe32 __user *frame;
157+
struct pt_regs *regs;
157158
sigset_t set;
158159
int sig;
159160

160-
frame = (struct rt_sigframe32 __user *) regs.regs[29];
161+
regs = current_pt_regs();
162+
frame = (struct rt_sigframe32 __user *)regs->regs[29];
161163
if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
162164
goto badframe;
163165
if (__copy_conv_sigset_from_user(&set, &frame->rs_uc.uc_sigmask))
164166
goto badframe;
165167

166168
set_current_blocked(&set);
167169

168-
sig = restore_sigcontext32(&regs, &frame->rs_uc.uc_mcontext);
170+
sig = restore_sigcontext32(regs, &frame->rs_uc.uc_mcontext);
169171
if (sig < 0)
170172
goto badframe;
171173
else if (sig)
@@ -180,8 +182,8 @@ asmlinkage void sys32_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
180182
__asm__ __volatile__(
181183
"move\t$29, %0\n\t"
182184
"j\tsyscall_exit"
183-
:/* no outputs */
184-
:"r" (&regs));
185+
: /* no outputs */
186+
: "r" (regs));
185187
/* Unreached */
186188

187189
badframe:
@@ -251,21 +253,23 @@ struct mips_abi mips_abi_32 = {
251253
};
252254

253255

254-
asmlinkage void sys32_sigreturn(nabi_no_regargs struct pt_regs regs)
256+
asmlinkage void sys32_sigreturn(void)
255257
{
256258
struct sigframe32 __user *frame;
259+
struct pt_regs *regs;
257260
sigset_t blocked;
258261
int sig;
259262

260-
frame = (struct sigframe32 __user *) regs.regs[29];
263+
regs = current_pt_regs();
264+
frame = (struct sigframe32 __user *)regs->regs[29];
261265
if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
262266
goto badframe;
263267
if (__copy_conv_sigset_from_user(&blocked, &frame->sf_mask))
264268
goto badframe;
265269

266270
set_current_blocked(&blocked);
267271

268-
sig = restore_sigcontext32(&regs, &frame->sf_sc);
272+
sig = restore_sigcontext32(regs, &frame->sf_sc);
269273
if (sig < 0)
270274
goto badframe;
271275
else if (sig)
@@ -277,8 +281,8 @@ asmlinkage void sys32_sigreturn(nabi_no_regargs struct pt_regs regs)
277281
__asm__ __volatile__(
278282
"move\t$29, %0\n\t"
279283
"j\tsyscall_exit"
280-
:/* no outputs */
281-
:"r" (&regs));
284+
: /* no outputs */
285+
: "r" (regs));
282286
/* Unreached */
283287

284288
badframe:

0 commit comments

Comments
 (0)