Re: [PATCH] LoongArch: KVM: Set cpu before IN_GUEST_MODE is set
From: Huacai Chen
Date: Sun Aug 09 2026 - 00:08:14 EST
Applied, thanks.
Huacai
On Tue, Aug 4, 2026 at 4:29 PM Bibo Mao <maobibo@xxxxxxxxxxx> 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: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Bibo Mao <maobibo@xxxxxxxxxxx>
> ---
> 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
>