From 3e800027016ea4eb19887bf626b46f45fc43fa5d Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Wed, 19 May 2021 22:08:59 +0100 Subject: [PATCH] Work around GCC issue 99578 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 Reported-by: Christopher Clark Signed-off-by: Andrew Cooper Tested-by: Christopher Clark --- tests/xsa-170/main.c | 2 +- tests/xsa-298/main.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/xsa-170/main.c b/tests/xsa-170/main.c index d83f5d0..9b79e02 100644 --- a/tests/xsa-170/main.c +++ b/tests/xsa-170/main.c @@ -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 diff --git a/tests/xsa-298/main.c b/tests/xsa-298/main.c index 9d242db..ebad3fe 100644 --- a/tests/xsa-298/main.c +++ b/tests/xsa-298/main.c @@ -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)); /* -- 2.39.5