Skip to content

Commit b20f679

Browse files
Andrew Jonespalmer-dabbelt
authored andcommitted
RISC-V: KVM: Expose Zicboz to the guest
Guests may use the cbo.zero instruction when the CPU has the Zicboz extension and the hypervisor sets henvcfg.CBZE. Add Zicboz support for KVM guests which may be enabled and disabled from KVM userspace using the ISA extension ONE_REG API. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20230224162631.405473-9-ajones@ventanamicro.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 665fd88 commit b20f679

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

arch/riscv/include/uapi/asm/kvm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ enum KVM_RISCV_ISA_EXT_ID {
106106
KVM_RISCV_ISA_EXT_SVINVAL,
107107
KVM_RISCV_ISA_EXT_ZIHINTPAUSE,
108108
KVM_RISCV_ISA_EXT_ZICBOM,
109+
KVM_RISCV_ISA_EXT_ZICBOZ,
109110
KVM_RISCV_ISA_EXT_MAX,
110111
};
111112

arch/riscv/kvm/vcpu.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ static const unsigned long kvm_isa_ext_arr[] = {
6363
KVM_ISA_EXT_ARR(SVPBMT),
6464
KVM_ISA_EXT_ARR(ZIHINTPAUSE),
6565
KVM_ISA_EXT_ARR(ZICBOM),
66+
KVM_ISA_EXT_ARR(ZICBOZ),
6667
};
6768

6869
static unsigned long kvm_riscv_vcpu_base2isa_ext(unsigned long base_ext)
@@ -872,6 +873,9 @@ static void kvm_riscv_vcpu_update_config(const unsigned long *isa)
872873
if (riscv_isa_extension_available(isa, ZICBOM))
873874
henvcfg |= (ENVCFG_CBIE | ENVCFG_CBCFE);
874875

876+
if (riscv_isa_extension_available(isa, ZICBOZ))
877+
henvcfg |= ENVCFG_CBZE;
878+
875879
csr_write(CSR_HENVCFG, henvcfg);
876880
#ifdef CONFIG_32BIT
877881
csr_write(CSR_HENVCFGH, henvcfg >> 32);

0 commit comments

Comments
 (0)