qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] target/riscv/tcg: do not set defaults for non-generic
@ 2023-12-29  8:02 Vladimir Isaev
  2023-12-29  9:15 ` Daniel Henrique Barboza
  0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Isaev @ 2023-12-29  8:02 UTC (permalink / raw)
  To: qemu-riscv
  Cc: qemu-devel, dbarboza, zhiwei_liu, liwei1518, bin.meng,
	alistair.francis, palmer, Vladimir Isaev

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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] target/riscv/tcg: do not set defaults for non-generic
  2023-12-29  8:02 [PATCH] target/riscv/tcg: do not set defaults for non-generic Vladimir Isaev
@ 2023-12-29  9:15 ` Daniel Henrique Barboza
  2023-12-29  9:54   ` Vladimir Isaev
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Henrique Barboza @ 2023-12-29  9:15 UTC (permalink / raw)
  To: Vladimir Isaev, qemu-riscv
  Cc: qemu-devel, zhiwei_liu, liwei1518, bin.meng, alistair.francis, palmer



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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] target/riscv/tcg: do not set defaults for non-generic
  2023-12-29  9:15 ` Daniel Henrique Barboza
@ 2023-12-29  9:54   ` Vladimir Isaev
  0 siblings, 0 replies; 3+ messages in thread
From: Vladimir Isaev @ 2023-12-29  9:54 UTC (permalink / raw)
  To: Daniel Henrique Barboza, qemu-riscv
  Cc: qemu-devel, zhiwei_liu, liwei1518, bin.meng, alistair.francis, palmer

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-29  9:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-29  8:02 [PATCH] target/riscv/tcg: do not set defaults for non-generic Vladimir Isaev
2023-12-29  9:15 ` Daniel Henrique Barboza
2023-12-29  9:54   ` Vladimir Isaev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).