From: Eric Auger <[email protected]> In case *_arm_host_cpu_features() fails, we currently record that state in cpu->host_cpu_probe_failed to later report the error on realize().
Replace the boolean by an error handle to allow more relevant error reports. Signed-off-by: Eric Auger <[email protected]> Reviewed-by: Peter Maydell <[email protected]> Message-id: [email protected] Suggested-by: Peter Maydell <[email protected]> Signed-off-by: Peter Maydell <[email protected]> --- target/arm/cpu.h | 5 +++-- target/arm/cpu.c | 10 ++++++++-- target/arm/hvf/hvf.c | 3 ++- target/arm/kvm.c | 3 ++- target/arm/whpx/whpx-all.c | 3 ++- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 5c5f551dacb..dae79539b54 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1075,10 +1075,11 @@ struct ArchCPU { /* Uniprocessor system with MP extensions */ bool mp_is_up; - /* True if we tried kvm_arm_host_cpu_features() during CPU instance_init + /* + * Set if we tried *_set_cpu_features_from_host() during CPU instance_init * and the probe failed (so we need to report the error in realize) */ - bool host_cpu_probe_failed; + Error *host_cpu_probe_err; /* QOM property to indicate we should use the back-compat CNTFRQ default */ bool backcompat_cntfrq; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index b9e4734de8d..c484c40a7e5 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1740,6 +1740,10 @@ static void arm_cpu_finalizefn(Object *obj) g_hash_table_destroy(cpu->cp_regs); + if (cpu->host_cpu_probe_err) { + error_free(cpu->host_cpu_probe_err); + } + QLIST_FOREACH_SAFE(hook, &cpu->pre_el_change_hooks, node, next) { QLIST_REMOVE(hook, node); g_free(hook); @@ -1842,12 +1846,14 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) * then it's possible that might have failed in the initfn, but * this is the first point where we can report it. */ - if (cpu->host_cpu_probe_failed) { + if (cpu->host_cpu_probe_err) { if (!kvm_enabled() && !hvf_enabled() && !whpx_enabled()) { error_setg(errp, "The 'host' CPU type can only be used with KVM, HVF or WHPX"); + error_free(cpu->host_cpu_probe_err); } else { - error_setg(errp, "Failed to retrieve host CPU features"); + error_propagate(errp, cpu->host_cpu_probe_err); } + cpu->host_cpu_probe_err = NULL; return; } diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 40b7febceb9..1c63553957d 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -1313,7 +1313,8 @@ void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu) * We can't report this error yet, so flag that we need to * in arm_cpu_realizefn(). */ - cpu->host_cpu_probe_failed = true; + error_setg(&cpu->host_cpu_probe_err, + "failed to retrieve host CPU features"); return; } } diff --git a/target/arm/kvm.c b/target/arm/kvm.c index b4b20c5dc27..f9c75774605 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -538,7 +538,8 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) * We can't report this error yet, so flag that we need to * in arm_cpu_realizefn(). */ - cpu->host_cpu_probe_failed = true; + error_setg(&cpu->host_cpu_probe_err, + "failed to retrieve host CPU features"); return; } diff --git a/target/arm/whpx/whpx-all.c b/target/arm/whpx/whpx-all.c index 024d18df046..ded42c980ba 100644 --- a/target/arm/whpx/whpx-all.c +++ b/target/arm/whpx/whpx-all.c @@ -767,7 +767,8 @@ void whpx_arm_set_cpu_features_from_host(ARMCPU *cpu) * We can't report this error yet, so flag that we need to * in arm_cpu_realizefn(). */ - cpu->host_cpu_probe_failed = true; + error_setg(&cpu->host_cpu_probe_err, + "failed to retrieve host CPU features"); return; } } -- 2.43.0
