aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnup Patel <apatel@ventanamicro.com>2022-10-18 19:38:54 +0530
committerWill Deacon <will@kernel.org>2022-11-08 15:34:21 +0000
commite17d182ad3f797f01947fc234d95c96c050c534b (patch)
treefb57274bb1ece0d86eb117972d9249607760cef9
parent798398f40a163d476ec142b57e35bc1de4f17ca0 (diff)
downloadkvmtool-e17d182ad3f797f01947fc234d95c96c050c534b.tar.gz
riscv: Add --disable-<xyz> options to allow user disable extensions
By default, the KVM RISC-V keeps all extensions available to VCPU enabled and KVMTOOL does not disable any extension. We add --disable-<xyz> command-line options in KVMTOOL RISC-V to allow users explicitly disable certain extension if they don't desire it. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Link: https://lore.kernel.org/r/20221018140854.69846-7-apatel@ventanamicro.com Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r--riscv/fdt.c8
-rw-r--r--riscv/include/kvm/kvm-config-arch.h18
2 files changed, 25 insertions, 1 deletions
diff --git a/riscv/fdt.c b/riscv/fdt.c
index 30d3460b..3cdb95ca 100644
--- a/riscv/fdt.c
+++ b/riscv/fdt.c
@@ -80,6 +80,14 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm)
/* This extension is not available in hardware */
continue;
+ if (kvm->cfg.arch.ext_disabled[isa_info_arr[i].ext_id]) {
+ isa_ext_out = 0;
+ if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, &reg) < 0)
+ pr_warning("Failed to disable %s ISA exension\n",
+ isa_info_arr[i].name);
+ continue;
+ }
+
if (isa_info_arr[i].ext_id == KVM_RISCV_ISA_EXT_ZICBOM && !cbom_blksz) {
reg.id = RISCV_CONFIG_REG(zicbom_block_size);
reg.addr = (unsigned long)&cbom_blksz;
diff --git a/riscv/include/kvm/kvm-config-arch.h b/riscv/include/kvm/kvm-config-arch.h
index 526fca26..188125c7 100644
--- a/riscv/include/kvm/kvm-config-arch.h
+++ b/riscv/include/kvm/kvm-config-arch.h
@@ -5,11 +5,27 @@
struct kvm_config_arch {
const char *dump_dtb_filename;
+ bool ext_disabled[KVM_RISCV_ISA_EXT_MAX];
};
#define OPT_ARCH_RUN(pfx, cfg) \
pfx, \
OPT_STRING('\0', "dump-dtb", &(cfg)->dump_dtb_filename, \
- ".dtb file", "Dump generated .dtb to specified file"),
+ ".dtb file", "Dump generated .dtb to specified file"),\
+ OPT_BOOLEAN('\0', "disable-sstc", \
+ &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_SSTC], \
+ "Disable Sstc Extension"), \
+ OPT_BOOLEAN('\0', "disable-svinval", \
+ &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_SVINVAL], \
+ "Disable Svinval Extension"), \
+ OPT_BOOLEAN('\0', "disable-svpbmt", \
+ &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_SVPBMT], \
+ "Disable Svpbmt Extension"), \
+ OPT_BOOLEAN('\0', "disable-zicbom", \
+ &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZICBOM], \
+ "Disable Zicbom Extension"), \
+ OPT_BOOLEAN('\0', "disable-zihintpause", \
+ &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZIHINTPAUSE],\
+ "Disable Zihintpause Extension"),
#endif /* KVM__KVM_CONFIG_ARCH_H */