qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] pc-bios/s390-ccw: Silence GCC 11 stringop-overflow warning


From: Thomas Huth
Subject: Re: [PATCH] pc-bios/s390-ccw: Silence GCC 11 stringop-overflow warning
Date: Sun, 2 May 2021 12:39:29 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0

On 22/04/2021 16.59, Philippe Mathieu-Daudé wrote:
When building on Fedora 34 (gcc version 11.0.0 20210210) we get:

   In file included from pc-bios/s390-ccw/main.c:11:
   In function ‘memset’,
       inlined from ‘boot_setup’ at pc-bios/s390-ccw/main.c:185:5,
       inlined from ‘main’ at pc-bios/s390-ccw/main.c:288:5:
   pc-bios/s390-ccw/libc.h:28:14: warning: writing 1 byte into a region of size 
0 [-Wstringop-overflow=]
      28 |         p[i] = c;
         |         ~~~~~^~~

The offending code is:

   memset((char *)S390EP, 0, 6);

where S390EP is a const address:

   #define S390EP 0x10008

The compiler doesn't now how big that pointed area is, so assume its
length is zero. This has been reported as BZ#99578 to GCC:
"gcc-11 -Warray-bounds or -Wstringop-overread warning when accessing a
pointer from integer literal"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578

As this warning does us more harm than good in the BIOS code (where
lot of direct accesses to low memory are done), silence this warning
for all BIOS objects.

Re-introduce the cc-c-option macro (see commit 036999e93e4) to check
whether the compiler supports this warning or not.

Suggested-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
  pc-bios/s390-ccw/Makefile | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile
index 29fd9019b83..21581d1258d 100644
--- a/pc-bios/s390-ccw/Makefile
+++ b/pc-bios/s390-ccw/Makefile
@@ -8,6 +8,8 @@ CFLAGS = -O2 -g
  quiet-command = $(if $(V),$1,$(if $(2),@printf "  %-7s %s\n" $2 $3 && $1, 
@$1))
  cc-option = $(if $(shell $(CC) $1 -S -o /dev/null -xc /dev/null > /dev/null \
              2>&1 && echo OK), $1, $2)
+cc-c-option = $(if $(shell $(CC) $1 $2 -c -o /dev/null -xc /dev/null \
+             >/dev/null 2>&1 && echo OK), $2, $3)
VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.sh %.rc Kconfig% %.json.in
  set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath 
$(PATTERN) $1)))
@@ -30,6 +32,7 @@ OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \
          virtio.o virtio-scsi.o virtio-blkdev.o libc.o cio.o dasd-ipl.o
QEMU_CFLAGS := -Wall $(filter -W%, $(QEMU_CFLAGS))
+QEMU_CFLAGS += $(call cc-c-option, $(QEMU_CFLAGS), -Wno-stringop-overflow)

 Hi Philippe,

looking at this patch again, I wonder whether it's really necessary to introduce the "cc-c-option" macro here? Wouldn't this work with the existing "cc-option" macro, too, since it's only about a flag that is used for the compiler, and not at the assembler stage?

 Thomas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]