Register the AArch64 host CPU when CONFIG_NITRO is set, matching
the existing initfn early-return for nitro_enabled().

- Add CONFIG_NITRO to the aarch64_cpus host type guard
- Treat nitro_enabled() like the other accels in realize
- Mention Nitro in the host-CPU realize error
- Set host_cpu_probe_failed instead of asserting when only Nitro
  is compiled in and it is not selected

Signed-off-by: Yonggang Luo <[email protected]>
---
 target/arm/cpu.c   | 5 +++--
 target/arm/cpu64.c | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 090470da40a..c138c4c0587 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -1835,8 +1835,9 @@ static void arm_cpu_realizefn(DeviceState *dev, Error 
**errp)
      * this is the first point where we can report it.
      */
     if (cpu->host_cpu_probe_failed) {
-        if (!kvm_enabled() && !hvf_enabled() && !whpx_enabled()) {
-            error_setg(errp, "The 'host' CPU type can only be used with KVM, 
HVF or WHPX");
+        if (!kvm_enabled() && !hvf_enabled() && !whpx_enabled() &&
+            !nitro_enabled()) {
+            error_setg(errp, "The 'host' CPU type can only be used with KVM, 
HVF, WHPX or Nitro");
         } else {
             error_setg(errp, "Failed to retrieve host CPU features");
         }
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
index 1e64eb54cdc..03f3d55f6ba 100644
--- a/target/arm/cpu64.c
+++ b/target/arm/cpu64.c
@@ -774,7 +774,7 @@ void aarch64_host_initfn(Object *obj)
 #elif defined(CONFIG_WHPX)
     whpx_arm_set_cpu_features_from_host(cpu);
 #else
-    g_assert_not_reached();
+    cpu->host_cpu_probe_failed = true;
 #endif
     if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
         aarch64_add_pauth_properties(obj);
@@ -784,7 +784,8 @@ void aarch64_host_initfn(Object *obj)
 static const ARMCPUInfo aarch64_cpus[] = {
     { .name = "cortex-a57",         .initfn = aarch64_a57_initfn },
     { .name = "cortex-a53",         .initfn = aarch64_a53_initfn },
-#if defined(CONFIG_KVM) || defined(CONFIG_HVF) || defined(CONFIG_WHPX)
+#if defined(CONFIG_KVM) || defined(CONFIG_HVF) || defined(CONFIG_WHPX) || \
+    defined(CONFIG_NITRO)
     { .name = "host",               .initfn = aarch64_host_initfn },
 #endif
 };
-- 
2.52.0.windows.1


Reply via email to