Skip to content

Few timer and AIA fixes for KVM RISC-V

Anup Patel kvm kvm-riscv linux-riscv lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 4 repliesIn review 1 of 2 applied
  2. v12 patches 5 repliesSuperseded

Changes in v2 from the cover letter

- Added more details about race condition in PATCH2 commit description.

Patches in v2 1 of 2 applied

#Subject and filesSizeRepliesApplied
1/2RISC-V: KVM: Disable vstimecmp before exiting to user-spacearch/riscv/kvm/vcpu_timer.c+16 -01 replyApplied
2/2RISC-V: KVM: Move HGEI[E|P] CSR access to IMSIC virtualizationarch/riscv/include/asm/kvm_aia.h arch/riscv/kvm/aia.c arch/riscv/kvm/aia_imsic.c +1 more+55 -472 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchAtish PatraHeinrich SchuchardtNutty Liu
1/2R-b T-b T-b R-b
2/2R-b T-b T-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 0/2] Few timer and AIA fixes for KVM RISC-V

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(-)
Signature · 1 line
2.43.0