586cba
From 055edf068196622a3e1868c9e4c991d410272a6d Mon Sep 17 00:00:00 2001
586cba
From: Andrew Jones <drjones@redhat.com>
586cba
Date: Wed, 15 Jun 2022 15:28:27 +0200
586cba
Subject: [PATCH 03/18] RHEL-only: AArch64: Drop unsupported CPU types
586cba
MIME-Version: 1.0
586cba
Content-Type: text/plain; charset=UTF-8
586cba
Content-Transfer-Encoding: 8bit
586cba
586cba
RH-Author: Daniel P. Berrangé <berrange@redhat.com>
586cba
RH-MergeRequest: 94: i386, aarch64, s390x: deprecate many named CPU models
586cba
RH-Commit: [3/6] 21f54c86dc87e5e75a64459b5a385686bc09640c (berrange/centos-src-qemu)
586cba
RH-Bugzilla: 2060839
586cba
RH-Acked-by: Thomas Huth <thuth@redhat.com>
586cba
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
586cba
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
586cba
586cba
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2066824
586cba
Upstream Status: RHEL only
586cba
586cba
We only need to support AArch64 cpu types and we only need three
586cba
types:
586cba
   1) A base type to use with TCG, i.e. a cpu type with only base
586cba
      features. 'cortex-a57' serves this role and is currently used
586cba
      by libguestfs.
586cba
   2) The 'max' type, which is for both KVM and TCG and is good for
586cba
      tests that just specify 'max' but run under both. 'max' with
586cba
      TCG also provides the VM with all the CPU features TCG
586cba
      supports, which is good for VMs that need features not
586cba
      provided by the basic cortex-a57.
586cba
   3) The host type which is used with KVM.
586cba
586cba
Signed-off-by: Andrew Jones <drjones@redhat.com>
586cba
---
586cba
 hw/arm/virt.c                  |  4 ++++
586cba
 target/arm/cpu64.c             |  6 ++++++
586cba
 target/arm/cpu_tcg.c           | 12 ++----------
586cba
 tests/qtest/arm-cpu-features.c |  6 ++++++
586cba
 4 files changed, 18 insertions(+), 10 deletions(-)
586cba
586cba
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
586cba
index 95d012d6eb..74119976d3 100644
586cba
--- a/hw/arm/virt.c
586cba
+++ b/hw/arm/virt.c
586cba
@@ -239,12 +239,16 @@ static const int a15irqmap[] = {
586cba
 };
586cba
 
586cba
 static const char *valid_cpus[] = {
586cba
+#if 0 /* Disabled for Red Hat Enterprise Linux */
586cba
     ARM_CPU_TYPE_NAME("cortex-a7"),
586cba
     ARM_CPU_TYPE_NAME("cortex-a15"),
586cba
     ARM_CPU_TYPE_NAME("cortex-a53"),
586cba
+#endif /* disabled for RHEL */
586cba
     ARM_CPU_TYPE_NAME("cortex-a57"),
586cba
+#if 0 /* Disabled for Red Hat Enterprise Linux */
586cba
     ARM_CPU_TYPE_NAME("cortex-a72"),
586cba
     ARM_CPU_TYPE_NAME("a64fx"),
586cba
+#endif /* disabled for RHEL */
586cba
     ARM_CPU_TYPE_NAME("host"),
586cba
     ARM_CPU_TYPE_NAME("max"),
586cba
 };
586cba
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
586cba
index eb44c05822..e80b831073 100644
586cba
--- a/target/arm/cpu64.c
586cba
+++ b/target/arm/cpu64.c
586cba
@@ -146,6 +146,7 @@ static void aarch64_a57_initfn(Object *obj)
586cba
     define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo);
586cba
 }
586cba
 
586cba
+#if 0 /* Disabled for Red Hat Enterprise Linux */
586cba
 static void aarch64_a53_initfn(Object *obj)
586cba
 {
586cba
     ARMCPU *cpu = ARM_CPU(obj);
586cba
@@ -249,6 +250,7 @@ static void aarch64_a72_initfn(Object *obj)
586cba
     cpu->gic_vprebits = 5;
586cba
     define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo);
586cba
 }
586cba
+#endif /* disabled for RHEL */
586cba
 
586cba
 void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp)
586cba
 {
586cba
@@ -923,6 +925,7 @@ static void aarch64_max_initfn(Object *obj)
586cba
     qdev_property_add_static(DEVICE(obj), &arm_cpu_lpa2_property);
586cba
 }
586cba
 
