Edgars Xen Queue.
-----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEErET+3BT38evtv0FRKcWWeA9ryoMFAmb+1rIACgkQKcWWeA9r yoN67QgAgg4eTLF00cXBGp+hCOs+Oy9go7MHkaiCrKRHde0f82wnPLH6BfaVfafd 3dn+y2MAv+v/gjrqcgQHlKOojoYwkBrvIc0yMXOK7GPwS/ppA4+L0ZSyONFcoM7j 1b7pfXn8yiJnRRWvSaM81nLWj3CgUR/piTMao72jBM0t+oVgY3ZEcidFlN2rcQwj 27BSNEF+CTYyA+fXGV0EgIjTLWHvvUR+WNO6jRsTpLK+/2tl1idoLm8t7hihfoN8 MW34R6RwmNv0PYCsz9+LCPUW+KbrA2w8YX+Rq1W4UVCm5BocibQ4Vwrn2bLAOgLP i7RwTtew+avZoQvA8lM3+yU8vo+Q+A== =95Ye -----END PGP SIGNATURE----- Merge tag 'edgar/xen-queue-2024-10-03-v2.for-upstream' of https://gitlab.com/edgar.iglesias/qemu into staging Edgars Xen Queue. # -----BEGIN PGP SIGNATURE----- # # iQEzBAABCgAdFiEErET+3BT38evtv0FRKcWWeA9ryoMFAmb+1rIACgkQKcWWeA9r # yoN67QgAgg4eTLF00cXBGp+hCOs+Oy9go7MHkaiCrKRHde0f82wnPLH6BfaVfafd # 3dn+y2MAv+v/gjrqcgQHlKOojoYwkBrvIc0yMXOK7GPwS/ppA4+L0ZSyONFcoM7j # 1b7pfXn8yiJnRRWvSaM81nLWj3CgUR/piTMao72jBM0t+oVgY3ZEcidFlN2rcQwj # 27BSNEF+CTYyA+fXGV0EgIjTLWHvvUR+WNO6jRsTpLK+/2tl1idoLm8t7hihfoN8 # MW34R6RwmNv0PYCsz9+LCPUW+KbrA2w8YX+Rq1W4UVCm5BocibQ4Vwrn2bLAOgLP # i7RwTtew+avZoQvA8lM3+yU8vo+Q+A== # =95Ye # -----END PGP SIGNATURE----- # gpg: Signature made Thu 03 Oct 2024 18:38:58 BST # gpg: using RSA key AC44FEDC14F7F1EBEDBF415129C596780F6BCA83 # gpg: Good signature from "Edgar E. Iglesias (Xilinx key) <edgar.iglesias@xilinx.com>" [unknown] # gpg: aka "Edgar E. Iglesias <edgar.iglesias@gmail.com>" [full] # Primary key fingerprint: AC44 FEDC 14F7 F1EB EDBF 4151 29C5 9678 0F6B CA83 * tag 'edgar/xen-queue-2024-10-03-v2.for-upstream' of https://gitlab.com/edgar.iglesias/qemu: hw/arm: xenpvh: Enable PCI for ARM PVH hw/xen: xenpvh: Add pci-intx-irq-base property hw/xen: xenpvh: Disable buffered IOREQs for ARM hw/xen: Expose handle_bufioreq in xen_register_ioreq hw/xen: Remove deadcode Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
33dab2dda0
@ -39,6 +39,16 @@ static void xen_arm_instance_init(Object *obj)
|
||||
VIRTIO_MMIO_DEV_SIZE };
|
||||
}
|
||||
|
||||
static void xen_pvh_set_pci_intx_irq(void *opaque, int intx_irq, int level)
|
||||
{
|
||||
XenPVHMachineState *s = XEN_PVH_MACHINE(opaque);
|
||||
int irq = s->cfg.pci_intx_irq_base + intx_irq;
|
||||
|
||||
if (xendevicemodel_set_irq_level(xen_dmod, xen_domid, irq, level)) {
|
||||
error_report("xendevicemodel_set_pci_intx_level failed");
|
||||
}
|
||||
}
|
||||
|
||||
static void xen_arm_machine_class_init(ObjectClass *oc, void *data)
|
||||
{
|
||||
XenPVHMachineClass *xpc = XEN_PVH_MACHINE_CLASS(oc);
|
||||
@ -66,7 +76,14 @@ static void xen_arm_machine_class_init(ObjectClass *oc, void *data)
|
||||
*/
|
||||
mc->max_cpus = GUEST_MAX_VCPUS;
|
||||
|
||||
/* Xen/ARM does not use buffered IOREQs. */
|
||||
xpc->handle_bufioreq = HVM_IOREQSRV_BUFIOREQ_OFF;
|
||||
|
||||
/* PCI INTX delivery. */
|
||||
xpc->set_pci_intx_irq = xen_pvh_set_pci_intx_irq;
|
||||
|
||||
/* List of supported features known to work on PVH ARM. */
|
||||
xpc->has_pci = true;
|
||||
xpc->has_tpm = true;
|
||||
xpc->has_virtio_mmio = true;
|
||||
|
||||
|
@ -614,7 +614,9 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory)
|
||||
|
||||
state = g_new0(XenIOState, 1);
|
||||
|
||||
xen_register_ioreq(state, max_cpus, &xen_memory_listener);
|
||||
xen_register_ioreq(state, max_cpus,
|
||||
HVM_IOREQSRV_BUFIOREQ_ATOMIC,
|
||||
&xen_memory_listener);
|
||||
|
||||
xen_is_stubdomain = xen_check_stubdomain(state->xenstore);
|
||||
|
||||
|
@ -89,6 +89,9 @@ static void xen_pvh_machine_class_init(ObjectClass *oc, void *data)
|
||||
/* We have an implementation specific init to create CPU objects. */
|
||||
xpc->init = xen_pvh_init;
|
||||
|
||||
/* Enable buffered IOREQs. */
|
||||
xpc->handle_bufioreq = HVM_IOREQSRV_BUFIOREQ_ATOMIC;
|
||||
|
||||
/*
|
||||
* PCI INTX routing.
|
||||
*
|
||||
|
@ -667,6 +667,8 @@ static int xen_map_ioreq_server(XenIOState *state)
|
||||
xen_pfn_t ioreq_pfn;
|
||||
xen_pfn_t bufioreq_pfn;
|
||||
evtchn_port_t bufioreq_evtchn;
|
||||
unsigned long num_frames = 1;
|
||||
unsigned long frame = 1;
|
||||
int rc;
|
||||
|
||||
/*
|
||||
@ -675,59 +677,78 @@ static int xen_map_ioreq_server(XenIOState *state)
|
||||
*/
|
||||
QEMU_BUILD_BUG_ON(XENMEM_resource_ioreq_server_frame_bufioreq != 0);
|
||||
QEMU_BUILD_BUG_ON(XENMEM_resource_ioreq_server_frame_ioreq(0) != 1);
|
||||
|
||||
if (state->has_bufioreq) {
|
||||
frame = 0;
|
||||
num_frames = 2;
|
||||
}
|
||||
state->fres = xenforeignmemory_map_resource(xen_fmem, xen_domid,
|
||||
XENMEM_resource_ioreq_server,
|
||||
state->ioservid, 0, 2,
|
||||
state->ioservid,
|
||||
frame, num_frames,
|
||||
&addr,
|
||||
PROT_READ | PROT_WRITE, 0);
|
||||
if (state->fres != NULL) {
|
||||
trace_xen_map_resource_ioreq(state->ioservid, addr);
|
||||
state->buffered_io_page = addr;
|
||||
state->shared_page = addr + XC_PAGE_SIZE;
|
||||
state->shared_page = addr;
|
||||
if (state->has_bufioreq) {
|
||||
state->buffered_io_page = addr;
|
||||
state->shared_page = addr + XC_PAGE_SIZE;
|
||||
}
|
||||
} else if (errno != EOPNOTSUPP) {
|
||||
error_report("failed to map ioreq server resources: error %d handle=%p",
|
||||
errno, xen_xc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = xen_get_ioreq_server_info(xen_domid, state->ioservid,
|
||||
(state->shared_page == NULL) ?
|
||||
&ioreq_pfn : NULL,
|
||||
(state->buffered_io_page == NULL) ?
|
||||
&bufioreq_pfn : NULL,
|
||||
&bufioreq_evtchn);
|
||||
if (rc < 0) {
|
||||
error_report("failed to get ioreq server info: error %d handle=%p",
|
||||
errno, xen_xc);
|
||||
return rc;
|
||||
}
|
||||
/*
|
||||
* If we fail to map the shared page with xenforeignmemory_map_resource()
|
||||
* or if we're using buffered ioreqs, we need xen_get_ioreq_server_info()
|
||||
* to provide the the addresses to map the shared page and/or to get the
|
||||
* event-channel port for buffered ioreqs.
|
||||
*/
|
||||
if (state->shared_page == NULL || state->has_bufioreq) {
|
||||
rc = xen_get_ioreq_server_info(xen_domid, state->ioservid,
|
||||
(state->shared_page == NULL) ?
|
||||
&ioreq_pfn : NULL,
|
||||
(state->has_bufioreq &&
|
||||
state->buffered_io_page == NULL) ?
|
||||
&bufioreq_pfn : NULL,
|
||||
&bufioreq_evtchn);
|
||||
if (rc < 0) {
|
||||
error_report("failed to get ioreq server info: error %d handle=%p",
|
||||
errno, xen_xc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (state->shared_page == NULL) {
|
||||
trace_xen_map_ioreq_server_shared_page(ioreq_pfn);
|
||||
if (state->shared_page == NULL) {
|
||||
trace_xen_map_ioreq_server_shared_page(ioreq_pfn);
|
||||
|
||||
state->shared_page = xenforeignmemory_map(xen_fmem, xen_domid,
|
||||
PROT_READ | PROT_WRITE,
|
||||
1, &ioreq_pfn, NULL);
|
||||
state->shared_page = xenforeignmemory_map(xen_fmem, xen_domid,
|
||||
PROT_READ | PROT_WRITE,
|
||||
1, &ioreq_pfn, NULL);
|
||||
}
|
||||
if (state->shared_page == NULL) {
|
||||
error_report("map shared IO page returned error %d handle=%p",
|
||||
errno, xen_xc);
|
||||
}
|
||||
}
|
||||
|
||||
if (state->buffered_io_page == NULL) {
|
||||
trace_xen_map_ioreq_server_buffered_io_page(bufioreq_pfn);
|
||||
if (state->has_bufioreq && state->buffered_io_page == NULL) {
|
||||
trace_xen_map_ioreq_server_buffered_io_page(bufioreq_pfn);
|
||||
|
||||
state->buffered_io_page = xenforeignmemory_map(xen_fmem, xen_domid,
|
||||
PROT_READ | PROT_WRITE,
|
||||
1, &bufioreq_pfn,
|
||||
NULL);
|
||||
if (state->buffered_io_page == NULL) {
|
||||
error_report("map buffered IO page returned error %d", errno);
|
||||
return -1;
|
||||
state->buffered_io_page = xenforeignmemory_map(xen_fmem, xen_domid,
|
||||
PROT_READ | PROT_WRITE,
|
||||
1, &bufioreq_pfn,
|
||||
NULL);
|
||||
if (state->buffered_io_page == NULL) {
|
||||
error_report("map buffered IO page returned error %d", errno);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (state->shared_page == NULL || state->buffered_io_page == NULL) {
|
||||
if (state->shared_page == NULL ||
|
||||
(state->has_bufioreq && state->buffered_io_page == NULL)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -830,14 +851,15 @@ static void xen_do_ioreq_register(XenIOState *state,
|
||||
state->ioreq_local_port[i] = rc;
|
||||
}
|
||||
|
||||
rc = qemu_xen_evtchn_bind_interdomain(state->xce_handle, xen_domid,
|
||||
state->bufioreq_remote_port);
|
||||
if (rc == -1) {
|
||||
error_report("buffered evtchn bind error %d", errno);
|
||||
goto err;
|
||||
if (state->has_bufioreq) {
|
||||
rc = qemu_xen_evtchn_bind_interdomain(state->xce_handle, xen_domid,
|
||||
state->bufioreq_remote_port);
|
||||
if (rc == -1) {
|
||||
error_report("buffered evtchn bind error %d", errno);
|
||||
goto err;
|
||||
}
|
||||
state->bufioreq_local_port = rc;
|
||||
}
|
||||
state->bufioreq_local_port = rc;
|
||||
|
||||
/* Init RAM management */
|
||||
#ifdef XEN_COMPAT_PHYSMAP
|
||||
xen_map_cache_init(xen_phys_offset_to_gaddr, state);
|
||||
@ -865,6 +887,7 @@ err:
|
||||
}
|
||||
|
||||
void xen_register_ioreq(XenIOState *state, unsigned int max_cpus,
|
||||
uint8_t handle_bufioreq,
|
||||
const MemoryListener *xen_memory_listener)
|
||||
{
|
||||
int rc;
|
||||
@ -883,7 +906,8 @@ void xen_register_ioreq(XenIOState *state, unsigned int max_cpus,
|
||||
goto err;
|
||||
}
|
||||
|
||||
rc = xen_create_ioreq_server(xen_domid, &state->ioservid);
|
||||
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);
|
||||
} else {
|
||||
|
@ -147,24 +147,6 @@ void xen_be_unmap_grant_refs(struct XenLegacyDevice *xendev, void *ptr,
|
||||
}
|
||||
}
|
||||
|
||||
int xen_be_copy_grant_refs(struct XenLegacyDevice *xendev,
|
||||
bool to_domain,
|
||||
XenGrantCopySegment segs[],
|
||||
unsigned int nr_segs)
|
||||
{
|
||||
int rc;
|
||||
|
||||
assert(xendev->ops->flags & DEVOPS_FLAG_NEED_GNTDEV);
|
||||
|
||||
rc = qemu_xen_gnttab_grant_copy(xendev->gnttabdev, to_domain, xen_domid,
|
||||
segs, nr_segs, NULL);
|
||||
if (rc) {
|
||||
xen_pv_printf(xendev, 0, "xengnttab_grant_copy failed: %s\n",
|
||||
strerror(-rc));
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* get xen backend device, allocate a new one if it doesn't exist.
|
||||
*/
|
||||
|
@ -194,7 +194,9 @@ static void xen_pvh_init(MachineState *ms)
|
||||
}
|
||||
|
||||
xen_pvh_init_ram(s, sysmem);
|
||||
xen_register_ioreq(&s->ioreq, ms->smp.max_cpus, &xen_memory_listener);
|
||||
xen_register_ioreq(&s->ioreq, ms->smp.max_cpus,
|
||||
xpc->handle_bufioreq,
|
||||
&xen_memory_listener);
|
||||
|
||||
if (s->cfg.virtio_mmio_num) {
|
||||
xen_create_virtio_mmio_devices(s);
|
||||
@ -216,6 +218,11 @@ static void xen_pvh_init(MachineState *ms)
|
||||
error_report("pci-ecam-size only supports values 0 or 0x10000000");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (!s->cfg.pci_intx_irq_base) {
|
||||
error_report("PCI enabled but pci-intx-irq-base not set");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
xenpvh_gpex_init(s, xpc, sysmem);
|
||||
}
|
||||
|
||||
@ -271,6 +278,30 @@ XEN_PVH_PROP_MEMMAP(pci_ecam)
|
||||
XEN_PVH_PROP_MEMMAP(pci_mmio)
|
||||
XEN_PVH_PROP_MEMMAP(pci_mmio_high)
|
||||
|
||||
static void xen_pvh_set_pci_intx_irq_base(Object *obj, Visitor *v,
|
||||
const char *name, void *opaque,
|
||||
Error **errp)
|
||||
{
|
||||
XenPVHMachineState *xp = XEN_PVH_MACHINE(obj);
|
||||
uint32_t value;
|
||||
|
||||
if (!visit_type_uint32(v, name, &value, errp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
xp->cfg.pci_intx_irq_base = value;
|
||||
}
|
||||
|
||||
static void xen_pvh_get_pci_intx_irq_base(Object *obj, Visitor *v,
|
||||
const char *name, void *opaque,
|
||||
Error **errp)
|
||||
{
|
||||
XenPVHMachineState *xp = XEN_PVH_MACHINE(obj);
|
||||
uint32_t value = xp->cfg.pci_intx_irq_base;
|
||||
|
||||
visit_type_uint32(v, name, &value, errp);
|
||||
}
|
||||
|
||||
void xen_pvh_class_setup_common_props(XenPVHMachineClass *xpc)
|
||||
{
|
||||
ObjectClass *oc = OBJECT_CLASS(xpc);
|
||||
@ -316,6 +347,13 @@ do { \
|
||||
OC_MEMMAP_PROP(oc, "pci-ecam", pci_ecam);
|
||||
OC_MEMMAP_PROP(oc, "pci-mmio", pci_mmio);
|
||||
OC_MEMMAP_PROP(oc, "pci-mmio-high", pci_mmio_high);
|
||||
|
||||
object_class_property_add(oc, "pci-intx-irq-base", "uint32_t",
|
||||
xen_pvh_get_pci_intx_irq_base,
|
||||
xen_pvh_set_pci_intx_irq_base,
|
||||
NULL, NULL);
|
||||
object_class_property_set_description(oc, "pci-intx-irq-base",
|
||||
"Set PCI INTX interrupt base line.");
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TPM
|
||||
|
@ -66,11 +66,3 @@ int xen_config_dev_vkbd(int vdev)
|
||||
xen_config_dev_dirs("vkbd", "vkbd", vdev, fe, be, sizeof(fe));
|
||||
return xen_config_dev_all(fe, be);
|
||||
}
|
||||
|
||||
int xen_config_dev_console(int vdev)
|
||||
{
|
||||
char fe[256], be[256];
|
||||
|
||||
xen_config_dev_dirs("console", "console", vdev, fe, be, sizeof(fe));
|
||||
return xen_config_dev_all(fe, be);
|
||||
}
|
||||
|
@ -81,6 +81,8 @@ typedef struct XenIOState {
|
||||
QLIST_HEAD(, XenPciDevice) dev_list;
|
||||
DeviceListener device_listener;
|
||||
|
||||
bool has_bufioreq;
|
||||
|
||||
Notifier exit;
|
||||
} XenIOState;
|
||||
|
||||
@ -95,6 +97,7 @@ 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);
|
||||
|
||||
void cpu_ioreq_pio(ioreq_t *req);
|
||||
|
@ -50,10 +50,6 @@ void *xen_be_map_grant_refs(struct XenLegacyDevice *xendev, uint32_t *refs,
|
||||
void xen_be_unmap_grant_refs(struct XenLegacyDevice *xendev, void *ptr,
|
||||
uint32_t *refs, unsigned int nr_refs);
|
||||
|
||||
int xen_be_copy_grant_refs(struct XenLegacyDevice *xendev,
|
||||
bool to_domain, XenGrantCopySegment segs[],
|
||||
unsigned int nr_segs);
|
||||
|
||||
static inline void *xen_be_map_grant_ref(struct XenLegacyDevice *xendev,
|
||||
uint32_t ref, int prot)
|
||||
{
|
||||
@ -70,6 +66,5 @@ static inline void xen_be_unmap_grant_ref(struct XenLegacyDevice *xendev,
|
||||
void xen_config_cleanup(void);
|
||||
int xen_config_dev_vfb(int vdev, const char *type);
|
||||
int xen_config_dev_vkbd(int vdev);
|
||||
int xen_config_dev_console(int vdev);
|
||||
|
||||
#endif /* HW_XEN_LEGACY_BACKEND_H */
|
||||
|
@ -43,6 +43,9 @@ struct XenPVHMachineClass {
|
||||
*/
|
||||
int (*set_pci_link_route)(uint8_t line, uint8_t irq);
|
||||
|
||||
/* Allow implementations to optionally enable buffered ioreqs. */
|
||||
uint8_t handle_bufioreq;
|
||||
|
||||
/*
|
||||
* Each implementation can optionally enable features that it
|
||||
* supports and are known to work.
|
||||
|
@ -464,10 +464,11 @@ static inline void xen_unmap_pcidev(domid_t dom,
|
||||
}
|
||||
|
||||
static inline int xen_create_ioreq_server(domid_t dom,
|
||||
int handle_bufioreq,
|
||||
ioservid_t *ioservid)
|
||||
{
|
||||
int rc = xendevicemodel_create_ioreq_server(xen_dmod, dom,
|
||||
HVM_IOREQSRV_BUFIOREQ_ATOMIC,
|
||||
handle_bufioreq,
|
||||
ioservid);
|
||||
|
||||
if (rc == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user