kvm-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Few timer and AIA fixes for KVM RISC-V
@ 2025-07-07  3:53 Anup Patel
  2025-07-07  3:53 ` [PATCH v2 1/2] RISC-V: KVM: Disable vstimecmp before exiting to user-space Anup Patel
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Anup Patel @ 2025-07-07  3:53 UTC (permalink / raw)
  To: Atish Patra
  Cc: Palmer Dabbelt, Paul Walmsley, Alexandre Ghiti, Andrew Jones,
	Anup Patel, kvm, kvm-riscv, linux-riscv, linux-kernel, Anup Patel

The RISC-V Privileged specificaiton says the following: "WFI is also
required to resume execution for locally enabled interrupts pending
at any privilege level, regardless of the global interrupt enable at
each privilege level."

Based on the above, if there is pending VS-timer interrupt when the
host (aka HS-mode) executes WFI then such a WFI will simply become NOP
and not do anything. This result in QEMU RISC-V consuming a lot of CPU
time on the x86 machine where it is running. The PATCH1 solves this
issue by adding appropriate cleanup in KVM RISC-V timer virtualization.

As a result PATCH1, race conditions in updating HGEI[E|P] CSRs when a
VCPU is moved from one host CPU to another are being observed on QEMU
so the PATCH2 tries to minimize the chances of these race conditions.

Changes since v1:
 - Added more details about race condition in PATCH2 commit description.

Anup Patel (2):
  RISC-V: KVM: Disable vstimecmp before exiting to user-space
  RISC-V: KVM: Move HGEI[E|P] CSR access to IMSIC virtualization

 arch/riscv/include/asm/kvm_aia.h |  4 ++-
 arch/riscv/kvm/aia.c             | 51 +++++---------------------------
 arch/riscv/kvm/aia_imsic.c       | 45 ++++++++++++++++++++++++++++
 arch/riscv/kvm/vcpu.c            |  2 --
 arch/riscv/kvm/vcpu_timer.c      | 16 ++++++++++
 5 files changed, 71 insertions(+), 47 deletions(-)

-- 
2.43.0


-- 
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-08-06 17:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-07  3:53 [PATCH v2 0/2] Few timer and AIA fixes for KVM RISC-V Anup Patel
2025-07-07  3:53 ` [PATCH v2 1/2] RISC-V: KVM: Disable vstimecmp before exiting to user-space Anup Patel
2025-07-07  4:06   ` Nutty Liu
2025-07-07  3:53 ` [PATCH v2 2/2] RISC-V: KVM: Move HGEI[E|P] CSR access to IMSIC virtualization Anup Patel
2025-07-07  4:20   ` Nutty Liu
2025-07-07  4:48     ` Anup Patel
2025-07-11 13:05 ` [PATCH v2 0/2] Few timer and AIA fixes for KVM RISC-V Anup Patel
2025-08-06 17:15 ` patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).