mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86 syscall.h: fix argument order
       [not found] <1223913511.15996.13.camel@elijah.suse.cz>
@ 2008-10-14  1:40 ` Roland McGrath
  2008-10-22 14:54   ` Ingo Molnar
  0 siblings, 1 reply; 2+ messages in thread
From: Roland McGrath @ 2008-10-14  1:40 UTC (permalink / raw)
  To: Linus Torvalds, Andrew Morton
  Cc: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Petr Tesarik, linux-kernel

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.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Signed-off-by: Roland McGrath <roland@redhat.com>
---
 include/asm-x86/syscall.h |  106 +++++++++++++++++++++++----------------------
 1 files changed, 54 insertions(+), 52 deletions(-)

diff --git a/include/asm-x86/syscall.h b/include/asm-x86/syscall.h
index 04c47dc..ec2a95e 100644
--- a/include/asm-x86/syscall.h
+++ b/include/asm-x86/syscall.h
@@ -93,26 +93,26 @@ 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();
@@ -120,26 +120,26 @@ static inline void syscall_get_arguments(struct task_struct *task,
 		}
 	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();
@@ -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;
 		}
 }
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86 syscall.h: fix argument order
  2008-10-14  1:40 ` [PATCH] x86 syscall.h: fix argument order Roland McGrath
@ 2008-10-22 14:54   ` Ingo Molnar
  0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2008-10-22 14:54 UTC (permalink / raw)
  To: Roland McGrath
  Cc: Linus Torvalds, Andrew Morton, Thomas Gleixner, H. Peter Anvin,
	Petr Tesarik, linux-kernel


* Roland McGrath <roland@redhat.com> wrote:

> 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.
> 
> Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
> Signed-off-by: Roland McGrath <roland@redhat.com>
> ---
>  include/asm-x86/syscall.h |  106 +++++++++++++++++++++++----------------------
>  1 files changed, 54 insertions(+), 52 deletions(-)

applied to tip/x86/urgent, thanks! I added an:

  Original-by: Petr Tesarik <ptesarik@suse.cz>

because Petr's SOB on the first line looks weird.

	Ingo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-10-22 14:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1223913511.15996.13.camel@elijah.suse.cz>
2008-10-14  1:40 ` [PATCH] x86 syscall.h: fix argument order Roland McGrath
2008-10-22 14:54   ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®