All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] RISC-V: KVM: fix vcpu vector context handling
@ 2026-07-15  5:16 ` Andy Chiu
  0 siblings, 0 replies; 13+ messages in thread
From: Andy Chiu @ 2026-07-15  5:16 UTC (permalink / raw)
  To: anup, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	linux-riscv
  Cc: kvm-riscv, Andy Chiu, dfustini, greentime.hu, linux-kernel, olof

This series fixes a vtype corruption encountered when running perf +
vector workload on KVM.

The root cause of the bug is that the kernel-mode vector (KMV)
misattributes the guest's vcpu context as the user's context. To solve
this, we need to correctly save the vcpu context when the kernel-mode
vector is serving a guest.

However, calling directly into KVM from RISC-V generic architecture code
creates a reverse dependency, which is problematic when KVM is built as
a module. To address this, we introduce an RCU-protected callback for
context flushing, which KVM registers during module init.

This series will create merge conflict with my v4 [1] series on syscall
optimization. I will send out a v5 that has the conflict resolved once
this series is sufficiently reviewed.

Patch 1 is a preparatory cleanup that refactors
riscv_v_start_kernel_context().
Patch 2 prepares get/put_cpu_vector_context() for gaurding the use of
vector in kvm_arch_vcpu_load/put()
Patch 3 implements the callback mechanism and fixes the context handling.

Patch summary:
 - unchanged patch: 1
 - new patch: 2
 - modified patch: 3

Changelog v2:
 - Address issues pointed out by sashiko (2, 3)
 - Link to v1: https://lore.kernel.org/all/20260711015835.767259-1-tchiu@tenstorrent.com/

[1]: https://lore.kernel.org/all/20260528190927.886558-1-tchiu@tenstorrent.com/

Andy Chiu (3):
  riscv: vector: refactor riscv_v_start_kernel_context
  riscv: vector: allow non-preemptible kernel-mode vector with IRQs off
  RISC-V: KVM: fix vcpu vector context handling for kernel-mode vector

 arch/riscv/include/asm/kvm_vcpu_vector.h | 24 +++++++
 arch/riscv/include/asm/processor.h       |  2 +
 arch/riscv/include/asm/simd.h            |  8 +--
 arch/riscv/include/asm/vector.h          |  5 ++
 arch/riscv/kernel/kernel_mode_vector.c   | 79 ++++++++++++++++--------
 arch/riscv/kvm/main.c                    |  4 ++
 arch/riscv/kvm/vcpu.c                    | 10 +++
 arch/riscv/kvm/vcpu_vector.c             | 20 ++++++
 8 files changed, 121 insertions(+), 31 deletions(-)

-- 
2.43.0


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

end of thread, other threads:[~2026-07-15  5:34 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-15  5:16 [PATCH v2 0/3] RISC-V: KVM: fix vcpu vector context handling Andy Chiu
2026-07-15  5:16 ` Andy Chiu
2026-07-15  5:16 ` Andy Chiu
2026-07-15  5:16 ` [PATCH v2 1/3] riscv: vector: refactor riscv_v_start_kernel_context Andy Chiu
2026-07-15  5:16   ` Andy Chiu
2026-07-15  5:16 ` [PATCH v2 2/3] riscv: vector: allow non-preemptible kernel-mode vector with IRQs off Andy Chiu
2026-07-15  5:16   ` Andy Chiu
2026-07-15  5:16   ` Andy Chiu
2026-07-15  5:32   ` sashiko-bot
2026-07-15  5:16 ` [PATCH v2 3/3] RISC-V: KVM: fix vcpu vector context handling for kernel-mode vector Andy Chiu
2026-07-15  5:16   ` Andy Chiu
2026-07-15  5:16   ` Andy Chiu
2026-07-15  5:34   ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.