902636
From 49164264d9928f73961acbbe4d56d8dfa23d8099 Mon Sep 17 00:00:00 2001
902636
From: Miroslav Rezanina <mrezanin@redhat.com>
902636
Date: Fri, 19 Oct 2018 12:53:31 +0200
902636
Subject: Add aarch64 machine types
902636
902636
Adding changes to add RHEL machine types for aarch64 architecture.
902636
902636
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
902636
902636
Rebase changes (4.0.0):
902636
- Use upstream compat handling
902636
902636
Rebase changes (4.1.0-rc0):
902636
- Removed a15memmap (upstream)
902636
- Use virt_flash_create in rhel800_virt_instance_init
902636
902636
Rebase changes (4.2.0-rc0):
902636
- Set numa_mem_supported
902636
902636
Rebase notes (4.2.0-rc3):
902636
- aarch64: Add virt-rhel8.2.0 machine type for ARM (patch 92246)
902636
- aarch64: virt: Allow more than 1TB of RAM (patch 92249)
902636
- aarch64: virt: Allow PCDIMM instantiation (patch 92247)
902636
- aarch64: virt: Enhance the comment related to gic-version (patch 92248)
902636
902636
Merged patches (4.0.0):
902636
- 7bfdb4c aarch64: Add virt-rhel8.0.0 machine type for ARM
902636
- 3433e69 aarch64: Set virt-rhel8.0.0 max_cpus to 512
902636
- 4d20863 aarch64: Use 256MB ECAM region by default
902636
902636
Merged patches (4.1.0):
902636
- c3e39ef aarch64: Add virt-rhel8.1.0 machine type for ARM
902636
- 59a46d1 aarch64: Allow ARM VIRT iommu option in RHEL8.1 machine
902636
902636
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
902636
---
902636
 hw/arm/virt.c         | 161 +++++++++++++++++++++++++++++++++++++++++-
902636
 include/hw/arm/virt.h |  11 +++
902636
 2 files changed, 171 insertions(+), 1 deletion(-)
902636
902636
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
902636
index d4bedc2607..e10839100e 100644
902636
--- a/hw/arm/virt.c
902636
+++ b/hw/arm/virt.c
902636
@@ -72,6 +72,7 @@
902636
 #include "hw/mem/nvdimm.h"
902636
 #include "hw/acpi/generic_event_device.h"
902636
 
902636
+#if 0 /* Disabled for Red Hat Enterprise Linux */
902636
 #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \
902636
     static void virt_##major##_##minor##_class_init(ObjectClass *oc, \
902636
                                                     void *data) \
902636
@@ -98,7 +99,49 @@
902636
     DEFINE_VIRT_MACHINE_LATEST(major, minor, true)
902636
 #define DEFINE_VIRT_MACHINE(major, minor) \
902636
     DEFINE_VIRT_MACHINE_LATEST(major, minor, false)
