1 /* 2 * QEMU ARM Xen PVH Machine 3 * 4 * SPDX-License-Identifier: MIT 5 */ 6 7 #include "qemu/osdep.h" 8 #include "qemu/error-report.h" 9 #include "qapi/qapi-commands-migration.h" 10 #include "hw/boards.h" 11 #include "system/system.h" 12 #include "hw/xen/xen-pvh-common.h" 13 14 #define TYPE_XEN_ARM MACHINE_TYPE_NAME("xenpvh") 15 16 /* 17 * VIRTIO_MMIO_DEV_SIZE is imported from tools/libs/light/libxl_arm.c under Xen 18 * repository. 19 * 20 * Origin: git://xenbits.xen.org/xen.git 2128143c114c 21 */ 22 #define VIRTIO_MMIO_DEV_SIZE 0x200 23 24 #define NR_VIRTIO_MMIO_DEVICES \ 25 (GUEST_VIRTIO_MMIO_SPI_LAST - GUEST_VIRTIO_MMIO_SPI_FIRST) 26 27 static void xen_arm_instance_init(Object *obj) 28 { 29 XenPVHMachineState *s = XEN_PVH_MACHINE(obj); 30 31 /* Default values. */ 32 s->cfg.ram_low = (MemMapEntry) { GUEST_RAM0_BASE, GUEST_RAM0_SIZE }; 33 s->cfg.ram_high = (MemMapEntry) { GUEST_RAM1_BASE, GUEST_RAM1_SIZE }; 34 35 s->cfg.virtio_mmio_num = NR_VIRTIO_MMIO_DEVICES; 36 s->cfg.virtio_mmio_irq_base = GUEST_VIRTIO_MMIO_SPI_FIRST; 37 s->cfg.virtio_mmio = (MemMapEntry) { GUEST_VIRTIO_MMIO_BASE, 38 VIRTIO_MMIO_DEV_SIZE }; 39 } 40 41 static void xen_pvh_set_pci_intx_irq(void *opaque, int intx_irq, int level) 42 { 43 XenPVHMachineState *s = XEN_PVH_MACHINE(opaque); 44 int irq = s->cfg.pci_intx_irq_base + intx_irq; 45 46 if (xendevicemodel_set_irq_level(xen_dmod, xen_domid, irq, level)) { 47 error_report("xendevicemodel_set_pci_intx_level failed"); 48 } 49 } 50 51 static void xen_arm_machine_class_init(ObjectClass *oc, const void *data) 52 { 53 XenPVHMachineClass *xpc = XEN_PVH_MACHINE_CLASS(oc); 54 MachineClass *mc = MACHINE_CLASS(oc); 55 56 mc->desc = "Xen PVH ARM machine"; 57 58 /* 59 * mc->max_cpus holds the MAX value allowed in the -smp command-line opts. 60 * 61 * 1. If users don't pass any -smp option: 62 * ms->smp.cpus will default to 1. 63 * ms->smp.max_cpus will default to 1. 64 * 65 * 2. If users pass -smp X: 66 * ms->smp.cpus will be set to X. 67 * ms->smp.max_cpus will also be set to X. 68 * 69 * 3. If users pass -smp X,maxcpus=Y: 70 * ms->smp.cpus will be set to X. 71 * ms->smp.max_cpus will be set to Y. 72 * 73 * In scenarios 2 and 3, if X or Y are set to something larger than 74 * mc->max_cpus, QEMU will bail out with an error message. 75 */ 76 mc->max_cpus = GUEST_MAX_VCPUS; 77 78 /* Xen/ARM does not use buffered IOREQs. */ 79 xpc->handle_bufioreq = HVM_IOREQSRV_BUFIOREQ_OFF; 80 81 /* PCI INTX delivery. */ 82 xpc->set_pci_intx_irq = xen_pvh_set_pci_intx_irq; 83 84 /* List of supported features known to work on PVH ARM. */ 85 xpc->has_pci = true; 86 xpc->has_tpm = true; 87 xpc->has_virtio_mmio = true; 88 89 xen_pvh_class_setup_common_props(xpc); 90 } 91 92 static const TypeInfo xen_arm_machine_type = { 93 .name = TYPE_XEN_ARM, 94 .parent = TYPE_XEN_PVH_MACHINE, 95 .class_init = xen_arm_machine_class_init, 96 .instance_size = sizeof(XenPVHMachineState), 97 .instance_init = xen_arm_instance_init, 98 }; 99 100 static void xen_arm_machine_register_types(void) 101 { 102 type_register_static(&xen_arm_machine_type); 103 } 104 105 type_init(xen_arm_machine_register_types) 106