Hi Song,
There is AI review comments about DMSI about irqchip-in-kernel driver, I
think it had better be handled before starting new feature.
https://sashiko.dev/#/patchset/20260522064945.614486-1-maobibo%40loongson.cn
This is a pre-existing issue, but looking at dmsintc_inject_irq(), could
it read uninitialized host stack memory? The local array unsigned long
vector[4] is declared without initialization. If atomic64_read() returns
0 for an index, the corresponding vector[i] element is not assigned and
retains uninitialized stack data:
arch/loongarch/kvm/intc/dmsintc.c:dmsintc_inject_irq() {
unsigned long vector[4], old;
...
for (i = 0; i < 4; i++) {
old = atomic64_read(&(ds->vector_map[i]));
if (old)
vector[i] = atomic64_xchg(&(ds->vector_map[i]), 0);
}
if (vector[0]) {
old = kvm_read_hw_gcsr(LOONGARCH_CSR_ISR0);
kvm_write_hw_gcsr(LOONGARCH_CSR_ISR0, vector[0] | old);
}
...
}
If the uninitialized stack memory contains non-zero garbage, it could be
written to the guest's LOONGARCH_CSR_ISRx registers, potentially causing
a guest-to-host information leak or spurious interrupts.
Regards
Bibo Mao
On 2026/5/25 下午4:46, Song Gao wrote:
> From: gaosong <gaosong@loongson.cn>
>
> Hi
>
> This series adds KVM put/get support for msgint CSRs and introduces
> msgint feature checks. It also adds kvm_dintc_realize() when
> kvm_irqchip_in_kernel is enabled, which creates and initializes the DINTC
> device in kernel mode.
>
> Since the kernel now supports DINTC on the KVM model,
> this series of updates will no longer use the' RFC' header;
>
> In addition, this series updates the Linux header files to version 7.1-rc4,
> and updates the `update-linux-headers.sh` script to include `typelimits.h`.
>
> About Testing:
> 1. run script with '-cpu max,msgint=on' and 'virt,dmsi=on.'
> '
> ./build/qemu-system-loongarch64 -accel kvm \
> -bios /usr/share/edk2/loongarch64/QEMU_EFI-silent-pflash.raw \
> -cpu max,msgint=on\
> -smp 4 \
> -machine virt,dmsi=on,kernel_irqchip=on\
> -m 16G \
> -netdev tap,id=net0,ifname=tap0,script=/root/net.sh,downscript=no,vhost=on,queues=4 \
> -device virtio-net-pci,netdev=net0,mq=on,vectors=128,mac=52:54:00:12:34:56 \
> -monitor telnet:localhost:4418,server,nowait \
> -device virtio-gpu-pci \
> -drive if=none,id=disk0,file=/home/kvm/lns23.qcow2,format=qcow2 \
> -device virtio-blk-pci,drive=disk0,id=virtio_disk0 \
> --nographic
> '
> 2 the vm can work well with with net test, such as netperf or iperf test.
>
> V3:
> Rebase,add patch4 to disable msgint in KVM model.
>
>
> Thanks,
> Song Gao
>
> Cédric Le Goater (1):
> linux-headers: Update to Linux v7.1-rc4
>
> Song Gao (2):
> target/loongarch: Add kvm support dintc
> Add dintc kvm_irqchip_in_kernel support
>
> gaosong (1):
> targe/loongarch: KVM disable msgint
>
> hw/intc/loongarch_dintc.c | 13 +
> hw/intc/loongarch_dintc_kvm.c | 48 ++
> hw/intc/meson.build | 2 +
> include/hw/intc/loongarch_dintc.h | 10 +
> include/standard-headers/drm/drm_fourcc.h | 28 +-
> include/standard-headers/linux/const.h | 18 +
> include/standard-headers/linux/ethtool.h | 28 +-
> .../linux/input-event-codes.h | 13 +
> include/standard-headers/linux/pci_regs.h | 71 ++-
> include/standard-headers/linux/typelimits.h | 8 +
> include/standard-headers/linux/virtio_ring.h | 5 +-
> include/standard-headers/linux/virtio_rtc.h | 237 ++++++++++
> include/standard-headers/linux/vmclock-abi.h | 20 +
> linux-headers/asm-arm64/kvm.h | 1 +
> linux-headers/asm-arm64/unistd_64.h | 1 +
> linux-headers/asm-generic/unistd.h | 5 +-
> linux-headers/asm-loongarch/kvm.h | 5 +
> linux-headers/asm-loongarch/kvm_para.h | 1 +
> linux-headers/asm-loongarch/unistd_64.h | 2 +
> linux-headers/asm-mips/unistd_n32.h | 1 +
> linux-headers/asm-mips/unistd_n64.h | 1 +
> linux-headers/asm-mips/unistd_o32.h | 1 +
> linux-headers/asm-powerpc/unistd_32.h | 1 +
> linux-headers/asm-powerpc/unistd_64.h | 1 +
> linux-headers/asm-riscv/kvm.h | 11 +-
> linux-headers/asm-riscv/ptrace.h | 37 ++
> linux-headers/asm-riscv/unistd_32.h | 1 +
> linux-headers/asm-riscv/unistd_64.h | 1 +
> linux-headers/asm-s390/unistd_32.h | 446 ------------------
> linux-headers/asm-s390/unistd_64.h | 1 +
> linux-headers/asm-x86/kvm.h | 21 +-
> linux-headers/asm-x86/unistd_32.h | 1 +
> linux-headers/asm-x86/unistd_64.h | 1 +
> linux-headers/asm-x86/unistd_x32.h | 1 +
> linux-headers/linux/const.h | 18 +
> linux-headers/linux/iommufd.h | 48 ++
> linux-headers/linux/kvm.h | 46 +-
> linux-headers/linux/mshv.h | 4 +-
> linux-headers/linux/psp-sev.h | 2 +-
> linux-headers/linux/stddef.h | 4 +
> linux-headers/linux/vduse.h | 85 +++-
> linux-headers/linux/vfio.h | 30 + > target/loongarch/cpu.c | 8 +-
> target/loongarch/cpu.h | 1 +
> target/loongarch/kvm/kvm.c | 74 +++
> 45 files changed, 866 insertions(+), 496 deletions(-)
> create mode 100644 hw/intc/loongarch_dintc_kvm.c
> create mode 100644 include/standard-headers/linux/typelimits.h
> create mode 100644 include/standard-headers/linux/virtio_rtc.h
> delete mode 100644 linux-headers/asm-s390/unistd_32.h
>