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

Re: [PATCH] xen/arm: smccc: Preserve argument types in v1.1 SMC


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Mon, 16 Feb 2026 09:31:29 +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=suse.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=uTj+yGqPL4YmlAbDtOeqjY6tDvYVS0U3TrbXDjHDUMo=; b=d5z1vZplWmxt54yHkMnUOEO/uYDykGO5Hvbjhy4OqozhmPepDYLk8WRACCuMsBrvAL9kby/y+8WO6MCNbyVzISdBMzENIdTLrTKfrhEJziIc2wOEm3aLlMv8yYhUItYAAeB9CAQCkcN/ik8RN8DZ3LP0HMDTim9A7ZgEEJwzKNuIaPgfjdSPKYk4jCiZiKHevZnNSLrwap6GMyTUNEhg8Dptg+tGx0Iw/6lLR9OqH3R3795eKjNC0zN/qXmhJ+vnBnd99tib01O9uxWMQrmCKAZr8tyXEN9VRaPm2D/7RhHBbBw3ZedzszY7nlTPAYMEz0r6AnBKwfNTuQ0g49O3aw==
  • 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=uTj+yGqPL4YmlAbDtOeqjY6tDvYVS0U3TrbXDjHDUMo=; b=kOZ5yj2KtH/Oj2ttCDaB8+7oRYB+c0V9mt2TxYDFc5TTsZBMllXhMmyO8U8OFUbkyrg5F6b5DcbsxKrRgeSAeWu8wf1r21ePaZSqQhEzW4aTz3QFA9Uu5BuQpfz1zwhbqbWS+f11zgLwJasB6UQTqo2VGLMeRhg7IoXimSdexvv4hTB1R/DHtd7jaorBr3v2De2tCt6lkYi8viRJzWtrHsvVVEHiDHTCby9m/jLneKWwe3wulWb3AAmF3//HKT+PzyeAcsVyPgsN/kQy/8rDNk+kdNc9gkatRnQlCo+jJHxouqYKhkfFaom+Iw326i+FrKbuHJ+RAIponH0qjYJ1fg==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=fCEPFP+uJxGu8dbj01ZEBRNrugbE9Rq0rM6wAMFJ8du3WX/bLAJzMfIPBTYdkdcq9VDRsK0jdQd++ESGBgjSwUVprs1eqk8FtkF2hfxnumqmbzuYnlEuScnW6B2P/iPczwEXq/CwfkHneWcbdvFHz+W1NbhS+B+Gi++rsdzJqh1+qQtHUfRlpLeYOhw0pZJVyjaWDPqhXCqkcyHli9te5RviFn6+S/pOPfROXu7WyY8WeaIxeFYl1OwdKF90X2fs24FEqAC6pKD9KnDrNdmlVKWsM0xd2vcPYCnsOtO6lQVcYvUAMfnMw4sz5nsVpD7TefAP6pOlJHMQpGCS/B58Eg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uSIJ8MyTey4dJsOBJ+19MtOlrCbYeh0GgbeT8sMSj2AzZomUw391Vd3Mm/kXWTlDvdPrwkEACmmeq/cD/TE8+80TPq6gDlk2jhCAh3ysXFRgnxUzLsKnmt5OvEKAcqH3tkqpWHZql0USr84GsyQh7FFA66dXkDnXvsYFSnQvo6Nhfa1gAxZGVpU600zls9KKGs6MvdDGSIPDdZsqmSkUcNrsdijNFVOo49rOyDaC9JPjfIE+v7J+f0zCZVIKRS96cOlTPhzpuEF7XH6FDc6xdSQ1yWJG2kdUIVgWnln8P2JFZO7Y1sGe+DNjgdWTWVd/JyL4Hq0NVSDyuRWf6aBbYw==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Mon, 16 Feb 2026 09:32:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHcnxiN7299tnoecUy3OIetO+v/gLWFDRSAgAACvYA=
  • Thread-topic: [PATCH] xen/arm: smccc: Preserve argument types in v1.1 SMC

Hi Jan,

