From: Zongmin Zhou When the Zicbop extension is available expose it to the guest. Also provide the guest the size of the cache block through DT. Signed-off-by: Zongmin Zhou --- riscv/fdt.c | 12 +++++++++++- riscv/include/kvm/kvm-config-arch.h | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/riscv/fdt.c b/riscv/fdt.c index eba9387..510641e 100644 --- a/riscv/fdt.c +++ b/riscv/fdt.c @@ -58,6 +58,7 @@ struct isa_ext_info isa_info_arr[] = { {"zfh", KVM_RISCV_ISA_EXT_ZFH}, {"zfhmin", KVM_RISCV_ISA_EXT_ZFHMIN}, {"zicbom", KVM_RISCV_ISA_EXT_ZICBOM}, + {"zicbop", KVM_RISCV_ISA_EXT_ZICBOP}, {"zicboz", KVM_RISCV_ISA_EXT_ZICBOZ}, {"ziccrse", KVM_RISCV_ISA_EXT_ZICCRSE}, {"zicntr", KVM_RISCV_ISA_EXT_ZICNTR}, @@ -195,7 +196,7 @@ static void dump_fdt(const char *dtb_file, void *fdt) #define CPU_NAME_MAX_LEN 15 static void generate_cpu_nodes(void *fdt, struct kvm *kvm) { - unsigned long cbom_blksz = 0, cboz_blksz = 0, satp_mode = 0; + unsigned long cbom_blksz = 0, cboz_blksz = 0, cbop_blksz = 0, satp_mode = 0; int i, cpu, pos, arr_sz = ARRAY_SIZE(isa_info_arr); _FDT(fdt_begin_node(fdt, "cpus")); @@ -249,6 +250,13 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm) die("KVM_GET_ONE_REG failed (config.zicboz_block_size)"); } + if (isa_info_arr[i].ext_id == KVM_RISCV_ISA_EXT_ZICBOP && !cbop_blksz) { + reg.id = RISCV_CONFIG_REG(zicbop_block_size); + reg.addr = (unsigned long)&cbop_blksz; + if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0) + die("KVM_GET_ONE_REG failed (config.zicbop_block_size)"); + } + if ((strlen(isa_info_arr[i].name) + pos + 1) >= CPU_ISA_MAX_LEN) { pr_warning("Insufficient space to append ISA exension %s\n", isa_info_arr[i].name); @@ -305,6 +313,8 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm) _FDT(fdt_property_cell(fdt, "riscv,cbom-block-size", cbom_blksz)); if (cboz_blksz) _FDT(fdt_property_cell(fdt, "riscv,cboz-block-size", cboz_blksz)); + if (cbop_blksz) + _FDT(fdt_property_cell(fdt, "riscv,cbop-block-size", cbop_blksz)); _FDT(fdt_property_cell(fdt, "reg", cpu)); _FDT(fdt_property_string(fdt, "status", "okay")); diff --git a/riscv/include/kvm/kvm-config-arch.h b/riscv/include/kvm/kvm-config-arch.h index 6d9a29a..d3e1f56 100644 --- a/riscv/include/kvm/kvm-config-arch.h +++ b/riscv/include/kvm/kvm-config-arch.h @@ -135,6 +135,9 @@ int riscv__cpu_type_parser(const struct option *opt, const char *arg, int unset) OPT_BOOLEAN('\0', "disable-zicboz", \ &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZICBOZ], \ "Disable Zicboz Extension"), \ + OPT_BOOLEAN('\0', "disable-zicbop", \ + &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZICBOP], \ + "Disable Zicbop Extension"), \ OPT_BOOLEAN('\0', "disable-ziccrse", \ &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_ZICCRSE], \ "Disable Ziccrse Extension"), \ -- 2.47.3