Blame SOURCES/kvm-pc-bios-s390-ccw-Silence-GCC-11-stringop-overflow-wa.patch

a83cc2
From c5b348e6d0334333295332c55fc4be51ce2668b8 Mon Sep 17 00:00:00 2001
a83cc2
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@redhat.com>
a83cc2
Date: Thu, 22 Apr 2021 16:59:11 +0200
a83cc2
Subject: [PATCH 33/39] pc-bios/s390-ccw: Silence GCC 11 stringop-overflow
a83cc2
 warning
a83cc2
MIME-Version: 1.0
a83cc2
Content-Type: text/plain; charset=UTF-8
a83cc2
Content-Transfer-Encoding: 8bit
a83cc2
a83cc2
RH-Author: Jon Maloy <jmaloy@redhat.com>
a83cc2
RH-MergeRequest: 24: v7:  Add support for building qemu-kvm with clang and safe-stack
a83cc2
RH-Commit: [6/11] 92851a154f2425363aa1f5ed2bb12740f589229e (jmaloy/qemu-kvm-centos-jon)
a83cc2
RH-Bugzilla: 1939509 1940132
a83cc2
RH-Acked-by: Danilo Cesar Lemes de Paula <ddepaula@redhat.com>
a83cc2
RH-Acked-by: Thomas Huth <thuth@redhat.com>
a83cc2
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
a83cc2
a83cc2
When building on Fedora 34 (gcc version 11.0.0 20210210) we get:
a83cc2
a83cc2
  In file included from pc-bios/s390-ccw/main.c:11:
a83cc2
  In function ‘memset’,
a83cc2
      inlined from ‘boot_setup’ at pc-bios/s390-ccw/main.c:185:5,
a83cc2
      inlined from ‘main’ at pc-bios/s390-ccw/main.c:288:5:
a83cc2
  pc-bios/s390-ccw/libc.h:28:14: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
a83cc2
     28 |         p[i] = c;
a83cc2
        |         ~~~~~^~~
a83cc2
a83cc2
The offending code is:
a83cc2
a83cc2
  memset((char *)S390EP, 0, 6);
a83cc2
a83cc2
where S390EP is a const address:
a83cc2
a83cc2
  #define S390EP 0x10008
a83cc2
a83cc2
The compiler doesn't know how big that pointed area is, so it assume that
a83cc2
its length is zero. This has been reported as BZ#99578 to GCC:
a83cc2
"gcc-11 -Warray-bounds or -Wstringop-overread warning when accessing a
a83cc2
pointer from integer literal"
a83cc2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578
a83cc2
a83cc2
As this warning does us more harm than good in the BIOS code (where
a83cc2
lot of direct accesses to low memory are done), silence this warning
a83cc2
for all BIOS objects.
a83cc2
a83cc2
Suggested-by: Thomas Huth <thuth@redhat.com>
a83cc2
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
a83cc2
Message-Id: <20210422145911.2513980-1-philmd@redhat.com>
a83cc2
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
a83cc2
Message-Id: <20210502174836.838816-4-thuth@redhat.com>
a83cc2
[thuth: Use the pre-existing cc-option macro instead of adding a new one]
a83cc2
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
a83cc2
Signed-off-by: Thomas Huth <thuth@redhat.com>
a83cc2
(cherry picked from commit da231910d33084ccf63f07de210b145e0fa31d98)
a83cc2
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
a83cc2
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
a83cc2
---
a83cc2
 pc-bios/s390-ccw/Makefile | 1 +
a83cc2
 1 file changed, 1 insertion(+)
a83cc2
a83cc2
diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile
a83cc2
index f0fe84c9eb..83fb1afb73 100644
a83cc2
--- a/pc-bios/s390-ccw/Makefile
a83cc2
+++ b/pc-bios/s390-ccw/Makefile
a83cc2
@@ -30,6 +30,7 @@ OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \
a83cc2
 	  virtio.o virtio-scsi.o virtio-blkdev.o libc.o cio.o dasd-ipl.o
a83cc2
 
a83cc2
 QEMU_CFLAGS := -Wall $(filter -W%, $(QEMU_CFLAGS))
a83cc2
+QEMU_CFLAGS += $(call cc-option,-Werror $(QEMU_CFLAGS),-Wno-stringop-overflow)
a83cc2
 QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE
a83cc2
 QEMU_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables
a83cc2
 QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector)
a83cc2
-- 
a83cc2
2.27.0
a83cc2