[PATCH] LoongArch: KVM: Add missing slots_lock for EIOINTC virtual extension device registration

Zeng Chi posted 1 patch 6 days, 19 hours ago
arch/loongarch/kvm/intc/eiointc.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] LoongArch: KVM: Add missing slots_lock for EIOINTC virtual extension device registration
Posted by Zeng Chi 6 days, 19 hours ago
From: Zeng Chi <zengchi@kylinos.cn>

The second kvm_io_bus_register_dev() call for device_vext was missing
kvm->slots_lock protection. Add it to match the first registration.

Signed-off-by: Zeng Chi <zengchi@kylinos.cn>
---
 arch/loongarch/kvm/intc/eiointc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/loongarch/kvm/intc/eiointc.c b/arch/loongarch/kvm/intc/eiointc.c
index 2ab7fafa86d5..ce64ffb706df 100644
--- a/arch/loongarch/kvm/intc/eiointc.c
+++ b/arch/loongarch/kvm/intc/eiointc.c
@@ -645,8 +645,10 @@ static int kvm_eiointc_create(struct kvm_device *dev, u32 type)
 
 	device = &s->device_vext;
 	kvm_iodevice_init(device, &kvm_eiointc_virt_ops);
+	mutex_lock(&kvm->slots_lock);
 	ret = kvm_io_bus_register_dev(kvm, KVM_IOCSR_BUS,
 			EIOINTC_VIRT_BASE, EIOINTC_VIRT_SIZE, device);
+	mutex_unlock(&kvm->slots_lock);
 	if (ret < 0) {
 		kvm_io_bus_unregister_dev(kvm, KVM_IOCSR_BUS, &s->device);
 		kfree(s);
-- 
2.25.1
Re: [PATCH] LoongArch: KVM: Add missing slots_lock for EIOINTC virtual extension device registration
Posted by Bibo Mao 6 days, 19 hours ago

On 2026/5/18 下午5:45, Zeng Chi wrote:
> From: Zeng Chi <zengchi@kylinos.cn>
> 
> The second kvm_io_bus_register_dev() call for device_vext was missing
> kvm->slots_lock protection. Add it to match the first registration.
> 
> Signed-off-by: Zeng Chi <zengchi@kylinos.cn>
> ---
>   arch/loongarch/kvm/intc/eiointc.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/arch/loongarch/kvm/intc/eiointc.c b/arch/loongarch/kvm/intc/eiointc.c
> index 2ab7fafa86d5..ce64ffb706df 100644
> --- a/arch/loongarch/kvm/intc/eiointc.c
> +++ b/arch/loongarch/kvm/intc/eiointc.c
> @@ -645,8 +645,10 @@ static int kvm_eiointc_create(struct kvm_device *dev, u32 type)
>   
>   	device = &s->device_vext;
>   	kvm_iodevice_init(device, &kvm_eiointc_virt_ops);
> +	mutex_lock(&kvm->slots_lock);
>   	ret = kvm_io_bus_register_dev(kvm, KVM_IOCSR_BUS,
>   			EIOINTC_VIRT_BASE, EIOINTC_VIRT_SIZE, device);
> +	mutex_unlock(&kvm->slots_lock);
>   	if (ret < 0) {
>   		kvm_io_bus_unregister_dev(kvm, KVM_IOCSR_BUS, &s->device);
>   		kfree(s);
> 
Hi ZengChi,

Good catch.

There should be the similar lock protection with function call 
kvm_io_bus_unregister_dev() in files pch_pic.c/ipi.c/eiointc.c

Would you like add these together?

Regards
Bibo Mao