Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c185655

Browse files
jellesels-armjforissier
authored andcommittedMar 5, 2021
core: Initiate and load Secure Partitions
Secure Partitions (SP) are S-El0 execution service defined in the Arm FF-A specification. The Secure Partitions are loaded as the last part of the boot process. A Secure Partitions can be added to image using the SP_PATHS build option. The SPs are loaded using ldelf. Signed-off-by: Jelle Sels <jelle.sels@arm.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
1 parent 4e994fd commit c185655

File tree

8 files changed

+357
-39
lines changed

8 files changed

+357
-39
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,76 @@
11
/* SPDX-License-Identifier: BSD-2-Clause */
22
/*
3-
* Copyright (c) 2020, Arm Limited.
3+
* Copyright (c) 2020-2021, Arm Limited.
44
*/
5-
#ifndef KERNEL_SECURE_PARTITION_H
6-
#define KERNEL_SECURE_PARTITION_H
5+
#ifndef __KERNEL_SECURE_PARTITION_H
6+
#define __KERNEL_SECURE_PARTITION_H
77

8+
#include <assert.h>
9+
#include <config.h>
810
#include <kernel/embedded_ts.h>
11+
#include <kernel/user_mode_ctx_struct.h>
912
#include <stdint.h>
1013
#include <tee_api_types.h>
14+
#include <tee/entry_std.h>
15+
16+
TAILQ_HEAD(sp_sessions_head, sp_session);
17+
18+
struct sp_name_value_pair {
19+
uint32_t name[4];
20+
uint64_t value;
21+
uint64_t size;
22+
};
23+
24+
/* SP entry arguments passed to SP image: see ABI in FF-A specification */
25+
struct sp_ffa_init_info {
26+
uint32_t magic; /* FF-A */
27+
uint32_t count; /* Count of name value size pairs */
28+
struct sp_name_value_pair nvp[]; /* Array of name value size pairs */
29+
};
30+
31+
enum sp_status { sp_idle, sp_busy, sp_preempted, sp_dead };
32+
33+
struct sp_session {
34+
enum sp_status state;
35+
uint16_t endpoint_id;
36+
uint16_t caller_id;
37+
struct ts_session ts_sess;
38+
struct sp_ffa_init_info *info;
39+
TAILQ_ENTRY(sp_session) link;
40+
};
41+
42+
struct sp_ctx {
43+
struct thread_ctx_regs sp_regs;
44+
struct sp_session *open_session;
45+
struct user_mode_ctx uctx;
46+
struct ts_ctx ts_ctx;
47+
};
48+
49+
#ifdef CFG_SECURE_PARTITION
50+
bool is_sp_ctx(struct ts_ctx *ctx);
51+
#else
52+
static inline bool is_sp_ctx(struct ts_ctx *ctx __unused)
53+
{
54+
return false;
55+
}
56+
#endif
57+
58+
static inline struct sp_session *__noprof
59+
to_sp_session(struct ts_session *sess)
60+
{
61+
assert(is_sp_ctx(sess->ctx));
62+
return container_of(sess, struct sp_session, ts_sess);
63+
}
64+
65+
static inline struct sp_ctx *to_sp_ctx(struct ts_ctx *ctx)
66+
{
67+
assert(is_sp_ctx(ctx));
68+
return container_of(ctx, struct sp_ctx, ts_ctx);
69+
}
70+
71+
struct sp_session *sp_get_session(uint32_t session_id);
1172

1273
#define for_each_secure_partition(_sp) \
1374
SCATTERED_ARRAY_FOREACH(_sp, sp_images, struct embedded_ts)
1475

15-
#endif /* KERNEL_SECURE_PARTITION_H */
16-
76+
#endif /* __KERNEL_SECURE_PARTITION_H */

‎core/arch/arm/include/kernel/thread.h

+18-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* Copyright (c) 2014, STMicroelectronics International N.V.
44
* Copyright (c) 2016-2017, Linaro Limited
5-
* Copyright (c) 2020, Arm Limited
5+
* Copyright (c) 2020-2021, Arm Limited
66
*/
77

88
#ifndef KERNEL_THREAD_H
@@ -194,6 +194,23 @@ struct thread_svc_regs {
194194
uint64_t x14; /* r14/lr_usr */
195195
uint64_t x30;
196196
uint64_t sp_el0;
197+
#ifdef CFG_SECURE_PARTITION
198+
uint64_t x15;
199+
uint64_t x16;
200+
uint64_t x17;
201+
uint64_t x18;
202+
uint64_t x19;
203+
uint64_t x20;
204+
uint64_t x21;
205+
uint64_t x22;
206+
uint64_t x23;
207+
uint64_t x24;
208+
uint64_t x25;
209+
uint64_t x26;
210+
uint64_t x27;
211+
uint64_t x28;
212+
uint64_t x29;
213+
#endif
197214
uint64_t pad;
198215
} __aligned(16);
199216
#endif /*ARM64*/
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* SPDX-License-Identifier: BSD-2-Clause */
2+
/*
3+
* Copyright (c) 2021, Arm Limited.
4+
*/
5+
#ifndef __KERNEL_THREAD_SPMC_H
6+
#define __KERNEL_THREAD_SPMC_H
7+
8+
/* FF-A endpoint base ID when OP-TEE is used as a S-EL1 endpoint */
9+
#define SPMC_ENDPOINT_ID 0x8001
10+
11+
#endif /* __KERNEL_THREAD_SPMC_H */
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Please sign in to comment.