10e14c9ebSEdgar E. Iglesias /* 20e14c9ebSEdgar E. Iglesias * QEMU ARM Xen PVH Machine 30e14c9ebSEdgar E. Iglesias * 40e14c9ebSEdgar E. Iglesias * SPDX-License-Identifier: MIT 50e14c9ebSEdgar E. Iglesias */ 60e14c9ebSEdgar E. Iglesias 70e14c9ebSEdgar E. Iglesias #include "qemu/osdep.h" 80e14c9ebSEdgar E. Iglesias #include "qemu/error-report.h" 90e14c9ebSEdgar E. Iglesias #include "qapi/qapi-commands-migration.h" 100e14c9ebSEdgar E. Iglesias #include "hw/boards.h" 110e14c9ebSEdgar E. Iglesias #include "sysemu/sysemu.h" 120e14c9ebSEdgar E. Iglesias #include "hw/xen/xen-pvh-common.h" 130e14c9ebSEdgar E. Iglesias #include "hw/xen/arch_hvm.h" 140e14c9ebSEdgar E. Iglesias 150e14c9ebSEdgar E. Iglesias #define TYPE_XEN_ARM MACHINE_TYPE_NAME("xenpvh") 160e14c9ebSEdgar E. Iglesias 170e14c9ebSEdgar E. Iglesias /* 180e14c9ebSEdgar E. Iglesias * VIRTIO_MMIO_DEV_SIZE is imported from tools/libs/light/libxl_arm.c under Xen 190e14c9ebSEdgar E. Iglesias * repository. 200e14c9ebSEdgar E. Iglesias * 210e14c9ebSEdgar E. Iglesias * Origin: git://xenbits.xen.org/xen.git 2128143c114c 220e14c9ebSEdgar E. Iglesias */ 230e14c9ebSEdgar E. Iglesias #define VIRTIO_MMIO_DEV_SIZE 0x200 240e14c9ebSEdgar E. Iglesias 250e14c9ebSEdgar E. Iglesias #define NR_VIRTIO_MMIO_DEVICES \ 260e14c9ebSEdgar E. Iglesias (GUEST_VIRTIO_MMIO_SPI_LAST - GUEST_VIRTIO_MMIO_SPI_FIRST) 270e14c9ebSEdgar E. Iglesias 280e14c9ebSEdgar E. Iglesias static void xen_arm_instance_init(Object *obj) 290e14c9ebSEdgar E. Iglesias { 300e14c9ebSEdgar E. Iglesias XenPVHMachineState *s = XEN_PVH_MACHINE(obj); 310e14c9ebSEdgar E. Iglesias 320e14c9ebSEdgar E. Iglesias /* Default values. */ 330e14c9ebSEdgar E. Iglesias s->cfg.ram_low = (MemMapEntry) { GUEST_RAM0_BASE, GUEST_RAM0_SIZE }; 340e14c9ebSEdgar E. Iglesias s->cfg.ram_high = (MemMapEntry) { GUEST_RAM1_BASE, GUEST_RAM1_SIZE }; 350e14c9ebSEdgar E. Iglesias 360e14c9ebSEdgar E. Iglesias s->cfg.virtio_mmio_num = NR_VIRTIO_MMIO_DEVICES; 370e14c9ebSEdgar E. Iglesias s->cfg.virtio_mmio_irq_base = GUEST_VIRTIO_MMIO_SPI_FIRST; 380e14c9ebSEdgar E. Iglesias s->cfg.virtio_mmio = (MemMapEntry) { GUEST_VIRTIO_MMIO_BASE, 390e14c9ebSEdgar E. Iglesias VIRTIO_MMIO_DEV_SIZE }; 400e14c9ebSEdgar E. Iglesias } 410e14c9ebSEdgar E. Iglesias 420e14c9ebSEdgar E. Iglesias static void xen_arm_machine_class_init(ObjectClass *oc, void *data) 430e14c9ebSEdgar E. Iglesias { 440e14c9ebSEdgar E. Iglesias XenPVHMachineClass *xpc = XEN_PVH_MACHINE_CLASS(oc); 450e14c9ebSEdgar E. Iglesias MachineClass *mc = MACHINE_CLASS(oc); 460e14c9ebSEdgar E. Iglesias 470e14c9ebSEdgar E. Iglesias mc->desc = "Xen PVH ARM machine"; 480e14c9ebSEdgar E. Iglesias 490e14c9ebSEdgar E. Iglesias /* 500e14c9ebSEdgar E. Iglesias * mc->max_cpus holds the MAX value allowed in the -smp command-line opts. 510e14c9ebSEdgar E. Iglesias * 520e14c9ebSEdgar E. Iglesias * 1. If users don't pass any -smp option: 530e14c9ebSEdgar E. Iglesias * ms->smp.cpus will default to 1. 540e14c9ebSEdgar E. Iglesias * ms->smp.max_cpus will default to 1. 550e14c9ebSEdgar E. Iglesias * 560e14c9ebSEdgar E. Iglesias * 2. If users pass -smp X: 570e14c9ebSEdgar E. Iglesias * ms->smp.cpus will be set to X. 580e14c9ebSEdgar E. Iglesias * ms->smp.max_cpus will also be set to X. 590e14c9ebSEdgar E. Iglesias * 600e14c9ebSEdgar E. Iglesias * 3. If users pass -smp X,maxcpus=Y: 610e14c9ebSEdgar E. Iglesias * ms->smp.cpus will be set to X. 620e14c9ebSEdgar E. Iglesias * ms->smp.max_cpus will be set to Y. 630e14c9ebSEdgar E. Iglesias * 640e14c9ebSEdgar E. Iglesias * In scenarios 2 and 3, if X or Y are set to something larger than 650e14c9ebSEdgar E. Iglesias * mc->max_cpus, QEMU will bail out with an error message. 660e14c9ebSEdgar E. Iglesias */ 670e14c9ebSEdgar E. Iglesias mc->max_cpus = GUEST_MAX_VCPUS; 680e14c9ebSEdgar E. Iglesias 69*cb988a10SEdgar E. Iglesias /* Xen/ARM does not use buffered IOREQs. */ 70*cb988a10SEdgar E. Iglesias xpc->handle_bufioreq = HVM_IOREQSRV_BUFIOREQ_OFF; 71*cb988a10SEdgar E. Iglesias 720e14c9ebSEdgar E. Iglesias /* List of supported features known to work on PVH ARM. */ 730e14c9ebSEdgar E. Iglesias xpc->has_tpm = true; 740e14c9ebSEdgar E. Iglesias xpc->has_virtio_mmio = true; 750e14c9ebSEdgar E. Iglesias 760e14c9ebSEdgar E. Iglesias xen_pvh_class_setup_common_props(xpc); 770e14c9ebSEdgar E. Iglesias } 780e14c9ebSEdgar E. Iglesias 790e14c9ebSEdgar E. Iglesias static const TypeInfo xen_arm_machine_type = { 800e14c9ebSEdgar E. Iglesias .name = TYPE_XEN_ARM, 810e14c9ebSEdgar E. Iglesias .parent = TYPE_XEN_PVH_MACHINE, 820e14c9ebSEdgar E. Iglesias .class_init = xen_arm_machine_class_init, 830e14c9ebSEdgar E. Iglesias .instance_size = sizeof(XenPVHMachineState), 840e14c9ebSEdgar E. Iglesias .instance_init = xen_arm_instance_init, 850e14c9ebSEdgar E. Iglesias }; 860e14c9ebSEdgar E. Iglesias 870e14c9ebSEdgar E. Iglesias static void xen_arm_machine_register_types(void) 880e14c9ebSEdgar E. Iglesias { 890e14c9ebSEdgar E. Iglesias type_register_static(&xen_arm_machine_type); 900e14c9ebSEdgar E. Iglesias } 910e14c9ebSEdgar E. Iglesias 920e14c9ebSEdgar E. Iglesias type_init(xen_arm_machine_register_types) 93