Skip to content

Commit d7ffc17

Browse files
bibo-maoMarkus Armbruster
authored andcommitted
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: 6edd2a9 (target/loongarch/kvm: Implement LoongArch PMU extension) Fixes: 936c3f4 (target/loongarch: Use auto method with LSX feature) Fixes: 5e360da (target/loongarch: Use auto method with LASX feature) Fixes: 620d9bd (target/loongarch: Add paravirt ipi feature detection) Signed-off-by: Bibo Mao <[email protected]> Reviewed-by: Markus Armbruster <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Message-ID: <[email protected]> Signed-off-by: Markus Armbruster <[email protected]>
1 parent 6121c55 commit d7ffc17

File tree

1 file changed

+6
-2
lines changed
  • target/loongarch/kvm

1 file changed

+6
-2
lines changed

target/loongarch/kvm/kvm.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,6 @@ int kvm_arch_init_vcpu(CPUState *cs)
10811081
int ret;
10821082
Error *local_err = NULL;
10831083

1084-
ret = 0;
10851084
qemu_add_vm_change_state_handler(kvm_loongarch_vm_stage_change, cs);
10861085

10871086
if (!kvm_get_one_reg(cs, KVM_REG_LOONGARCH_DEBUG_INST, &val)) {
@@ -1091,29 +1090,34 @@ int kvm_arch_init_vcpu(CPUState *cs)
10911090
ret = kvm_cpu_check_lsx(cs, &local_err);
10921091
if (ret < 0) {
10931092
error_report_err(local_err);
1093+
return ret;
10941094
}
10951095

10961096
ret = kvm_cpu_check_lasx(cs, &local_err);
10971097
if (ret < 0) {
10981098
error_report_err(local_err);
1099+
return ret;
10991100
}
11001101

11011102
ret = kvm_cpu_check_lbt(cs, &local_err);
11021103
if (ret < 0) {
11031104
error_report_err(local_err);
1105+
return ret;
11041106
}
11051107

11061108
ret = kvm_cpu_check_pmu(cs, &local_err);
11071109
if (ret < 0) {
11081110
error_report_err(local_err);
1111+
return ret;
11091112
}
11101113

11111114
ret = kvm_cpu_check_pv_features(cs, &local_err);
11121115
if (ret < 0) {
11131116
error_report_err(local_err);
1117+
return ret;
11141118
}
11151119

1116-
return ret;
1120+
return 0;
11171121
}
11181122

11191123
static bool loongarch_get_lbt(Object *obj, Error **errp)

0 commit comments

Comments
 (0)