Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] firmware: smccc: Pass only the required device probe arguments
@ 2026-10-10 10:02 Aneesh Kumar K.V (Arm)
  2026-10-11  9:45 ` Suzuki K Poulose
  2026-10-12  8:55 ` Sudeep Holla
  0 siblings, 2 replies; 5+ messages in thread
From: Aneesh Kumar K.V (Arm) @ 2026-10-10 10:02 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Aneesh Kumar K.V (Arm), Catalin Marinas, Lorenzo Pieralisi,
	Mark Rutland, Sudeep Holla, Will Deacon, Steven Price,
	Suzuki K Poulose, Andre Przywara, Russell King, kernel test robot

The device probe passes zeroes for all seven argument registers to
arm_smccc_1_1_invoke(). On ARM32 Thumb-2, this binds an input to r7 and
GCC 8.5 reports "r7 cannot be used in asm here".

The current smccc_devices entries need at most one argument after the
function ID: TRNG_VERSION has none and RSI_ABI_VERSION takes a requested
version. Pass zero for that argument and omit the unused arguments,
avoiding the r7 constraint. Check argument requirements when adding new
probe functions to smccc_devices.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Sudeep Holla <sudeep.holla@kernel.org>
Cc: Will Deacon <will@kernel.org>
Cc: Steven Price <steven.price@arm.com>
Cc: Suzuki K Poulose <Suzuki.Poulose@arm.com>
Cc: Andre Przywara <andre.przywara@arm.com>
Cc: Russell King <linux@armlinux.org.uk>
Fixes: d8263a131bb0 ("firmware: hwrng: arm_smccc_trng: Register as an SMCCC device")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202610070641.B8hxBJcf-lkp@intel.com/
Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
---
 drivers/firmware/smccc/smccc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/firmware/smccc/smccc.c b/drivers/firmware/smccc/smccc.c
index 07b864ff079d..377d2cda2b6e 100644
--- a/drivers/firmware/smccc/smccc.c
+++ b/drivers/firmware/smccc/smccc.c
@@ -122,8 +122,7 @@ static bool __init smccc_probe_smccc_device(const struct smccc_device_info *smcc
 	if (IS_ENABLED(CONFIG_ARM) && ARM_SMCCC_IS_64(smccc_dev->func_id))
 		return false;
 
-	arm_smccc_1_1_invoke(smccc_dev->func_id,
-			     0, 0, 0, 0, 0, 0, 0, &res);
+	arm_smccc_1_1_invoke(smccc_dev->func_id, 0, &res);
 	ret = res.a0;
 
 	if (ret == SMCCC_RET_NOT_SUPPORTED)
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] firmware: smccc: Pass only the required device probe arguments
  2026-10-10 10:02 [PATCH] firmware: smccc: Pass only the required device probe arguments Aneesh Kumar K.V (Arm)
