MMIO operation handlers can be expensive to process, hence attempt to
register only those that will be needed by the domain.
Subpage r/o MMIO regions are added exclusively at boot, further limit their
addition to strictly before the initial domain gets created, so by the time
initial domain creation happens Xen knows whether subpage is required or
not. This allows only registering the MMIO handler when there are
subpage regions to handle.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
register_portio_handler(d, XEN_HVM_DEBUGCONS_IOPORT, 1, hvm_print_line);
- register_subpage_ro_handler(d);
+ if ( subpage_ro_active() )
+ register_subpage_ro_handler(d);
if ( hvm_tsc_scaling_supported )
d->arch.hvm.tsc_scaling_ratio = hvm_default_tsc_scaling_ratio;
void __iomem *mapped;
DECLARE_BITMAP(ro_elems, PAGE_SIZE / MMIO_RO_SUBPAGE_GRAN);
};
+bool subpage_ro_active(void);
struct subpage_ro_range *subpage_mmio_find_page(mfn_t mfn);
void __iomem *subpage_mmio_map_page(struct subpage_ro_range *entry);
void subpage_mmio_write_emulate(
return rc;
}
+bool subpage_ro_active(void)
+{
+ return !list_empty(&subpage_ro_ranges);
+}
+
struct subpage_ro_range *subpage_mmio_find_page(mfn_t mfn)
{
struct subpage_ro_range *entry;
!IS_ALIGNED(size, MMIO_RO_SUBPAGE_GRAN) )
return -EINVAL;
+ /*
+ * Force all r/o subregions to be registered before initial domain
+ * creation, so that the emulation handlers can be added only when there
+ * are pages registered.
+ */
+ if ( system_state >= SYS_STATE_smp_boot )
+ {
+ ASSERT_UNREACHABLE();
+ return -EILSEQ;
+ }
+
if ( !size )
return 0;