Skip to content

Commit 665fd88

Browse files
Andrew Jonespalmer-dabbelt
authored andcommitted
RISC-V: KVM: Provide UAPI for Zicboz block size
We're about to allow guests to use the Zicboz extension. KVM userspace needs to know the cache block size in order to properly advertise it to the guest. Provide a virtual config register for userspace to get it with the GET_ONE_REG API, but setting it cannot be supported, so disallow SET_ONE_REG. 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-8-ajones@ventanamicro.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent ab0f774 commit 665fd88

2 files changed

Lines changed: 8 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
@@ -52,6 +52,7 @@ struct kvm_riscv_config {
5252
unsigned long mvendorid;
5353
unsigned long marchid;
5454
unsigned long mimpid;
55+
unsigned long zicboz_block_size;
5556
};
5657

5758
/* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */

arch/riscv/kvm/vcpu.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,11 @@ static int kvm_riscv_vcpu_get_reg_config(struct kvm_vcpu *vcpu,
283283
return -EINVAL;
284284
reg_val = riscv_cbom_block_size;
285285
break;
286+
case KVM_REG_RISCV_CONFIG_REG(zicboz_block_size):
287+
if (!riscv_isa_extension_available(vcpu->arch.isa, ZICBOZ))
288+
return -EINVAL;
289+
reg_val = riscv_cboz_block_size;
290+
break;
286291
case KVM_REG_RISCV_CONFIG_REG(mvendorid):
287292
reg_val = vcpu->arch.mvendorid;
288293
break;
@@ -354,6 +359,8 @@ static int kvm_riscv_vcpu_set_reg_config(struct kvm_vcpu *vcpu,
354359
break;
355360
case KVM_REG_RISCV_CONFIG_REG(zicbom_block_size):
356361
return -EOPNOTSUPP;
362+
case KVM_REG_RISCV_CONFIG_REG(zicboz_block_size):
363+
return -EOPNOTSUPP;
357364
case KVM_REG_RISCV_CONFIG_REG(mvendorid):
358365
if (!vcpu->arch.ran_atleast_once)
359366
vcpu->arch.mvendorid = reg_val;

0 commit comments

Comments
 (0)