References: bsc#1181921

For linux.c and private.h
linux.c:165:50: error: argument 7 of type 'const xen_pfn_t[]' {aka 'const long unsigned int[]'} declared as an ordinary array [-Werror=vla-parameter]
  165 |                                  const xen_pfn_t arr[/*num*/], int err[/*num*/])
      |                                  ~~~~~~~~~~~~~~~~^~~~~~~~~~~~
In file included from linux.c:29:
private.h:35:50: note: previously declared as a variable length array 'const xen_pfn_t[num]' {aka 'const long unsigned int[num]'}
   35 |                                  const xen_pfn_t arr[num], int err[num]);
      |                                  ~~~~~~~~~~~~~~~~^~~~~~~~
linux.c:165:68: error: argument 8 of type 'int[]' declared as an ordinary array [-Werror=vla-parameter]
  165 |                                  const xen_pfn_t arr[/*num*/], int err[/*num*/])
      |                                                                ~~~~^~~~~~~~~~~~
In file included from linux.c:29:
private.h:35:64: note: previously declared as a variable length array 'int[num]'
   35 |                                  const xen_pfn_t arr[num], int err[num]);
      |                                                            ~~~~^~~~~~~~
cc1: all warnings being treated as errors


For mpparse.c
/home/abuild/rpmbuild/BUILD/xen-4.14.1-testing/xen/include/xen/string.h:101:27: error: '__builtin_memcmp' specified bound 4 exceeds source size 0 [-Werror=stringop-overread]
  101 | #define memcmp(s1, s2, n) __builtin_memcmp(s1, s2, n)
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
mpparse.c:722:13: note: in expansion of macro 'memcmp'
  722 |         if (memcmp(mpf->mpf_signature, "_MP_", 4) == 0 &&
      |             ^~~~~~


For tboot.c
In file included from tboot.c:16:
tboot.c: In function 'tboot_gen_frametable_integrity':
/home/abuild/rpmbuild/BUILD/xen-4.14.1-testing/xen/include/crypto/vmac.h:143:21: error: 'vhash_update' accessing 1 byte in a region of size 0 [-Werror=stringop-overflow=]
  143 | #define vmac_update vhash_update
tboot.c:324:9: note: in expansion of macro 'vmac_update'
  324 |         vmac_update((uint8_t *)pdx_to_page(sidx * PDX_GROUP_COUNT),
      |         ^~~~~~~~~~~
/home/abuild/rpmbuild/BUILD/xen-4.14.1-testing/xen/include/crypto/vmac.h:143:21: note: referencing argument 1 of type 'unsigned char *'
  143 | #define vmac_update vhash_update
tboot.c:324:9: note: in expansion of macro 'vmac_update'
  324 |         vmac_update((uint8_t *)pdx_to_page(sidx * PDX_GROUP_COUNT),
      |         ^~~~~~~~~~~
/home/abuild/rpmbuild/BUILD/xen-4.14.1-testing/xen/include/crypto/vmac.h:145:6: note: in a call to function 'vhash_update'
  145 | void vhash_update(unsigned char m[],
      |      ^~~~~~~~~~~~
/home/abuild/rpmbuild/BUILD/xen-4.14.1-testing/xen/include/crypto/vmac.h:143:21: error: 'vhash_update' accessing 1 byte in a region of size 0 [-Werror=stringop-overflow=]
  143 | #define vmac_update vhash_update
tboot.c:328:5: note: in expansion of macro 'vmac_update'
  328 |     vmac_update((uint8_t *)pdx_to_page(sidx * PDX_GROUP_COUNT),
      |     ^~~~~~~~~~~
/home/abuild/rpmbuild/BUILD/xen-4.14.1-testing/xen/include/crypto/vmac.h:143:21: note: referencing argument 1 of type 'unsigned char *'
  143 | #define vmac_update vhash_update
tboot.c:328:5: note: in expansion of macro 'vmac_update'
  328 |     vmac_update((uint8_t *)pdx_to_page(sidx * PDX_GROUP_COUNT),
      |     ^~~~~~~~~~~
/home/abuild/rpmbuild/BUILD/xen-4.14.1-testing/xen/include/crypto/vmac.h:145:6: note: in a call to function 'vhash_update'
  145 | void vhash_update(unsigned char m[],
      |      ^~~~~~~~~~~~
  INIT_O  bzimage.init.o
In file included from /home/abuild/rpmbuild/BUILD/xen-4.14.1-testing/xen/include/xen/lib.h:22,
                 from tboot.c:3:
tboot.c: In function 'tboot_probe':
/home/abuild/rpmbuild/BUILD/xen-4.14.1-testing/xen/include/xen/string.h:101:27: error: '__builtin_memcmp' specified bound 16 exceeds source size 0 [-Werror=stringop-overread]
  101 | #define memcmp(s1, s2, n) __builtin_memcmp(s1, s2, n)
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
tboot.c:105:10: note: in expansion of macro 'memcmp'
  105 |     if ( memcmp(&tboot_shared_uuid, (uuid_t *)tboot_shared, sizeof(uuid_t)) )
      |          ^~~~~~


For x86_emulate/x86_emulate.c
x86_emulate/x86_emulate.c:728:26: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
  728 |     (ptr)[0 - PFX_BYTES] = ext < ext_8f08 ? 0xc4 : 0x8f; \
      |     ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
x86_emulate/x86_emulate.c:736:9: note: in expansion of macro 'copy_VEX'
  736 |         copy_VEX(ptr, vex); \
      |         ^~~~~~~~



--- trunk.orig/tools/libs/foreignmemory/private.h	2021-03-05 12:35:57.802022411 +0100
+++ trunk/tools/libs/foreignmemory/private.h	2021-03-05 12:39:34.022154265 +0100
@@ -29,6 +29,9 @@ struct xenforeignmemory_handle {
 int osdep_xenforeignmemory_open(xenforeignmemory_handle *fmem);
 int osdep_xenforeignmemory_close(xenforeignmemory_handle *fmem);
 
+#if __GNUC__ >= 11
+#pragma GCC diagnostic ignored "-Wvla-parameter"
+#endif
 void *osdep_xenforeignmemory_map(xenforeignmemory_handle *fmem,
                                  uint32_t dom, void *addr,
                                  int prot, int flags, size_t num,
--- trunk.orig/xen/arch/x86/mpparse.c	2021-03-05 12:35:57.802022411 +0100
+++ trunk/xen/arch/x86/mpparse.c	2021-03-05 12:39:34.022154265 +0100
@@ -709,6 +709,9 @@ static int __init smp_scan_config (unsig
 	return 0;
 }
 
+#if __GNUC__ >= 11
+#pragma GCC diagnostic ignored "-Wstringop-overread"
+#endif
 static void __init efi_check_config(void)
 {
 	struct intel_mp_floating *mpf;
--- trunk.orig/xen/arch/x86/tboot.c	2021-03-05 12:35:57.802022411 +0100
+++ trunk/xen/arch/x86/tboot.c	2021-03-05 12:39:34.022154265 +0100
@@ -89,6 +89,9 @@ static void __init tboot_copy_memory(uns
     }
 }
 
+#if __GNUC__ >= 11
+#pragma GCC diagnostic ignored "-Wstringop-overread"
+#endif
 void __init tboot_probe(void)
 {
     tboot_shared_t *tboot_shared;
@@ -306,6 +309,9 @@ static void tboot_gen_xenheap_integrity(
     memset(&ctx, 0, sizeof(ctx));
 }
 
+#if __GNUC__ >= 11
+#pragma GCC diagnostic ignored "-Wstringop-overflow="
+#endif
 static void tboot_gen_frametable_integrity(const uint8_t key[TB_KEY_SIZE],
                                            vmac_t *mac)
 {
--- trunk.orig/xen/arch/x86/x86_emulate/x86_emulate.c	2021-03-05 12:35:57.802022411 +0100
+++ trunk/xen/arch/x86/x86_emulate/x86_emulate.c	2021-03-05 12:39:34.022154265 +0100
@@ -722,6 +722,9 @@ union vex {
     buf_ + 3; \
 })
 
+#if __GNUC__ >= 11
+#pragma GCC diagnostic ignored "-Wstringop-overflow="
+#endif
 #define copy_VEX(ptr, vex) ({ \
     if ( !mode_64bit() ) \
         (vex).reg |= 8; \
