linux-next/arch/loongarch
Huacai Chen 7f71507851 LoongArch: KVM: Protect kvm_io_bus_{read,write}() with SRCU
When we enable lockdep we get such a warning:

 =============================
 WARNING: suspicious RCU usage
 6.12.0-rc7+ #1891 Tainted: G        W
 -----------------------------
 arch/loongarch/kvm/../../../virt/kvm/kvm_main.c:5945 suspicious rcu_dereference_check() usage!
 other info that might help us debug this:
 rcu_scheduler_active = 2, debug_locks = 1
 1 lock held by qemu-system-loo/948:
  #0: 90000001184a00a8 (&vcpu->mutex){+.+.}-{4:4}, at: kvm_vcpu_ioctl+0xf4/0xe20 [kvm]
 stack backtrace:
 CPU: 2 UID: 0 PID: 948 Comm: qemu-system-loo Tainted: G        W          6.12.0-rc7+ #1891
 Tainted: [W]=WARN
 Hardware name: Loongson Loongson-3A5000-7A1000-1w-CRB/Loongson-LS3A5000-7A1000-1w-CRB, BIOS vUDK2018-LoongArch-V2.0.0-prebeta9 10/21/2022
 Stack : 0000000000000089 9000000005a0db9c 90000000071519c8 900000012c578000
         900000012c57b940 0000000000000000 900000012c57b948 9000000007e53788
         900000000815bcc8 900000000815bcc0 900000012c57b7b0 0000000000000001
         0000000000000001 4b031894b9d6b725 0000000005dec000 9000000100427b00
         00000000000003d2 0000000000000001 000000000000002d 0000000000000003
         0000000000000030 00000000000003b4 0000000005dec000 0000000000000000
         900000000806d000 9000000007e53788 00000000000000b4 0000000000000004
         0000000000000004 0000000000000000 0000000000000000 9000000107baf600
         9000000008916000 9000000007e53788 9000000005924778 000000001fe001e5
         00000000000000b0 0000000000000007 0000000000000000 0000000000071c1d
         ...
 Call Trace:
 [<9000000005924778>] show_stack+0x38/0x180
 [<90000000071519c4>] dump_stack_lvl+0x94/0xe4
 [<90000000059eb754>] lockdep_rcu_suspicious+0x194/0x240
 [<ffff80000221f47c>] kvm_io_bus_read+0x19c/0x1e0 [kvm]
 [<ffff800002225118>] kvm_emu_mmio_read+0xd8/0x440 [kvm]
 [<ffff8000022254bc>] kvm_handle_read_fault+0x3c/0xe0 [kvm]
 [<ffff80000222b3c8>] kvm_handle_exit+0x228/0x480 [kvm]

Fix it by protecting kvm_io_bus_{read,write}() with SRCU.

Cc: stable@vger.kernel.org
Reviewed-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
2024-12-03 19:49:28 +08:00
..
boot LoongArch: dts: Add I2S support to Loongson-2K2000 2024-11-26 18:06:08 +08:00
configs dmaengine updates for v6.13 2024-11-27 13:25:47 -08:00
crypto move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
include LoongArch: BPF: Adjust the parameter of emit_jirl() 2024-12-02 16:42:08 +08:00
kernel LoongArch: BPF: Adjust the parameter of emit_jirl() 2024-12-02 16:42:08 +08:00
kvm LoongArch: KVM: Protect kvm_io_bus_{read,write}() with SRCU 2024-12-03 19:49:28 +08:00
lib LoongArch: Select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 2024-05-14 12:24:18 +08:00
mm LoongArch changes for v6.13 2024-11-27 11:15:27 -08:00
net LoongArch: BPF: Adjust the parameter of emit_jirl() 2024-12-02 16:42:08 +08:00
pci LoongArch: Fix memleak in pci_acpi_scan_root() 2024-09-24 15:32:20 +08:00
power LoongArch: Add ACPI standard hardware register based S3 support 2024-07-20 22:41:06 +08:00
vdso LoongArch changes for v6.13 2024-11-27 11:15:27 -08:00
Kbuild LoongArch: Allow device trees be built into the kernel 2024-01-17 12:43:00 +08:00
Kconfig LoongArch: Allow to enable PREEMPT_LAZY 2024-11-26 18:06:04 +08:00
Kconfig.debug LoongArch: Only allow OBJTOOL & ORC unwinder if toolchain supports -mthin-add-sub 2024-06-21 10:18:40 +08:00
Makefile LoongArch: Explicitly specify code model in Makefile 2024-11-26 18:06:03 +08:00