[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 3/5] xen/arm: Clean up 32bit arm_smccc_1_1_smc()


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Fri, 4 Sep 2026 12:08:14 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=citrix.com smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SxLwEAMhmo17uxWlJyGZKHqeeRrXoOvc5qWiUbbbdSg=; b=ybCSS4mFtQAq2Lu86VRLsWx0EbbL0sXXvNQuEYEpH/uw4o6/ZPS1TYoD+KmthuKdTfbNdhMFtUQ3pOwRC281fjgbT54pvKh93auaYbmvF/L+XYWHV9JU4l0WAgGCvyNFEzhcWDyLQYB9qVS13wsAcDCnfC0NQ3wBjhlc4WH3lAqzATUp0tU5rqkOR+EtxvWwsZDvoMdPl0WH0ldJN94gvUHADjmPA/orABQ3baWXu0VNE8fLwpD7opz/12DVgkltexrEY7k5Y9LtAFCYMl8H22Fcsytx/s1m3hxFf0gYrVxR3rxsp/tmHKe5ZbIT7A/5xIREZeqRuyL7XeH2/RIj0g==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SxLwEAMhmo17uxWlJyGZKHqeeRrXoOvc5qWiUbbbdSg=; b=RyEZN8duB/GKM3CBYkNiDa0HVe3KsX+7bpXOvm8OVKWqP+JdPGAN3a4GjxuJVF6wzF7ssR8bRk1IcpwlghxqnMYn2a7Ww+Pq525myZu1KYbmcL91OVj8UDAkk1460SgnZ+FHqkT5YoMD8wqpsasSOdrNFyl+8iLi0yH1b1JzJUvYl8RlcmVLPiio5HyvJ45Yx3/dXBuyuiES/voCGk/rvWWkHMHDMIw6AqEpoPeoEVp4fcv7ptLMjVklQMHhyPUJ7r6osbBeSwVBjwp1VyEojPG32gN770PyNdzO43Vd0+YL4X/qtaEUe7K8Mhrkh794l5Y98fZBsxr2/YvAbUsSAA==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=TdURaDGFh93m/rHFZy22EfCifIPOmomEpZxXo0yKCxCHL7/l59TPUZOX9WY98gpGVZuOfofVdBHF9DUGI68si3Kc6Kmnx9BfzRrBE/tVp1KMuQls6oHGcNyCsjtw1od3CHYT9yZmWRB5cHc8J6bicu8zDw9VatKln+1ptPYT0/GjY1L6DFqyoi0vb9y2L/HkaZLBCoBtKeJ5OQkgKM55X7JA70F5tzOhBusVL4acOHaNqldsuJk22cLYkyvzu6wi/BY7bU/c7mK39TPbBqpAn75/Y0/sjDrhmWQwGkD1YqoLlDIUMvB1S2PqOkW35lGZf2wj4S1skhc2QxpN0r1JwA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UPFjYjsbs6Ko8IuJk4t7IB1Lb57hI5FLQ5tyYl/iOokfm6QYIAI7G//5T84QYAuGBDQkU39Zxl/ny0WR0+wDQ+7Ui5+4WBkQaKG3TAIyLGNOJZRItngtlUUAzjvnZldqo/+PDjAnqGOe8v/gb1gX+y3Zx9ie7yfqPndff8V8eZgIGciugomajoZ2Mtl4RoGsxQH48EAUWRi8pCdQl1bCXs022KRW8casRbsJ4RnHh4PyYoOkmn0IGnnt2mYUkcU+u8PvpCfDGFW6mdPjpU3JbrGkOJjWYQ1m1l7jGO/WBguEsfMs7kpP708Nmx6wlTaq9vq1QkdjhKiV73G92RP8Lg==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Setje-Eilers <Jan.SetjeEilers@xxxxxxxxxx>
  • Delivery-date: Fri, 04 Sep 2026 12:08:55 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHdPF5MaImMoDplI0uGAg1xhuIeaLa+U1WA
  • Thread-topic: [PATCH v2 3/5] xen/arm: Clean up 32bit arm_smccc_1_1_smc()

Hi Andrew,

> On 4 Sep 2026, at 13:12, Andrew Cooper <andrew.cooper3@xxxxxxxxxx> wrote:
> 
> ... before making a related copy of it.
> 
> * Drop __constraints() so the output parameters are visible in the same block
>   as they're defined.  Use PASTE() rather than opencoding it.
> * Adust the indentation of trailing \'s for consistency.

Small typo to fix s/Adust/Adjust/

Can be done on commit and retain my R-b

Cheers
Bertrand