586cba
+#if 0 /* Disabled for Red Hat Enterprise Linux */
586cba
 static void aarch64_a64fx_initfn(Object *obj)
586cba
 {
586cba
     ARMCPU *cpu = ARM_CPU(obj);
586cba
@@ -969,12 +972,15 @@ static void aarch64_a64fx_initfn(Object *obj)
586cba
 
586cba
     /* TODO:  Add A64FX specific HPC extension registers */
586cba
 }
586cba
+#endif /* disabled for RHEL */
586cba
 
586cba
 static const ARMCPUInfo aarch64_cpus[] = {
586cba
     { .name = "cortex-a57",         .initfn = aarch64_a57_initfn },
586cba
+#if 0 /* Disabled for Red Hat Enterprise Linux */
586cba
     { .name = "cortex-a53",         .initfn = aarch64_a53_initfn },
586cba
     { .name = "cortex-a72",         .initfn = aarch64_a72_initfn },
586cba
     { .name = "a64fx",              .initfn = aarch64_a64fx_initfn },
586cba
+#endif /* disabled for RHEL */
586cba
     { .name = "max",                .initfn = aarch64_max_initfn },
586cba
 #if defined(CONFIG_KVM) || defined(CONFIG_HVF)
586cba
     { .name = "host",               .initfn = aarch64_host_initfn },
586cba
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
586cba
index 3826fa5122..74727fc92c 100644
586cba
--- a/target/arm/cpu_tcg.c
586cba
+++ b/target/arm/cpu_tcg.c
586cba
@@ -19,10 +19,10 @@
586cba
 #include "hw/boards.h"
586cba
 #endif
586cba
 
586cba
+#if 0 /* Disabled for Red Hat Enterprise Linux */
586cba
 /* CPU models. These are not needed for the AArch64 linux-user build. */
586cba
 #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
586cba
 
586cba
-#if 0 /* Disabled for Red Hat Enterprise Linux */
586cba
 #if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG)
586cba
 static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
586cba
 {
586cba
@@ -376,7 +376,6 @@ static void cortex_a9_initfn(Object *obj)
586cba
     cpu->ccsidr[1] = 0x200fe019; /* 16k L1 icache. */
586cba
     define_arm_cp_regs(cpu, cortexa9_cp_reginfo);
586cba
 }
586cba
-#endif /* disabled for RHEL */
586cba
 
586cba
 #ifndef CONFIG_USER_ONLY
586cba
 static uint64_t a15_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri)
586cba
@@ -402,7 +401,6 @@ static const ARMCPRegInfo cortexa15_cp_reginfo[] = {
586cba
     REGINFO_SENTINEL
586cba
 };
586cba
 
586cba
-#if 0 /* Disabled for Red Hat Enterprise Linux */
586cba
 static void cortex_a7_initfn(Object *obj)
586cba
 {
586cba
     ARMCPU *cpu = ARM_CPU(obj);
586cba
@@ -448,7 +446,6 @@ static void cortex_a7_initfn(Object *obj)
586cba
     cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */
586cba
     define_arm_cp_regs(cpu, cortexa15_cp_reginfo); /* Same as A15 */
586cba
 }
586cba
-#endif /* disabled for RHEL */
586cba
 
586cba
 static void cortex_a15_initfn(Object *obj)
586cba
 {
586cba
@@ -492,7 +489,6 @@ static void cortex_a15_initfn(Object *obj)
586cba
     define_arm_cp_regs(cpu, cortexa15_cp_reginfo);
586cba
 }
586cba
 
586cba
-#if 0 /* Disabled for Red Hat Enterprise Linux */
586cba
 static void cortex_m0_initfn(Object *obj)
586cba
 {
586cba
     ARMCPU *cpu = ARM_CPU(obj);
586cba
@@ -933,7 +929,6 @@ static void arm_v7m_class_init(ObjectClass *oc, void *data)
586cba
 
586cba
     cc->gdb_core_xml_file = "arm-m-profile.xml";
586cba
 }
586cba
-#endif /* disabled for RHEL */
586cba
 
586cba
 #ifndef TARGET_AARCH64
586cba
 /*
586cba
@@ -1013,7 +1008,6 @@ static void arm_max_initfn(Object *obj)
586cba
 #endif /* !TARGET_AARCH64 */
586cba
 
