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