x86: constrain sub-page access length in mmio_ro_emulated_write()
PATCH v2 1/1 x86: constrain sub-page access length in mmio_ro_emulated_write()
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 ...
---
v2: Emit a warning message otherwise.
xen/arch/x86/mm.c +7 -2
@@ -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 ; }
Quoted 6 lines · Jan Beulich
Without doing so we could trigger the
ASSERT_UNREACHABLE()insubpage_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 <[email protected]>
Thanks,
Jason
Quoted 6 lines · Jan Beulich
Without doing so we could trigger the
ASSERT_UNREACHABLE()insubpage_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 <[email protected]>
Quoted 8 lines
---
v2: Emit a warning message otherwise.xen/arch/x86/mm.c +0
-0@@ -5195,8 +5195,13 @@ int cf_check mmio_ro_emulated_write(return X86EMUL_UNHANDLEABLE ; }
xen/arch/x86/mm.c int cf_check mmio_ro_emulated_write( · line 5204
Quoted 10 lines
xen/arch/x86/mm.c +7
-2-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));
It feels more natural to me to use:
"unsupported %u-byte write to r/o MMIO %#lx\n", bytes, mfn_to_maddr(mmio_ro_ctxt->mfn) + PAGE_OFFSET(offset)
As it simplifies the printf format string, but that's just my taste.
Thanks, Roger.