firmware: smccc: Pass only the required device probe arguments
PATCH 1/1 firmware: smccc: Pass only the required device probe arguments
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.
--- drivers/firmware/smccc/smccc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/firmware/smccc/smccc.c +1 -2
@@ -122,8 +122,7 @@ static bool __init smccc_probe_smccc_device(const struct smccc_device_info *smccif (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 )
Signature · 1 line
2.43.0
Hi Aneesh
Quoted 9 lines · Aneesh Kumar K.V (Arm)
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_devicesentries need at most one argument after the function ID:TRNG_VERSIONhas none andRSI_ABI_VERSIONtakes 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 tosmccc_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
Quoted 32 lines
Cc Catalin Marinas <[email protected]>Cc Lorenzo Pieralisi <[email protected]>Cc Mark Rutland <[email protected]>Cc Sudeep Holla <[email protected]>Cc Will Deacon <[email protected]>Cc Steven Price <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Andre Przywara <[email protected]>Cc Russell King <[email protected]>Fixes d8263a131bb0 ("firmware: hwrng: arm_smccc_trng: Register as an SMCCC device")Reported-by kernel test robot <[email protected]>Signed-off-by Aneesh Kumar K.V (Arm) <[email protected]>--- drivers/firmware/smccc/smccc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/firmware/smccc/smccc.c +1
-2@@ -122,8 +122,7 @@ static bool __init smccc_probe_smccc_device(const struct smccc_device_info *smccif (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 )
Quoted 7 lines · Suzuki K Poulose
Hi Aneesh
Quoted 4 lines · Aneesh Kumar K.V (Arm)
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".
Quoted 9 lines
Quoted 5 lines
The current
smccc_devicesentries need at most one argument after the function ID:TRNG_VERSIONhas none andRSI_ABI_VERSIONtakes 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 tosmccc_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
Quoted 10 lines · Aneesh Kumar K.V (Arm)
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_devicesentries need at most one argument after the function ID:TRNG_VERSIONhas none andRSI_ABI_VERSIONtakes 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 tosmccc_devices.
LGTM and should be enough for now.
Signature · 2 lines
Regards, Sudeep
Suzuki K Poulose
Reviewed-byQuoted 20 lines · Aneesh Kumar K.V
Quoted 7 lines · Suzuki K Poulose
Hi Aneesh
Quoted 4 lines · Aneesh Kumar K.V (Arm)
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".Quoted 9 lines
Quoted 5 lines
The current
smccc_devicesentries need at most one argument after the function ID:TRNG_VERSIONhas none andRSI_ABI_VERSIONtakes 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 tosmccc_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 ?
Quoted 5 lines
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,
Cheers
Suzuki
Quoted 3 lines
-aneesh
Quoted 22 lines · Suzuki K Poulose
Quoted 12 lines · Aneesh Kumar K.V
Quoted 11 lines · Suzuki K Poulose
Quoted 9 lines · Aneesh Kumar K.V (Arm)
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_devicesentries need at most one argument after the function ID:TRNG_VERSIONhas none andRSI_ABI_VERSIONtakes 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 tosmccc_devices.Quoted 8 lines
Quoted 2 lines
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?
Quoted 5 lines
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.
I'd keep it like this for now, it's pretty random anyway. The next time we need a meaningful argument to pass, we'll probably add an args array in struct smccc_device_info.
Quoted 3 lines
Either way,
Reviewed-by Suzuki K Poulose <[email protected]>
Thanks.
Signature · 1 line
Catalin
Catalin Marinas
AppliedQuoted 11 lines · Aneesh Kumar K.V (Arm)
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_devicesentries need at most one argument after the function ID:TRNG_VERSIONhas none andRSI_ABI_VERSIONtakes 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 tosmccc_devices.[...]
Applied to arm64 (for-next/smccc-bus), thanks!
[1/1] firmware: smccc: Pass only the required device probe arguments
https://git.kernel.org/arm64/c/c6e78a4080a3