From nobody Sun Nov 24 14:31:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1722506909; cv=none; d=zohomail.com; s=zohoarc; b=JgD8Fy3MRJ/kwQV3PRmEU7dMgfrm7EW+rvPPH4hLOCzKDlti3DVAvI23ENF9MTpX+jQtUcPBupEiCXlAsk4wb+UWjfb5uuRccUgV//jH7sB+OCJK9PQEfgHb1BUpuUwGy7X5X9yxSgByeud8FHqCTr/hSkoIBABY6bMUOqAmh80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722506909; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=a6ArcVT1vup6+uuJoJ1ubNJgA9SGz0vY4xBKeQu+H+s=; b=irRB7Wy7YsgjpYy7CfO53ADsdwTslHJAgS9Ar0OCW+V0Et+WMd00VLI1P/1M6Qg1rUvT1tP+Ka4nlZp1wrBR2ldwMKzz1uE9ZKwC58qovp2saDDHclzZ31RByFh4s/Krqva7pTjMlTkW90fhZ2brJrfQljuM8tqvmU+8LtRqx8U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722506909760141.98315313746116; Thu, 1 Aug 2024 03:08:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZSit-000112-O5; Thu, 01 Aug 2024 06:07:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZSis-0000v4-1Q for qemu-devel@nongnu.org; Thu, 01 Aug 2024 06:07:50 -0400 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZSiq-0006c3-AQ for qemu-devel@nongnu.org; Thu, 01 Aug 2024 06:07:49 -0400 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a7abe5aa9d5so781676766b.1 for ; Thu, 01 Aug 2024 03:07:47 -0700 (PDT) Received: from m1x-phil.lan ([176.176.130.148]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acad9026fsm891732966b.145.2024.08.01.03.07.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 01 Aug 2024 03:07:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722506866; x=1723111666; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=a6ArcVT1vup6+uuJoJ1ubNJgA9SGz0vY4xBKeQu+H+s=; b=Wg8Rf95aKalsgQvpCS/MSR04pJymW/w+2uXctciVrHlH2mOH+avq5dETbdVqMZRPO0 v9FfynZU9P2t6ploJF9Ay7HiCVTEK0+bI8+qm6/U8stchSysGHLWsIMpSNLHF6ntjcQ2 kM2J6APh53qBlYOWhOdH6SNDroUkP8sfxqG5gStMZHEXN91pPde1dZRdCOj/zFUGt3hJ rs8yF4haKTZCRPEnZdJEr161Ou4wZPwZR2xeUYnRla3ksKPFMBrjrjEkq9BDhJ18b12i eyvsZha5DO6ry8Kb68Y/7ukD0m6E/OI3Lmiy+NPE8LwQwUk9im89nAPp/LrBAiihu3G1 mr2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722506866; x=1723111666; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=a6ArcVT1vup6+uuJoJ1ubNJgA9SGz0vY4xBKeQu+H+s=; b=kOegMB8DRk3miVID7Gqd11MrNz+mtRRXzd6czEWES5+xvF3zuL24gOrfywmKVCQLdJ 0sae7N3ZkvQoWoEgYeTPPyKkgw7d6KHJnEzGv42tinQf/OWpHnEyhVEdu6t/TZZjDqfH 3vfOLQ8HdDn2iMjM7cpSoPtUZDT3lFZ+fu7tlIGeVXalhYD7iJpC621fTltTFfVnW0vc zC2idp35EBQXAITnt3Y9LqzEbgiZk8/mZDoxlJZrSaBmHMyx/2cjBjJpGdFyM3+JvoHf k/YOo9Esss3sCLds/hoBYAD6MjOvSwNaxFSzYxYKBjV7mCITXJ8Ug3UtvnAQJQRLXHqJ gFAg== X-Gm-Message-State: AOJu0YwtnukIASefspNe2wN6v45ygxGfnwA7QOl0NGp3qPm0hqTp33A8 u3eFvxb6h/c//3R5RSIIdevA7tFFpMXp8kcBv0bqy3fo56xlQQHC9Ac7qiBhEyvCcsHGzUhP/tj E X-Google-Smtp-Source: AGHT+IF+gp8X9NEcdWcSwWpHzSINyZz2V93EMceK+gnmJc+psMfLWxuFUUOteZ2IdgJ0j+EvBVj9CA== X-Received: by 2002:a17:907:3909:b0:a7d:3cf6:48d1 with SMTP id a640c23a62f3a-a7daf56b6admr108148566b.32.1722506865968; Thu, 01 Aug 2024 03:07:45 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.1?] hw/pci/pci-hmp-cmds: Avoid displaying bogus size in 'info pci' Date: Thu, 1 Aug 2024 12:07:42 +0200 Message-ID: <20240801100742.50312-1-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62c; envelope-from=philmd@linaro.org; helo=mail-ej1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1722506911546116600 When BAR aren't configured, we get: (qemu) info pci Bus 0, device 0, function 0: Host bridge: PCI device dead:beef ... BAR4: 32 bit memory at 0xffffffffffffffff [0x00000ffe]. BAR5: I/O at 0xffffffffffffffff [0x0ffe]. Improve logging to not display bogus sizes: BAR4: 32 bit memory (not configured) BAR5: I/O (not configured) Remove trailing dot which is not used in other commands format. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/pci/pci-hmp-cmds.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/hw/pci/pci-hmp-cmds.c b/hw/pci/pci-hmp-cmds.c index b09fce9377..8421c3f74a 100644 --- a/hw/pci/pci-hmp-cmds.c +++ b/hw/pci/pci-hmp-cmds.c @@ -83,15 +83,25 @@ static void hmp_info_pci_device(Monitor *mon, const Pci= DeviceInfo *dev) monitor_printf(mon, " BAR%" PRId64 ": ", region->value->bar); =20 if (!strcmp(region->value->type, "io")) { - monitor_printf(mon, "I/O at 0x%04" PRIx64 - " [0x%04" PRIx64 "].\n", - addr, addr + size - 1); + if (addr !=3D UINT64_MAX) { + monitor_printf(mon, "I/O at 0x%04" PRIx64 + " [0x%04" PRIx64 "]\n", + addr, addr + size - 1); + } else { + monitor_printf(mon, "I/O (not configured)\n"); + } } else { - monitor_printf(mon, "%d bit%s memory at 0x%08" PRIx64 - " [0x%08" PRIx64 "].\n", - region->value->mem_type_64 ? 64 : 32, - region->value->prefetch ? " prefetchable" : "", - addr, addr + size - 1); + if (addr !=3D UINT64_MAX) { + monitor_printf(mon, "%d bit%s memory at 0x%08" PRIx64 + " [0x%08" PRIx64 "]\n", + region->value->mem_type_64 ? 64 : 32, + region->value->prefetch ? " prefetchable" := "", + addr, addr + size - 1); + } else { + monitor_printf(mon, "%d bit%s memory (not configured)\n", + region->value->mem_type_64 ? 64 : 32, + region->value->prefetch ? " prefetchable" := ""); + } } } =20 --=20 2.45.2