Skip to content

Commit a37e31f

Browse files
Andre-ARMwilldeacon
authored andcommitted
firmware: smccc: Introduce SMCCC TRNG framework
The ARM DEN0098 document describe an SMCCC based firmware service to deliver hardware generated random numbers. Its existence is advertised according to the SMCCC v1.1 specification. Add a (dummy) call to probe functions implemented in each architecture (ARM and arm64), to determine the existence of this interface. For now this return false, but this will be overwritten by each architecture's support patch. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Will Deacon <will@kernel.org>
1 parent 67c6bb5 commit a37e31f

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎arch/arm/include/asm/archrandom.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _ASM_ARCHRANDOM_H
3+
#define _ASM_ARCHRANDOM_H
4+
5+
static inline bool __init smccc_probe_trng(void)
6+
{
7+
return false;
8+
}
9+
10+
#endif /* _ASM_ARCHRANDOM_H */

‎arch/arm64/include/asm/archrandom.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
#include <linux/kernel.h>
99
#include <asm/cpufeature.h>
1010

11+
static inline bool __init smccc_probe_trng(void)
12+
{
13+
return false;
14+
}
15+
1116
static inline bool __arm64_rndr(unsigned long *v)
1217
{
1318
bool ok;
@@ -79,5 +84,12 @@ arch_get_random_seed_long_early(unsigned long *v)
7984
}
8085
#define arch_get_random_seed_long_early arch_get_random_seed_long_early
8186

87+
#else /* !CONFIG_ARCH_RANDOM */
88+
89+
static inline bool __init smccc_probe_trng(void)
90+
{
91+
return false;
92+
}
93+
8294
#endif /* CONFIG_ARCH_RANDOM */
8395
#endif /* _ASM_ARCHRANDOM_H */

‎drivers/firmware/smccc/smccc.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@
55

66
#define pr_fmt(fmt) "smccc: " fmt
77

8+
#include <linux/cache.h>
89
#include <linux/init.h>
910
#include <linux/arm-smccc.h>
11+
#include <asm/archrandom.h>
1012

1113
static u32 smccc_version = ARM_SMCCC_VERSION_1_0;
1214
static enum arm_smccc_conduit smccc_conduit = SMCCC_CONDUIT_NONE;
1315

16+
bool __ro_after_init smccc_trng_available = false;
17+
1418
void __init arm_smccc_version_init(u32 version, enum arm_smccc_conduit conduit)
1519
{
1620
smccc_version = version;
1721
smccc_conduit = conduit;
22+
23+
smccc_trng_available = smccc_probe_trng();
1824
}
1925

2026
enum arm_smccc_conduit arm_smccc_1_1_get_conduit(void)

0 commit comments

Comments
 (0)