diff mbox series

[1/2] x86/emul: dump unhandled memory accesses for PVH dom0

Message ID 20250214092928.28932-2-roger.pau@citrix.com (mailing list archive)
State Superseded
Headers show
Series x86/pvh: workaround missing MMIO regions in dom0 p2m | expand

Commit Message

Roger Pau Monne Feb. 14, 2025, 9:29 a.m. UTC
A PV dom0 can map any host memory as long as it's allowed by the IO
capability range in d->iomem_caps.  On the other hand, a PVH dom0 has no
way to populate MMIO region onto it's p2m, so it's limited to what Xen
initially populates on the p2m based on the host memory map and the enabled
device BARs.

Introduce a new debug build only printk that reports attempts by dom0 to
access addresses not populated on the p2m, and not handled by any emulator.
This is for information purposes only, but might allow getting an idea of
what MMIO ranges might be missing on the p2m.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/hvm/emulate.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Jan Beulich Feb. 14, 2025, 11:23 a.m. UTC | #1
On 14.02.2025 10:29, Roger Pau Monne wrote:
> A PV dom0 can map any host memory as long as it's allowed by the IO
> capability range in d->iomem_caps.  On the other hand, a PVH dom0 has no
> way to populate MMIO region onto it's p2m, so it's limited to what Xen
> initially populates on the p2m based on the host memory map and the enabled
> device BARs.
> 
> Introduce a new debug build only printk that reports attempts by dom0 to
> access addresses not populated on the p2m, and not handled by any emulator.
> This is for information purposes only, but might allow getting an idea of
> what MMIO ranges might be missing on the p2m.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Hmm, yes, why not:
Acked-by: Jan Beulich <jbeulich@suse.com>
with one suggestion:

> --- a/xen/arch/x86/hvm/emulate.c
> +++ b/xen/arch/x86/hvm/emulate.c
> @@ -337,6 +337,9 @@ static int hvmemul_do_io(
>          /* If there is no suitable backing DM, just ignore accesses */
>          if ( !s )
>          {
> +            if ( is_mmio && is_hardware_domain(currd) )
> +                gdprintk(XENLOG_DEBUG, "unhandled memory %s to %#lx size %u\n",
> +                         dir ? "read" : "write", addr, size);

Can we make it "read from" and "write to"?

Jan
diff mbox series

Patch

diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index 0d90cc4598be..8aa7e49c056c 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -337,6 +337,9 @@  static int hvmemul_do_io(
         /* If there is no suitable backing DM, just ignore accesses */
         if ( !s )
         {
+            if ( is_mmio && is_hardware_domain(currd) )
+                gdprintk(XENLOG_DEBUG, "unhandled memory %s to %#lx size %u\n",
+                         dir ? "read" : "write", addr, size);
             rc = hvm_process_io_intercept(&null_handler, &p);
             vio->req.state = STATE_IOREQ_NONE;
         }