> On 16 Feb 2026, at 10:21, Jan Beulich <jbeulich@xxxxxxxx> wrote:
> 
> On 16.02.2026 08:47, Bertrand Marquis wrote:
>> The SMCCC v1.1 inline helper currently forces a1-a4 into
>> unsigned long and uses in/out constraints for r0-r3. In
>> contrast, a5-a7 are passed with their original types via
>> read-only constraints. On arm64 this means a 32-bit signed
>> value in a1-a4 is converted to a 64-bit unsigned value, while
>> the same value in a5-a7 keeps its signed 32-bit form. For
>> example, a negative int in a2 is widened to unsigned long, but
>> a negative int in a5 is passed as a 32-bit signed value, so the
>> SMC sees different encodings depending on argument position.
>> 
>> Switch the helper to use typed input registers arg0-arg7
>> derived from the call arguments (keeping a0 cast to u32) and
>> separate output registers r0-r3. This preserves argument types
>> consistently across all positions. Argument evaluation order
>> is unchanged, so we do not reintroduce the issue fixed in
>> "e00dc325bd9e" ("xen/arm: smccc-1.1: Handle function result as
>> parameters").
>> 
>> This also aligns Xen's SMCCC parameter handling with Linux's type-
>> preserving behavior (same externally visible argument handling,
>> independent implementation) to avoid surprising differences
>> between a1-a4 and a5-a7.
>> 
>> Current callers (PSCI, SCMI, platform SMC pass-through, OP-TEE,
>> and exynos5) pass unsigned values; exynos5 passes an int CPU id
>> which should always be > 0.
> 
> Reported-by: Andrew ?

Ack, sorry forgot that.

> 
>> Signed-off-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
>> ---
>> xen/arch/arm/include/asm/smccc.h | 69 +++++++++++++-------------------
>> 1 file changed, 27 insertions(+), 42 deletions(-)
>> 
>> diff --git a/xen/arch/arm/include/asm/smccc.h 
>> b/xen/arch/arm/include/asm/smccc.h
>> index 441b3ab65dee..5b30dd57b69d 100644
>> --- a/xen/arch/arm/include/asm/smccc.h
>> +++ b/xen/arch/arm/include/asm/smccc.h
>> @@ -99,87 +99,68 @@ struct arm_smccc_res {
>> #define __count_args(...)                               \
>>     ___count_args(__VA_ARGS__, 7, 6, 5, 4, 3, 2, 1, 0)
>> 
>> -#define __constraint_write_0                        \
>> -    "+r" (r0), "=&r" (r1), "=&r" (r2), "=&r" (r3)
>> -#define __constraint_write_1                        \
>> -    "+r" (r0), "+r" (r1), "=&r" (r2), "=&r" (r3)
>> -#define __constraint_write_2                        \
>> -    "+r" (r0), "+r" (r1), "+r" (r2), "=&r" (r3)
>> -#define __constraint_write_3                        \
>> -    "+r" (r0), "+r" (r1), "+r" (r2), "+r" (r3)
>> -#define __constraint_write_4    __constraint_write_3
>> -#define __constraint_write_5    __constraint_write_4
>> -#define __constraint_write_6    __constraint_write_5
>> -#define __constraint_write_7    __constraint_write_6
>> -
>> -#define __constraint_read_0
>> -#define __constraint_read_1
>> -#define __constraint_read_2
>> -#define __constraint_read_3
>> -#define __constraint_read_4 "r" (r4)
>> -#define __constraint_read_5 __constraint_read_4, "r" (r5)
>> -#define __constraint_read_6 __constraint_read_5, "r" (r6)
>> -#define __constraint_read_7 __constraint_read_6, "r" (r7)
>> +#define __constraint_read_0 "r" (arg0)
>> +#define __constraint_read_1 __constraint_read_0, "r" (arg1)
>> +#define __constraint_read_2 __constraint_read_1, "r" (arg2)
>> +#define __constraint_read_3 __constraint_read_2, "r" (arg3)
>> +#define __constraint_read_4 __constraint_read_3, "r" (arg4)
>> +#define __constraint_read_5 __constraint_read_4, "r" (arg5)
>> +#define __constraint_read_6 __constraint_read_5, "r" (arg6)
>> +#define __constraint_read_7 __constraint_read_6, "r" (arg7)
>> 
>> #define __declare_arg_0(a0, res)                            \
>>     struct arm_smccc_res    *___res = (res);                \
>> -    register unsigned long  r0 ASM_REG(0) = (uint32_t)(a0); \
>> -    register unsigned long  r1 ASM_REG(1);                  \
>> -    register unsigned long  r2 ASM_REG(2);                  \
>> -    register unsigned long  r3 ASM_REG(3)
>> +    register unsigned long  arg0 ASM_REG(0) = (uint32_t)(a0)
>> 
>> #define __declare_arg_1(a0, a1, res)                        \
>>     typeof(a1) __a1 = (a1);                                 \
>>     struct arm_smccc_res    *___res = (res);                \
>> -    register unsigned long  r0 ASM_REG(0) = (uint32_t)(a0); \
>> -    register unsigned long  r1 ASM_REG(1) = __a1;           \
>> -    register unsigned long  r2 ASM_REG(2);                  \
>> -    register unsigned long  r3 ASM_REG(3)
>> +    register unsigned long  arg0 ASM_REG(0) = (uint32_t)(a0);\
>> +    register typeof(a1)     arg1 ASM_REG(1) = __a1
> 
> Is it intentional that you switch to typeof() rather than directly going
> to auto? This was it'll be more churn, aiui. And if deliberately going
> only half a step, perhaps worth saying so in the description?
> 

Yes it is because Andrew wants to rebase his serie on top of this
patch.

Cheers
Bertrand

> Jan





 


Rackspace

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