target/loongarch: Fix error handling of KVM feature checks

For some paravirt KVM features, if user forces to enable it however
KVM does not support, qemu should fail to run and exit immediately,
rather than continue to run. Here set error message and return directly
in function kvm_arch_init_vcpu().

Fixes: 6edd2a9bec90 (target/loongarch/kvm: Implement LoongArch PMU extension)
Fixes: 936c3f4d7916 (target/loongarch: Use auto method with LSX feature)
Fixes: 5e360dabedb1 (target/loongarch: Use auto method with LASX feature)
Fixes: 620d9bd0022e (target/loongarch: Add paravirt ipi feature detection)
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20250320032158.1762751-2-maobibo@loongson.cn>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
Bibo Mao 2025-03-20 11:21:53 +08:00 committed by Markus Armbruster
parent 6121c55db9
commit d7ffc17de7

View File

@ -1081,7 +1081,6 @@ int kvm_arch_init_vcpu(CPUState *cs)
int ret; int ret;
Error *local_err = NULL; Error *local_err = NULL;
ret = 0;
qemu_add_vm_change_state_handler(kvm_loongarch_vm_stage_change, cs); qemu_add_vm_change_state_handler(kvm_loongarch_vm_stage_change, cs);
if (!kvm_get_one_reg(cs, KVM_REG_LOONGARCH_DEBUG_INST, &val)) { if (!kvm_get_one_reg(cs, KVM_REG_LOONGARCH_DEBUG_INST, &val)) {
@ -1091,29 +1090,34 @@ int kvm_arch_init_vcpu(CPUState *cs)
ret = kvm_cpu_check_lsx(cs, &local_err); ret = kvm_cpu_check_lsx(cs, &local_err);
if (ret < 0) { if (ret < 0) {
error_report_err(local_err); error_report_err(local_err);
return ret;
} }
ret = kvm_cpu_check_lasx(cs, &local_err); ret = kvm_cpu_check_lasx(cs, &local_err);
if (ret < 0) { if (ret < 0) {
error_report_err(local_err); error_report_err(local_err);
return ret;
} }
ret = kvm_cpu_check_lbt(cs, &local_err); ret = kvm_cpu_check_lbt(cs, &local_err);
if (ret < 0) { if (ret < 0) {
error_report_err(local_err); error_report_err(local_err);
return ret;
} }
ret = kvm_cpu_check_pmu(cs, &local_err); ret = kvm_cpu_check_pmu(cs, &local_err);
if (ret < 0) { if (ret < 0) {
error_report_err(local_err); error_report_err(local_err);
return ret;
} }
ret = kvm_cpu_check_pv_features(cs, &local_err); ret = kvm_cpu_check_pv_features(cs, &local_err);
if (ret < 0) { if (ret < 0) {
error_report_err(local_err); error_report_err(local_err);
return ret;
} }
return ret; return 0;
} }
static bool loongarch_get_lbt(Object *obj, Error **errp) static bool loongarch_get_lbt(Object *obj, Error **errp)