Re: [Xen-devel] [PATCH] fix asm syntax

John Levon
Tue, 17 Oct 2006 16:42:11 -0000

On Tue, Oct 17, 2006 at 05:27:23PM +0100, Keir Fraser wrote:

> > Possibly --divide should alter the semantics in this case too.
It''s
> > something I need to bring up on the binutils list, but in the
meantime,
> > it seems like a bug we have to work around.
>
> Would ''rex64\'' work on Solaris, then?
>
> We could provide an OS-specific macro for forcing rex64.

How about the below.

regards
john

# HG changeset patch
# User john.levon@sun.com
# Date 1161103248 25200
# Node ID 4e217ea549122efcf2b6bba2c6aaf4b9581cac2f
# Parent  e5a8b0d52d68be688de73101dfe44145158d0cff
Define REX64_PREFIX to account for assembler syntax differences on SVR4
targets.

Signed-off-by: John Levon <john.levon@sun.com>

diff --git a/xen/arch/x86/i387.c b/xen/arch/x86/i387.c
--- a/xen/arch/x86/i387.c
+++ b/xen/arch/x86/i387.c
@@ -14,6 +14,7 @@
 #include <asm/processor.h>
 #include <asm/hvm/support.h>
 #include <asm/i387.h>
+#include <asm/asm_defns.h>

 void init_fpu(void)
 {
@@ -45,7 +46,7 @@ void save_init_fpu(struct vcpu *v)
          * mode that doesn''t require extended registers.
          */
         __asm__ __volatile__ (
-            "rex64/fxsave (%1)"
+            REX64_PREFIX "fxsave (%1)"
             : "=m" (*fpu_ctxt) : "cdaSDb" (fpu_ctxt) );
 #endif

@@ -95,7 +96,7 @@ void restore_fpu(struct vcpu *v)
             "1: fxrstor %0            \n"
 #else /* __x86_64__ */
             /* See above for why the operands/constraints are this way. */
-            "1: rex64/fxrstor (%2)    \n"
+            "1: " REX64_PREFIX "fxrstor (%2)    \n"
 #endif
             ".section .fixup,\"ax\"   \n"
             "2: push %%"__OP"ax       \n"
diff --git a/xen/include/asm-x86/x86_64/asm_defns.h
b/xen/include/asm-x86/x86_64/asm_defns.h
--- a/xen/include/asm-x86/x86_64/asm_defns.h
+++ b/xen/include/asm-x86/x86_64/asm_defns.h
@@ -60,6 +60,12 @@
 #define safe_swapgs                             \
         "mfence; swapgs;"

+#ifdef __sun__
+#define REX64_PREFIX "rex64\\"
+#else
+#define REX64_PREFIX "rex64/"
+#endif
+
 #define BUILD_SMP_INTERRUPT(x,v) XBUILD_SMP_INTERRUPT(x,v)
 #define XBUILD_SMP_INTERRUPT(x,v)               \
 asmlinkage void x(void);                        \