Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Nov 2008 23:14:03 GMT
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 152335 for review
Message-ID:  <200811012314.mA1NE37l045516@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=152335

Change 152335 by peter@peter_overcee on 2008/11/01 23:13:59

	Take a halfway complete shot at implementing async syscall wrappers for
	amd64.  (And sync/reduce-diffs with linux version)

Affected files ...

.. //depot/projects/valgrind/coregrind/m_syswrap/syscall-amd64-freebsd.S#4 edit

Differences ...

==== //depot/projects/valgrind/coregrind/m_syswrap/syscall-amd64-freebsd.S#4 (text+ko) ====

@@ -1,13 +1,13 @@
 
-##--------------------------------------------------------------------##
-##--- Support for doing system calls.        syscall-amd64-linux.S ---##
-##--------------------------------------------------------------------##
+/*--------------------------------------------------------------------*/
+/*--- Support for doing system calls.      syscall-amd64-freebsd.S ---*/
+/*--------------------------------------------------------------------*/
 
 /*
   This file is part of Valgrind, a dynamic binary instrumentation
   framework.
 
-  Copyright (C) 2000-2006 Julian Seward 
+  Copyright (C) 2000-2008 Julian Seward 
      jseward@acm.org
 
   This program is free software; you can redistribute it and/or
@@ -66,8 +66,20 @@
 				  void* guest_state,		// rsi
 				  const vki_sigset_t *sysmask,	// rdx
 				  const vki_sigset_t *postmask,	// rcx
-				  Int nsigwords)		// r8
-				   
+				  Int nsigwords,		// r8
+				  SyscallArgs *args)		// r9
+
+See priv_types_n_macros.h for SyscallArgs layout:
+      UWord sysno;             // 0
+      UWord arg1;              // 8
+      UWord arg2;              // 16
+      UWord arg3;              // 24
+      UWord arg4;              // 32
+      UWord arg5;              // 40
+      UWord arg6;              // 48
+      UWord arg7;              // 56
+      UWord arg8;              // 64
+
 */
 
 /* from vki_arch.h */	
@@ -113,13 +125,11 @@
 	movq	$VKI_SIG_SETMASK, %rdi		// how
 	movq	%rdx, %rsi			// sysmask
 	movq	%rcx, %rdx			// postmask
-	movq	%r8, %r10			// nsigwords
 	syscall
 
 	POP_di_si_dx_cx_8
 	
-	testq	%rax, %rax
-	js	7f	/* sigprocmask failed */
+	jb	7f	/* sigprocmask failed */
 
 	/* OK, that worked.  Now do the syscall proper. */
 	
@@ -144,8 +154,13 @@
 
 	POP_di_si_dx_cx_8
 
+	pushf
+	popq	%r15
 	movq	%rax, OFFSET_amd64_RAX(%rsi)	/* save back to RAX */
+	movq	%rdx, OFFSET_amd64_RDX(%rsi)	/* save back to RDX */
 
+	/* QQQ Race here.  see syscall-x86-freebsd.S comment */
+
 4:	/* Re-block signals.  If eip is in [4,5), then the syscall 
 	   is complete and we needn't worry about it. */
 
@@ -155,15 +170,22 @@
 	movq	$VKI_SIG_SETMASK, %rdi		// how
 	movq	%rcx, %rsi			// postmask
 	xorq	%rdx, %rdx			// NULL
-	movq	%r8, %r10			// nsigwords
 	syscall
 
 	POP_di_si_dx_cx_8
 
-	testq	%rax, %rax
-	js	7f	/* sigprocmask failed */
+	jb	7f	/* sigprocmask failed */
 
 5:	/* now safe from signals */
+
+	PUSH_di_si_dx_cx_8
+	/* Export carry state */
+	movq	%r15,%rdi
+	andq	$1, %rdi
+	/* rsi still --> VexGuestAMD64State * */
+	call	LibVEX_GuestAMD64_put_rflag_c
+	POP_di_si_dx_cx_8
+
 	movq	$0, %rax	/* SUCCESS */
 	popq	%r15
 	popq	%r14
@@ -174,8 +196,6 @@
 	ret
 
 7:	/* failure:	 return 0x8000 | error code */
-	negq	%rax
-	andq	$0x7FFF, %rax
 	orq	$0x8000, %rax
 	popq	%r15
 	popq	%r14
@@ -206,6 +226,6 @@
 /* Let the linker know we don't need an executable stack */
 .section .note.GNU-stack,"",@progbits
 
-##--------------------------------------------------------------------##
-##--- end                                                          ---##
-##--------------------------------------------------------------------##
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811012314.mA1NE37l045516>