@ 2026-10-11  9:45 ` Suzuki K Poulose
  2026-10-11 13:25   ` Aneesh Kumar K.V
  2026-10-12  8:55 ` Sudeep Holla
  1 sibling, 1 reply; 5+ messages in thread
From: Suzuki K Poulose @ 2026-10-11  9:45 UTC (permalink / raw)
  To: Aneesh Kumar K.V (Arm), linux-arm-kernel
  Cc: Catalin Marinas, Lorenzo Pieralisi, Mark Rutland, Sudeep Holla,
	Will Deacon, Steven Price, Andre Przywara, Russell King,
	kernel test robot

Hi Aneesh

On 10/10/2026 11:02, Aneesh Kumar K.V (Arm) wrote:
> The device probe passes zeroes for all seven argument registers to
> arm_smccc_1_1_invoke(). On ARM32 Thumb-2, this binds an input to r7 and
> GCC 8.5 reports "r7 cannot be used in asm here".
> 
> The current smccc_devices entries need at most one argument after the
> function ID: TRNG_VERSION has none and RSI_ABI_VERSION takes a requested
> version. Pass zero for that argument and omit the unused arguments,
> avoiding the r7 constraint. Check argument requirements when adding new
> probe functions to smccc_devices.

Is it safer to use x1-x3 to 0 as they could be the results that we
get back from SMCCC v1.0 onwards ?


Suzuki



> 
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Sudeep Holla <sudeep.holla@kernel.org>
> Cc: Will Deacon <will@kernel.org>
> Cc: Steven Price <steven.price@arm.com>
> Cc: Suzuki K Poulose <Suzuki.Poulose@arm.com>
> Cc: Andre Przywara <andre.przywara@arm.com>
> Cc: Russell King <linux@armlinux.org.uk>
> Fixes: d8263a131bb0 ("firmware: hwrng: arm_smccc_trng: Register as an SMCCC device")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202610070641.B8hxBJcf-lkp@intel.com/
> Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
> ---
>   drivers/firmware/smccc/smccc.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/firmware/smccc/smccc.c b/drivers/firmware/smccc/smccc.c
> index 07b864ff079d..377d2cda2b6e 100644
> --- a/drivers/firmware/smccc/smccc.c
> +++ b/drivers/firmware/smccc/smccc.c
> @@ -122,8 +122,7 @@ static bool __init smccc_probe_smccc_device(const struct smccc_device_info *smcc
>   	if (IS_ENABLED(CONFIG_ARM) && ARM_SMCCC_IS_64(smccc_dev->func_id))
>   		return false;
>   
> -	arm_smccc_1_1_invoke(smccc_dev->func_id,
> -			     0, 0, 0, 0, 0, 0, 0, &res);
> +	arm_smccc_1_1_invoke(smccc_dev->func_id, 0, &res);
>   	ret = res.a0;
>   
>   	if (ret == SMCCC_RET_NOT_SUPPORTED)



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] firmware: smccc: Pass only the required device probe arguments
  2026-10-11  9:45 ` Suzuki K Poulose
@ 2026-10-11 13:25   ` Aneesh Kumar K.V
  2026-10-12  9:39     ` Suzuki K Poulose
  0 siblings, 1 reply; 5+ messages in thread
From: Aneesh Kumar K.V @ 2026-10-11 13:25 UTC (permalink / raw)
  To: Suzuki K Poulose, linux-arm-kernel
  Cc: Catalin Marinas, Lorenzo Pieralisi, Mark Rutland, Sudeep Holla,
	Will Deacon, Steven Price, Andre Przywara, Russell King,
	kernel test robot

Suzuki K Poulose <suzuki.poulose@arm.com> writes:

> Hi Aneesh
>
> On 10/10/2026 11:02, Aneesh Kumar K.V (Arm) wrote:
>> The device probe passes zeroes for all seven argument registers to
>> arm_smccc_1_1_invoke(). On ARM32 Thumb-2, this binds an input to r7 and
>> GCC 8.5 reports "r7 cannot be used in asm here".
>> 
>> The current smccc_devices entries need at most one argument after the
>> function ID: TRNG_VERSION has none and RSI_ABI_VERSION takes a requested
>> version. Pass zero for that argument and omit the unused arguments,
>> avoiding the r7 constraint. Check argument requirements when adding new
>> probe functions to smccc_devices.
>
> Is it safer to use x1-x3 to 0 as they could be the results that we
> get back from SMCCC v1.0 onwards ?
>


I'm not sure I follow. Passing additional zero arguments only
initializes the input registers; it should not affect how return values
are handled. arm_smccc_1_1_invoke() already declares x0-x3 as outputs.
Since these probe functions require no inputs in x2 or x3 and we only
inspect x0 on return, why do we need to initialize them to zero?


-aneesh


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] firmware: smccc: Pass only the required device probe arguments
  2026-10-10 10:02 [PATCH] firmware: smccc: Pass only the required device probe arguments Aneesh Kumar K.V (Arm)
  2026-10-11  9:45 ` Suzuki K Poulose
@ 2026-10-12  8:55 ` Sudeep Holla
  1 sibling, 0 replies; 5+ messages in thread
