diff mbox series

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

Message ID 20231229080302.125418-1-vladimir.isaev@syntacore.com (mailing list archive)
State New, archived
Headers show
Series target/riscv/tcg: do not set defaults for non-generic | expand

Commit Message

Vladimir Isaev Dec. 29, 2023, 8:02 a.m. UTC
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(+)

Comments

Daniel Henrique Barboza Dec. 29, 2023, 9:15 a.m. UTC | #1
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);
>       }
>   }
Vladimir Isaev Dec. 29, 2023, 9:54 a.m. UTC | #2
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);
>>       }
>>   }
diff mbox series

Patch

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);
     }
 }