Skip to content

Commit

Permalink
x86 syscall.h: fix argument order
Browse files Browse the repository at this point in the history
Petr Tesarik noticed that I'd bungled the syscall_get_arguments code for
64-bit kernels, so it inverted the order of the syscall argument registers.
Petr wrote a patch to fix that, and I've amended it to fix the same braino
in the syscall_set_arguments code.

Original-by: Petr Tesarik <ptesarik@suse.cz>
Signed-off-by: Roland McGrath <roland@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Roland McGrath authored and Ingo Molnar committed Oct 22, 2008
1 parent aef8f5b commit 746e7ce
Showing 1 changed file with 54 additions and 52 deletions.
106 changes: 54 additions & 52 deletions include/asm-x86/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,53 +93,53 @@ static inline void syscall_get_arguments(struct task_struct *task,
{
# ifdef CONFIG_IA32_EMULATION
if (task_thread_info(task)->status & TS_COMPAT)
switch (i + n) {
case 6:
switch (i) {
case 0:
if (!n--) break;
*args++ = regs->bp;
case 5:
*args++ = regs->bx;
case 1:
if (!n--) break;
*args++ = regs->di;
case 4:
*args++ = regs->cx;
case 2:
if (!n--) break;
*args++ = regs->si;
*args++ = regs->dx;
case 3:
if (!n--) break;
*args++ = regs->dx;
case 2:
*args++ = regs->si;
case 4:
if (!n--) break;
*args++ = regs->cx;
case 1:
*args++ = regs->di;
case 5:
if (!n--) break;
*args++ = regs->bx;
case 0:
*args++ = regs->bp;
case 6:
if (!n--) break;
default:
BUG();
break;
}
else
# endif
switch (i + n) {
case 6:
switch (i) {
case 0:
if (!n--) break;
*args++ = regs->r9;
case 5:
*args++ = regs->di;
case 1:
if (!n--) break;
*args++ = regs->r8;
case 4:
*args++ = regs->si;
case 2:
if (!n--) break;
*args++ = regs->r10;
*args++ = regs->dx;
case 3:
if (!n--) break;
*args++ = regs->dx;
case 2:
*args++ = regs->r10;
case 4:
if (!n--) break;
*args++ = regs->si;
case 1:
*args++ = regs->r8;
case 5:
if (!n--) break;
*args++ = regs->di;
case 0:
*args++ = regs->r9;
case 6:
if (!n--) break;
default:
BUG();
Expand All @@ -154,55 +154,57 @@ static inline void syscall_set_arguments(struct task_struct *task,
{
# ifdef CONFIG_IA32_EMULATION
if (task_thread_info(task)->status & TS_COMPAT)
switch (i + n) {
case 6:
switch (i) {
case 0:
if (!n--) break;
regs->bp = *args++;
case 5:
regs->bx = *args++;
case 1:
if (!n--) break;
regs->di = *args++;
case 4:
regs->cx = *args++;
case 2:
if (!n--) break;
regs->si = *args++;
regs->dx = *args++;
case 3:
if (!n--) break;
regs->dx = *args++;
case 2:
regs->si = *args++;
case 4:
if (!n--) break;
regs->cx = *args++;
case 1:
regs->di = *args++;
case 5:
if (!n--) break;
regs->bx = *args++;
case 0:
regs->bp = *args++;
case 6:
if (!n--) break;
default:
BUG();
break;
}
else
# endif
switch (i + n) {
case 6:
switch (i) {
case 0:
if (!n--) break;
regs->r9 = *args++;
case 5:
regs->di = *args++;
case 1:
if (!n--) break;
regs->r8 = *args++;
case 4:
regs->si = *args++;
case 2:
if (!n--) break;
regs->r10 = *args++;
regs->dx = *args++;
case 3:
if (!n--) break;
regs->dx = *args++;
case 2:
regs->r10 = *args++;
case 4:
if (!n--) break;
regs->si = *args++;
case 1:
regs->r8 = *args++;
case 5:
if (!n--) break;
regs->di = *args++;
case 0:
regs->r9 = *args++;
case 6:
if (!n--) break;
default:
BUG();
break;
}
}

Expand Down

0 comments on commit 746e7ce

Please sign in to comment.