qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Xianglai Li <lixianglai@loongson.cn>,
	qemu-devel@nongnu.org, kvm-devel <kvm@vger.kernel.org>
Cc: Bibo Mao <Maobibo@loongson.cn>, Song Gao <gaosong@loongson.cn>
Subject: Re: [PATCH V2] target/loongarch: fix vcpu reset command word issue
Date: Sun, 9 Feb 2025 18:48:35 +0100	[thread overview]
Message-ID: <62ad5a5b-9860-42dc-a4f3-37f504f3ded6@linaro.org> (raw)
In-Reply-To: <20250208075023.5647-1-lixianglai@loongson.cn>

Hi,

On 8/2/25 08:50, Xianglai Li wrote:
> When the KVM_REG_LOONGARCH_VCPU_RESET command word
> is sent to the kernel through the kvm_set_one_reg interface,
> the parameter source needs to be a legal address,
> otherwise the kernel will return an error and the command word
> will fail to be sent.
> 
> Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
> ---
> Cc: Bibo Mao <Maobibo@loongson.cn>
> Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
> Cc: Song Gao <gaosong@loongson.cn>
> Cc: Xianglai Li <lixianglai@loongson.cn>
> 
> CHANGE:
> V2<-V1:
>    1.Sets the initial value of the variable and
>    adds a function return value judgment and prints a log
> 
>   target/loongarch/kvm/kvm.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c
> index a3f55155b0..3f499e60ab 100644
> --- a/target/loongarch/kvm/kvm.c
> +++ b/target/loongarch/kvm/kvm.c
> @@ -581,9 +581,14 @@ static int kvm_loongarch_get_lbt(CPUState *cs)
>   void kvm_arch_reset_vcpu(CPUState *cs)
>   {
>       CPULoongArchState *env = cpu_env(cs);
> +    int ret = 0;
> +    uint64_t unused = 0;
>   
>       env->mp_state = KVM_MP_STATE_RUNNABLE;
> -    kvm_set_one_reg(cs, KVM_REG_LOONGARCH_VCPU_RESET, 0);
> +    ret = kvm_set_one_reg(cs, KVM_REG_LOONGARCH_VCPU_RESET, &unused);
> +    if (ret) {
> +        error_report("Failed to set KVM_REG_LOONGARCH_VCPU_RESET");

If this call fails, I'd not rely on the state of the VM. What about:

if (ret < 0) {
     error_report("Failed to set KVM_REG_LOONGARCH_VCPU_RESET: %s",
                  strerror(errno));
     exit(EXIT_FAILURE);
}

?

> +    }
>   }
>   
>   static int kvm_loongarch_get_mpstate(CPUState *cs)



  reply	other threads:[~2025-02-09 17:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-08  7:50 [PATCH V2] target/loongarch: fix vcpu reset command word issue Xianglai Li
2025-02-09 17:48 ` Philippe Mathieu-Daudé [this message]
2025-02-10  1:17   ` lixianglai
  -- strict thread matches above, loose matches on Subject: below --
2025-02-08  7:48 Xianglai Li

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=62ad5a5b-9860-42dc-a4f3-37f504f3ded6@linaro.org \
    --to=philmd@linaro.org \
    --cc=Maobibo@loongson.cn \
    --cc=gaosong@loongson.cn \
    --cc=kvm@vger.kernel.org \
    --cc=lixianglai@loongson.cn \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).