public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] Enable hstateen bits lazily for the KVM RISC-V Guests
@ 2025-05-05 21:39 Atish Patra
  2025-05-05 21:39 ` [PATCH 1/5] RISC-V: KVM: Lazy enable hstateen IMSIC & ISEL bit Atish Patra
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Atish Patra @ 2025-05-05 21:39 UTC (permalink / raw)
  To: Anup Patel, Atish Patra, Paul Walmsley, Palmer Dabbelt,
	Alexandre Ghiti
  Cc: kvm, kvm-riscv, linux-riscv, linux-kernel, Atish Patra

This series adds support for enabling hstateen bits lazily at runtime
instead of statically at bootime. The boot time enabling happens for
all the guests if the required extensions are present in the host and/or
guest. That may not be necessary if the guest never exercise that
feature. We can enable the hstateen bits that controls the access lazily
upon first access. This providers KVM more granular control of which
feature is enabled in the guest at runtime.

Currently, the following hstateen bits are supported to control the access
from VS mode.

1. BIT(58): IMSIC     : STOPEI and IMSIC guest interrupt file
2. BIT(59): AIA       : SIPH/SIEH/STOPI
3. BIT(60): AIA_ISEL  : Indirect csr access via siselect/sireg
4. BIT(62): HSENVCFG  : SENVCFG access
5. BIT(63): SSTATEEN0 : SSTATEEN0 access

KVM already support trap/enabling of BIT(58) and BIT(60) in order
to support sw version of the guest interrupt file. This series extends
those to enable to correpsonding hstateen bits in PATCH1. The remaining
patches adds lazy enabling support of the other bits.

I am working on a followup series to add indirect CSR extension and move the
siselect/sireg handlers out of AIA so that other features(e.g CTR) can leverage
it.

Note: This series just updates the hstateen bit in cfg so that any update
would reflect in the correct VM state during the next vcpu load.
Alternatively, we can save the hstateen state in vcpu_put to achieve this.
However, it will incur additional cost on every VM exit while the current
approach just updates the configuration once per VM life time upon first
access.

To: Anup Patel <anup@brainfault.org>
To: Atish Patra <atishp@atishpatra.org>
To: Paul Walmsley <paul.walmsley@sifive.com>
To: Palmer Dabbelt <palmer@dabbelt.com>
To: Alexandre Ghiti <alex@ghiti.fr>
Cc: kvm@vger.kernel.org
Cc: kvm-riscv@lists.infradead.org
Cc: linux-riscv@lists.infradead.org
Cc: linux-kernel@vger.kernel.org

Signed-off-by: Atish Patra <atishp@rivosinc.com>
---
Atish Patra (5):
      RISC-V: KVM: Lazy enable hstateen IMSIC & ISEL bit
      RISC-V: KVM: Add a hstateen lazy enabler helper function
      RISC-V: KVM: Support lazy enabling of siselect and aia bits
      RISC-V: KVM: Enable envcfg and sstateen bits lazily
      RISC-V: KVM: Remove the boot time enabling of hstateen bits

 arch/riscv/include/asm/kvm_aia.h       | 14 ++++++-
 arch/riscv/include/asm/kvm_vcpu_insn.h |  4 ++
 arch/riscv/kvm/aia.c                   | 77 ++++++++++++++++++++++++++++++++++
 arch/riscv/kvm/aia_imsic.c             |  8 ++++
 arch/riscv/kvm/vcpu.c                  | 10 -----
 arch/riscv/kvm/vcpu_insn.c             | 52 +++++++++++++++++++++++
 6 files changed, 154 insertions(+), 11 deletions(-)
---
base-commit: 01f95500a162fca88cefab9ed64ceded5afabc12
change-id: 20250430-kvm_lazy_enable_stateen-33c8aa9a3071
--
Regards,
Atish patra


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

end of thread, other threads:[~2025-05-12 10:25 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-05 21:39 [PATCH 0/5] Enable hstateen bits lazily for the KVM RISC-V Guests Atish Patra
2025-05-05 21:39 ` [PATCH 1/5] RISC-V: KVM: Lazy enable hstateen IMSIC & ISEL bit Atish Patra
2025-05-08 13:31   ` Radim Krčmář
2025-05-05 21:39 ` [PATCH 2/5] RISC-V: KVM: Add a hstateen lazy enabler helper function Atish Patra
2025-05-05 21:39 ` [PATCH 3/5] RISC-V: KVM: Support lazy enabling of siselect and aia bits Atish Patra
2025-05-05 21:39 ` [PATCH 4/5] RISC-V: KVM: Enable envcfg and sstateen bits lazily Atish Patra
2025-05-08 13:32   ` Radim Krčmář
2025-05-09 22:38     ` Atish Patra
2025-05-12 10:25       ` Radim Krčmář
2025-05-05 21:39 ` [PATCH 5/5] RISC-V: KVM: Remove the boot time enabling of hstateen bits Atish Patra
2025-05-06  9:24 ` [PATCH 0/5] Enable hstateen bits lazily for the KVM RISC-V Guests Radim Krčmář
2025-05-06 18:24   ` Atish Patra
2025-05-07 14:36     ` Radim Krčmář
2025-05-08  0:34       ` Atish Patra
2025-05-08 13:45         ` Radim Krčmář
2025-05-09 22:26           ` Atish Patra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox