Skip to content

Commit 71cd3b2

Browse files
committed
drivers: versal: drivers to upstream [WIP]
Current: - TRNG (random number generation) - PM: soc version, FPGA programming - FPGA needs the buffer in DDR - MBOX (PLM comms with different services) - NVM (interface to the efuse service) - crypto: ECC, RSA, HASH, AES-GCM When booting this OP-TEE, the tests get executed This is the expected output. OP-TEE build flags: make -j 8 PLATFORM=versal \ CFG_TEE_CORE_LOG_LEVEL=4 \ CFG_VERSAL_TRACE_PLM=y \ CFG_VERSAL_CRYPTO_DRIVER=y \ CFG_CRYPTO_DRIVER_DEBUG=y \ CFG_EARLY_TA=y \ CFG_IN_TREE_EARLY_TAS=hello_world/8aaaf200-2450-11e4-abe2-0002a5d5c51b \ -C /home/jramirez/Work/xilinx/project/local,optee-os \ O=/home/jramirez/Work/xilinx/project/.build/op-tee OP-TEE output: I/TC: OP-TEE version: 3.16.0-184-gedfe0aa2-dev (gcc version 7.3.1 20180425 [linaro-7.3-2018.05 revision d29120a424ecfbc167ef90065c0eeb7f91977701] (Linaro GCC 7.3-2018.05)) OP-TEE#1 vie 03 jun 2022 16:45:00 UTC aarch64 I/TC: WARNING: This OP-TEE configuration might be insecure! I/TC: WARNING: Please check https://optee.readthedocs.io/en/latest/architecture/porting_guidelines.html I/TC: Primary CPU initializing D/TC:0 0 call_preinitcalls:21 level 2 mobj_mapped_shm_init() D/TC:0 0 mobj_mapped_shm_init:464 Shared memory address range: 60200000, 62200000 D/TC:0 0 call_initcalls:40 level 1 register_time_source() D/TC:0 0 call_initcalls:40 level 1 versal_mbox_init() D/TC:0 0 call_initcalls:40 level 1 teecore_init_pub_ram() D/TC:0 0 call_initcalls:40 level 3 platform_banner() I/TC: Platform Versal - Silicon Revision v2 D/TC:0 0 call_initcalls:40 level 3 check_ta_store() D/TC:0 0 check_ta_store:408 TA store: "early TA" D/TC:0 0 check_ta_store:408 TA store: "Secure Storage TA" D/TC:0 0 check_ta_store:408 TA store: "REE" D/TC:0 0 call_initcalls:40 level 3 early_ta_init() D/TC:0 0 early_ta_init:57 Early TA 8aaaf200-2450-11e4-abe2-0002a5d5c51b size 23267 (compressed, uncompressed 38616) D/TC:0 0 call_initcalls:40 level 3 verify_pseudo_tas_conformance() D/TC:0 0 call_initcalls:40 level 3 tee_cryp_init() D/TC:0 0 call_initcalls:40 level 4 tee_fs_init_key_manager() D/TC:0 0 call_initcalls:40 level 5 trng_hrng_mode_init() D/TC:0 0 call_initcalls:40 level 5 versal_nvm_test() I/TC: Versal: Test NVM I/TC: ---- wr usr: [OK] I/TC: ---- rd usr: [OK] I/TC: ---- rd dna: [OK] I/TC: ---- rd ppk: [OK] I/TC: ---- rd iv: [OK] I/TC: ---- rd rvk: [OK] I/TC: ---- rd misc: [OK] I/TC: ---- rd sec ctrl: [OK] I/TC: ---- rd sec misc: [OK] I/TC: ---- rd boot env: [OK] I/TC: ---- rd off rvk: [OK] I/TC: ---- rd dec only: [OK] I/TC: ---- rd puf ctrl: [OK] I/TC: ---- rd puf: [OK] D/TC:0 0 call_initcalls:40 level 5 ecc_init() D/TC:0 0 drvcrypt_register:16 Registering module id 6 with 0x0x6006f348 D/TC:0 0 call_initcalls:40 level 5 rsa_init() D/TC:0 0 drvcrypt_register:16 Registering module id 3 with 0x0x6006f3d0 D/TC:0 0 call_initcalls:40 level 5 sha3_init() D/TC:0 0 drvcrypt_register:16 Registering module id 0 with 0x0x600179bc D/TC:0 0 call_initcalls:40 level 6 versal_crypto_test() D/TC:0 0 drvcrypt_asym_alloc_ecc_keypair:353 ECC Keypair (1024 bits) alloc ret = 0x0 D/TC:0 0 ecc_generate_keypair:115 ECC Keypair (384 bits) generate ret = 0x0 D/TC:0 0 drvcrypt_asym_alloc_ecc_public_key:390 ECC Public Key (1024 bits) alloc ret = 0x0 D/TC:0 0 algo_is_valid:60 Algo 0x70004041 curve 0x4 is valid D/TC:0 0 ecc_sign:187 Sign algo (0x70004041) returned 0x0 D/TC:0 0 algo_is_valid:60 Algo 0x70004041 curve 0x4 is valid D/TC:0 0 ecc_verify:247 Verify algo (0x70004041) returned 0x0 I/TC: Versal: Test ECC I/TC: ---- ecc gen pair: [OK] I/TC: ---- ecc gen sign: [OK] I/TC: ---- ecc ver sign: [OK] D/TC:0 0 call_initcalls:40 level 6 versal_register_authenc() D/TC:0 0 drvcrypt_register:16 Registering module id 9 with 0x0x6006f460 D/TC:0 0 call_initcalls:40 level 6 mobj_init() D/TC:0 0 call_initcalls:40 level 6 default_mobj_init() D/TC:0 0 call_finalcalls:59 level 1 versal_crypto_test() D/TC:0 0 crypto_acipher_alloc_rsa_keypair:36 RSA Keypair (4096 bits) alloc ret = 0x0 D/TC:0 0 crypto_acipher_rsanopad_decrypt:155 RSA Decrypt NO PAD ret = 0x0 D/TC:0 0 crypto_acipher_free_rsa_keypair:85 RSA Keypair free D/TC:0 0 crypto_acipher_alloc_rsa_public_key:60 RSA Public Key (4096 bits) alloc ret = 0x0 D/TC:0 0 crypto_acipher_rsanopad_encrypt:214 RSA Encrypt NO PAD ret = 0x0 D/TC:0 0 crypto_acipher_free_rsa_public_key:72 RSA Public Key free I/TC: Versal: Test RSA I/TC: ---- rsa decrypt: [OK] I/TC: ---- rsa encrypt: [OK] D/TC:0 0 call_finalcalls:59 level 1 versal_sha3_test() D/TC:0 0 drvcrypt_hash_alloc_ctx:18 hash alloc_ctx algo 0x50000005 D/TC:0 0 drvcrypt_hash_alloc_ctx:27 hash alloc_ctx ret 0x0 I/TC: Versal: Test HASH I/TC: ---- hash sha384: [OK] D/TC:0 0 call_finalcalls:59 level 1 versal_authenc_test() D/TC:0 0 drvcrypt_authenc_alloc_ctx:311 authenc alloc_ctx algo 0x40000810 D/TC:0 0 drvcrypt_authenc_alloc_ctx:330 authenc alloc_ctx ret 0x0 D/TC:0 0 authenc_init:107 authenc ret 0x0 D/TC:0 0 authenc_update_aad:139 authenc ret 0x0 D/TC:0 0 authenc_enc_final:231 authenc ret 0x0 D/TC:0 0 authenc_init:107 authenc ret 0x0 D/TC:0 0 authenc_update_aad:139 authenc ret 0x0 D/TC:0 0 authenc_dec_final:277 authenc ret 0x0 I/TC: Versal: Test AUTHENC I/TC: ---- auth enc: [OK] I/TC: ---- auth dec: [OK] I/TC: Primary CPU switching to normal world boot INFO: BL31: Preparing for EL3 exit to normal world INFO: Entry point address = 0x8000000 INFO: SPSR = 0x3c9 U-Boot 2021.01-00106-gd8887ac90b (May 05 2022 - 10:00:18 +0200) Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
1 parent 3f957d1 commit 71cd3b2

