Skip to content

Commit 8b3a89f

Browse files
feat(trp): test el3-rmm ide km interface
This patch introduces test functions to the Test Realm Payload (TRP) for performing basic sanity checks on the RMM-EL3 IDE KM support added to EL3. The primary goal of this patch is to only to verify the basic functionality and ensure the implemented functions return the correct return values. The test uses random values for the ecam address, rootport ID, IDE stream info, keys, and IV values. Change-Id: Icf47627da9a6a7dd0d6e40e20ac94cc977072177 Signed-off-by: Sona Mathew <[email protected]>
1 parent 2132c70 commit 8b3a89f

File tree

9 files changed

+141
-13
lines changed

9 files changed

+141
-13
lines changed

include/services/trp/platform_trp.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
2+
* Copyright (c) 2021-2025, Arm Limited and Contributors. All rights reserved.
33
*
44
* SPDX-License-Identifier: BSD-3-Clause
55
*/
@@ -16,4 +16,8 @@ struct rmm_manifest;
1616
******************************************************************************/
1717
void trp_early_platform_setup(struct rmm_manifest *manifest);
1818

19+
#if RMMD_ENABLE_IDE_KEY_PROG
20+
uint64_t trp_get_test_rootport(uint64_t *ecam, uint64_t *rootport);
21+
#endif /* RMMD_ENABLE_IDE_KEY_PROG */
22+
1923
#endif /* PLATFORM_TRP_H */

include/services/trp/trp_helpers.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, Arm Limited. All rights reserved.
2+
* Copyright (c) 2022-2025, Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: BSD-3-Clause
55
*/
@@ -17,7 +17,11 @@
1717
#define TRP_ARG5 0x28
1818
#define TRP_ARG6 0x30
1919
#define TRP_ARG7 0x38
20-
#define TRP_ARGS_END 0x40
20+
#define TRP_ARG8 0x40
21+
#define TRP_ARG9 0x48
22+
#define TRP_ARG10 0x50
23+
#define TRP_ARG11 0x58
24+
#define TRP_ARGS_END 0x60
2125

2226
#ifndef __ASSEMBLER__
2327

@@ -35,7 +39,11 @@ trp_args_t *set_smc_args(uint64_t arg0,
3539
uint64_t arg4,
3640
uint64_t arg5,
3741
uint64_t arg6,
38-
uint64_t arg7);
42+
uint64_t arg7,
43+
uint64_t arg8,
44+
uint64_t arg9,
45+
uint64_t arg10,
46+
uint64_t arg11);
3947

4048
__dead2 void trp_boot_abort(uint64_t err);
4149

plat/arm/board/fvp/fvp_ide_keymgmt.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,5 @@ int plat_rmmd_el3_ide_km_pull_response(uint64_t ecam_address, uint64_t root_port
4444
uint64_t *cookie)
4545
{
4646
/* placeholder to add further implementation */
47-
4847
return E_RMM_UNK;
4948
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) 2025, Arm Limited and Contributors. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
#include <common/debug.h>
8+
#include <plat/common/platform.h>
9+
#include <services/trp/platform_trp.h>
10+
11+
#include <platform_def.h>
12+
13+
/*
14+
* Helper function for ecam address and root port ID
15+
*
16+
*/
17+
uint64_t trp_get_test_rootport(uint64_t *ecam_address, uint64_t *rp_id)
18+
{
19+
20+
*ecam_address = 0xE001C000;
21+
*rp_id = 0x001C0001;
22+
23+
return 0;
24+
}
25+

plat/arm/board/fvp/trp/trp-fvp.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
# TRP source files specific to FVP platform
88

9-
RMM_SOURCES += plat/arm/board/fvp/aarch64/fvp_helpers.S
9+
RMM_SOURCES += plat/arm/board/fvp/aarch64/fvp_helpers.S \
10+
plat/arm/board/fvp/trp/test_ide_km_interface.c
1011

1112
include plat/arm/common/trp/arm_trp.mk
1213

