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