25 files changed

+5052
-1
lines changed

core/arch/arm/plat-versal/conf.mk

+20
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,23 @@ $(call force,CFG_WITH_LPAE,y)
3232
else
3333
$(call force,CFG_ARM32_core,y)
3434
endif
35+
36+
$(call force, CFG_VERSAL_RNG_DRV, y)
37+
$(call force, CFG_WITH_SOFTWARE_PRNG,n)
38+
$(call force, CFG_VERSAL_PM, y)
39+
$(call force, CFG_VERSAL_MBOX, y)
40+
$(call force, CFG_VERSAL_NVM, y)
41+
42+
# TRNG configuration
43+
CFG_VERSAL_TRNG_SEED_LIFE ?= 3
44+
CFG_VERSAL_TRNG_DF_MUL ?= 7
45+
46+
# MBOX configuration
47+
CFG_VERSAL_MBOX_IPI_ID ?=3
48+
49+
# Crypto
50+
CFG_VERSAL_CRYPTO_DRIVER ?= n
51+
52+
# FPGA
53+
CFG_VERSAL_FPGA_INIT ?= n
54+
CFG_VERSAL_FPGA_DDR_ADDR ?= 0x80000

core/arch/arm/plat-versal/main.c

+27
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <console.h>
88
#include <drivers/gic.h>
99
#include <drivers/pl011.h>
10+
#include <drivers/versal_nvm.h>
11+
#include <drivers/versal_pm.h>
1012
#include <kernel/boot.h>
1113
#include <kernel/interrupt.h>
1214
#include <kernel/misc.h>
@@ -56,3 +58,28 @@ void console_init(void)
5658
CONSOLE_UART_CLK_IN_HZ, CONSOLE_BAUDRATE);
5759
register_serial_console(&console_data.chip);
5860
}
61+
62+
static TEE_Result platform_banner(void)
63+
{
64+
TEE_Result ret = TEE_SUCCESS;
65+
uint8_t version = 0;
66+
67+
ret = versal_soc_version(&version);
68+
if (ret) {
69+
EMSG("Failure to retrieve SoC version");
70+
return ret;
71+
}
72+
73+
IMSG("Platform Versal - Silicon Revision v%d", version);
74+
75+
if (IS_ENABLED(CFG_VERSAL_FPGA_INIT)) {
76+
ret = versal_write_fpga(CFG_VERSAL_FPGA_DDR_ADDR);
77+
if (ret) {
78+
EMSG("Failure to load the FPGA bitstream");
79+
return TEE_ERROR_GENERIC;
80+
}
81+
}
82+
83+
return TEE_SUCCESS;
84+
}
85+
service_init(platform_banner);

core/arch/arm/plat-versal/platform_config.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
#include <mm/generic_ram_layout.h>
1010

1111
/* Make stacks aligned to data cache line length */
12-
#define STACK_ALIGNMENT 64
12+
#define CACHELINE_LEN 64
13+
#define STACK_ALIGNMENT CACHELINE_LEN
1314

1415
#if defined(PLATFORM_FLAVOR_generic)
1516

@@ -29,6 +30,9 @@
2930
#define DRAM0_BASE 0
3031
#define DRAM0_SIZE 0x80000000
3132

33+
#define TRNG_BASE 0xF1230000
34+
#define TRNG_SIZE 0x10000
35+
3236
#ifdef ARM64
3337
/* DDR High area base is only available when compiling for 64 bits */
3438
#define DRAM1_BASE 0x800000000

core/drivers/crypto/sub.mk

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ subdirs-$(CFG_NXP_SE05X) += se050
99
subdirs-$(CFG_STM32_CRYPTO_DRIVER) += stm32
1010

1111
subdirs-$(CFG_ASPEED_CRYPTO_DRIVER) += aspeed
12+
13+
subdirs-$(CFG_VERSAL_CRYPTO_DRIVER) += versal

0 commit comments

Comments
 (0)