* [PATCH-for-9.1? v2] hw/pci/pci-hmp-cmds: Avoid displaying bogus size in 'info pci'
@ 2024-08-01 13:14 Philippe Mathieu-Daudé
2024-08-16 6:16 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-01 13:14 UTC (permalink / raw)
To: qemu-devel
Cc: Michael S. Tsirkin, Marcel Apfelbaum, Philippe Mathieu-Daudé
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é <philmd@linaro.org>
---
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 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);
+ 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 {
- 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, "%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.45.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH-for-9.1? v2] hw/pci/pci-hmp-cmds: Avoid displaying bogus size in 'info pci'
2024-08-01 13:14 [PATCH-for-9.1? v2] hw/pci/pci-hmp-cmds: Avoid displaying bogus size in 'info pci' Philippe Mathieu-Daudé
@ 2024-08-16 6:16 ` Philippe Mathieu-Daudé
2024-08-16 7:37 ` Michael S. Tsirkin
0 siblings, 1 reply; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-16 6:16 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael S. Tsirkin, Marcel Apfelbaum
ping
On 1/8/24 15:14, Philippe Mathieu-Daudé wrote:
> 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é <philmd@linaro.org>
> ---
> 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 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);
> + 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 {
> - 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, "%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" : "");
> + }
> }
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-08-16 7:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-01 13:14 [PATCH-for-9.1? v2] hw/pci/pci-hmp-cmds: Avoid displaying bogus size in 'info pci' Philippe Mathieu-Daudé
2024-08-16 6:16 ` Philippe Mathieu-Daudé
2024-08-16 7:37 ` Michael S. Tsirkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).