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

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


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Thu, 3 Sep 2026 11:52:25 +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=ZlHvx6LzBPucMI3DdfND5m53grain8pP6uaUnLyPbs4=; b=rUoyu5hywcAFeUBhtTXglIN6LT/QzJhjgbDUcuLJI2KOMUFjdVoY71csWk8lXggF6h2zxKwWS6zHdRzhEqNbPghwkQ0gW1YOt8lpAb0gYq+iQ9vgOIZIKnEVJfOpZ2GSDFNBmxZZLr56Uoiggtr6uw/fdW0S9A/HAfUlBvPx6bZX7tqAhY6+8viYbDyQl9U+HuUu5oTcOHgpWgraJCV/HUjjY8+mAZ46DqFklvzIeY/dlvn8/OQflvGLUoxwq9c434518T2gH9MC/h4LH8gk9HAaYMr6c6h/AB/ZXGjEwborKi4qT3J197o0bDEn8n1JAT2Jp6cFC8v6oIpDwGGCVQ==
  • 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=ZlHvx6LzBPucMI3DdfND5m53grain8pP6uaUnLyPbs4=; b=aQFs0e6Z9Ta6LXRyRx9keTlBoEiccKtd0dcUcBvIasCgxKAERJTDnrBiYCUdkrsJ+LwPbvh+rnXY4xScQGH0Q+aMG7lKTVqsawyR6yuCUnUPuLMEO1g4Y2RfvEcrkHWrhBXErDIwB6xq0WE+o99/VB5JQXoKD3Hb7xc7voCb6TLnVL3cfZHG1h1JfetuTdiBatRsoYNM5eLcO4dr6pkDKfuCTKpwrukiaVk798y7LCTEPidOwr4G1C7xdwMt13TV8vavcSfnr66bCOUeexH5J3ve39wMB7MQfcez7tAZN/cWQMT2DZD5ZDIqjHJhy3h5rDdfdIIKEnNxjs7HrJcW8g==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=HjZxQVk5tRBv75h+wmygC93YsCdAgD27So1KGkkhSspPyen7iGt8K2vfRKE/ZHQ0SfzSmrW3gpUh3z/3MfDAuA4tp3XCCHNWE24qEGNfDs1K8oPrMzI+uRq7Mmew/NLlz4LOO825pc6TnhcX3TzezdQDCLpqdtuRoS9ofHIk+kXN2nad8B5hoXB0H9henuZMhocIPCramJe9uEqPp8k7+DxSHX+9KfWXXu+JWIGQUdt3EPqERLYNL2KI2BgD15izN7Fp5SWmA3+4QmRMwxmkkIPiyqotbzT7cMp89zSF9ajsha7xQWzUPlNqk61qrkKQ+pPeT4y1iaX/tBNTGkR5Hw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fbOqakLNJ8UHNPE77Wj2nI2bYc0J8bcA+k8VculRNaPCOwh4nTpFEAXJU6Kt/3leRXsDZpX0GGLlXHX/aLSUt+DoQX45evTy6zYorJQ2tvxtoKyZO9VOh9Ntsv7V3e5TfwDb1Bw/H7DPE392/fUoNK2ELkax7NsywmbwAxvgJ3xcC8wZ9O+E1jrVnfbU83zfkoorLeknt5IYnzSnSHqA6Sm3lGRcaUAAcZowwoLx+VciLBc8GoLElz9LWxvkdxbZdILVwEKf2L6My3efSjf29jnBMeC8xY32or0PBPpQkDa0hapMT++G8yzpE+CrsHtMhM13DfXTsZVhMccBaSpcIQ==
  • 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: Thu, 03 Sep 2026 11:53:12 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHdOUMPTd/l4DNdekW/1tH97277xLa8ws2A
  • Thread-topic: [PATCH 3/6] xen/arm: Clean up 32bit arm_smccc_1_1_smc()

Hi Andrew,

> On 31 Aug 2026, at 14:19, 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.
> * 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>


Looks good and i was not aware of this PASTE, result looks nit.

Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>

Cheers
Bertrand

> ---
> 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®.