From nobody Sat Jul 12 15:13:39 2025 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.zoho.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 1486020285923182.09642267179765; Wed, 1 Feb 2017 23:24:45 -0800 (PST) Received: from localhost ([::1]:55006 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZBl6-00010n-0J for importer@patchew.org; Thu, 02 Feb 2017 02:24:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZ9kH-0007xm-6j for qemu-devel@nongnu.org; Thu, 02 Feb 2017 00:15:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZ9kA-0004IC-EO for qemu-devel@nongnu.org; Thu, 02 Feb 2017 00:15:45 -0500 Received: from ozlabs.org ([103.22.144.67]:47247) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZ9kA-0004F0-06; Thu, 02 Feb 2017 00:15:38 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3vDSqZ6V4dz9sN5; Thu, 2 Feb 2017 16:15:03 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1486012506; bh=E5YGdwqxPm6TYKCZQ/G6BNbBKyyYsFy26V3L7+cF5Og=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pWtQj44SvxwJqkFKHj0cybA2zDAqbYgCRymX8U7AjfFfNfWM2W4eI9pCz/xGSWKwd E3H34X54YMUP2m/pKhpBPCe68GgfLIuc7JgJBUT2U3TmyD31qS+micon17nY37Wv8e o1h7jypgeVvJxgKQKfXQvYTAsqUrDrYqA6mFgTW4= From: David Gibson To: peter.maydell@linaro.org Date: Thu, 2 Feb 2017 16:14:36 +1100 Message-Id: <20170202051445.5735-99-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170202051445.5735-1-david@gibson.dropbear.id.au> References: <20170202051445.5735-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 098/107] ppc: switch to constants within BUILD_BUG_ON 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: lvivier@redhat.com, thuth@redhat.com, "Michael S. Tsirkin" , qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Michael S. Tsirkin" We are switching BUILD_BUG_ON to verify that it's parameter is a compile-time constant, and it turns out that some gcc versions (specifically gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609) are not smart enough to figure it out for expressions involving local variables. This is harmless but means that the check is ineffective for these platforms. To fix, replace the variable with macros. Reported-by: Peter Maydell Signed-off-by: Michael S. Tsirkin [dwg: Correct a printf format warning] Signed-off-by: David Gibson --- hw/ppc/spapr.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 9fc3fb9..e465d7a 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2662,8 +2662,8 @@ static void spapr_phb_placement(sPAPRMachineState *sp= apr, uint32_t index, * 1TiB 64-bit MMIO windows for each PHB. */ const uint64_t base_buid =3D 0x800000020000000ULL; - const int max_phbs =3D - (SPAPR_PCI_LIMIT - SPAPR_PCI_BASE) / SPAPR_PCI_MEM64_WIN_SIZE - 1; +#define SPAPR_MAX_PHBS ((SPAPR_PCI_LIMIT - SPAPR_PCI_BASE) / \ + SPAPR_PCI_MEM64_WIN_SIZE - 1) int i; =20 /* Sanity check natural alignments */ @@ -2672,12 +2672,14 @@ static void spapr_phb_placement(sPAPRMachineState *= spapr, uint32_t index, QEMU_BUILD_BUG_ON((SPAPR_PCI_MEM64_WIN_SIZE % SPAPR_PCI_MEM32_WIN_SIZE= ) !=3D 0); QEMU_BUILD_BUG_ON((SPAPR_PCI_MEM32_WIN_SIZE % SPAPR_PCI_IO_WIN_SIZE) != =3D 0); /* Sanity check bounds */ - QEMU_BUILD_BUG_ON((max_phbs * SPAPR_PCI_IO_WIN_SIZE) > SPAPR_PCI_MEM32= _WIN_SIZE); - QEMU_BUILD_BUG_ON((max_phbs * SPAPR_PCI_MEM32_WIN_SIZE) > SPAPR_PCI_ME= M64_WIN_SIZE); - - if (index >=3D max_phbs) { - error_setg(errp, "\"index\" for PAPR PHB is too large (max %u)", - max_phbs - 1); + QEMU_BUILD_BUG_ON((SPAPR_MAX_PHBS * SPAPR_PCI_IO_WIN_SIZE) > + SPAPR_PCI_MEM32_WIN_SIZE); + QEMU_BUILD_BUG_ON((SPAPR_MAX_PHBS * SPAPR_PCI_MEM32_WIN_SIZE) > + SPAPR_PCI_MEM64_WIN_SIZE); + + if (index >=3D SPAPR_MAX_PHBS) { + error_setg(errp, "\"index\" for PAPR PHB is too large (max %llu)", + SPAPR_MAX_PHBS - 1); return; } =20 --=20 2.9.3