twx-linux/arch/riscv/kvm
Anup Patel 4cec89db80 RISC-V: KVM: Move HGEI[E|P] CSR access to IMSIC virtualization
Currently, the common AIA functions kvm_riscv_vcpu_aia_has_interrupts()
and kvm_riscv_aia_wakeon_hgei() lookup HGEI line using an array of VCPU
pointers before accessing HGEI[E|P] CSR which is slow and prone to race
conditions because there is a separate per-hart lock for the VCPU pointer
array and a separate per-VCPU rwlock for IMSIC VS-file (including HGEI
line) used by the VCPU. Due to these race conditions, it is observed
on QEMU RISC-V host that Guest VCPUs sleep in WFI and never wakeup even
with interrupt pending in the IMSIC VS-file because VCPUs were waiting
for HGEI wakeup on the wrong host CPU.

The IMSIC virtualization already keeps track of the HGEI line and the
associated IMSIC VS-file used by each VCPU so move the HGEI[E|P] CSR
access to IMSIC virtualization so that costly HGEI line lookup can be
avoided and likelihood of race-conditions when updating HGEI[E|P] CSR
is also reduced.

Reviewed-by: Atish Patra <atishp@rivosinc.com>
Tested-by: Atish Patra <atishp@rivosinc.com>
Tested-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Fixes: 3385339296d1 ("RISC-V: KVM: Use IMSIC guest files when available")
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-by: Nutty Liu <liujingqi@lanxincomputing.com>
Link: https://lore.kernel.org/r/20250707035345.17494-3-apatel@ventanamicro.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2025-07-11 18:33:27 +05:30
..
aia_aplic.c RISC-V: KVM: Fix APLIC in_clrip and clripnum write emulation 2024-11-05 13:27:28 +05:30
aia_device.c RISC-V: KVM: use kvm_trylock_all_vcpus when locking all vCPUs 2025-05-27 12:16:41 -04:00
aia_imsic.c RISC-V: KVM: Move HGEI[E|P] CSR access to IMSIC virtualization 2025-07-11 18:33:27 +05:30
aia.c RISC-V: KVM: Move HGEI[E|P] CSR access to IMSIC virtualization 2025-07-11 18:33:27 +05:30
Kconfig RISC-V: KVM: Remove experimental tag for RISC-V 2025-05-21 09:34:42 +05:30
main.c RISC-V: KVM: Teardown riscv specific bits after kvm_exit 2025-03-19 20:21:38 +05:30
Makefile RISC-V: KVM: Add SBI system suspend support 2024-12-30 14:01:01 +05:30
mmu.c KVM/riscv changes for 6.13 2024-11-08 12:13:48 -05:00
nacl.c RISC-V: KVM: Add common nested acceleration support 2024-10-28 16:43:57 +05:30
tlb.c RISC-V: KVM: Use NACL HFENCEs for KVM request based HFENCEs 2024-10-28 16:44:08 +05:30
trace.h RISCV: KVM: add tracepoints for entry and exit events 2024-06-26 18:37:36 +05:30
vcpu_exit.c RISC-V: KVM: Add new exit statstics for redirected traps 2024-12-30 14:01:02 +05:30
vcpu_fp.c riscv: Rearrange hwcap.h and cpufeature.h 2023-11-09 10:15:51 -08:00
vcpu_insn.c KVM: riscv: Support guest wrs.nto 2024-07-12 08:54:51 -07:00
vcpu_onereg.c RISC-V Patches for the 6.15 Merge Window, Part 1 2025-04-04 09:49:17 -07:00
vcpu_pmu.c RISC-V: KVM: Disable the kernel perf counter during configure 2025-03-06 09:57:07 +05:30
vcpu_sbi_base.c RISC-V: KVM: Add ONE_REG interface to enable/disable SBI extensions 2023-04-21 17:38:44 +05:30
vcpu_sbi_hsm.c KVM: RISC-V: refactor sbi reset request 2025-05-21 09:34:49 +05:30
vcpu_sbi_pmu.c RISC-V: KVM: Improve firmware counter read function 2024-04-26 13:13:54 +05:30
vcpu_sbi_replace.c RISC-V: KVM: Don't treat SBI HFENCE calls as NOPs 2025-06-17 10:18:40 +05:30
vcpu_sbi_sta.c RISC-V: KVM: Rename the SBI_STA_SHMEM_DISABLE to a generic name 2024-04-22 11:13:52 +05:30
vcpu_sbi_system.c KVM: RISC-V: refactor sbi reset request 2025-05-21 09:34:49 +05:30
vcpu_sbi_v01.c RISC-V: KVM: Modify SBI extension handler to return SBI error code 2023-02-07 20:35:45 +05:30
vcpu_sbi.c RISC-V: KVM: lock the correct mp_state during reset 2025-05-24 21:30:47 +05:30
vcpu_switch.S RISC-V: KVM: Use SBI sync SRET call when available 2024-10-28 16:44:03 +05:30
vcpu_timer.c RISC-V: KVM: Disable vstimecmp before exiting to user-space 2025-07-11 18:30:17 +05:30
vcpu_vector.c KVM: RISC-V: refactor vector state reset 2025-05-21 09:34:46 +05:30
vcpu.c RISC-V: KVM: Move HGEI[E|P] CSR access to IMSIC virtualization 2025-07-11 18:33:27 +05:30
vm.c RISC-V: KVM: add KVM_CAP_RISCV_MP_STATE_RESET 2025-05-21 09:34:57 +05:30
vmid.c RISC-V: KVM: Drop the _MASK suffix from hgatp.VMID mask defines 2023-04-21 17:45:44 +05:30