diff mbox series

[PATCH-for-10.0,6/6] accel/tcg: Allow tcg_exec_realizefn() initialize multiple frontends

Message ID 20241127121658.88966-7-philmd@linaro.org
State New
Headers show
Series accel/tcg: Allow tcg_exec_realizefn() initialize multiple frontends | expand

Commit Message

Philippe Mathieu-Daudé Nov. 27, 2024, 12:16 p.m. UTC
Rather than initializing the first random target architecture
and ignore the following ones when a global boolean is set,
use a bitmask allowing different frontend targets to be
initialized.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/tcg/cpu-exec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Anton Johansson Nov. 27, 2024, 5:28 p.m. UTC | #1
On 27/11/24, Philippe Mathieu-Daudé wrote:
> Rather than initializing the first random target architecture
> and ignore the following ones when a global boolean is set,
> use a bitmask allowing different frontend targets to be
> initialized.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  accel/tcg/cpu-exec.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
> index ab77740c954..b37995f7d0c 100644
> --- a/accel/tcg/cpu-exec.c
> +++ b/accel/tcg/cpu-exec.c
> @@ -1070,16 +1070,17 @@ int cpu_exec(CPUState *cpu)
>  
>  bool tcg_exec_realizefn(CPUState *cpu, Error **errp)
>  {
> +    static unsigned initialized_targets;
>      const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;
>  
> -    if (!tcg_target_initialized) {
> +    if (!(initialized_targets & tcg_ops->arch_id)) {
>          /* Check mandatory TCGCPUOps handlers */
>  #ifndef CONFIG_USER_ONLY
>          assert(tcg_ops->cpu_exec_halt);
>          assert(tcg_ops->cpu_exec_interrupt);
>  #endif /* !CONFIG_USER_ONLY */
>          tcg_ops->initialize_once();
> -        tcg_target_initialized = true;
> +        initialized_targets |= tcg_ops->arch_id;
>      }
>  
>      cpu->tb_jmp_cache = g_new0(CPUJumpCache, 1);
> -- 
> 2.45.2
> 

Only suggestion would be to assert that arch_id is set, might save some
headache in the future.

Reviewed-by: Anton Johansson <anjo@rev.ng>
Richard Henderson Nov. 27, 2024, 5:41 p.m. UTC | #2
On 11/27/24 11:28, Anton Johansson wrote:
> On 27/11/24, Philippe Mathieu-Daudé wrote:
>> Rather than initializing the first random target architecture
>> and ignore the following ones when a global boolean is set,
>> use a bitmask allowing different frontend targets to be
>> initialized.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   accel/tcg/cpu-exec.c | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
>> index ab77740c954..b37995f7d0c 100644
>> --- a/accel/tcg/cpu-exec.c
>> +++ b/accel/tcg/cpu-exec.c
>> @@ -1070,16 +1070,17 @@ int cpu_exec(CPUState *cpu)
>>   
>>   bool tcg_exec_realizefn(CPUState *cpu, Error **errp)
>>   {
>> +    static unsigned initialized_targets;
>>       const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;
>>   
>> -    if (!tcg_target_initialized) {
>> +    if (!(initialized_targets & tcg_ops->arch_id)) {
>>           /* Check mandatory TCGCPUOps handlers */
>>   #ifndef CONFIG_USER_ONLY
>>           assert(tcg_ops->cpu_exec_halt);
>>           assert(tcg_ops->cpu_exec_interrupt);
>>   #endif /* !CONFIG_USER_ONLY */
>>           tcg_ops->initialize_once();
>> -        tcg_target_initialized = true;
>> +        initialized_targets |= tcg_ops->arch_id;
>>       }
>>   
>>       cpu->tb_jmp_cache = g_new0(CPUJumpCache, 1);
>> -- 
>> 2.45.2
>>
> 
> Only suggestion would be to assert that arch_id is set, might save some
> headache in the future.

Yep.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
diff mbox series

Patch

diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index ab77740c954..b37995f7d0c 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -1070,16 +1070,17 @@  int cpu_exec(CPUState *cpu)
 
 bool tcg_exec_realizefn(CPUState *cpu, Error **errp)
 {
+    static unsigned initialized_targets;
     const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;
 
-    if (!tcg_target_initialized) {
+    if (!(initialized_targets & tcg_ops->arch_id)) {
         /* Check mandatory TCGCPUOps handlers */
 #ifndef CONFIG_USER_ONLY
         assert(tcg_ops->cpu_exec_halt);
         assert(tcg_ops->cpu_exec_interrupt);
 #endif /* !CONFIG_USER_ONLY */
         tcg_ops->initialize_once();
-        tcg_target_initialized = true;
+        initialized_targets |= tcg_ops->arch_id;
     }
 
     cpu->tb_jmp_cache = g_new0(CPUJumpCache, 1);