]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
x86/hvm: Adjust hvmemul_rep_stos() to compile with -Wvla
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 17 Sep 2018 15:32:32 +0000 (16:32 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 25 Sep 2018 10:59:32 +0000 (11:59 +0100)
When using -Wvla, the typecast of buf triggers a Variable Length Array
warning.  This is less than ideal, as this typecast doesn't occupy any stack
space, but we don't have a finer grain option to use.

Alter the asm expression to avoid the typecast, which necessitates the
introduction of a memory clobber as the compiler can no longer identify
the total quantity of written memory.

Despite the memory clobber, there is no change to the generated asm.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
xen/arch/x86/hvm/emulate.c

index a577685dc61bad26064c95bd4df35496f29c2372..eab66eab7799882f2c33ab4c1e116d8bc5e8fcae 100644 (file)
@@ -1859,7 +1859,7 @@ static int hvmemul_rep_stos(
     switch ( p2mt )
     {
         unsigned long bytes;
-        void *buf;
+        char *buf;
 
     default:
         /* Allocate temporary buffer. */
@@ -1882,10 +1882,10 @@ static int hvmemul_rep_stos(
 #define CASE(bits, suffix)                                     \
             case (bits) / 8:                                   \
                 asm ( "rep stos" #suffix                       \
-                      : "=m" (*(char (*)[bytes])buf),          \
+                      : "=m" (*buf),                           \
                         "=D" (dummy), "=c" (dummy)             \
                       : "a" (*(const uint##bits##_t *)p_data), \
-                         "1" (buf), "2" (*reps) );             \
+                        "1" (buf), "2" (*reps) : "memory" );   \
                 break
             CASE(8, b);
             CASE(16, w);