28f2e1
From 670e90f5cbd92189155e079b8c6e2aafdf82d162 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
febaa2
Rebase notes (4.0.0):
22c213
- Use upstream compat handling
22c213
febaa2
Rebase notes (4.1.0-rc0):
22c213
- Removed a15memmap (upstream)
22c213
- Use virt_flash_create in rhel800_virt_instance_init
22c213
febaa2
Rebase notes (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
febaa2
Rebase notes (5.0.0):
febaa2
- Set default_ram_id in rhel_machine_class_init
febaa2
- Added setting acpi properties
febaa2
febaa2
Rebase notes (5.1.0):
febaa2
- Added ras property
febaa2
- Added to virt_machine_device_unplug_cb to machine type (upstream)
febaa2
- added mte property (upstream)
febaa2
febaa2
Rebase notes (weekly-210210):
febaa2
- Added support for oem fields to machine type
febaa2
febaa2
Rebase notes (weekly-210303):
febaa2
- Use rhel-8.4.0 hw compat
febaa2
febaa2
Rebase notes (6.0.0-rc2):
febaa2
- renamed oem-id and oem-table-id to x-oem-id and x-oem-table-id
febaa2
febaa2
Rebase notes (210623):
febaa2
- Protect TPM functions by CONFIG_TPM ifdef
febaa2
febaa2
Rebase notes (6.1.0-rc0):
febaa2
- Add support for default_bus_bypass_iommu
febaa2
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
febaa2
Merged patches (5.2.0 rc0):
febaa2
- 12990ad hw/arm: Changes to rhel820 machine
febaa2
- 46d5a79 hw/arm: Introduce rhel_virt_instance_init() helper
febaa2
- 098954a hw/arm: Add rhel830 machine type
febaa2
- ee8e99d arm: Set correct max_cpus value on virt-rhel* machine types
febaa2
- e5edd38 RHEL-only: arm/virt: Allow the TPM_TIS_SYSBUS device dynamic allocation in machvirt
febaa2
- 6d7ba66 machine types/numa: set numa_mem_supported on old machine types (partialy)
febaa2
- 25c5644 machine_types/numa: compatibility for auto_enable_numa_with_memdev (partialy)
febaa2
febaa2
Merged patches (6.0):
febaa2
- 078fadb5da AArch64 machine types cleanup
febaa2
- ea7b7425fa hw/arm/virt: Add 8.4 Machine type
febaa2
febaa2
Merged patches (weekly-210609):
febaa2
- 73b1578882 hw/arm/virt: Add 8.5 machine type
febaa2
- 5333038d11 hw/arm/virt: Disable PL011 clock migration through hw_compat_rhel_8_3
febaa2
- 63adb8ae86 arm/virt: Register highmem and gic-version as class properties
febaa2
28f2e1
Merged patches (weekly-211027):
28f2e1
- 86e3057c0a hw: arm: virt: Add hw_compat_rhel_8_5 to 8.5 machine type
22c213
---
28f2e1
 hw/arm/virt.c         | 226 +++++++++++++++++++++++++++++++++++++++++-
febaa2
 hw/core/machine.c     |   2 +
febaa2
 include/hw/arm/virt.h |   8 ++
28f2e1
 3 files changed, 235 insertions(+), 1 deletion(-)
22c213
22c213
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
28f2e1
index 5de4d9d73b..c77d26ab13 100644
22c213
--- a/hw/arm/virt.c
22c213
+++ b/hw/arm/virt.c
28f2e1
@@ -79,6 +79,7 @@
febaa2
 #include "hw/char/pl011.h"
febaa2
 #include "qemu/guest-random.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) \
28f2e1
@@ -105,7 +106,48 @@
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
+        .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
28f2e1
@@ -2180,6 +2222,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);
28f2e1
@@ -2207,6 +2250,7 @@ static void virt_set_virt(Object *obj, bool value, Error **errp)
febaa2
 
22c213
     vms->virt = value;
22c213
 }
22c213
+#endif /* disabled for RHEL */
febaa2
 
22c213
 static bool virt_get_highmem(Object *obj, Error **errp)
