From nobody Sun Nov 24 14:05:28 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=1722518113; cv=none; d=zohomail.com; s=zohoarc; b=RD/79ofoaO4md0VhR/xotUEEgsnlB1MdgyViYU1vUC6SBeIPgEY2k3RM1biBN+dos5EA3Dh1Mh3s15x1TcdoxoVmj0n8Fzp/QPJMgWj4p+HzFaSUOKhDplSWmkCv+eQ8Ww21f3g1zfmAXtWoWdTDmiMrNMrdr0HcLz+XEPI0X9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722518113; 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=7jwh8lRQxFh4MuUn3bOEyy7JI6tHJM1nsPaQiEvU4+o=; b=SM8cI4oME6Wewim4GTwjactNSjz4PiLqUYhZGGKdu3ZX2Egu9HXrFoWWRnpnrNe2ae4e5B2bh1d89CEKQl+38mdNe8alpC+p/5rUEc+r5TWnvuIC1kYU6Hyib8/gV9cyyMm0kLmqLKwxMetwYNGiEqjMgGq1Mzw6qX3jgK5Z+TA= 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 1722518113082541.1709699855256; Thu, 1 Aug 2024 06:15:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZVe1-0000ZP-VQ; Thu, 01 Aug 2024 09:15:01 -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 1sZVe0-0000YY-I8 for qemu-devel@nongnu.org; Thu, 01 Aug 2024 09:15:00 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZVdy-0007U9-QP for qemu-devel@nongnu.org; Thu, 01 Aug 2024 09:15:00 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-52f025bc147so9761505e87.3 for ; Thu, 01 Aug 2024 06:14:58 -0700 (PDT) Received: from m1x-phil.lan ([176.176.130.148]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acab4de47sm899780766b.67.2024.08.01.06.14.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 01 Aug 2024 06:14:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722518096; x=1723122896; 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=7jwh8lRQxFh4MuUn3bOEyy7JI6tHJM1nsPaQiEvU4+o=; b=lpgjrqae2LJ7EmskjYMD70ejmfc2Qn2TdyUpFZS75hMBSsXQs4vhGUbIcipSlDQ3Ob wSQ2zyFK3mxnTUcyddahUI9JsF/jocbSiek/3G1GcdbZmHk8FXufYqIEc7tn/erB34a0 4S6VYuIbNR6jnGZepr57Z9a6Po8epum8KCcsyQrmnT0cwM2VySs5cKZd08nUYZz6MFi1 TK1gANgi+zfiThgEVc+o46mESxzzAt08tVzcUMKqe1lgsePqVNCZVbN5Luai5nMA7+W7 IhSibZv3ZrRC95aUbxhFDUvXqN8OitUhrxXomF67qFGbN7o03N/cRSNo9eaNaAJkFQhH siQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722518096; x=1723122896; 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=7jwh8lRQxFh4MuUn3bOEyy7JI6tHJM1nsPaQiEvU4+o=; b=uPjsKG19uCJlj15CKgMf++Dwdg7Q8yMJ+rxSbCeDMOoaDG7U5WjNVGo9wmBLPFMUGj OcbRc+dH6Cd/7u5ZEW81PQDK2QSg6xCURTn1PmYBPat4+RlROhCqmxV7dXmHnzjS7NOj DZ7z2G1UKQKfC7qb6FLIzTj0e+jD2Is8qDUG4VLfrkoVq5u3mE6LjXOGDMyF3Kxceahl lFAjJpLKDd4ILLqD7vJEWx8sBZR56g02SOvD9IoguM6lKev9+LJxx86eespIwUwiAXSO qjEQawbkFHZkdazGam8wXDemkZW7CDgRDnWA2RA9Dm2XgpJ1+PvIkRFVyTj6pXuf0qv9 HzdQ== X-Gm-Message-State: AOJu0Yzrnz2ev46sG/PgFXMpCezwWg5eX0Y8Yh5GaUEo8l3D0fJtTjBz l6oO4VSx1/wjrOjOzxLkJo5bGTuiSBFj4/0MSIBNjcwrhiUdz9je32iI1SNDlkXDrLJ8Xm8/I6o 2L0w= X-Google-Smtp-Source: AGHT+IFDltY5HLk7iJijJ61W0mkLA6AfANbssOvnrf19t4bwqkm9cChuhqIDqQl8XZkgIc1M5ajjIw== X-Received: by 2002:a05:6512:2208:b0:52e:9b92:4999 with SMTP id 2adb3069b0e04-530b61a986bmr1708141e87.2.1722518096232; Thu, 01 Aug 2024 06:14:56 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.1? v2] hw/pci/pci-hmp-cmds: Avoid displaying bogus size in 'info pci' Date: Thu, 1 Aug 2024 15:14:49 +0200 Message-ID: <20240801131449.51328-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::133; envelope-from=philmd@linaro.org; helo=mail-lf1-x133.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: 1722518115083116600 When BAR aren't mapped, 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]. Check the BAR is mapped comparing its address to PCI_BAR_UNMAPPED which is what the PCI layer uses for unmapped BARs. See pci_bar_address and pci_update_mappings implementations and in "hw/pci/pci.h": typedef struct PCIIORegion { pcibus_t addr; /* current PCI mapping address. -1 means not mapped */ #define PCI_BAR_UNMAPPED (~(pcibus_t)0) ... This improves the logging, not displaying bogus sizes: (qemu) info pci Bus 0, device 0, function 0: Host bridge: PCI device dead:beef ... BAR4: 32 bit memory (not mapped) BAR5: I/O (not mapped) 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..fdfe44435c 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 PCI_BAR_UNMAPPED) { + monitor_printf(mon, "I/O at 0x%04" PRIx64 + " [0x%04" PRIx64 "]\n", + addr, addr + size - 1); + } else { + monitor_printf(mon, "I/O (not mapped)\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 PCI_BAR_UNMAPPED) { + 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 mapped)\n", + region->value->mem_type_64 ? 64 : 32, + region->value->prefetch ? " prefetchable" := ""); + } } } =20 --=20 2.45.2