[PATCH-for-11.1 v4] target/arm: Use vaddr type in handle_psci_call()

Philippe Mathieu-Daudé posted 1 patch 1 day, 1 hour ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260410142932.33089-1-philmd@linaro.org
Maintainers: Alexander Graf <agraf@csgraf.de>, Peter Maydell <peter.maydell@linaro.org>
target/arm/hvf/hvf.c  | 2 +-
target/arm/tcg/psci.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
[PATCH-for-11.1 v4] target/arm: Use vaddr type in handle_psci_call()
Posted by Philippe Mathieu-Daudé 1 day, 1 hour ago
Use 'vaddr' type for @entry, which is the start %pc for the
on-lining vCPU. This allows to remove an unnecessary target_ulong
in hvf_handle_psci_call().

Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/arm/hvf/hvf.c  | 2 +-
 target/arm/tcg/psci.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 5fc8f6bbbd9..124644918ef 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -1418,7 +1418,7 @@ static bool hvf_handle_psci_call(CPUState *cpu, int *excp_ret)
     bool target_aarch64 = true;
     CPUState *target_cpu_state;
     ARMCPU *target_cpu;
-    target_ulong entry;
+    vaddr entry;
     int target_el = 1;
     int32_t ret = 0;
 
diff --git a/target/arm/tcg/psci.c b/target/arm/tcg/psci.c
index 56754bde951..5df17bd059d 100644
--- a/target/arm/tcg/psci.c
+++ b/target/arm/tcg/psci.c
@@ -68,7 +68,7 @@ void arm_handle_psci_call(ARMCPU *cpu)
     CPUARMState *env = &cpu->env;
     uint64_t param[4];
     uint64_t context_id, mpidr;
-    uint64_t entry;
+    vaddr entry;
     int32_t ret = 0;
     int i;
 
-- 
2.53.0


Re: [PATCH-for-11.1 v4] target/arm: Use vaddr type in handle_psci_call()
Posted by Peter Maydell 1 day ago
On Fri, 10 Apr 2026 at 15:29, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Use 'vaddr' type for @entry, which is the start %pc for the
> on-lining vCPU. This allows to remove an unnecessary target_ulong
> in hvf_handle_psci_call().
>
> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  target/arm/hvf/hvf.c  | 2 +-
>  target/arm/tcg/psci.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
> index 5fc8f6bbbd9..124644918ef 100644
> --- a/target/arm/hvf/hvf.c
> +++ b/target/arm/hvf/hvf.c
> @@ -1418,7 +1418,7 @@ static bool hvf_handle_psci_call(CPUState *cpu, int *excp_ret)
>      bool target_aarch64 = true;
>      CPUState *target_cpu_state;
>      ARMCPU *target_cpu;
> -    target_ulong entry;
> +    vaddr entry;
>      int target_el = 1;
>      int32_t ret = 0;
>
> diff --git a/target/arm/tcg/psci.c b/target/arm/tcg/psci.c
> index 56754bde951..5df17bd059d 100644
> --- a/target/arm/tcg/psci.c
> +++ b/target/arm/tcg/psci.c
> @@ -68,7 +68,7 @@ void arm_handle_psci_call(ARMCPU *cpu)
>      CPUARMState *env = &cpu->env;
>      uint64_t param[4];
>      uint64_t context_id, mpidr;
> -    uint64_t entry;
> +    vaddr entry;
>      int32_t ret = 0;
>      int i;

So we take our argument which is a uint64_t in param[], and we
put it into a vaddr entry, and then the only thing we do with that
is pass it to arm_set_cpu_on() which takes a uint64_t... I'm not
sure what the vaddr type is getting us here.

Should we just do in hvf.c the same thing we did already for
tcg/psci.c in 3580aa03547f92, and make 'entry' a uint64_t ?

-- PMM
Re: [PATCH-for-11.1 v4] target/arm: Use vaddr type in handle_psci_call()
Posted by Philippe Mathieu-Daudé 21 hours ago
On 10/4/26 16:43, Peter Maydell wrote:
> On Fri, 10 Apr 2026 at 15:29, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>
>> Use 'vaddr' type for @entry, which is the start %pc for the
>> on-lining vCPU. This allows to remove an unnecessary target_ulong
>> in hvf_handle_psci_call().
>>
>> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>   target/arm/hvf/hvf.c  | 2 +-
>>   target/arm/tcg/psci.c | 2 +-
>>   2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
>> index 5fc8f6bbbd9..124644918ef 100644
>> --- a/target/arm/hvf/hvf.c
>> +++ b/target/arm/hvf/hvf.c
>> @@ -1418,7 +1418,7 @@ static bool hvf_handle_psci_call(CPUState *cpu, int *excp_ret)
>>       bool target_aarch64 = true;
>>       CPUState *target_cpu_state;
>>       ARMCPU *target_cpu;
>> -    target_ulong entry;
>> +    vaddr entry;
>>       int target_el = 1;
>>       int32_t ret = 0;
>>
>> diff --git a/target/arm/tcg/psci.c b/target/arm/tcg/psci.c
>> index 56754bde951..5df17bd059d 100644
>> --- a/target/arm/tcg/psci.c
>> +++ b/target/arm/tcg/psci.c
>> @@ -68,7 +68,7 @@ void arm_handle_psci_call(ARMCPU *cpu)
>>       CPUARMState *env = &cpu->env;
>>       uint64_t param[4];
>>       uint64_t context_id, mpidr;
>> -    uint64_t entry;
>> +    vaddr entry;
>>       int32_t ret = 0;
>>       int i;
> 
> So we take our argument which is a uint64_t in param[], and we
> put it into a vaddr entry, and then the only thing we do with that
> is pass it to arm_set_cpu_on() which takes a uint64_t... I'm not
> sure what the vaddr type is getting us here.
> 
> Should we just do in hvf.c the same thing we did already for
> tcg/psci.c in 3580aa03547f92, and make 'entry' a uint64_t ?

Well this was v3, I just wanted to address Richard comment:
https://lore.kernel.org/qemu-devel/e02da1c8-9f48-4dab-b4b8-302ab8c69d74@linaro.org/

I'll repost v3 as v5 so we can choose :)