98 lines
3.6 KiB
Diff
98 lines
3.6 KiB
Diff
|
|
From 0ccf41541a2c2a65196327fc5466af611aa9f929 Mon Sep 17 00:00:00 2001
|
||
|
|
From: dinglimin <dinglimin@cmss.chinamobile.com>
|
||
|
|
Date: Mon, 16 Sep 2024 17:07:55 +0800
|
||
|
|
Subject: [PATCH] monitor/hmp-cmds: Avoid displaying bogus size in 'info pci'
|
||
|
|
When BAR aren't mapped, we get:
|
||
|
|
MIME-Version: 1.0
|
||
|
|
Content-Type: text/plain; charset=UTF-8
|
||
|
|
Content-Transfer-Encoding: 8bit
|
||
|
|
|
||
|
|
(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é <philmd@linaro.org>
|
||
|
|
Message-Id: <20240801131449.51328-1-philmd@linaro.org>
|
||
|
|
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||
|
|
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||
|
|
Signed-off-by: dinglimin <dinglimin@cmss.chinamobile.com>
|
||
|
|
---
|
||
|
|
monitor/hmp-cmds.c | 30 +++++++++++++++++++++---------
|
||
|
|
1 file changed, 21 insertions(+), 9 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
|
||
|
|
index c139e8087e..4abd4a8aa0 100644
|
||
|
|
--- a/monitor/hmp-cmds.c
|
||
|
|
+++ b/monitor/hmp-cmds.c
|
||
|
|
@@ -60,6 +60,8 @@
|
||
|
|
#include <spice/enums.h>
|
||
|
|
#endif
|
||
|
|
|
||
|
|
+#include "hw/pci/pci.h"
|
||
|
|
+
|
||
|
|
bool hmp_handle_error(Monitor *mon, Error *err)
|
||
|
|
{
|
||
|
|
if (err) {
|
||
|
|
@@ -781,15 +783,25 @@ static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev)
|
||
|
|
monitor_printf(mon, " BAR%" PRId64 ": ", region->value->bar);
|
||
|
|
|
||
|
|
if (!strcmp(region->value->type, "io")) {
|
||
|
|
- monitor_printf(mon, "I/O at 0x%04" PRIx64
|
||
|
|
- " [0x%04" PRIx64 "].\n",
|
||
|
|
- addr, addr + size - 1);
|
||
|
|
- } 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 != 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 {
|
||
|
|
+ if (addr != 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" : "");
|
||
|
|
+ }
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|