From: Markus Armbruster <armbru@redhat.com>
To: Bibo Mao <maobibo@loongson.cn>
Cc: Song Gao <gaosong@loongson.cn>,
Jiaxun Yang <jiaxun.yang@flygoat.com>,
qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 1/3] target/loongarch: Return directly when detect KVM disabled features
Date: Thu, 13 Mar 2025 11:26:43 +0100 [thread overview]
Message-ID: <87a59pb50c.fsf@pond.sub.org> (raw)
In-Reply-To: <20250313091350.3770394-2-maobibo@loongson.cn> (Bibo Mao's message of "Thu, 13 Mar 2025 17:13:48 +0800")
Suggest something like
arget/loongarch: Fix error handling of KVM feature checks
That way, the nature of the patch (it's an error handling bug fix) is
obvious at a glance.
Bibo Mao <maobibo@loongson.cn> writes:
> For some paravirt KVM features, if user forces to enable it however
> KVM does not support, qemu should fail to run. Here set error message
> and return directly in function kvm_arch_init_vcpu().
>
Please add
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>
> ---
> target/loongarch/kvm/kvm.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c
> index 28735c80be..b7f370ba97 100644
> --- a/target/loongarch/kvm/kvm.c
> +++ b/target/loongarch/kvm/kvm.c
int kvm_arch_init_vcpu(CPUState *cs)
{
uint64_t val;
int ret;
Error *local_err = NULL;
ret = 0;
Please drop this assignment, it's useless.
qemu_add_vm_change_state_handler(kvm_loongarch_vm_stage_change, cs);
if (!kvm_get_one_reg(cs, KVM_REG_LOONGARCH_DEBUG_INST, &val)) {
brk_insn = val;
}
> @@ -1091,21 +1091,25 @@ int kvm_arch_init_vcpu(CPUState *cs)
> ret = kvm_cpu_check_lsx(cs, &local_err);
> if (ret < 0) {
> error_report_err(local_err);
> + return ret;
> }
>
> ret = kvm_cpu_check_lasx(cs, &local_err);
> if (ret < 0) {
> error_report_err(local_err);
> + return ret;
> }
>
> ret = kvm_cpu_check_lbt(cs, &local_err);
> if (ret < 0) {
> error_report_err(local_err);
> + return ret;
> }
>
> ret = kvm_cpu_check_pmu(cs, &local_err);
> if (ret < 0) {
> error_report_err(local_err);
> + return ret;
> }
>
Recommend to
> ret = kvm_cpu_check_pv_features(cs, &local_err);
if (ret < 0) {
error_report_err(local_err);
+ return ret;
}
- return ret;
return 0;
}
Why? Have a look at commit 6edd2a9bec90:
@@ -793,6 +828,12 @@ int kvm_arch_init_vcpu(CPUState *cs)
if (ret < 0) {
error_report_err(local_err);
}
+
+ ret = kvm_cpu_check_pmu(cs, &local_err);
+ if (ret < 0) {
+ error_report_err(local_err);
+ }
+
return ret;
}
The new call broke the previous call's error handling. Easy mistake to
make. Less easy with my version.
With that
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Thanks!
next prev parent reply other threads:[~2025-03-13 10:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-13 9:13 [PATCH 0/3] target/loongarch: Solve some issues reported from coccinelle Bibo Mao
2025-03-13 9:13 ` [PATCH 1/3] target/loongarch: Return directly when detect KVM disabled features Bibo Mao
2025-03-13 10:26 ` Markus Armbruster [this message]
2025-03-13 11:17 ` bibo mao
2025-03-13 9:13 ` [PATCH 2/3] hw/loongarch/virt: Remove unnecessary NULL pointer checking Bibo Mao
2025-03-13 10:32 ` Markus Armbruster
2025-03-13 11:22 ` bibo mao
2025-03-14 2:27 ` bibo mao
2025-03-14 5:38 ` Markus Armbruster
2025-03-14 6:28 ` bibo mao
2025-03-14 6:58 ` bibo mao
2025-03-14 8:56 ` Markus Armbruster
2025-03-13 9:13 ` [PATCH 3/3] target/loongarch: Remove unnecessary temporary variable assignment Bibo Mao
2025-03-13 10:33 ` Markus Armbruster
2025-03-13 10:41 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a59pb50c.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=gaosong@loongson.cn \
--cc=jiaxun.yang@flygoat.com \
--cc=maobibo@loongson.cn \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.