loongarch.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Bibo Mao <maobibo@loongson.cn>
To: Huacai Chen <chenhuacai@kernel.org>
Cc: kernel@xen0n.name, kvm@vger.kernel.org,
	loongarch@lists.linux.dev, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v3 1/6] LoongArch: KVM: Check irq validility in kvm_vcpu_ioctl_interrupt()
Date: Tue, 19 May 2026 20:57:16 +0800	[thread overview]
Message-ID: <786dda77-1fda-7741-c20f-bafbaacd6fd2@loongson.cn> (raw)
In-Reply-To: <20260519094308.3983046-2-maobibo@loongson.cn>



On 2026/5/19 下午5:43, Bibo Mao wrote:
> Function kvm_vcpu_ioctl_interrupt() can be called from userspace, here
> add irq validility cheking in kvm_vcpu_ioctl_interrupt().
> 
> Fixes: f45ad5b8aa93 ("LoongArch: KVM: Implement vcpu interrupt operations")
> Cc: stable@vger.kernel.org
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> ---
>   arch/loongarch/kvm/vcpu.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c
> index e28084c49e68..673977a25138 100644
> --- a/arch/loongarch/kvm/vcpu.c
> +++ b/arch/loongarch/kvm/vcpu.c
> @@ -1486,7 +1486,14 @@ void kvm_lose_fpu(struct kvm_vcpu *vcpu)
>   
>   int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq)
>   {
> -	int intr = (int)irq->irq;
> +	int vector, intr = (int)irq->irq;
> +
> +	vector = intr;
> +	if (intr < 0)
> +		vector = -intr;
By AI review, there is still problem if the value of intr is 0x8000000. 
I should notice this earlier :(

http://sashiko.dev/#/patchset/20260519094308.3983046-1-maobibo%40loongson.cn

Regards
Bibo Mao
> +
> +	if (vector >= EXCCODE_INT_NUM)
> +		return -EINVAL;
>   
>   	if (intr > 0)
>   		kvm_queue_irq(vcpu, intr);
> 


  reply	other threads:[~2026-05-19 13:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-19  9:43 [PATCH v3 0/6] LoongArch: KVM: Small enhancement about interrupt injection Bibo Mao
2026-05-19  9:43 ` [PATCH v3 1/6] LoongArch: KVM: Check irq validility in kvm_vcpu_ioctl_interrupt() Bibo Mao
2026-05-19 12:57   ` Bibo Mao [this message]
2026-05-19  9:43 ` [PATCH v3 2/6] LoongArch: KVM: Check msgint feature in interrupt post Bibo Mao
2026-05-19  9:43 ` [PATCH v3 3/6] LoongArch: KVM: Use existing macro about interrupt bit mask Bibo Mao
2026-05-19  9:43 ` [PATCH v3 4/6] LoongArch: KVM: Inject interrupt with batch method Bibo Mao
2026-05-19  9:43 ` [PATCH v3 5/6] LoongArch: KVM: Add valid bit check when set ESTAT CSR register Bibo Mao
2026-05-19  9:43 ` [PATCH v3 6/6] LoongArch: KVM: Simple interrupt status acquire interface Bibo Mao

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=786dda77-1fda-7741-c20f-bafbaacd6fd2@loongson.cn \
    --to=maobibo@loongson.cn \
    --cc=chenhuacai@kernel.org \
    --cc=kernel@xen0n.name \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=stable@vger.kernel.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 read-only IMAP folder(s) and NNTP newsgroup(s).