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