> * Drop the newline at the end of the instruction.
> * Indent the if condition correctly.  ___res is always of type
>   arm_smccc_res (declared in __declare_arg_0()), so drop the typeof().
> * Drop arm_smccc_1_0_smc() as it has no users.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
> ---
> CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
> CC: Julien Grall <julien@xxxxxxx>
> CC: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
> CC: Bertrand Marquis <bertrand.marquis@xxxxxxx>
> CC: Michal Orzel <michal.orzel@xxxxxxx>
> CC: Jan Setje-Eilers <Jan.SetjeEilers@xxxxxxxxxx>
> ---
> xen/arch/arm/include/asm/smccc.h | 45 ++++++++++++++++----------------
> 1 file changed, 22 insertions(+), 23 deletions(-)
> 
> diff --git a/xen/arch/arm/include/asm/smccc.h 
> b/xen/arch/arm/include/asm/smccc.h
> index 832157f43734..5fe54013ac83 100644
> --- a/xen/arch/arm/include/asm/smccc.h
> +++ b/xen/arch/arm/include/asm/smccc.h
> @@ -56,6 +56,8 @@
> 
> #ifndef __ASSEMBLER__
> 
> +#include <xen/macros.h>
> +
> extern uint32_t smccc_ver;
> 
> /* Check if this is fast call. */
> @@ -115,24 +117,24 @@ struct arm_smccc_res {
>  * This is manual register scheduling for the asm() statement, and any other
>  * logic to evaluate may clobber the already-scheduled registers.
>  */
> -#define __declare_arg_0(a0, res)                            \
> -    auto __a0 = (uint32_t)(a0);                             \
> -    struct arm_smccc_res    *___res = (res);                \
> +#define __declare_arg_0(a0, res)                        \
> +    auto __a0 = (uint32_t)(a0);                         \
> +    struct arm_smccc_res    *___res = (res);            \
>     register unsigned long  arg0 ASM_REG(0) = __a0
> 
> -#define __declare_arg_1(a0, a1, res)                        \
> -    auto __a1 = (a1);                                       \
> -    __declare_arg_0(a0, res);                               \
> +#define __declare_arg_1(a0, a1, res)                    \
> +    auto __a1 = (a1);                                   \
> +    __declare_arg_0(a0, res);                           \
>     register auto           arg1 ASM_REG(1) = __a1
> 
> -#define __declare_arg_2(a0, a1, a2, res)                    \
> -    auto __a2 = (a2);                                       \
> -    __declare_arg_1(a0, a1, res);                           \
> +#define __declare_arg_2(a0, a1, a2, res)                \
> +    auto __a2 = (a2);                                   \
> +    __declare_arg_1(a0, a1, res);                       \
>     register auto           arg2 ASM_REG(2) = __a2
> 
> -#define __declare_arg_3(a0, a1, a2, a3, res)                \
> -    auto __a3 = (a3);                                       \
> -    __declare_arg_2(a0, a1, a2, res);                       \
> +#define __declare_arg_3(a0, a1, a2, a3, res)            \
> +    auto __a3 = (a3);                                   \
> +    __declare_arg_2(a0, a1, a2, res);                   \
>     register auto           arg3 ASM_REG(3) = __a3
> 
> #define __declare_arg_4(a0, a1, a2, a3, a4, res)        \
> @@ -158,12 +160,6 @@ struct arm_smccc_res {
> #define ___declare_args(count, ...) __declare_arg_ ## count(__VA_ARGS__)
> #define __declare_args(count, ...)  ___declare_args(count, __VA_ARGS__)
> 
> -#define ___constraints(count)                       \
> -    : "=r" (r0), "=r" (r1), "=r" (r2), "=r" (r3)     \
> -    : __constraint_read_ ## count                   \
> -    : "memory"
> -#define __constraints(count)    ___constraints(count)
> -
> /*
>  * arm_smccc_1_1_smc() - make an SMCCC v1.1 compliant SMC call
>  *
> @@ -189,10 +185,14 @@ struct arm_smccc_res {
>         register unsigned long r2 ASM_REG(2);                   \
>         register unsigned long r3 ASM_REG(3);                   \
>         __declare_args(__count_args(__VA_ARGS__), __VA_ARGS__); \
> -        asm volatile("smc #0\n"                                 \
> -                     __constraints(__count_args(__VA_ARGS__))); \
> +        asm volatile (                                          \
> +            "smc #0"                                            \
> +            : "=r" (r0), "=r" (r1), "=r" (r2), "=r" (r3)        \
> +            : PASTE(__constraint_read_,                         \
> +                    __count_args(__VA_ARGS__))                  \
> +            : "memory" );                                       \
>         if ( ___res )                                           \
> -        *___res = (typeof(*___res)){r0, r1, r2, r3};            \
> +            *___res = (struct arm_smccc_res){ r0, r1, r2, r3 }; \
>     } while ( 0 )
> 
> /*
> @@ -200,7 +200,6 @@ struct arm_smccc_res {
>  * v1.1.
>  */
> #ifdef CONFIG_ARM_32
> -#define arm_smccc_1_0_smc(...) arm_smccc_1_1_smc(__VA_ARGS__)
> #define arm_smccc_smc(...) arm_smccc_1_1_smc(__VA_ARGS__)
> 
> /* Make an SMCCC v1.1 compliant SMC call with guest register state. */
> @@ -217,7 +216,7 @@ static inline void arm_smccc_guest_smc(struct 
> cpu_user_regs *regs)
>     regs->r3 = res.a3;
> }
> 
> -#else
> +#else /* CONFIG_ARM_64 */
> 
> void __arm_smccc_1_0_smc(register_t a0, register_t a1, register_t a2,
>                          register_t a3, register_t a4, register_t a5,
> -- 
> 2.39.5
> 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.