2
0

xen-pvh.c 3.1 KB

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