public inbox for trinity@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix syscall32 to supply 6th arg to syscal
@ 2013-09-19 21:24 Ildar Muslukhov
  2013-09-19 21:35 ` Dave Jones
  2013-10-02 15:12 ` Dave Jones
  0 siblings, 2 replies; 12+ messages in thread
From: Ildar Muslukhov @ 2013-09-19 21:24 UTC (permalink / raw)
  To: trinity; +Cc: davej


This patch fixes missing 6th param for 32bit syscalls in i386 and x86_64 
archs.

Note: I have to remove static from syscall32, because gcc messes up with 
inline asm becuase of that.

Signed-off-by: Ildar Muslukhov <ildarm@google.com>

---
 include/syscall.h |  1 +
 syscall.c         | 44 +++++++++++++++++++++++++++++++++++---------
 2 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/include/syscall.h b/include/syscall.h
index 9fc9885..faaeafc 100644
--- a/include/syscall.h
+++ b/include/syscall.h
@@ -134,6 +134,7 @@ void count_syscalls_enabled(void);
 void display_enabled_syscalls(void);
 void disable_non_net_syscalls(void);
 void init_syscalls(void);
+long syscall32(int num_args, unsigned int call, unsigned long a1, unsigned long a2, unsigned long a3, unsigned long a4, unsigned long a5, unsigned long a6);
 
 #define for_each_32bit_syscall(i) \
 	for (i = 0; i < max_nr_32bit_syscalls; i++)
diff --git a/syscall.c b/syscall.c
index 866ac71..63f25a6 100644
--- a/syscall.c
+++ b/syscall.c
@@ -33,22 +33,48 @@
 	return (type) (res); \
 } while (0)
 
-static long syscall32(int num_args, unsigned int call,
+long syscall32(int num_args, unsigned int call,
 	unsigned long a1, unsigned long a2, unsigned long a3,
-	unsigned long a4, unsigned long a5, __unused__ unsigned long a6)
+	unsigned long a4, unsigned long a5, unsigned long a6)
 {
 #if defined(__i386__) || defined (__x86_64__)
-	if (num_args < 6) {
+
+	if (num_args <= 6) {
 		long __res;
-		__asm__ volatile ("int $0x80"
+#if defined( __i386__)
+		__asm__ volatile (
+			"pushl %%ebp\n\t"
+			"movl %7, %%ebp\n\t"
+			"int $0x80\n\t"
+			"popl %%ebp\n\t"
+			: "=a" (__res)
+			: "0" (call),"b" ((long)(a1)),"c" ((long)(a2)),"d" ((long)(a3)), "S" ((long)(a4)),"D" ((long)(a5)), "g" ((long)(a6))
+			: "%ebp" /* mark EBP reg as dirty */
+			);
+#elif defined(__x86_64__)
+		__asm__ volatile (
+			"pushq %%rbp\n\t"
+			"movq %7, %%rbp\n\t"
+			"int $0x80\n\t"
+			"popq %%rbp\n\t"
 			: "=a" (__res)
-			: "0" (call),"b" ((long)(a1)),"c" ((long)(a2)),
-			"d" ((long)(a3)), "S" ((long)(a4)),
-			"D" ((long)(a5)));
+			: "0" (call),"b" ((long)(a1)),"c" ((long)(a2)),"d" ((long)(a3)), "S" ((long)(a4)),"D" ((long)(a5)), "g" ((long)(a6))
+			: "%rbp" /* mark EBP reg as dirty */
+			);
+#else
+	//To shut up gcc on unused args. This code should never be reached.
+	__res = 0;
+	UNUSED(num_args);
+	UNUSED(call);
+	UNUSED(a1);
+	UNUSED(a2);
+	UNUSED(a3);
+	UNUSED(a4);
+	UNUSED(a5);
+	UNUSED(a6);
+#endif
 		__syscall_return(long,__res);
-		return __res;
 	}
-/* TODO: 6 arg 32bit x86 syscall goes here.*/
 #else
 
 // TODO: 32-bit syscall entry for non-x86 archs goes here.
-- 
1.8.4

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

end of thread, other threads:[~2013-10-02 21:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-19 21:24 [PATCH] Fix syscall32 to supply 6th arg to syscal Ildar Muslukhov
2013-09-19 21:35 ` Dave Jones
2013-10-02 15:12 ` Dave Jones
2013-10-02 16:14   ` Ildar Muslukhov
2013-10-02 16:43     ` Dave Jones
2013-10-02 18:12       ` Ildar Muslukhov
2013-10-02 18:15         ` Dave Jones
2013-10-02 20:44           ` Ildar Muslukhov
2013-10-02 20:48             ` Dave Jones
2013-10-02 20:53               ` Ildar Muslukhov
2013-10-02 20:57                 ` Dave Jones
2013-10-02 21:03                   ` Ildar Muslukhov

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