]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
Work around GCC issue 99578
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 19 May 2021 21:08:59 +0000 (22:08 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 17 Jun 2021 23:08:14 +0000 (00:08 +0100)
GCC 11.1 objects to pointers derived from a constant:

  error: '__builtin_memcpy' offset [0, 7] is out of the bounds [0, 0]  [-Werror=array-bounds]

This is a GCC bug, but work around it rather than turning array-bounds
checking off generally.

Reported-by: Damien Thenot <damien.thenot@vates.fr>
Reported-by: Christopher Clark <christopher.w.clark@gmail.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Christopher Clark <christopher.w.clark@gmail.com>
tests/xsa-170/main.c
tests/xsa-298/main.c

index d83f5d097cabf26ea0e8f64b12af54fbfdf3549d..9b79e023db794a68fc31187e22cefe23d70ac61b 100644 (file)
@@ -72,7 +72,7 @@ void test_main(void)
     pae_l4_identmap[255] = pte_from_virt(pae_l3_identmap, PF_SYM(AD, U, RW, P));
     barrier();
 
-    uint64_t *ptr = _p(0x00007ffffffffff8ULL);
+    void *volatile /* GCC issue 99578 */ ptr = _p(0x00007ffffffffff8ULL);
 
     /*
      * Put a NOP slide and Forced Emulation Prefix as the final instructions
index 9d242dbdcc7c1be933ac4c895d8c40889237fcd1..ebad3fe9829a2e6c6aed55073478731df6fc8f30 100644 (file)
@@ -97,7 +97,8 @@ void test_main(void)
     /*
      * Prepare userspace memory.
      */
-    memset(gate, 0, PAGE_SIZE);
+    void *volatile /* GCC issue 99578 */ ptr = gate;
+    memset(ptr, 0, PAGE_SIZE);
     remap_linear(gate, PF_SYM(AD, U, RW, P));
 
     /*