902636
-
902636
+#endif /* disabled for RHEL */
902636
+
902636
+#define DEFINE_RHEL_MACHINE_LATEST(m, n, s, latest)                     \
902636
+    static void rhel##m##n##s##_virt_class_init(ObjectClass *oc,        \
902636
+                                                void *data)             \
902636
+    {                                                                   \
902636
+        MachineClass *mc = MACHINE_CLASS(oc);                           \
902636
+        rhel##m##n##s##_virt_options(mc);                               \
902636
+        mc->desc = "RHEL " # m "." # n "." # s " ARM Virtual Machine";  \
902636
+        if (latest) {                                                   \
902636
+            mc->alias = "virt";                                         \
902636
+            mc->is_default = 1;                                         \
902636
+        }                                                               \
902636
+    }                                                                   \
902636
+    static const TypeInfo rhel##m##n##s##_machvirt_info = {             \
902636
+        .name = MACHINE_TYPE_NAME("virt-rhel" # m "." # n "." # s),     \
902636
+        .parent = TYPE_RHEL_MACHINE,                                    \
902636
+        .instance_init = rhel##m##n##s##_virt_instance_init,            \
902636
+        .class_init = rhel##m##n##s##_virt_class_init,                  \
902636
+    };                                                                  \
902636
+    static void rhel##m##n##s##_machvirt_init(void)                     \
902636
+    {                                                                   \
902636
+        type_register_static(&rhel##m##n##s##_machvirt_info);           \
902636
+    }                                                                   \
902636
+    type_init(rhel##m##n##s##_machvirt_init);
902636
+
902636
+#define DEFINE_RHEL_MACHINE_AS_LATEST(major, minor, subminor)   \
902636
+    DEFINE_RHEL_MACHINE_LATEST(major, minor, subminor, true)
902636
+#define DEFINE_RHEL_MACHINE(major, minor, subminor)             \
902636
+    DEFINE_RHEL_MACHINE_LATEST(major, minor, subminor, false)
902636
+
902636
+/* This variable is for changes to properties that are RHEL specific,
902636
+ * different to the current upstream and to be applied to the latest
902636
+ * machine type.
902636
+ */
902636
+GlobalProperty arm_rhel_compat[] = {
902636
+    {
902636
+        .driver   = "virtio-net-pci",
902636
+        .property = "romfile",
902636
+        .value    = "",
902636
+    },
902636
+};
902636
+const size_t arm_rhel_compat_len = G_N_ELEMENTS(arm_rhel_compat);
902636
 
902636
 /* Number of external interrupt lines to configure the GIC with */
902636
 #define NUM_IRQS 256
902636
@@ -1763,6 +1806,7 @@ static void machvirt_init(MachineState *machine)
902636
     qemu_add_machine_init_done_notifier(&vms->machine_done);
902636
 }
902636
 
902636
+#if 0 /* Disabled for Red Hat Enterprise Linux */
902636
 static bool virt_get_secure(Object *obj, Error **errp)
902636
 {
902636
     VirtMachineState *vms = VIRT_MACHINE(obj);
902636
@@ -1791,6 +1835,7 @@ static void virt_set_virt(Object *obj, bool value, Error **errp)
902636
     vms->virt = value;
902636
 }
902636
 
902636
+#endif /* disabled for RHEL */
902636
 static bool virt_get_highmem(Object *obj, Error **errp)
902636
 {
902636
     VirtMachineState *vms = VIRT_MACHINE(obj);
902636
@@ -2022,6 +2067,7 @@ static int virt_kvm_type(MachineState *ms, const char *type_str)
902636
     return requested_pa_size > 40 ? requested_pa_size : 0;
902636
 }
902636
 
902636
+#if 0 /* Disabled for Red Hat Enterprise Linux */
902636
 static void virt_machine_class_init(ObjectClass *oc, void *data)
902636
 {
902636
     MachineClass *mc = MACHINE_CLASS(oc);
902636
@@ -2258,3 +2304,116 @@ static void virt_machine_2_6_options(MachineClass *mc)
902636
     vmc->no_pmu = true;
902636
 }
902636
 DEFINE_VIRT_MACHINE(2, 6)
902636
+#endif /* disabled for RHEL */
902636
+
902636
+static void rhel_machine_class_init(ObjectClass *oc, void *data)
902636
+{
902636
+    MachineClass *mc = MACHINE_CLASS(oc);
902636
+    HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
902636
+
902636
+    mc->family = "virt-rhel-Z";
902636
+    mc->init = machvirt_init;
902636
+    /* Start with max_cpus set to 512, which is the maximum supported by KVM.
902636
+     * The value may be reduced later when we have more information about the
902636
+     * configuration of the particular instance.
902636
+     */
902636
+    mc->max_cpus = 512;
902636
+    mc->block_default_type = IF_VIRTIO;
902636
+    mc->no_cdrom = 1;
902636
+    mc->pci_allow_0_address = true;
902636
+    /* We know we will never create a pre-ARMv7 CPU which needs 1K pages */
902636
+    mc->minimum_page_bits = 12;
902636
+    mc->possible_cpu_arch_ids = virt_possible_cpu_arch_ids;
902636
+    mc->cpu_index_to_instance_props = virt_cpu_index_to_props;
902636
+    mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a57");
902636
+    mc->get_default_cpu_node_id = virt_get_default_cpu_node_id;
902636
+    mc->kvm_type = virt_kvm_type;
902636
+    assert(!mc->get_hotplug_handler);
902636
+    mc->get_hotplug_handler = virt_machine_get_hotplug_handler;
902636
+    hc->pre_plug = virt_machine_device_pre_plug_cb;
902636
+    hc->plug = virt_machine_device_plug_cb;
902636
+    hc->unplug_request = virt_machine_device_unplug_request_cb;
902636
+    mc->numa_mem_supported = true;
902636
+    mc->auto_enable_numa_with_memhp = true;
902636
+}
902636
+
902636
+static const TypeInfo rhel_machine_info = {
902636
+    .name          = TYPE_RHEL_MACHINE,
902636
+    .parent        = TYPE_MACHINE,
902636
+    .abstract      = true,
902636
+    .instance_size = sizeof(VirtMachineState),
902636
+    .class_size    = sizeof(VirtMachineClass),
902636
+    .class_init    = rhel_machine_class_init,
902636
+    .interfaces = (InterfaceInfo[]) {
902636
+         { TYPE_HOTPLUG_HANDLER },
902636
+         { }
902636
+    },
902636
+};
902636
+
902636
+static void rhel_machine_init(void)
902636
+{
902636
+    type_register_static(&rhel_machine_info);
902636
+}
902636
+type_init(rhel_machine_init);
902636
+
902636
+static void rhel820_virt_instance_init(Object *obj)
902636
+{
902636
+    VirtMachineState *vms = VIRT_MACHINE(obj);
902636
+    VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
902636
+
902636
+    /* EL3 is disabled by default and non-configurable for RHEL */
902636
+    vms->secure = false;
902636
+    /* EL2 is disabled by default and non-configurable for RHEL */
902636
+    vms->virt = false;
902636
+    /* High memory is enabled by default for RHEL */
902636
+    vms->highmem = true;
902636
+    object_property_add_bool(obj, "highmem", virt_get_highmem,
902636
+                             virt_set_highmem, NULL);
902636
+    object_property_set_description(obj, "highmem",
902636
+                                    "Set on/off to enable/disable using "
902636
+                                    "physical address space above 32 bits",
902636
+                                    NULL);
902636
+    /*
902636
+     * Default GIC type is still v2, but became configurable for RHEL. We
902636
+     * keep v2 instead of max as TCG CI test cases require an MSI controller
902636
+     * and there is no userspace ITS MSI emulation available.
902636
+     */
902636
+    vms->gic_version = 2;
902636
+    object_property_add_str(obj, "gic-version", virt_get_gic_version,
902636
+                        virt_set_gic_version, NULL);
902636
+    object_property_set_description(obj, "gic-version",
902636
+                                    "Set GIC version. "
902636
+                                    "Valid values are 2, 3 and host", NULL);
902636
+
902636
+    vms->highmem_ecam = !vmc->no_highmem_ecam;
902636
+
902636
+    if (vmc->no_its) {
902636
+        vms->its = false;
902636
+    } else {
902636
+        /* Default allows ITS instantiation */
902636
+        vms->its = true;
902636
+        object_property_add_bool(obj, "its", virt_get_its,
902636
+                                 virt_set_its, NULL);
902636
+        object_property_set_description(obj, "its",
902636
+                                        "Set on/off to enable/disable "
902636
+                                        "ITS instantiation",
902636
+                                        NULL);
902636
+    }
902636
+
902636
+    /* Default disallows iommu instantiation */
902636
+    vms->iommu = VIRT_IOMMU_NONE;
902636
+    object_property_add_str(obj, "iommu", virt_get_iommu, virt_set_iommu, NULL);
902636
+    object_property_set_description(obj, "iommu",
902636
+                                    "Set the IOMMU type. "
902636
+                                    "Valid values are none and smmuv3",
902636
+                                    NULL);
902636
+
902636
+    vms->irqmap=a15irqmap;
902636
+    virt_flash_create(vms);
902636
+}
902636
+
902636
+static void rhel820_virt_options(MachineClass *mc)
902636
+{
902636
+    compat_props_add(mc->compat_props, arm_rhel_compat, arm_rhel_compat_len);
902636
+}
902636
+DEFINE_RHEL_MACHINE_AS_LATEST(8, 2, 0)
902636
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
902636
index 0b41083e9d..53fdf16563 100644
902636
--- a/include/hw/arm/virt.h
902636
+++ b/include/hw/arm/virt.h
902636
@@ -142,6 +142,7 @@ typedef struct {
902636
 
902636
 #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM)
902636
 
902636
+#if 0 /* disabled for Red Hat Enterprise Linux */
902636
 #define TYPE_VIRT_MACHINE   MACHINE_TYPE_NAME("virt")
902636
 #define VIRT_MACHINE(obj) \
902636
     OBJECT_CHECK(VirtMachineState, (obj), TYPE_VIRT_MACHINE)
902636
@@ -150,6 +151,16 @@ typedef struct {
902636
 #define VIRT_MACHINE_CLASS(klass) \
902636
     OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_VIRT_MACHINE)
902636
 
902636
+#else
902636
+#define TYPE_RHEL_MACHINE MACHINE_TYPE_NAME("virt-rhel")
902636
+#define VIRT_MACHINE(obj) \
902636
+    OBJECT_CHECK(VirtMachineState, (obj), TYPE_RHEL_MACHINE)
902636
+#define VIRT_MACHINE_GET_CLASS(obj) \
902636
+    OBJECT_GET_CLASS(VirtMachineClass, obj, TYPE_RHEL_MACHINE)
902636
+#define VIRT_MACHINE_CLASS(klass) \
902636
+    OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_RHEL_MACHINE)
902636
+#endif
902636
+
902636
 void virt_acpi_setup(VirtMachineState *vms);
902636
 
902636
 /* Return the number of used redistributor regions  */
902636
-- 
902636
2.21.0
902636