[PATCH 2/2] xen/arm: Simplify type handling for SMCCC declarations

Andrew Cooper posted 2 patches 6 days, 14 hours ago
[PATCH 2/2] xen/arm: Simplify type handling for SMCCC declarations
Posted by Andrew Cooper 6 days, 14 hours ago
There's no use creating a typed copy of a macro argument, simply to use it to
create a second typed copy.  Remove the indirection, halving the number of
local variables created in scope.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien@xen.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Michal Orzel <michal.orzel@amd.com>

This also makes them clearly elliglbe for converstion to auto, where they
weren't before (typeof expression not being that of the RHS).
---
 xen/arch/arm/include/asm/smccc.h | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/xen/arch/arm/include/asm/smccc.h b/xen/arch/arm/include/asm/smccc.h
index 347c4526d12a..7e90b0b56550 100644
--- a/xen/arch/arm/include/asm/smccc.h
+++ b/xen/arch/arm/include/asm/smccc.h
@@ -113,39 +113,32 @@ struct arm_smccc_res {
     register unsigned long  arg0 ASM_REG(0) = (uint32_t)(a0)
 
 #define __declare_arg_1(a0, a1, res)                        \
-    typeof(a1) __a1 = (a1);                                 \
     __declare_arg_0(a0, res);                               \
-    register typeof(a1)     arg1 ASM_REG(1) = __a1
+    register typeof(a1)     arg1 ASM_REG(1) = a1
 
 #define __declare_arg_2(a0, a1, a2, res)                    \
-    typeof(a1) __a1 = (a1);                                 \
     __declare_arg_1(a0, a1, res);                           \
-    register typeof(a2)     arg2 ASM_REG(2) = __a2
+    register typeof(a2)     arg2 ASM_REG(2) = a2
 
 #define __declare_arg_3(a0, a1, a2, a3, res)                \
-    typeof(a1) __a1 = (a1);                                 \
     __declare_arg_2(a0, a1, a2, res);                       \
-    register typeof(a3)     arg3 ASM_REG(3) = __a3
+    register typeof(a3)     arg3 ASM_REG(3) = a3
 
 #define __declare_arg_4(a0, a1, a2, a3, a4, res)        \
-    typeof(a4) __a4 = (a4);                             \
     __declare_arg_3(a0, a1, a2, a3, res);               \
-    register typeof(a4)     arg4 ASM_REG(4) = __a4
+    register typeof(a4)     arg4 ASM_REG(4) = a4
 
 #define __declare_arg_5(a0, a1, a2, a3, a4, a5, res)    \
-    typeof(a5) __a5 = (a5);                             \
     __declare_arg_4(a0, a1, a2, a3, a4, res);           \
-    register typeof(a5)     arg5 ASM_REG(5) = __a5
+    register typeof(a5)     arg5 ASM_REG(5) = a5
 
 #define __declare_arg_6(a0, a1, a2, a3, a4, a5, a6, res)    \
-    typeof(a6) __a6 = (a6);                                 \
     __declare_arg_5(a0, a1, a2, a3, a4, a5, res);           \
-    register typeof(a6)     arg6 ASM_REG(6) = __a6
+    register typeof(a6)     arg6 ASM_REG(6) = a6
 
 #define __declare_arg_7(a0, a1, a2, a3, a4, a5, a6, a7, res)    \
-    typeof(a7) __a7 = (a7);                                     \
     __declare_arg_6(a0, a1, a2, a3, a4, a5, a6, res);           \
-    register typeof(a7)     arg7 ASM_REG(7) = __a7
+    register typeof(a7)     arg7 ASM_REG(7) = a7
 
 #define ___declare_args(count, ...) __declare_arg_ ## count(__VA_ARGS__)
 #define __declare_args(count, ...)  ___declare_args(count, __VA_ARGS__)
-- 
2.39.5
Re: [PATCH 2/2] xen/arm: Simplify type handling for SMCCC declarations
Posted by Orzel, Michal 6 days, 13 hours ago

On 24/02/2026 13:45, Andrew Cooper wrote:
> There's no use creating a typed copy of a macro argument, simply to use it to
> create a second typed copy.  Remove the indirection, halving the number of
> local variables created in scope.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Julien Grall <julien@xen.org>
> CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
> CC: Bertrand Marquis <bertrand.marquis@arm.com>
> CC: Michal Orzel <michal.orzel@amd.com>
> 
> This also makes them clearly elliglbe for converstion to auto, where they
> weren't before (typeof expression not being that of the RHS).
> ---
>  xen/arch/arm/include/asm/smccc.h | 21 +++++++--------------
>  1 file changed, 7 insertions(+), 14 deletions(-)
> 
> diff --git a/xen/arch/arm/include/asm/smccc.h b/xen/arch/arm/include/asm/smccc.h
> index 347c4526d12a..7e90b0b56550 100644
> --- a/xen/arch/arm/include/asm/smccc.h
> +++ b/xen/arch/arm/include/asm/smccc.h
> @@ -113,39 +113,32 @@ struct arm_smccc_res {
>      register unsigned long  arg0 ASM_REG(0) = (uint32_t)(a0)
>  
>  #define __declare_arg_1(a0, a1, res)                        \
> -    typeof(a1) __a1 = (a1);                                 \
>      __declare_arg_0(a0, res);                               \
> -    register typeof(a1)     arg1 ASM_REG(1) = __a1
> +    register typeof(a1)     arg1 ASM_REG(1) = a1
>  
>  #define __declare_arg_2(a0, a1, a2, res)                    \
> -    typeof(a1) __a1 = (a1);                                 \
>      __declare_arg_1(a0, a1, res);                           \
> -    register typeof(a2)     arg2 ASM_REG(2) = __a2
> +    register typeof(a2)     arg2 ASM_REG(2) = a2
Here you fix the issue introduced in patch 1/2 :) You drop typeof(a1) and
replace it with correct typeof(a2).

Provided this patch is rebased on fixed 1/2:
Reviewed-by: Michal Orzel <michal.orzel@amd.com>

~Michal
Re: [PATCH 2/2] xen/arm: Simplify type handling for SMCCC declarations
Posted by Andrew Cooper 6 days, 11 hours ago
On 24/02/2026 2:18 pm, Orzel, Michal wrote:
>
> On 24/02/2026 13:45, Andrew Cooper wrote:
>> There's no use creating a typed copy of a macro argument, simply to use it to
>> create a second typed copy.  Remove the indirection, halving the number of
>> local variables created in scope.
>>
>> No functional change.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
>> ---
>> CC: Stefano Stabellini <sstabellini@kernel.org>
>> CC: Julien Grall <julien@xen.org>
>> CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
>> CC: Bertrand Marquis <bertrand.marquis@arm.com>
>> CC: Michal Orzel <michal.orzel@amd.com>
>>
>> This also makes them clearly elliglbe for converstion to auto, where they
>> weren't before (typeof expression not being that of the RHS).
>> ---
>>  xen/arch/arm/include/asm/smccc.h | 21 +++++++--------------
>>  1 file changed, 7 insertions(+), 14 deletions(-)
>>
>> diff --git a/xen/arch/arm/include/asm/smccc.h b/xen/arch/arm/include/asm/smccc.h
>> index 347c4526d12a..7e90b0b56550 100644
>> --- a/xen/arch/arm/include/asm/smccc.h
>> +++ b/xen/arch/arm/include/asm/smccc.h
>> @@ -113,39 +113,32 @@ struct arm_smccc_res {
>>      register unsigned long  arg0 ASM_REG(0) = (uint32_t)(a0)
>>  
>>  #define __declare_arg_1(a0, a1, res)                        \
>> -    typeof(a1) __a1 = (a1);                                 \
>>      __declare_arg_0(a0, res);                               \
>> -    register typeof(a1)     arg1 ASM_REG(1) = __a1
>> +    register typeof(a1)     arg1 ASM_REG(1) = a1
>>  
>>  #define __declare_arg_2(a0, a1, a2, res)                    \
>> -    typeof(a1) __a1 = (a1);                                 \
>>      __declare_arg_1(a0, a1, res);                           \
>> -    register typeof(a2)     arg2 ASM_REG(2) = __a2
>> +    register typeof(a2)     arg2 ASM_REG(2) = a2
> Here you fix the issue introduced in patch 1/2 :) You drop typeof(a1) and
> replace it with correct typeof(a2).
>
> Provided this patch is rebased on fixed 1/2:
> Reviewed-by: Michal Orzel <michal.orzel@amd.com>

Thanks.  Sadly, ECLAIR rejects this change.  I need to retain the
brackets around the macro parameter after move, so this kind of
incremental diff:

> @@ -114,7 +114,7 @@ struct arm_smccc_res {
>  
>  #define __declare_arg_1(a0, a1, res)                        \
>      __declare_arg_0(a0, res);                               \
> -    register typeof(a1)     arg1 ASM_REG(1) = a1
> +    register typeof(a1)     arg1 ASM_REG(1) = (a1)
>  
>  #define __declare_arg_2(a0, a1, a2, res)                    \
>      __declare_arg_1(a0, a1, res);                           \

~Andrew

Re: [PATCH 2/2] xen/arm: Simplify type handling for SMCCC declarations
Posted by Andrew Cooper 6 days, 10 hours ago
On 24/02/2026 4:02 pm, Andrew Cooper wrote:
> On 24/02/2026 2:18 pm, Orzel, Michal wrote:
>> On 24/02/2026 13:45, Andrew Cooper wrote:
>>> There's no use creating a typed copy of a macro argument, simply to use it to
>>> create a second typed copy.  Remove the indirection, halving the number of
>>> local variables created in scope.
>>>
>>> No functional change.
>>>
>>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
>>> ---
>>> CC: Stefano Stabellini <sstabellini@kernel.org>
>>> CC: Julien Grall <julien@xen.org>
>>> CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
>>> CC: Bertrand Marquis <bertrand.marquis@arm.com>
>>> CC: Michal Orzel <michal.orzel@amd.com>
>>>
>>> This also makes them clearly elliglbe for converstion to auto, where they
>>> weren't before (typeof expression not being that of the RHS).
>>> ---
>>>  xen/arch/arm/include/asm/smccc.h | 21 +++++++--------------
>>>  1 file changed, 7 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/xen/arch/arm/include/asm/smccc.h b/xen/arch/arm/include/asm/smccc.h
>>> index 347c4526d12a..7e90b0b56550 100644
>>> --- a/xen/arch/arm/include/asm/smccc.h
>>> +++ b/xen/arch/arm/include/asm/smccc.h
>>> @@ -113,39 +113,32 @@ struct arm_smccc_res {
>>>      register unsigned long  arg0 ASM_REG(0) = (uint32_t)(a0)
>>>  
>>>  #define __declare_arg_1(a0, a1, res)                        \
>>> -    typeof(a1) __a1 = (a1);                                 \
>>>      __declare_arg_0(a0, res);                               \
>>> -    register typeof(a1)     arg1 ASM_REG(1) = __a1
>>> +    register typeof(a1)     arg1 ASM_REG(1) = a1
>>>  
>>>  #define __declare_arg_2(a0, a1, a2, res)                    \
>>> -    typeof(a1) __a1 = (a1);                                 \
>>>      __declare_arg_1(a0, a1, res);                           \
>>> -    register typeof(a2)     arg2 ASM_REG(2) = __a2
>>> +    register typeof(a2)     arg2 ASM_REG(2) = a2
>> Here you fix the issue introduced in patch 1/2 :) You drop typeof(a1) and
>> replace it with correct typeof(a2).
>>
>> Provided this patch is rebased on fixed 1/2:
>> Reviewed-by: Michal Orzel <michal.orzel@amd.com>
> Thanks.  Sadly, ECLAIR rejects this change.  I need to retain the
> brackets around the macro parameter after move, so this kind of
> incremental diff:
>
>> @@ -114,7 +114,7 @@ struct arm_smccc_res {
>>  
>>  #define __declare_arg_1(a0, a1, res)                        \
>>      __declare_arg_0(a0, res);                               \
>> -    register typeof(a1)     arg1 ASM_REG(1) = a1
>> +    register typeof(a1)     arg1 ASM_REG(1) = (a1)
>>  
>>  #define __declare_arg_2(a0, a1, a2, res)                    \
>>      __declare_arg_1(a0, a1, res);                           \

Passing pipeline:

https://gitlab.com/xen-project/hardware/xen-staging/-/jobs/13244194836

~Andrew