22c213
 {
28f2e1
@@ -2304,6 +2348,7 @@ static void virt_set_acpi(Object *obj, Visitor *v, const char *name,
febaa2
     visit_type_OnOffAuto(v, name, &vms->acpi, errp);
febaa2
 }
febaa2
 
febaa2
+#if 0 /* Disabled for Red Hat Enterprise Linux */
febaa2
 static bool virt_get_ras(Object *obj, Error **errp)
febaa2
 {
22c213
     VirtMachineState *vms = VIRT_MACHINE(obj);
28f2e1
@@ -2331,6 +2376,7 @@ static void virt_set_mte(Object *obj, bool value, Error **errp)
febaa2
 
febaa2
     vms->mte = value;
febaa2
 }
febaa2
+#endif /* disabled for RHEL */
febaa2
 
febaa2
 static char *virt_get_gic_version(Object *obj, Error **errp)
febaa2
 {
28f2e1
@@ -2666,6 +2712,7 @@ static int virt_kvm_type(MachineState *ms, const char *type_str)
febaa2
     return fixed_ipa ? 0 : requested_pa_size;
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);
28f2e1
@@ -3031,3 +3078,180 @@ 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;
febaa2
+    /* Maximum supported VCPU count for all virt-rhel* machines */
febaa2
+    mc->max_cpus = 384;
febaa2
+#ifdef CONFIG_TPM
febaa2
+    machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_TIS_SYSBUS);
febaa2
+#endif
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;
febaa2
+    hc->unplug = virt_machine_device_unplug_cb;
febaa2
+    mc->nvdimm_supported = true;
22c213
+    mc->auto_enable_numa_with_memhp = true;
febaa2
+    mc->auto_enable_numa_with_memdev = true;
febaa2
+    mc->default_ram_id = "mach-virt.ram";
22c213
+
febaa2
+    object_class_property_add(oc, "acpi", "OnOffAuto",
febaa2
+        virt_get_acpi, virt_set_acpi,
febaa2
+        NULL, NULL);
febaa2
+    object_class_property_set_description(oc, "acpi",
febaa2
+        "Enable ACPI");
febaa2
+
febaa2
+    object_class_property_add_bool(oc, "highmem", virt_get_highmem,
febaa2
+                                   virt_set_highmem);
febaa2
+    object_class_property_set_description(oc, "highmem",
febaa2
+                                          "Set on/off to enable/disable using "
febaa2
+                                          "physical address space above 32 bits");
febaa2
+
febaa2
+    object_class_property_add_str(oc, "gic-version", virt_get_gic_version,
febaa2
+                                  virt_set_gic_version);
febaa2
+    object_class_property_set_description(oc, "gic-version",
febaa2
+                                          "Set GIC version. "
febaa2
+                                          "Valid values are 2, 3, host and max");
febaa2
+
febaa2
+    object_class_property_add_str(oc, "x-oem-id",
febaa2
+                                  virt_get_oem_id,
febaa2
+                                  virt_set_oem_id);
febaa2
+    object_class_property_set_description(oc, "x-oem-id",
febaa2
+                                          "Override the default value of field OEMID "
febaa2
+                                          "in ACPI table header."
febaa2
+                                          "The string may be up to 6 bytes in size");
febaa2
+
febaa2
+    object_class_property_add_str(oc, "x-oem-table-id",
febaa2
+                                  virt_get_oem_table_id,
febaa2
+                                  virt_set_oem_table_id);
febaa2
+    object_class_property_set_description(oc, "x-oem-table-id",
febaa2
+                                          "Override the default value of field OEM Table ID "
febaa2
+                                          "in ACPI table header."
febaa2
+                                          "The string may be up to 8 bytes in size");
febaa2
+    object_class_property_add_bool(oc, "default_bus_bypass_iommu",
febaa2
+                                   virt_get_default_bus_bypass_iommu,
febaa2
+                                   virt_set_default_bus_bypass_iommu);
22c213
+
22c213
+}
22c213
+
febaa2
+static void rhel_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;
febaa2
+
22c213
+    /* EL2 is disabled by default and non-configurable for RHEL */
22c213
+    vms->virt = false;
febaa2
+
febaa2
+    /* High memory is enabled by default */
22c213
+    vms->highmem = true;
febaa2
+    vms->gic_version = VIRT_GIC_VERSION_NOSEL;
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,
febaa2
+                                 virt_set_its);
22c213
+        object_property_set_description(obj, "its",
22c213
+                                        "Set on/off to enable/disable "
febaa2
+                                        "ITS instantiation");
22c213
+    }
22c213
+
22c213
+    /* Default disallows iommu instantiation */
22c213
+    vms->iommu = VIRT_IOMMU_NONE;
febaa2
+    object_property_add_str(obj, "iommu", virt_get_iommu, virt_set_iommu);
22c213
+    object_property_set_description(obj, "iommu",
22c213
+                                    "Set the IOMMU type. "
febaa2
+                                    "Valid values are none and smmuv3");
febaa2
+
febaa2
+    /* Default disallows RAS instantiation and is non-configurable for RHEL */
febaa2
+    vms->ras = false;
febaa2
+
febaa2
+    /* MTE is disabled by default and non-configurable for RHEL */
febaa2
+    vms->mte = false;
febaa2
+
febaa2
+    vms->default_bus_bypass_iommu = false;
febaa2
+    vms->irqmap = a15irqmap;
22c213
+
22c213
+    virt_flash_create(vms);
febaa2
+    vms->oem_id = g_strndup(ACPI_BUILD_APPNAME6, 6);
febaa2
+    vms->oem_table_id = g_strndup(ACPI_BUILD_APPNAME8, 8);
febaa2
+
22c213
+}
22c213
+
febaa2
+static const TypeInfo rhel_machine_info = {
febaa2
+    .name          = TYPE_RHEL_MACHINE,
febaa2
+    .parent        = TYPE_MACHINE,
febaa2
+    .abstract      = true,
febaa2
+    .instance_size = sizeof(VirtMachineState),
febaa2
+    .class_size    = sizeof(VirtMachineClass),
febaa2
+    .class_init    = rhel_machine_class_init,
febaa2
+    .instance_init = rhel_virt_instance_init,
febaa2
+    .interfaces = (InterfaceInfo[]) {
febaa2
+         { TYPE_HOTPLUG_HANDLER },
febaa2
+         { }
febaa2
+    },
febaa2
+};
febaa2
+
febaa2
+static void rhel_machine_init(void)
febaa2
+{
febaa2
+    type_register_static(&rhel_machine_info);
febaa2
+}
febaa2
+type_init(rhel_machine_init);
febaa2
+
febaa2
+static void rhel850_virt_options(MachineClass *mc)
22c213
+{
22c213
+    compat_props_add(mc->compat_props, arm_rhel_compat, arm_rhel_compat_len);
28f2e1
+    compat_props_add(mc->compat_props, hw_compat_rhel_8_5, hw_compat_rhel_8_5_len);
22c213
+}
febaa2
+DEFINE_RHEL_MACHINE_AS_LATEST(8, 5, 0)
febaa2
+
febaa2
+static void rhel840_virt_options(MachineClass *mc)
febaa2
+{
febaa2
+    rhel850_virt_options(mc);
febaa2
+    compat_props_add(mc->compat_props, hw_compat_rhel_8_4, hw_compat_rhel_8_4_len);
febaa2
+}
febaa2
+DEFINE_RHEL_MACHINE(8, 4, 0)
febaa2
+
febaa2
+static void rhel830_virt_options(MachineClass *mc)
febaa2
+{
febaa2
+    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
febaa2
+
febaa2
+    rhel840_virt_options(mc);
febaa2
+    compat_props_add(mc->compat_props, hw_compat_rhel_8_3, hw_compat_rhel_8_3_len);
febaa2
+    vmc->no_kvm_steal_time = true;
febaa2
+}
febaa2
+DEFINE_RHEL_MACHINE(8, 3, 0)
febaa2
+
febaa2
+static void rhel820_virt_options(MachineClass *mc)
febaa2
+{
febaa2
+    rhel830_virt_options(mc);
febaa2
+    compat_props_add(mc->compat_props, hw_compat_rhel_8_2, hw_compat_rhel_8_2_len);
febaa2
+    mc->numa_mem_supported = true;
febaa2
+    mc->auto_enable_numa_with_memdev = false;
febaa2
+}
febaa2
+DEFINE_RHEL_MACHINE(8, 2, 0)
febaa2
diff --git a/hw/core/machine.c b/hw/core/machine.c
28f2e1
index be4f9864cd..62febde5aa 100644
febaa2
--- a/hw/core/machine.c
febaa2
+++ b/hw/core/machine.c
28f2e1
@@ -87,6 +87,8 @@ GlobalProperty hw_compat_rhel_8_3[] = {
febaa2
     { "nvme", "use-intel-id", "on"},
febaa2
     /* hw_compat_rhel_8_3 from hw_compat_5_1 */
febaa2
     { "pvpanic", "events", "1"}, /* PVPANIC_PANICKED */
febaa2
+    /* hw_compat_rhel_8_3 from hw_compat_5_1 */
febaa2
+    { "pl011", "migrate-clk", "off" },
febaa2
     /* hw_compat_rhel_8_3 bz 1912846 */
febaa2
     { "pci-xhci", "x-rh-late-msi-cap", "off" },
febaa2
     /* hw_compat_rhel_8_3 from hw_compat_5_1 */
22c213
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
28f2e1
index dc6b66ffc8..9364628847 100644
22c213
--- a/include/hw/arm/virt.h
22c213
+++ b/include/hw/arm/virt.h
28f2e1
@@ -175,9 +175,17 @@ struct VirtMachineState {
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")
febaa2
 OBJECT_DECLARE_TYPE(VirtMachineState, VirtMachineClass, VIRT_MACHINE)
22c213
 
22c213
+#else
22c213
+#define TYPE_RHEL_MACHINE MACHINE_TYPE_NAME("virt-rhel")
febaa2
+typedef struct VirtMachineClass VirtMachineClass;
febaa2
+typedef struct VirtMachineState VirtMachineState;
febaa2
+DECLARE_OBJ_CHECKERS(VirtMachineState, VirtMachineClass, VIRT_MACHINE, TYPE_RHEL_MACHINE)
22c213
+#endif
22c213
+
22c213
 void virt_acpi_setup(VirtMachineState *vms);
febaa2
 bool virt_is_acpi_enabled(VirtMachineState *vms);
22c213
 
22c213
-- 
28f2e1
2.27.0
22c213