All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pc-bios/s390-ccw: Silence GCC 11 stringop-overflow warning
@ 2021-04-22 14:59 Philippe Mathieu-Daudé
  2021-04-22 15:02 ` Christian Borntraeger
  2021-05-02 10:39 ` Thomas Huth
  0 siblings, 2 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-22 14:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Thomas Huth, Daniel P . Berrangé,
	Janosch Frank, Cornelia Huck, Richard Henderson,
	Christian Borntraeger, qemu-s390x, Miroslav Rezanina,
	Philippe Mathieu-Daudé,
	Stefano Garzarella

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)
 QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE
 QEMU_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables
 QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector)
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] pc-bios/s390-ccw: Silence GCC 11 stringop-overflow warning
  2021-04-22 14:59 [PATCH] pc-bios/s390-ccw: Silence GCC 11 stringop-overflow warning Philippe Mathieu-Daudé
@ 2021-04-22 15:02 ` Christian Borntraeger
  2021-05-02 10:39 ` Thomas Huth
  1 sibling, 0 replies; 4+ messages in thread
From: Christian Borntraeger @ 2021-04-22 15:02 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Thomas Huth, Daniel P . Berrangé,
	Janosch Frank, Cornelia Huck, Richard Henderson, qemu-s390x,
	Miroslav Rezanina, Stefano Garzarella

On 22.04.21 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>

untested, but
Acked-by: Christian Borntraeger <borntraeger@de.ibm.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)
>   QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE
>   QEMU_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables
>   QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector)
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] pc-bios/s390-ccw: Silence GCC 11 stringop-overflow warning
  2021-04-22 14:59 [PATCH] pc-bios/s390-ccw: Silence GCC 11 stringop-overflow warning Philippe Mathieu-Daudé
  2021-04-22 15:02 ` Christian Borntraeger
@ 2021-05-02 10:39 ` Thomas Huth
  2021-05-02 11:01   ` Thomas Huth
  1 sibling, 1 reply; 4+ messages in thread
From: Thomas Huth @ 2021-05-02 10:39 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Daniel P . Berrangé,
	Janosch Frank, Cornelia Huck, Richard Henderson,
	Christian Borntraeger, qemu-s390x, Miroslav Rezanina,
	Stefano Garzarella

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] pc-bios/s390-ccw: Silence GCC 11 stringop-overflow warning
  2021-05-02 10:39 ` Thomas Huth
@ 2021-05-02 11:01   ` Thomas Huth
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Huth @ 2021-05-02 11:01 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, Daniel P . Berrangé,
	Janosch Frank, Cornelia Huck, Richard Henderson,
	Christian Borntraeger, qemu-s390x, Miroslav Rezanina,
	Stefano Garzarella

On 02/05/2021 12.39, Thomas Huth wrote:
> 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?

Darn, that old cc-option macro seems to be broken ... needs to be fixed 
first ... I'll try to come up with a patch.

  Thomas



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-02 11:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22 14:59 [PATCH] pc-bios/s390-ccw: Silence GCC 11 stringop-overflow warning Philippe Mathieu-Daudé
2021-04-22 15:02 ` Christian Borntraeger
2021-05-02 10:39 ` Thomas Huth
2021-05-02 11:01   ` Thomas Huth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.