]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commitdiff
x86: constrain sub-page access length in mmio_ro_emulated_write()
authorJan Beulich <jbeulich@suse.com>
Mon, 28 Apr 2025 07:48:14 +0000 (09:48 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 28 Apr 2025 07:48:14 +0000 (09:48 +0200)
Without doing so we could trigger the ASSERT_UNREACHABLE() in
subpage_mmio_write_emulate(). A comment there actually says this
validation would already have been done ...

Fixes: 8847d6e23f97 ("x86/mm: add API for marking only part of a MMIO page read only")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
xen/arch/x86/mm.c

index 1cf23651678987f8e0724ebd5386bfef10db7508..ac5b51d17acacda60901b5643f40a1d2267af4b2 100644 (file)
@@ -5195,8 +5195,13 @@ int cf_check mmio_ro_emulated_write(
         return X86EMUL_UNHANDLEABLE;
     }
 
-    subpage_mmio_write_emulate(mmio_ro_ctxt->mfn, PAGE_OFFSET(offset),
-                               p_data, bytes);
+    if ( bytes <= 8 )
+        subpage_mmio_write_emulate(mmio_ro_ctxt->mfn, PAGE_OFFSET(offset),
+                                   p_data, bytes);
+    else if ( subpage_mmio_find_page(mmio_ro_ctxt->mfn) )
+        gprintk(XENLOG_WARNING,
+                "unsupported %u-byte write to R/O MMIO 0x%"PRI_mfn"%03lx\n",
+                bytes, mfn_x(mmio_ro_ctxt->mfn), PAGE_OFFSET(offset));
 
     return X86EMUL_OKAY;
 }