From nobody Mon Feb 9 19:07:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502206470825390.8172436531694; Tue, 8 Aug 2017 08:34:30 -0700 (PDT) Received: from localhost ([::1]:43209 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df6Wb-0005n0-DQ for importer@patchew.org; Tue, 08 Aug 2017 11:34:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df6S4-00016x-Jh for qemu-devel@nongnu.org; Tue, 08 Aug 2017 11:29:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df6S3-0006eo-Bz for qemu-devel@nongnu.org; Tue, 08 Aug 2017 11:29:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2113) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1df6S3-0006eL-3a for qemu-devel@nongnu.org; Tue, 08 Aug 2017 11:29:47 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11BBF356FD; Tue, 8 Aug 2017 15:29:46 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-116-237.ams2.redhat.com [10.36.116.237]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DD227095B; Tue, 8 Aug 2017 15:29:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 11BBF356FD Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=pbonzini@redhat.com From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 8 Aug 2017 17:29:35 +0200 Message-Id: <20170808152941.11247-4-pbonzini@redhat.com> In-Reply-To: <20170808152941.11247-1-pbonzini@redhat.com> References: <20170808152941.11247-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 08 Aug 2017 15:29:46 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/9] kvm: workaround build break on gcc-7.1.1 / fedora26 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz Building QEMU on fedora26 with the latest gcc package fails: CC ppc64-softmmu/target/ppc/kvm.o In file included from include/sysemu/hw_accel.h:16:0, from target/ppc/kvm.c:31: target/ppc/kvm.c: In function =C3=A2=E2=82=AC=CB=9Ckvmppc_booke_watchdog_en= able=C3=A2=E2=82=AC=E2=84=A2: include/sysemu/kvm.h:449:35: error: =C3=A2=E2=82=AC=CB=9Cargs_tmp[i]=C3=A2= =E2=82=AC=E2=84=A2 may be used uninitialized in this function [-Werror=3Dmaybe-uninitialized] cap.args[i] =3D args_tmp[i]; \ ^ target/ppc/kvm.c: In function =C3=A2=E2=82=AC=CB=9Ckvmppc_set_papr=C3=A2=E2= =82=AC=E2=84=A2: include/sysemu/kvm.h:449:35: error: =C3=A2=E2=82=AC=CB=9Cargs_tmp[i]=C3=A2= =E2=82=AC=E2=84=A2 may be used uninitialized in this function [-Werror=3Dmaybe-uninitialized] cc1: all warnings being treated as errors $ rpm -q gcc gcc-7.1.1-3.fc26.ppc64le The compiler should obviously optimize this code away when no extra agument is passed to kvm_vm_enable_cap() and kvm_vcpu_enable_cap(), but it doesn't. This bug should be fixed one day in gcc, but we can also change our code pattern so that we don't hit the issue anymore. We workaround this, by using memcpy() instead of open-coding the copy. Signed-off-by: Greg Kurz Message-Id: <150210580404.1343.7325713896658799315.stgit@bahia.lan> Acked-by: Cornelia Huck Signed-off-by: Paolo Bonzini --- include/sysemu/kvm.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 91fc07ee9a..3a458f50e9 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -428,11 +428,8 @@ int kvm_vm_check_extension(KVMState *s, unsigned int e= xtension); .flags =3D cap_flags, \ }; \ uint64_t args_tmp[] =3D { __VA_ARGS__ }; \ - int i; \ - for (i =3D 0; i < (int)ARRAY_SIZE(args_tmp) && \ - i < ARRAY_SIZE(cap.args); i++) { \ - cap.args[i] =3D args_tmp[i]; \ - } \ + size_t n =3D MIN(ARRAY_SIZE(args_tmp), ARRAY_SIZE(cap.args)); \ + memcpy(cap.args, args_tmp, n * sizeof(cap.args[0])); \ kvm_vm_ioctl(s, KVM_ENABLE_CAP, &cap); \ }) =20 @@ -443,11 +440,8 @@ int kvm_vm_check_extension(KVMState *s, unsigned int e= xtension); .flags =3D cap_flags, \ }; \ uint64_t args_tmp[] =3D { __VA_ARGS__ }; \ - int i; \ - for (i =3D 0; i < (int)ARRAY_SIZE(args_tmp) && \ - i < ARRAY_SIZE(cap.args); i++) { \ - cap.args[i] =3D args_tmp[i]; \ - } \ + size_t n =3D MIN(ARRAY_SIZE(args_tmp), ARRAY_SIZE(cap.args)); \ + memcpy(cap.args, args_tmp, n * sizeof(cap.args[0])); \ kvm_vcpu_ioctl(cpu, KVM_ENABLE_CAP, &cap); \ }) =20 --=20 2.13.3