* [PATCH] LoongArch: KVM: Return the actual error code in kvm_pch_pic_create()
@ 2026-09-29 5:27 Chaithanya Lagisetty
2026-09-29 9:04 ` Bibo Mao
0 siblings, 1 reply; 2+ messages in thread
From: Chaithanya Lagisetty @ 2026-09-29 5:27 UTC (permalink / raw)
To: Huacai Chen, Bibo Mao, Tianrui Zhao
Cc: WANG Xuerui, Xianglai Li, kvm, loongarch, linux-kernel,
Chaithanya Lagisetty
kvm_pch_pic_create() sets up the default IRQ routing and reports every
failure as -ENOMEM, discarding the error code it was given:
ret = kvm_setup_default_irq_routing(kvm);
if (ret)
return -ENOMEM;
kvm_setup_default_irq_routing() returns -ENOMEM only when its routing
entry array cannot be allocated. Otherwise it forwards the result of
kvm_set_irq_routing(), which also fails with -EINVAL when an entry is
rejected by setup_routing_entry(). Userspace creating a
KVM_DEV_TYPE_LOONGARCH_PCHPIC device can therefore receive -ENOMEM even
when IRQ routing setup actually failed with -EINVAL.
Return ret so the original error code reaches userspace. This matches
kvm_eiointc_create(), which already propagates the error code from the
helpers it calls.
Only compile-tested.
Fixes: 1928254c5ccb ("LoongArch: KVM: Add irqfd support")
Signed-off-by: Chaithanya Lagisetty <nagachaithanya9911@gmail.com>
---
arch/loongarch/kvm/intc/pch_pic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/loongarch/kvm/intc/pch_pic.c b/arch/loongarch/kvm/intc/pch_pic.c
index 2b63b0c2c7ce..7fee60ae01a5 100644
--- a/arch/loongarch/kvm/intc/pch_pic.c
+++ b/arch/loongarch/kvm/intc/pch_pic.c
@@ -444,7 +444,7 @@ static int kvm_pch_pic_create(struct kvm_device *dev, u32 type)
ret = kvm_setup_default_irq_routing(kvm);
if (ret)
- return -ENOMEM;
+ return ret;
s = kzalloc_obj(struct loongarch_pch_pic);
if (!s)
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] LoongArch: KVM: Return the actual error code in kvm_pch_pic_create()
2026-09-29 5:27 [PATCH] LoongArch: KVM: Return the actual error code in kvm_pch_pic_create() Chaithanya Lagisetty
@ 2026-09-29 9:04 ` Bibo Mao
0 siblings, 0 replies; 2+ messages in thread
From: Bibo Mao @ 2026-09-29 9:04 UTC (permalink / raw)
To: Chaithanya Lagisetty, Huacai Chen, Tianrui Zhao
Cc: WANG Xuerui, Xianglai Li, kvm, loongarch, linux-kernel
Hi Chaithanya,
Thanks for patch, there is similar version at:
https://lore.kernel.org/lkml/20260927075240.3007947-6-cui.tao@linux.dev/
Regards
Bibo Mao
在 2026/9/29 13:27, Chaithanya Lagisetty 写道:
> kvm_pch_pic_create() sets up the default IRQ routing and reports every
> failure as -ENOMEM, discarding the error code it was given:
>
> ret = kvm_setup_default_irq_routing(kvm);
> if (ret)
> return -ENOMEM;
>
> kvm_setup_default_irq_routing() returns -ENOMEM only when its routing
> entry array cannot be allocated. Otherwise it forwards the result of
> kvm_set_irq_routing(), which also fails with -EINVAL when an entry is
> rejected by setup_routing_entry(). Userspace creating a
> KVM_DEV_TYPE_LOONGARCH_PCHPIC device can therefore receive -ENOMEM even
> when IRQ routing setup actually failed with -EINVAL.
>
> Return ret so the original error code reaches userspace. This matches
> kvm_eiointc_create(), which already propagates the error code from the
> helpers it calls.
>
> Only compile-tested.
>
> Fixes: 1928254c5ccb ("LoongArch: KVM: Add irqfd support")
> Signed-off-by: Chaithanya Lagisetty <nagachaithanya9911@gmail.com>
> ---
> arch/loongarch/kvm/intc/pch_pic.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/loongarch/kvm/intc/pch_pic.c b/arch/loongarch/kvm/intc/pch_pic.c
> index 2b63b0c2c7ce..7fee60ae01a5 100644
> --- a/arch/loongarch/kvm/intc/pch_pic.c
> +++ b/arch/loongarch/kvm/intc/pch_pic.c
> @@ -444,7 +444,7 @@ static int kvm_pch_pic_create(struct kvm_device *dev, u32 type)
>
> ret = kvm_setup_default_irq_routing(kvm);
> if (ret)
> - return -ENOMEM;
> + return ret;
>
> s = kzalloc_obj(struct loongarch_pch_pic);
> if (!s)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-29 9:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-29 5:27 [PATCH] LoongArch: KVM: Return the actual error code in kvm_pch_pic_create() Chaithanya Lagisetty
2026-09-29 9:04 ` Bibo Mao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®