From: Sudeep Holla @ 2026-10-12  8:55 UTC (permalink / raw)
  To: Aneesh Kumar K.V (Arm)
  Cc: linux-arm-kernel, Sudeep Holla, Catalin Marinas,
	Lorenzo Pieralisi, Mark Rutland, Will Deacon, Steven Price,
	Suzuki K Poulose, Andre Przywara, Russell King, kernel test robot

On Sat, Oct 10, 2026 at 03:32:49PM +0530, Aneesh Kumar K.V (Arm) wrote:
> The device probe passes zeroes for all seven argument registers to
> arm_smccc_1_1_invoke(). On ARM32 Thumb-2, this binds an input to r7 and
> GCC 8.5 reports "r7 cannot be used in asm here".
> 
> The current smccc_devices entries need at most one argument after the
> function ID: TRNG_VERSION has none and RSI_ABI_VERSION takes a requested
> version. Pass zero for that argument and omit the unused arguments,
> avoiding the r7 constraint. Check argument requirements when adding new
> probe functions to smccc_devices.
> 

LGTM and should be enough for now.

Reviewed-by: Sudeep Holla <sudeep.holla@kernel.org>

-- 
Regards,
Sudeep


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] firmware: smccc: Pass only the required device probe arguments
  2026-10-11 13:25   ` Aneesh Kumar K.V
@ 2026-10-12  9:39     ` Suzuki K Poulose
  0 siblings, 0 replies; 5+ messages in thread
From: Suzuki K Poulose @ 2026-10-12  9:39 UTC (permalink / raw)
  To: Aneesh Kumar K.V, linux-arm-kernel
  Cc: Catalin Marinas, Lorenzo Pieralisi, Mark Rutland, Sudeep Holla,
	Will Deacon, Steven Price, Andre Przywara, Russell King,
	kernel test robot

On 11/10/2026 14:25, Aneesh Kumar K.V wrote:
> Suzuki K Poulose <suzuki.poulose@arm.com> writes:
> 
>> Hi Aneesh
>>
>> On 10/10/2026 11:02, Aneesh Kumar K.V (Arm) wrote:
>>> The device probe passes zeroes for all seven argument registers to
>>> arm_smccc_1_1_invoke(). On ARM32 Thumb-2, this binds an input to r7 and
>>> GCC 8.5 reports "r7 cannot be used in asm here".
>>>
>>> The current smccc_devices entries need at most one argument after the
>>> function ID: TRNG_VERSION has none and RSI_ABI_VERSION takes a requested
>>> version. Pass zero for that argument and omit the unused arguments,
>>> avoiding the r7 constraint. Check argument requirements when adding new
>>> probe functions to smccc_devices.
>>
>> Is it safer to use x1-x3 to 0 as they could be the results that we
>> get back from SMCCC v1.0 onwards ?
>>
> 
> 
> I'm not sure I follow. Passing additional zero arguments only
> initializes the input registers; it should not affect how return values
> are handled. arm_smccc_1_1_invoke() already declares x0-x3 as outputs.
> Since these probe functions require no inputs in x2 or x3 and we only
> inspect x0 on return, why do we need to initialize them to zero?

Agree, I meant, passing 0s for x0-x3 future proofs the new calls.
We know that x0-x3 could get overwritten by these calls, and is
safe to be zero'd on a call.

But agree, for the existing users just x1 is enough.

Either way,

Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>


Cheers
Suzuki

> 
> 
> -aneesh



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-12  9:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-10 10:02 [PATCH] firmware: smccc: Pass only the required device probe arguments Aneesh Kumar K.V (Arm)
2026-10-11  9:45 ` Suzuki K Poulose
2026-10-11 13:25   ` Aneesh Kumar K.V
2026-10-12  9:39     ` Suzuki K Poulose
2026-10-12  8:55 ` Sudeep Holla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox