[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 17/19] target/riscv: update multi-letter extension KVM propert
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH v4 17/19] target/riscv: update multi-letter extension KVM properties |
Date: |
Mon, 26 Jun 2023 19:02:07 -0300 |
We're now ready to update the multi-letter extensions status for KVM.
kvm_riscv_update_cpu_cfg_isa_ext() is called called during vcpu creation
time to verify which user options changes host defaults (via the 'user_set'
flag) and tries to write them back to KVM.
Failure to commit a change to KVM is only ignored in case KVM doesn't
know about the extension (-EINVAL error code) and the user wanted to
disable the given extension. Otherwise we're going to abort the boot
process.
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
---
target/riscv/kvm.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c
index 376bbc68b4..6eebeb123a 100644
--- a/target/riscv/kvm.c
+++ b/target/riscv/kvm.c
@@ -273,6 +273,32 @@ static void kvm_cpu_set_multi_ext_cfg(Object *obj, Visitor
*v,
kvm_cpu_cfg_set(cpu, multi_ext_cfg, value);
}
+static void kvm_riscv_update_cpu_cfg_isa_ext(RISCVCPU *cpu, CPUState *cs)
+{
+ CPURISCVState *env = &cpu->env;
+ uint64_t id, reg;
+ int i, ret;
+
+ for (i = 0; i < ARRAY_SIZE(kvm_multi_ext_cfgs); i++) {
+ KVMCPUConfig *multi_ext_cfg = &kvm_multi_ext_cfgs[i];
+
+ if (!multi_ext_cfg->user_set) {
+ continue;
+ }
+
+ id = kvm_riscv_reg_id(env, KVM_REG_RISCV_ISA_EXT,
+ multi_ext_cfg->kvm_reg_id);
+ reg = kvm_cpu_cfg_get(cpu, multi_ext_cfg);
+ ret = kvm_set_one_reg(cs, id, ®);
+ if (ret != 0) {
+ error_report("Unable to %s extension %s in KVM, error %d",
+ reg ? "enable" : "disable",
+ multi_ext_cfg->name, ret);
+ exit(EXIT_FAILURE);
+ }
+ }
+}
+
static void kvm_riscv_add_cpu_user_properties(Object *cpu_obj)
{
int i;
@@ -792,6 +818,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
}
kvm_riscv_update_cpu_misa_ext(cpu, cs);
+ kvm_riscv_update_cpu_cfg_isa_ext(cpu, cs);
return ret;
}
--
2.41.0
- [PATCH v4 03/19] target/riscv/cpu.c: restrict 'mvendorid' value, (continued)
- [PATCH v4 03/19] target/riscv/cpu.c: restrict 'mvendorid' value, Daniel Henrique Barboza, 2023/06/26
- [PATCH v4 05/19] target/riscv/cpu.c: restrict 'marchid' value, Daniel Henrique Barboza, 2023/06/26
- [PATCH v4 07/19] target/riscv: read marchid/mimpid in kvm_riscv_init_machine_ids(), Daniel Henrique Barboza, 2023/06/26
- [PATCH v4 08/19] target/riscv: handle mvendorid/marchid/mimpid for KVM CPUs, Daniel Henrique Barboza, 2023/06/26
- [PATCH v4 10/19] target/riscv/kvm.c: init 'misa_ext_mask' with scratch CPU, Daniel Henrique Barboza, 2023/06/26
- [PATCH v4 12/19] target/riscv: add KVM specific MISA properties, Daniel Henrique Barboza, 2023/06/26
- [PATCH v4 11/19] target/riscv/cpu: add misa_ext_info_arr[], Daniel Henrique Barboza, 2023/06/26
- [PATCH v4 09/19] linux-headers: Update to v6.4-rc1, Daniel Henrique Barboza, 2023/06/26
- [PATCH v4 13/19] target/riscv/kvm.c: update KVM MISA bits, Daniel Henrique Barboza, 2023/06/26
- [PATCH v4 15/19] target/riscv/cpu.c: remove priv_ver check from riscv_isa_string_ext(), Daniel Henrique Barboza, 2023/06/26
- [PATCH v4 17/19] target/riscv: update multi-letter extension KVM properties,
Daniel Henrique Barboza <=
- [PATCH v4 18/19] target/riscv/kvm.c: add kvmconfig_get_cfg_addr() helper, Daniel Henrique Barboza, 2023/06/26
- [PATCH v4 14/19] target/riscv/kvm.c: add multi-letter extension KVM properties, Daniel Henrique Barboza, 2023/06/26
- [PATCH v4 16/19] target/riscv/cpu.c: create KVM mock properties, Daniel Henrique Barboza, 2023/06/26
- [PATCH v4 19/19] target/riscv/kvm.c: read/write (cbom|cboz)_blocksize in KVM, Daniel Henrique Barboza, 2023/06/26