services/std_svc/rmmd/trp/trp_entry.S

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021-2022, Arm Limited. All rights reserved.
2+
* Copyright (c) 2021-2025, Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: BSD-3-Clause
55
*/
@@ -21,6 +21,8 @@
2121
* ---------------------------------------------
2222
*/
2323
.macro restore_args_call_smc
24+
ldp x10, x11, [x0, #TRP_ARG10]
25+
ldp x8, x9, [x0, #TRP_ARG8]
2426
ldp x6, x7, [x0, #TRP_ARG6]
2527
ldp x4, x5, [x0, #TRP_ARG4]
2628
ldp x2, x3, [x0, #TRP_ARG2]

services/std_svc/rmmd/trp/trp_helpers.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, Arm Limited. All rights reserved.
2+
* Copyright (c) 2022-2025, Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: BSD-3-Clause
55
*/
@@ -25,7 +25,11 @@ trp_args_t *set_smc_args(uint64_t arg0,
2525
uint64_t arg4,
2626
uint64_t arg5,
2727
uint64_t arg6,
28-
uint64_t arg7)
28+
uint64_t arg7,
29+
uint64_t arg8,
30+
uint64_t arg9,
31+
uint64_t arg10,
32+
uint64_t arg11)
2933
{
3034
uint32_t linear_id;
3135
trp_args_t *pcpu_smc_args;
@@ -44,6 +48,10 @@ trp_args_t *set_smc_args(uint64_t arg0,
4448
write_trp_arg(pcpu_smc_args, TRP_ARG5, arg5);
4549
write_trp_arg(pcpu_smc_args, TRP_ARG6, arg6);
4650
write_trp_arg(pcpu_smc_args, TRP_ARG7, arg7);
51+
write_trp_arg(pcpu_smc_args, TRP_ARG8, arg8);
52+
write_trp_arg(pcpu_smc_args, TRP_ARG9, arg9);
53+
write_trp_arg(pcpu_smc_args, TRP_ARG10, arg10);
54+
write_trp_arg(pcpu_smc_args, TRP_ARG11, arg11);
4755

4856
return pcpu_smc_args;
4957
}
@@ -53,6 +61,6 @@ trp_args_t *set_smc_args(uint64_t arg0,
5361
*/
5462
__dead2 void trp_boot_abort(uint64_t err)
5563
{
56-
(void)trp_smc(set_smc_args(RMM_BOOT_COMPLETE, err, 0, 0, 0, 0, 0, 0));
64+
(void)trp_smc(set_smc_args(RMM_BOOT_COMPLETE, err, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
5765
panic();
5866
}

services/std_svc/rmmd/trp/trp_main.c

Lines changed: 83 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021-2024, Arm Limited and Contributors. All rights reserved.
2+
* Copyright (c) 2021-2025, Arm Limited and Contributors. All rights reserved.
33
*
44
* SPDX-License-Identifier: BSD-3-Clause
55
*/
@@ -15,6 +15,27 @@
1515

1616
#include <platform_def.h>
1717

18+
#define RMI_ERROR_REALM 2U
19+
#define RMI_ERROR_NOT_SUPPORTED 6U
20+
21+
#define DIR_BIT_SHIFT 0x8
22+
#define KEYSET_SHIFT 0xC
23+
#define STREAM_ID_MASK 0xFF
24+
#define STREAM_ID_SHIFT 0x0
25+
#define SUBSTREAM_MASK 0x7
26+
#define SUBSTREAM_SHIFT 0x8
27+
28+
#define KEY_SET 0x0
29+
#define DIR_VAL 0x0
30+
#define SUBSTREAM_VAL 0x1
31+
#define STREAM_ID 0x1
32+
33+
#define ENCODE_STREAM_INFO(key, dir, substream, stream_id) \
34+
(((key & 0x1) << KEYSET_SHIFT) | \
35+
((dir & 0x1) << DIR_BIT_SHIFT) | \
36+
((substream && SUBSTREAM_MASK) << SUBSTREAM_SHIFT) | \
37+
((stream_id && STREAM_ID_MASK) << STREAM_ID_SHIFT))
38+
1839
/* Parameters received from the previous image */
1940
static unsigned int trp_boot_abi_version;
2041
static uintptr_t trp_shared_region_start;
@@ -129,7 +150,7 @@ static void trp_asc_mark_realm(unsigned long long x1,
129150
{
130151
VERBOSE("Delegating granule 0x%llx\n", x1);
131152
smc_ret->x[0] = trp_smc(set_smc_args(RMM_GTSI_DELEGATE, x1,
132-
0UL, 0UL, 0UL, 0UL, 0UL, 0UL));
153+
0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL));
133154

134155
if (smc_ret->x[0] != 0ULL) {
135156
ERROR("Granule transition from NON-SECURE type to REALM type "
@@ -145,14 +166,70 @@ static void trp_asc_mark_nonsecure(unsigned long long x1,
145166
{
146167
VERBOSE("Undelegating granule 0x%llx\n", x1);
147168
smc_ret->x[0] = trp_smc(set_smc_args(RMM_GTSI_UNDELEGATE, x1,
148-
0UL, 0UL, 0UL, 0UL, 0UL, 0UL));
169+
0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL));
149170

150171
if (smc_ret->x[0] != 0ULL) {
151172
ERROR("Granule transition from REALM type to NON-SECURE type "
152173
"failed 0x%llx\n", smc_ret->x[0]);
153174
}
154175
}
155176

177+
/*******************************************************************************
178+
* Test the IDE Key management interface
179+
******************************************************************************/
180+
static void trp_ide_keymgmt_interface_fn(unsigned long long x1, unsigned long long x2,
181+
struct trp_smc_result *smc_ret)
182+
{
183+
uint64_t ecam_address = 0U, rp_id = 0U, ide_stream_info;
184+
uint64_t keyqw0, keyqw1, keyqw2, keyqw3;
185+
uint64_t ifvqw0, ifvqw1;
186+
int return_value;
187+
188+
#if RMMD_ENABLE_IDE_KEY_PROG
189+
trp_get_test_rootport(&ecam_address, &rp_id);
190+
#endif /* RMMD_ENABLE_IDE_KEY_PROG */
191+
/*
192+
* Dummy values for testing:
193+
* Key set = 0x0
194+
* Dir = 0x0
195+
* Substream = 0x1
196+
* Stream ID = 0x1
197+
*/
198+
ide_stream_info = ENCODE_STREAM_INFO(KEY_SET, DIR_VAL, SUBSTREAM_VAL, STREAM_ID);
199+
200+
/* Dummy key and IV values for testing */
201+
keyqw0 = 0xA1B2C3D4E5F60708;
202+
keyqw1 = 0x1122334455667788;
203+
keyqw2 = 0xDEADBEEFCAFEBABE;
204+
keyqw3 = 0x1234567890ABCDEF;
205+
ifvqw0 = 0xABCDEF0123456789;
206+
ifvqw1 = 0x9876543210FEDCBA;
207+
208+
return_value = trp_smc(set_smc_args(RMM_IDE_KEY_PROG, ecam_address, rp_id,
209+
ide_stream_info, keyqw0, keyqw1, keyqw2, keyqw3, ifvqw0,
210+
ifvqw1, 0UL, 0UL));
211+
212+
INFO("return value from RMM_IDE_KEY_PROG = %d\n", return_value);
213+
214+
return_value = trp_smc(set_smc_args(RMM_IDE_KEY_SET_GO, ecam_address, rp_id,
215+
ide_stream_info, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL));
216+
217+
INFO("return value from RMM_IDE_KEY_SET_GO = %d\n", return_value);
218+
219+
return_value = trp_smc(set_smc_args(RMM_IDE_KEY_SET_STOP, ecam_address, rp_id,
220+
ide_stream_info, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL));
221+
222+
INFO("return value from RMM_IDE_KEY_SET_STOP = %d\n", return_value);
223+
224+
return_value = trp_smc(set_smc_args(RMM_IDE_KM_PULL_RESPONSE, ecam_address, rp_id,
225+
0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL));
226+
227+
INFO("return value from RMM_IDE_KEY_SET_STOP = %d\n", return_value);
228+
229+
smc_ret->x[0] = RMI_ERROR_NOT_SUPPORTED;
230+
231+
}
232+
156233
/*******************************************************************************
157234
* Main RMI SMC handler function
158235
******************************************************************************/
@@ -179,6 +256,9 @@ void trp_rmi_handler(unsigned long fid,
179256
case RMI_RMM_GRANULE_UNDELEGATE:
180257
trp_asc_mark_nonsecure(x1, smc_ret);
181258
break;
259+
case RMI_RMM_PDEV_CREATE:
260+
trp_ide_keymgmt_interface_fn(x1, x2, smc_ret);
261+
break;
182262
default:
183263
ERROR("Invalid SMC code to %s, FID %lx\n", __func__, fid);
184264
smc_ret->x[0] = SMC_UNK;

services/std_svc/rmmd/trp/trp_private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#define RMI_RMM_REQ_VERSION SMC64_RMI_FID(U(0))
2929
#define RMI_RMM_GRANULE_DELEGATE SMC64_RMI_FID(U(1))
3030
#define RMI_RMM_GRANULE_UNDELEGATE SMC64_RMI_FID(U(2))
31+
#define RMI_RMM_PDEV_CREATE SMC64_RMI_FID(U(0x26))
3132

3233
/* Definitions for RMI VERSION */
3334
#define RMI_ABI_VERSION_MAJOR U(0x0)

0 commit comments

Comments
 (0)