586cba
 static const ARMCPUInfo arm_tcg_cpus[] = {
586cba
-#if 0 /* Disabled for Red Hat Enterprise Linux */
586cba
     { .name = "arm926",      .initfn = arm926_initfn },
586cba
     { .name = "arm946",      .initfn = arm946_initfn },
586cba
     { .name = "arm1026",     .initfn = arm1026_initfn },
586cba
@@ -1029,9 +1023,7 @@ static const ARMCPUInfo arm_tcg_cpus[] = {
586cba
     { .name = "cortex-a7",   .initfn = cortex_a7_initfn },
586cba
     { .name = "cortex-a8",   .initfn = cortex_a8_initfn },
586cba
     { .name = "cortex-a9",   .initfn = cortex_a9_initfn },
586cba
-#endif /* disabled for RHEL */
586cba
     { .name = "cortex-a15",  .initfn = cortex_a15_initfn },
586cba
-#if 0 /* Disabled for Red Hat Enterprise Linux */
586cba
     { .name = "cortex-m0",   .initfn = cortex_m0_initfn,
586cba
                              .class_init = arm_v7m_class_init },
586cba
     { .name = "cortex-m3",   .initfn = cortex_m3_initfn,
586cba
@@ -1062,7 +1054,6 @@ static const ARMCPUInfo arm_tcg_cpus[] = {
586cba
     { .name = "pxa270-b1",   .initfn = pxa270b1_initfn },
586cba
     { .name = "pxa270-c0",   .initfn = pxa270c0_initfn },
586cba
     { .name = "pxa270-c5",   .initfn = pxa270c5_initfn },
586cba
-#endif /* disabled for RHEL */
586cba
 #ifndef TARGET_AARCH64
586cba
     { .name = "max",         .initfn = arm_max_initfn },
586cba
 #endif
586cba
@@ -1090,3 +1081,4 @@ static void arm_tcg_cpu_register_types(void)
586cba
 type_init(arm_tcg_cpu_register_types)
586cba
 
586cba
 #endif /* !CONFIG_USER_ONLY || !TARGET_AARCH64 */
586cba
+#endif /* disabled for RHEL */
586cba
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
586cba
index f76652143a..fe2a0a070d 100644
586cba
--- a/tests/qtest/arm-cpu-features.c
586cba
+++ b/tests/qtest/arm-cpu-features.c
586cba
@@ -440,8 +440,10 @@ static void test_query_cpu_model_expansion(const void *data)
586cba
     assert_error(qts, "host", "The CPU type 'host' requires KVM", NULL);
586cba
 
586cba
     /* Test expected feature presence/absence for some cpu types */
586cba
+#if 0 /* Disabled for Red Hat Enterprise Linux */
586cba
     assert_has_feature_enabled(qts, "cortex-a15", "pmu");
586cba
     assert_has_not_feature(qts, "cortex-a15", "aarch64");
586cba
+#endif /* disabled for RHEL */
586cba
 
586cba
     /* Enabling and disabling pmu should always work. */
586cba
     assert_has_feature_enabled(qts, "max", "pmu");
586cba
@@ -458,6 +460,7 @@ static void test_query_cpu_model_expansion(const void *data)
586cba
         assert_has_feature_enabled(qts, "cortex-a57", "pmu");
586cba
         assert_has_feature_enabled(qts, "cortex-a57", "aarch64");
586cba
 
586cba
+#if 0 /* Disabled for Red Hat Enterprise Linux */
586cba
         assert_has_feature_enabled(qts, "a64fx", "pmu");
586cba
         assert_has_feature_enabled(qts, "a64fx", "aarch64");
586cba
         /*
586cba
@@ -470,6 +473,7 @@ static void test_query_cpu_model_expansion(const void *data)
586cba
                      "{ 'sve384': true }");
586cba
         assert_error(qts, "a64fx", "cannot enable sve640",
586cba
                      "{ 'sve640': true }");
586cba
+#endif /* disabled for RHEL */
586cba
 
586cba
         sve_tests_default(qts, "max");
586cba
         pauth_tests_default(qts, "max");
586cba
@@ -505,9 +509,11 @@ static void test_query_cpu_model_expansion_kvm(const void *data)
586cba
         QDict *resp;
586cba
         char *error;
586cba
 
586cba
+#if 0 /* Disabled for Red Hat Enterprise Linux */
586cba
         assert_error(qts, "cortex-a15",
586cba
             "We cannot guarantee the CPU type 'cortex-a15' works "
586cba
             "with KVM on this host", NULL);
586cba
+#endif /* disabled for RHEL */
586cba
 
586cba
         assert_has_feature_enabled(qts, "host", "aarch64");
586cba
 
586cba
-- 
586cba
2.35.3
586cba