Re: [PATCH] LoongArch: KVM: Set cpu before IN_GUEST_MODE is set

Huacai Chen <[email protected]>
Newsgroups org.kernel.vger.kvm,dev.linux.lists.loongarch,org.kernel.vger.linux-kernel,org.kernel.vger.stable
Message-ID <CAAhV-H4PcWnwqYqo3swkowKzUvGENfHhFktHaghsLFSaNkkLqg@mail.gmail.com>
Applied, thanks.

Huacai

On Tue, Aug 4, 2026 at 4:29 PM Bibo Mao <[email protected]> wrote:
>
> In function kvm_make_vcpu_request(), it will send IPI to physical CPU
> when vCPU is in IN_GUEST_MODE mode. And physical CPU is set in function
> kvm_check_vpid(), and it should be called before IN_GUEST_MODE is set.
> Otherwise IPI will send to wrong old physical CPU where vCPU is running.
>
> Fixes: 2fc3bd86db4b ("LoongArch: KVM: Implement basic vcpu interfaces")
> Cc: [email protected]
> Signed-off-by: Bibo Mao <[email protected]>
> ---
>  arch/loongarch/kvm/vcpu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c
> index 20c207d80e31..fd0dd22a7162 100644
> --- a/arch/loongarch/kvm/vcpu.c
> +++ b/arch/loongarch/kvm/vcpu.c
> @@ -300,10 +300,10 @@ static int kvm_pre_enter_guest(struct kvm_vcpu *vcpu)
>                  */
>                 local_irq_disable();
>                 kvm_deliver_exception(vcpu);
> +               kvm_check_vpid(vcpu);
>                 /* Make sure the vcpu mode has been written */
>                 smp_store_mb(vcpu->mode, IN_GUEST_MODE);
>                 kvm_deliver_intr(vcpu);
> -               kvm_check_vpid(vcpu);
>
>                 /*
>                  * Called after function kvm_check_vpid()
>
> base-commit: 075b74841bd0065a3bda3440873c747938e69b68
> --
> 2.39.3
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.