Message ID | 20230622135700.105383-16-dbarboza@ventanamicro.com |
---|---|
State | New |
Headers | show |
Series | target/riscv, KVM: fixes and enhancements | expand |
On Thu, Jun 22, 2023 at 10:56:56AM -0300, Daniel Henrique Barboza wrote: > riscv_isa_string_ext() is being used by riscv_isa_string(), which is > then used by boards to retrieve the 'riscv,isa' string to be written in > the FDT. All this happens after riscv_cpu_realize(), meaning that we're > already past riscv_cpu_validate_set_extensions() and, more important, > riscv_cpu_disable_priv_spec_isa_exts(). > > This means that all extensions that needed to be disabled due to > priv_spec mismatch are already disabled. Checking this again during > riscv_isa_string_ext() is unneeded. Remove it. > > As a bonus, riscv_isa_string_ext() can now be used with the 'host' > KVM-only CPU type since it doesn't have a env->priv_ver assigned and it > would fail this check for no good reason. > > Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> > --- > target/riscv/cpu.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c > index 5a50cb1d0b..b65db165cc 100644 > --- a/target/riscv/cpu.c > +++ b/target/riscv/cpu.c > @@ -2001,8 +2001,7 @@ static void riscv_isa_string_ext(RISCVCPU *cpu, char **isa_str, > int i; > > for (i = 0; i < ARRAY_SIZE(isa_edata_arr); i++) { > - if (cpu->env.priv_ver >= isa_edata_arr[i].min_version && > - isa_ext_is_enabled(cpu, &isa_edata_arr[i])) { > + if (isa_ext_is_enabled(cpu, &isa_edata_arr[i])) { > new = g_strconcat(old, "_", isa_edata_arr[i].name, NULL); > g_free(old); > old = new; > -- > 2.41.0 > Nice! Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 5a50cb1d0b..b65db165cc 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -2001,8 +2001,7 @@ static void riscv_isa_string_ext(RISCVCPU *cpu, char **isa_str, int i; for (i = 0; i < ARRAY_SIZE(isa_edata_arr); i++) { - if (cpu->env.priv_ver >= isa_edata_arr[i].min_version && - isa_ext_is_enabled(cpu, &isa_edata_arr[i])) { + if (isa_ext_is_enabled(cpu, &isa_edata_arr[i])) { new = g_strconcat(old, "_", isa_edata_arr[i].name, NULL); g_free(old); old = new;
riscv_isa_string_ext() is being used by riscv_isa_string(), which is then used by boards to retrieve the 'riscv,isa' string to be written in the FDT. All this happens after riscv_cpu_realize(), meaning that we're already past riscv_cpu_validate_set_extensions() and, more important, riscv_cpu_disable_priv_spec_isa_exts(). This means that all extensions that needed to be disabled due to priv_spec mismatch are already disabled. Checking this again during riscv_isa_string_ext() is unneeded. Remove it. As a bonus, riscv_isa_string_ext() can now be used with the 'host' KVM-only CPU type since it doesn't have a env->priv_ver assigned and it would fail this check for no good reason. Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> --- target/riscv/cpu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)