From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41BDC2D29C3 for ; Tue, 12 Aug 2025 02:06:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754964413; cv=none; b=Nkpg1mIwTaz+GE7qgJH7f8LCZjBJKb3q9RU3kn0SdM/dzJnkLRKNX72or8rhC1mFXqzHT4KVYuiopFPSnT0HidC3r37C35rLPvbLeZZZkAXa2SH7VhiMGlw4HsMcaP7KVw3Ui+3atE5Cwv/PPfqjDuAdH2iZF44rn1+PvRzv0xk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754964413; c=relaxed/simple; bh=Q4Z3qXVn3J42JB4Mt5A9yNqNBJp506Y4Xw/nPFcjBzg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=dkX/Fbf5AIBXKeQQfTLnlYGMHA5S0En+Jb4OLbD7ub8En76rFaOGMUasbQW74soaA1rH3csBcYEKLSLV2vcALTA3+2fIEFs8UppBS/gVd5f2i/rt86w7OWNxt3DIPG9OZJbSvvse6uAW31Ce0u9JyKwKsa0YXkHHlMaNiJx6+n0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=DoHPqktM; arc=none smtp.client-ip=95.215.58.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="DoHPqktM" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1754964408; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yb/42nEJ2muvgQ6lHP6YmjzEIJNGbje0iFA6wKFEZGI=; b=DoHPqktM0aPB4n3AoOiG1up3ZkRzWty4W+nNKrOxLXLVrlZGsjqBjruYe121OlVLz//lUU RBCayvb/D6083F02bS2koJX41z6kK3V0hHh5aB3ksOLkB+oUrVitNdJd+We9JjbNBShijh EjPLHv/xotIxI7NLXz1GtVU5I3nRMRw= Date: Tue, 12 Aug 2025 10:06:17 +0800 Precedence: bulk X-Mailing-List: loongarch@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH] LoongArch: KVM: Use kvm_get_vcpu_by_id() instead of kvm_get_vcpu() To: Song Gao , maobibo@loongson.cn, zhaotianrui@loongson.cn, chenhuacai@kernel.org, lixianglai@loongson.cn Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org References: <20250811025544.458422-1-gaosong@loongson.cn> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yanteng Si In-Reply-To: <20250811025544.458422-1-gaosong@loongson.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 在 8/11/25 10:55 AM, Song Gao 写道: > Use kvm_get_vcpu() may can't get vcpu context, use kvm_get_vcpu_by_id() > instead of kvm_get_vcpu(). Since using kvm_get_vcpu() may fail to retrieve the vcpu context, kvm_get_vcpu_by_id() should be used instead. Under this premise, and under the premise of making revisions in accordance with Bibo's and Huacai's suggestions,pick up my tag in v2. Reviewed-by: Yanteng Si Additionally, do we need a fixes tag? Thanks, Yanteng > > Signed-off-by: Song Gao > --- > arch/loongarch/kvm/intc/eiointc.c | 5 ++++- > arch/loongarch/kvm/intc/ipi.c | 2 +- > 2 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/arch/loongarch/kvm/intc/eiointc.c b/arch/loongarch/kvm/intc/eiointc.c > index a3a12af9ecbf..5180da91d2e6 100644 > --- a/arch/loongarch/kvm/intc/eiointc.c > +++ b/arch/loongarch/kvm/intc/eiointc.c > @@ -45,7 +45,10 @@ static void eiointc_update_irq(struct loongarch_eiointc *s, int irq, int level) > } > > cpu = s->sw_coremap[irq]; > - vcpu = kvm_get_vcpu(s->kvm, cpu); > + vcpu = kvm_get_vcpu_by_id(s->kvm, cpu); > + if (unlikely(vcpu == NULL)) { > + return; > + } > if (level) { > /* if not enable return false */ > if (!test_bit(irq, (unsigned long *)s->enable.reg_u32)) > diff --git a/arch/loongarch/kvm/intc/ipi.c b/arch/loongarch/kvm/intc/ipi.c > index e658d5b37c04..0348a83a7ed7 100644 > --- a/arch/loongarch/kvm/intc/ipi.c > +++ b/arch/loongarch/kvm/intc/ipi.c > @@ -298,7 +298,7 @@ static int kvm_ipi_regs_access(struct kvm_device *dev, > cpu = (attr->attr >> 16) & 0x3ff; > addr = attr->attr & 0xff; > > - vcpu = kvm_get_vcpu(dev->kvm, cpu); > + vcpu = kvm_get_vcpu_by_id(dev->kvm, cpu); > if (unlikely(vcpu == NULL)) { > kvm_err("%s: invalid target cpu: %d\n", __func__, cpu); > return -EINVAL;