hw/xen-hvm: Add a mapcache arg to xen_register_ioreq()

Add a mapcache argument to xen_register_ioreq() allowing
the caller to optionally disable the mapcache.

All callers still call it with mapcache = true so there's no
functional change yet.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
This commit is contained in:
Edgar E. Iglesias
2025-07-23 12:06:18 +02:00
parent c1d78ba63c
commit ad0c53fb5b
4 changed files with 17 additions and 9 deletions

View File

@@ -622,7 +622,7 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory)
xen_register_ioreq(state, max_cpus,
HVM_IOREQSRV_BUFIOREQ_ATOMIC,
&xen_memory_listener);
&xen_memory_listener, true);
xen_is_stubdomain = xen_check_stubdomain(state->xenstore);

View File

@@ -473,7 +473,9 @@ static void handle_ioreq(XenIOState *state, ioreq_t *req)
case IOREQ_TYPE_TIMEOFFSET:
break;
case IOREQ_TYPE_INVALIDATE:
xen_invalidate_map_cache();
if (xen_map_cache_enabled()) {
xen_invalidate_map_cache();
}
break;
case IOREQ_TYPE_PCI_CONFIG:
cpu_ioreq_config(state, req);
@@ -823,7 +825,8 @@ void xen_shutdown_fatal_error(const char *fmt, ...)
static void xen_do_ioreq_register(XenIOState *state,
unsigned int max_cpus,
const MemoryListener *xen_memory_listener)
const MemoryListener *xen_memory_listener,
bool mapcache)
{
int i, rc;
@@ -874,11 +877,13 @@ static void xen_do_ioreq_register(XenIOState *state,
state->bufioreq_local_port = rc;
}
/* Init RAM management */
if (mapcache) {
#ifdef XEN_COMPAT_PHYSMAP
xen_map_cache_init(xen_phys_offset_to_gaddr, state);
xen_map_cache_init(xen_phys_offset_to_gaddr, state);
#else
xen_map_cache_init(NULL, state);
xen_map_cache_init(NULL, state);
#endif
}
qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state);
@@ -901,7 +906,8 @@ err:
void xen_register_ioreq(XenIOState *state, unsigned int max_cpus,
uint8_t handle_bufioreq,
const MemoryListener *xen_memory_listener)
const MemoryListener *xen_memory_listener,
bool mapcache)
{
int rc;
@@ -922,7 +928,7 @@ void xen_register_ioreq(XenIOState *state, unsigned int max_cpus,
state->has_bufioreq = handle_bufioreq != HVM_IOREQSRV_BUFIOREQ_OFF;
rc = xen_create_ioreq_server(xen_domid, handle_bufioreq, &state->ioservid);
if (!rc) {
xen_do_ioreq_register(state, max_cpus, xen_memory_listener);
xen_do_ioreq_register(state, max_cpus, xen_memory_listener, mapcache);
} else {
warn_report("xen: failed to create ioreq server");
}

View File

@@ -202,7 +202,8 @@ static void xen_pvh_init(MachineState *ms)
xen_pvh_init_ram(s, sysmem);
xen_register_ioreq(&s->ioreq, ms->smp.max_cpus,
xpc->handle_bufioreq,
&xen_memory_listener);
&xen_memory_listener,
true);
if (s->cfg.virtio_mmio_num) {
xen_create_virtio_mmio_devices(s);

View File

@@ -91,7 +91,8 @@ void xen_device_unrealize(DeviceListener *listener, DeviceState *dev);
void xen_hvm_change_state_handler(void *opaque, bool running, RunState rstate);
void xen_register_ioreq(XenIOState *state, unsigned int max_cpus,
uint8_t handle_bufioreq,
const MemoryListener *xen_memory_listener);
const MemoryListener *xen_memory_listener,
bool mapcache);
void cpu_ioreq_pio(ioreq_t *req);
#endif /* HW_XEN_HVM_COMMON_H */