[PATCH] target/riscv/tcg: do not set defaults for non-generic

Vladimir Isaev posted 1 patch 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20231229080302.125418-1-vladimir.isaev@syntacore.com
Maintainers: Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Bin Meng <bin.meng@windriver.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <dbarboza@ventanamicro.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>
target/riscv/tcg/tcg-cpu.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH] target/riscv/tcg: do not set defaults for non-generic
Posted by Vladimir Isaev 11 months ago
riscv_cpu_options[] are exported using qdev and some of them are defined
with default values. This is unfortunate since riscv_cpu_add_user_properties()
is called after CPU instance init and there is no clear way to disable MMU/PMP
for some CPUs.

Can't define them as NODEFAULT since we still need defaults for generic CPU.

Signed-off-by: Vladimir Isaev <vladimir.isaev@syntacore.com>
---
 target/riscv/tcg/tcg-cpu.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c
index 8a35683a345d..9ffce1c9f7b0 100644
--- a/target/riscv/tcg/tcg-cpu.c
+++ b/target/riscv/tcg/tcg-cpu.c
@@ -937,6 +937,8 @@ static void riscv_cpu_add_multiext_prop_array(Object *obj,
  */
 static void riscv_cpu_add_user_properties(Object *obj)
 {
+    bool use_def_vals = riscv_cpu_is_generic(obj);
+
 #ifndef CONFIG_USER_ONLY
     riscv_add_satp_mode_properties(obj);
 #endif
@@ -950,6 +952,8 @@ static void riscv_cpu_add_user_properties(Object *obj)
     riscv_cpu_add_multiext_prop_array(obj, riscv_cpu_deprecated_exts);
 
     for (Property *prop = riscv_cpu_options; prop && prop->name; prop++) {
+        prop->set_default = prop->set_default && use_def_vals;
+
         qdev_property_add_static(DEVICE(obj), prop);
     }
 }
-- 
2.43.0
Re: [PATCH] target/riscv/tcg: do not set defaults for non-generic
Posted by Daniel Henrique Barboza 11 months ago

On 12/29/23 05:02, Vladimir Isaev wrote:
> riscv_cpu_options[] are exported using qdev and some of them are defined
> with default values. This is unfortunate since riscv_cpu_add_user_properties()
> is called after CPU instance init and there is no clear way to disable MMU/PMP
> for some CPUs.
> 
> Can't define them as NODEFAULT since we still need defaults for generic CPU.
> 
> Signed-off-by: Vladimir Isaev <vladimir.isaev@syntacore.com>
> ---

This issue is fixed by this series:


"[PATCH v2 00/16] target/riscv: deprecate riscv_cpu_options[]"

https://lore.kernel.org/qemu-riscv/20231222122235.545235-1-dbarboza@ventanamicro.com/


Feel free to give it a go. Thanks,


Daniel


>   target/riscv/tcg/tcg-cpu.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c
> index 8a35683a345d..9ffce1c9f7b0 100644
> --- a/target/riscv/tcg/tcg-cpu.c
> +++ b/target/riscv/tcg/tcg-cpu.c
> @@ -937,6 +937,8 @@ static void riscv_cpu_add_multiext_prop_array(Object *obj,
>    */
>   static void riscv_cpu_add_user_properties(Object *obj)
>   {
> +    bool use_def_vals = riscv_cpu_is_generic(obj);
> +
>   #ifndef CONFIG_USER_ONLY
>       riscv_add_satp_mode_properties(obj);
>   #endif
> @@ -950,6 +952,8 @@ static void riscv_cpu_add_user_properties(Object *obj)
>       riscv_cpu_add_multiext_prop_array(obj, riscv_cpu_deprecated_exts);
>   
>       for (Property *prop = riscv_cpu_options; prop && prop->name; prop++) {
> +        prop->set_default = prop->set_default && use_def_vals;
> +
>           qdev_property_add_static(DEVICE(obj), prop);
>       }
>   }
Re: [PATCH] target/riscv/tcg: do not set defaults for non-generic
Posted by Vladimir Isaev 11 months ago
29.12.2023 12:15, Daniel Henrique Barboza wrote:
> 
> On 12/29/23 05:02, Vladimir Isaev wrote:
>> riscv_cpu_options[] are exported using qdev and some of them are defined
>> with default values. This is unfortunate since riscv_cpu_add_user_properties()
>> is called after CPU instance init and there is no clear way to disable MMU/PMP
>> for some CPUs.
>>
>> Can't define them as NODEFAULT since we still need defaults for generic CPU.
>>
>> Signed-off-by: Vladimir Isaev <vladimir.isaev@syntacore.com>
>> ---
> 
> This issue is fixed by this series:
> 
> 
> "[PATCH v2 00/16] target/riscv: deprecate riscv_cpu_options[]"
> 
> https://lore.kernel.org/qemu-riscv/20231222122235.545235-1-dbarboza@ventanamicro.com/
> 
> 
> Feel free to give it a go. Thanks,
> 
> 
> Daniel

Works for me, thank you!

Vladimir Isaev
> 
> 
>>   target/riscv/tcg/tcg-cpu.c | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c
>> index 8a35683a345d..9ffce1c9f7b0 100644
>> --- a/target/riscv/tcg/tcg-cpu.c
>> +++ b/target/riscv/tcg/tcg-cpu.c
>> @@ -937,6 +937,8 @@ static void riscv_cpu_add_multiext_prop_array(Object *obj,
>>    */
>>   static void riscv_cpu_add_user_properties(Object *obj)
>>   {
>> +    bool use_def_vals = riscv_cpu_is_generic(obj);
>> +
>>   #ifndef CONFIG_USER_ONLY
>>       riscv_add_satp_mode_properties(obj);
>>   #endif
>> @@ -950,6 +952,8 @@ static void riscv_cpu_add_user_properties(Object *obj)
>>       riscv_cpu_add_multiext_prop_array(obj, riscv_cpu_deprecated_exts);
>>
>>       for (Property *prop = riscv_cpu_options; prop && prop->name; prop++) {
>> +        prop->set_default = prop->set_default && use_def_vals;
>> +
>>           qdev_property_add_static(DEVICE(obj), prop);
>>       }
>>   }