From nobody Sun Nov 24 07:59:01 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1726065058; cv=none; d=zohomail.com; s=zohoarc; b=Ry6bV6+UZTnmlv78Rm6/uX3CLC5AdhZGe05SeLJJYJXWSgi5oqfaxxlvyxcpJIji9YFsQIGGERh0qfmsKjA60TOZjW8nCsBwfrZ8iaeYBWhJlADAgIQnfuoqHWOOIG2RCEX/kF98bLGLDXpy/Utu0JF56agpf4Cyp5MO5PYe1lo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726065058; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iEUY6iNItmilx4GQ008agO3v3YGH5P6LxKz939t7m08=; b=AqadMQy8m0ERFSCu5NisultcZ6U92Emr94Fxy0ppzmx4qm633pNJ9dzjug3H68PEwpKg7RHSIGre0ncVDKBaKHikCo5zvHwTGuJu6j3Vy9oFSl5v1ELfpbqW3hZIZPfOlfpqIX13oObnb2NIlmNoNRlKDcanboESJ0zFNqD7MQE= 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 1726065058381904.838989176762; Wed, 11 Sep 2024 07:30:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soOKD-0000Vd-7q; Wed, 11 Sep 2024 10:28:05 -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 1soOJR-00079e-Ti for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:27:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1soOJO-0003NK-3q for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:27:15 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-345-BgIOjzUWOwmXZs7R1SCXDA-1; Wed, 11 Sep 2024 09:51:47 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a870f3a65a0so490947966b.0 for ; Wed, 11 Sep 2024 06:51:47 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d2593dbb7sm616986366b.56.2024.09.11.06.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:51:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726064832; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iEUY6iNItmilx4GQ008agO3v3YGH5P6LxKz939t7m08=; b=K4bUneE59c19ooa5tkGnHmgw2y1zGKa6q6umzd/YW2L7qqaazPvTbwMD1AXdoSyRTnBFEG jlH0ZRMWv/QK2CpNugmNvrxhfHai7ev+MrVR+g4DECgF8+Vi3t17Fdk3IMpqgtGhLd9H6R mP1gKOVCpk2izKy3SJ0BG1xVqXK7GiE= X-MC-Unique: BgIOjzUWOwmXZs7R1SCXDA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062705; x=1726667505; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iEUY6iNItmilx4GQ008agO3v3YGH5P6LxKz939t7m08=; b=tHxZcFXGiE7zWYXFZUFjCKqkzvDwoZeJhuJh3QXy51m0ysyfDV7SYPAJrK9AKh4Ae/ oS8mk0Dmd77cgcqcaaVAQqotkzqEnqc425yPCcV1ui1y4MXzeTCnYXpWj3f52i2RItJu IgYlAK0/6PCWx/1Ju8r4Y7GssDgF8A53MUKMOCaaRsHEGa9ol1mJzClhscAzy5/M3s+q 1pTTbzh7zv3b8OwM7+zn62AviZSU4w1g4D9N4It/OadbiFlofg2Ki/8Q7+AIM1sDfuak kzk4YaIyVkaW+MJbosN462ZCYracsnbSipJzJNI4E0CVwH7AXsEszZ0ukEvrhXnUHglf loWA== X-Gm-Message-State: AOJu0YyHv+kRkIJdNvB1CVapv4/zqeRYMxufEJTmCzuDGIqGgfMQNymu zlLDTEZrSbRskz84oxWrKPvKYljQ5yD9oM6i2Mp2c35JWZd1mVyopfvOunZyZCgc6YHX5sZywkQ a3Ww9lBRID8R9p9IGozyt/UkPDy/fi95oY0xL2hESehtg17nL7cuTNcm5YoYTy9YBwgxcjKjS1x YPuCpNO8NuLTEb7Cs/6K/s0j9+Azo2Eg== X-Received: by 2002:a17:906:794f:b0:a86:91c3:9517 with SMTP id a640c23a62f3a-a8ffab70902mr459445666b.35.1726062705417; Wed, 11 Sep 2024 06:51:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXPDKKnMF35RBQtFeyBFrrESbl4FumZQ7bj7lit8s9FtDwIrT3ZqdsFp8v83Z6DooXPauh/A== X-Received: by 2002:a17:906:794f:b0:a86:91c3:9517 with SMTP id a640c23a62f3a-a8ffab70902mr459442066b.35.1726062704829; Wed, 11 Sep 2024 06:51:44 -0700 (PDT) Date: Wed, 11 Sep 2024 09:51:41 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Marcel Apfelbaum Subject: [PULL 06/18] hw/pci/pci-hmp-cmds: Avoid displaying bogus size in 'info pci' Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1726065060062116600 From: Philippe Mathieu-Daud=C3=A9 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 Message-Id: <20240801131449.51328-1-philmd@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 MST