]> xenbits.xensource.com Git - xen.git/commitdiff
x86: fix build following c/s 623c720f "x86: use CLFLUSHOPT when available"
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 12 Feb 2016 09:32:52 +0000 (10:32 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 12 Feb 2016 09:32:52 +0000 (10:32 +0100)
CentOS 7 gets into trouble when compiling Xen citing:

  flushtlb.c: Assembler messages:
  flushtlb.c:149: Error: value of 256 too large for field of 1 bytes at 1

The line number is wrong, and the error message not helpful.  It turns out
that the intermediate generated assembly was

  # 139 "arch/x86/flushtlb.c" 1
      661:
      rex clflush (%r15)
  662:
  .pushsection .altinstructions,"a"

and it was having trouble combining the explicit REX prefix with the REX.B
required for the use of %r15.

Follow what Linux does and use a redundant %ds prefix instead, for a final
generated instruction of `3e 41 0f ae 3f`

While modifying this line, fix the indentation which was out by one space.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Doug Goldstein <cardoe@cardoe.com>
Introduce and use NOP_DS_PREFIX.

Also the above description of the issue is slightly wrong: We're not
suffering from some gas versions not being able to combine multiple REX
prefixes, but from the replacement instruction, when requiring a REX
prefix in order to express the memory operand, becoming one byte longer
than the original one, triggering the respective build time safety
check.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/flushtlb.c
xen/include/asm-x86/nops.h

index 90a004f88ffe7e26af172ba73d18652f3fb34842..961bb1dd02f1f0fe19485393d40714357aa8c0ff 100644 (file)
@@ -141,10 +141,11 @@ void flush_area_local(const void *va, unsigned int flags)
         {
             alternative(ASM_NOP3, "sfence", X86_FEATURE_CLFLUSHOPT);
             for ( i = 0; i < sz; i += c->x86_clflush_size )
-                 alternative_input("rex clflush %0",
-                                   "data16 clflush %0",
-                                   X86_FEATURE_CLFLUSHOPT,
-                                   "m" (((const char *)va)[i]));
+                alternative_input(".byte " __stringify(NOP_DS_PREFIX) ";"
+                                  " clflush %0",
+                                  "data16 clflush %0",      /* clflushopt */
+                                  X86_FEATURE_CLFLUSHOPT,
+                                  "m" (((const char *)va)[i]));
         }
         else
         {
index 05f916230f48cba6ad51e1febee362eec396c486..1368a971dfe4ed6fa2a5bf556f682afe0fc27b5e 100644 (file)
@@ -7,6 +7,8 @@
  * Define nops for use with alternative().
  */
 
+#define NOP_DS_PREFIX 0x3e
+
 /*
  * Opteron 64bit nops
  * 1: nop