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