blob: 2075d01e7073bdf68b5a5a9769beeb68a9ac7d19 [file] [log] [blame]
Soby Mathewb4c6df42022-11-09 11:13:29 +00001/*
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
5 */
6
7#ifndef SMC_RMI_H
8#define SMC_RMI_H
9
Soby Mathewb4c6df42022-11-09 11:13:29 +000010#include <smc.h>
11
12/*
13 * This file describes the Realm Management Interface (RMI) Application Binary
14 * Interface (ABI) for SMC calls made from Non-secure state to the RMM and
15 * serviced by the RMM.
Soby Mathewb4c6df42022-11-09 11:13:29 +000016 */
17
18/*
19 * The major version number of the RMI implementation. Increase this whenever
20 * the binary format or semantics of the SMC calls change.
21 */
AlexeiFedorov2cc6cee2023-10-09 16:19:05 +010022#define RMI_ABI_VERSION_MAJOR UL(1)
Soby Mathewb4c6df42022-11-09 11:13:29 +000023
24/*
25 * The minor version number of the RMI implementation. Increase this when
26 * a bug is fixed, or a feature is added without breaking binary compatibility.
27 */
AlexeiFedorovddf5daf2023-10-10 14:28:56 +010028#define RMI_ABI_VERSION_MINOR UL(0)
Soby Mathewb4c6df42022-11-09 11:13:29 +000029
Soby Mathewc9b6ecd2023-01-17 03:40:44 +000030#define RMI_ABI_VERSION ((RMI_ABI_VERSION_MAJOR << U(16)) | \
AlexeiFedorovddf5daf2023-10-10 14:28:56 +010031 RMI_ABI_VERSION_MINOR)
Soby Mathewb4c6df42022-11-09 11:13:29 +000032
Soby Mathewc9b6ecd2023-01-17 03:40:44 +000033#define RMI_ABI_VERSION_GET_MAJOR(_version) ((_version) >> U(16))
34#define RMI_ABI_VERSION_GET_MINOR(_version) ((_version) & U(0xFFFF))
Soby Mathewb4c6df42022-11-09 11:13:29 +000035
36#define SMC64_RMI_FID(_offset) SMC64_STD_FID(RMI, _offset)
37
38#define IS_SMC64_RMI_FID(_fid) IS_SMC64_STD_FAST_IN_RANGE(RMI, _fid)
39
Yousuf A0ec040d2022-10-31 12:30:57 +000040/* Command completed successfully. index is zero. */
41#define RMI_SUCCESS U(0)
42
43/*
44 * The value of a command input value caused the command to fail.
45 * Index is zero.
46 */
47#define RMI_ERROR_INPUT U(1)
48
49/*
50 * An attribute of a Realm does not match the expected value.
51 * index varies between usages.
52 */
53#define RMI_ERROR_REALM U(2)
54
55/*
56 * An attribute of a REC does not match the expected value.
57 * Index is zero.
58 */
59#define RMI_ERROR_REC U(3)
60
61/*
62 * An RTT walk terminated before reaching the target RTT level, or reached
63 * an RTTE with an unexpected value. index: RTT level at which the walk
64 * terminated
65 */
66#define RMI_ERROR_RTT U(4)
67
68/*
Yousuf A0ec040d2022-10-31 12:30:57 +000069 * Number of RMI Status Errors.
70 */
AlexeiFedorov892abce2023-04-06 16:32:12 +010071#define RMI_ERROR_COUNT U(5)
Yousuf A0ec040d2022-10-31 12:30:57 +000072
Soby Mathewb4c6df42022-11-09 11:13:29 +000073/*
74 * The number of GPRs (starting from X0) that are
75 * configured by the host when a REC is created.
76 */
Soby Mathewc9b6ecd2023-01-17 03:40:44 +000077#define REC_CREATE_NR_GPRS U(8)
Soby Mathewb4c6df42022-11-09 11:13:29 +000078
Soby Mathewc9b6ecd2023-01-17 03:40:44 +000079#define REC_PARAMS_FLAG_RUNNABLE (UL(1) << 0)
Soby Mathewb4c6df42022-11-09 11:13:29 +000080
81/*
82 * The number of GPRs (starting from X0) per voluntary exit context.
83 * Per SMCCC.
84 */
Soby Mathewc9b6ecd2023-01-17 03:40:44 +000085#define REC_EXIT_NR_GPRS U(31)
Soby Mathewb4c6df42022-11-09 11:13:29 +000086
87/* RmiHashAlgorithm type */
AlexeiFedorov6a4314e2023-10-20 15:40:14 +010088#define RMI_HASH_SHA_256 0U
89#define RMI_HASH_SHA_512 1U
Soby Mathewb4c6df42022-11-09 11:13:29 +000090
91/* Maximum number of Interrupt Controller List Registers */
Soby Mathewc9b6ecd2023-01-17 03:40:44 +000092#define REC_GIC_NUM_LRS U(16)
Soby Mathewb4c6df42022-11-09 11:13:29 +000093
Mate Toth-Pal0a8f37c2023-08-09 13:37:55 +020094#ifndef CBMC
Soby Mathewb4c6df42022-11-09 11:13:29 +000095/* Maximum number of auxiliary granules required for a REC */
Soby Mathewc9b6ecd2023-01-17 03:40:44 +000096#define MAX_REC_AUX_GRANULES U(16)
Mate Toth-Pal0a8f37c2023-08-09 13:37:55 +020097#else /* CBMC */
98#define MAX_REC_AUX_GRANULES U(1)
99#endif /* CBMC */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000100
AlexeiFedorov9b29c6b2023-09-12 17:09:50 +0100101/* Whether Host has completed emulation for an Emulatable Data Abort */
Soby Mathewc9b6ecd2023-01-17 03:40:44 +0000102#define REC_ENTRY_FLAG_EMUL_MMIO (UL(1) << 0)
AlexeiFedorov9b29c6b2023-09-12 17:09:50 +0100103
104/* Whether to inject a Synchronous External Abort into Realm */
Soby Mathewc9b6ecd2023-01-17 03:40:44 +0000105#define REC_ENTRY_FLAG_INJECT_SEA (UL(1) << 1)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000106
AlexeiFedorov9b29c6b2023-09-12 17:09:50 +0100107/* Whether to trap WFI/WFE execution by Realm */
Soby Mathewc9b6ecd2023-01-17 03:40:44 +0000108#define REC_ENTRY_FLAG_TRAP_WFI (UL(1) << 2)
109#define REC_ENTRY_FLAG_TRAP_WFE (UL(1) << 3)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000110
AlexeiFedorov9b29c6b2023-09-12 17:09:50 +0100111/* Host response to RIPAS change request */
112#define REC_ENTRY_FLAG_RIPAS_RESPONSE (UL(1) << 4)
113
Soby Mathewb4c6df42022-11-09 11:13:29 +0000114/*
115 * RmiRecExitReason represents the reason for a REC exit.
116 * This is returned to NS hosts via RMI_REC_ENTER::run_ptr.
117 */
Soby Mathewc9b6ecd2023-01-17 03:40:44 +0000118#define RMI_EXIT_SYNC U(0)
119#define RMI_EXIT_IRQ U(1)
120#define RMI_EXIT_FIQ U(2)
121#define RMI_EXIT_PSCI U(3)
122#define RMI_EXIT_RIPAS_CHANGE U(4)
123#define RMI_EXIT_HOST_CALL U(5)
124#define RMI_EXIT_SERROR U(6)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000125
126/* RmiRttEntryState represents the state of an RTTE */
AlexeiFedorovc53b1f72023-07-04 15:37:03 +0100127#define RMI_UNASSIGNED UL(0)
128#define RMI_ASSIGNED UL(1)
129#define RMI_TABLE UL(2)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000130
AlexeiFedorov7bb7a702023-01-17 17:04:14 +0000131/* RmiFeature enumerations */
AlexeiFedorovc09b1652023-04-04 15:41:37 +0100132#define RMI_FEATURE_FALSE UL(0)
133#define RMI_FEATURE_TRUE UL(1)
AlexeiFedorov7bb7a702023-01-17 17:04:14 +0000134
Yousuf Aa297b9b2022-10-13 13:54:21 +0100135/* RmiFeatureRegister0 format */
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100136#define RMI_FEATURE_REGISTER_0_INDEX UL(0)
Yousuf Aa297b9b2022-10-13 13:54:21 +0100137
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100138#define RMI_FEATURE_REGISTER_0_S2SZ_SHIFT UL(0)
139#define RMI_FEATURE_REGISTER_0_S2SZ_WIDTH UL(8)
Yousuf Aa297b9b2022-10-13 13:54:21 +0100140
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100141#define RMI_FEATURE_REGISTER_0_LPA2_SHIFT UL(8)
142#define RMI_FEATURE_REGISTER_0_LPA2_WIDTH UL(1)
Yousuf Aa297b9b2022-10-13 13:54:21 +0100143
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100144#define RMI_FEATURE_REGISTER_0_SVE_EN_SHIFT UL(9)
145#define RMI_FEATURE_REGISTER_0_SVE_EN_WIDTH UL(1)
Yousuf Aa297b9b2022-10-13 13:54:21 +0100146
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100147#define RMI_FEATURE_REGISTER_0_SVE_VL_SHIFT UL(10)
148#define RMI_FEATURE_REGISTER_0_SVE_VL_WIDTH UL(4)
Yousuf Aa297b9b2022-10-13 13:54:21 +0100149
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100150#define RMI_FEATURE_REGISTER_0_NUM_BPS_SHIFT UL(14)
151#define RMI_FEATURE_REGISTER_0_NUM_BPS_WIDTH UL(6)
AlexeiFedorov18002922023-04-06 10:19:51 +0100152
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100153#define RMI_FEATURE_REGISTER_0_NUM_WPS_SHIFT UL(20)
154#define RMI_FEATURE_REGISTER_0_NUM_WPS_WIDTH UL(6)
AlexeiFedorov18002922023-04-06 10:19:51 +0100155
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100156#define RMI_FEATURE_REGISTER_0_PMU_EN_SHIFT UL(26)
157#define RMI_FEATURE_REGISTER_0_PMU_EN_WIDTH UL(1)
AlexeiFedorov7bb7a702023-01-17 17:04:14 +0000158
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100159#define RMI_FEATURE_REGISTER_0_PMU_NUM_CTRS_SHIFT UL(27)
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100160#define RMI_FEATURE_REGISTER_0_PMU_NUM_CTRS_WIDTH UL(5)
AlexeiFedorov7bb7a702023-01-17 17:04:14 +0000161
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100162#define RMI_FEATURE_REGISTER_0_HASH_SHA_256_SHIFT UL(32)
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100163#define RMI_FEATURE_REGISTER_0_HASH_SHA_256_WIDTH UL(1)
AlexeiFedorov18002922023-04-06 10:19:51 +0100164
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100165#define RMI_FEATURE_REGISTER_0_HASH_SHA_512_SHIFT UL(33)
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100166#define RMI_FEATURE_REGISTER_0_HASH_SHA_512_WIDTH UL(1)
Arunachalam Ganapathyf6491212023-02-23 16:04:34 +0000167
AlexeiFedorov9baa1002024-08-05 16:02:19 +0100168#define RMI_FEATURE_REGISTER_0_GICV3_NUM_LRS_SHIFT UL(34)
169#define RMI_FEATURE_REGISTER_0_GICV3_NUM_LRS_WIDTH UL(4)
170
171#define RMI_FEATURE_REGISTER_0_MAX_RECS_ORDER_SHIFT UL(38)
172#define RMI_FEATURE_REGISTER_0_MAX_RECS_ORDER_WIDTH UL(4)
173
AlexeiFedorovc53b1f72023-07-04 15:37:03 +0100174/* The RmiRipas enumeration represents realm IPA state */
175
176/* Address where no Realm resources are mapped */
177#define RMI_EMPTY UL(0)
178
179/* Address where private code or data owned by the Realm is mapped */
180#define RMI_RAM UL(1)
181
182/* Address which is inaccessible to the Realm due to an action taken by the Host */
183#define RMI_DESTROYED UL(2)
Yousuf A62808152022-10-31 10:35:42 +0000184
AlexeiFedorov4d4e7342023-06-12 12:10:06 +0100185/* RmiPmuOverflowStatus enumeration representing PMU overflow status */
186#define RMI_PMU_OVERFLOW_NOT_ACTIVE U(0)
187#define RMI_PMU_OVERFLOW_ACTIVE U(1)
188
AlexeiFedorov9b29c6b2023-09-12 17:09:50 +0100189/*
190 * RmiResponse enumeration represents whether the Host accepted
191 * or rejected a Realm request
192 */
AlexeiFedorov6a4314e2023-10-20 15:40:14 +0100193#define RMI_ACCEPT 0U
194#define RMI_REJECT 1U
AlexeiFedorov9b29c6b2023-09-12 17:09:50 +0100195
AlexeiFedorov2cc6cee2023-10-09 16:19:05 +0100196/*
197 * arg0: Requested interface version
198 *
199 * ret0: Command return status
200 * ret1: Lower implemented interface revision
201 * ret2: Higher implemented interface revision
202 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100203#define SMC_RMI_VERSION SMC64_RMI_FID(U(0x0))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000204
205/*
206 * arg0 == target granule address
207 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100208#define SMC_RMI_GRANULE_DELEGATE SMC64_RMI_FID(U(0x1))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000209
210/*
211 * arg0 == target granule address
212 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100213#define SMC_RMI_GRANULE_UNDELEGATE SMC64_RMI_FID(U(0x2))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000214
215/* RmiDataMeasureContent type */
AlexeiFedorov93f5ec52023-08-31 14:26:53 +0100216#define RMI_NO_MEASURE_CONTENT U(0)
217#define RMI_MEASURE_CONTENT U(1)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000218
219/*
AlexeiFedorovac923c82023-04-06 15:12:04 +0100220 * arg0 == RD address
221 * arg1 == data address
Soby Mathewb4c6df42022-11-09 11:13:29 +0000222 * arg2 == map address
223 * arg3 == SRC address
224 * arg4 == flags
225 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100226#define SMC_RMI_DATA_CREATE SMC64_RMI_FID(U(0x3))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000227
228/*
AlexeiFedorovac923c82023-04-06 15:12:04 +0100229 * arg0 == RD address
230 * arg1 == data address
Soby Mathewb4c6df42022-11-09 11:13:29 +0000231 * arg2 == map address
232 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100233#define SMC_RMI_DATA_CREATE_UNKNOWN SMC64_RMI_FID(U(0x4))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000234
235/*
236 * arg0 == RD address
237 * arg1 == map address
AlexeiFedorove2002be2023-04-19 17:20:12 +0100238 *
239 * ret1 == Address(PA) of the DATA granule, if ret0 == RMI_SUCCESS.
240 * Otherwise, undefined.
241 * ret2 == Top of the non-live address region. Only valid
AlexeiFedorov697445b2023-04-25 15:27:57 +0100242 * if ret0 == RMI_SUCCESS or ret0 == (RMI_ERROR_RTT, x)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000243 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100244#define SMC_RMI_DATA_DESTROY SMC64_RMI_FID(U(0x5))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000245
246/*
247 * arg0 == RD address
248 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100249#define SMC_RMI_REALM_ACTIVATE SMC64_RMI_FID(U(0x7))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000250
251/*
252 * arg0 == RD address
AlexeiFedorovac923c82023-04-06 15:12:04 +0100253 * arg1 == struct rmi_realm_params address
Soby Mathewb4c6df42022-11-09 11:13:29 +0000254 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100255#define SMC_RMI_REALM_CREATE SMC64_RMI_FID(U(0x8))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000256
257/*
258 * arg0 == RD address
259 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100260#define SMC_RMI_REALM_DESTROY SMC64_RMI_FID(U(0x9))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000261
262/*
AlexeiFedorovac923c82023-04-06 15:12:04 +0100263 * arg0 == RD address
264 * arg1 == REC address
Soby Mathewb4c6df42022-11-09 11:13:29 +0000265 * arg2 == struct rmm_rec address
266 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100267#define SMC_RMI_REC_CREATE SMC64_RMI_FID(U(0xA))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000268
269/*
270 * arg0 == REC address
271 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100272#define SMC_RMI_REC_DESTROY SMC64_RMI_FID(U(0xB))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000273
274/*
275 * arg0 == rec address
AlexeiFedorovac923c82023-04-06 15:12:04 +0100276 * arg1 == struct rec_run address
Soby Mathewb4c6df42022-11-09 11:13:29 +0000277 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100278#define SMC_RMI_REC_ENTER SMC64_RMI_FID(U(0xC))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000279
280/*
AlexeiFedorovac923c82023-04-06 15:12:04 +0100281 * arg0 == RD address
282 * arg1 == RTT address
Soby Mathewb4c6df42022-11-09 11:13:29 +0000283 * arg2 == map address
284 * arg3 == level
285 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100286#define SMC_RMI_RTT_CREATE SMC64_RMI_FID(U(0xD))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000287
288/*
AlexeiFedorove2002be2023-04-19 17:20:12 +0100289 * arg0 == RD address
290 * arg1 == map address
291 * arg2 == level
292 *
293 * ret1 == Address (PA) of the RTT, if ret0 == RMI_SUCCESS
294 * Otherwise, undefined.
295 * ret2 == Top of the non-live address region. Only valid
AlexeiFedorov697445b2023-04-25 15:27:57 +0100296 * if ret0 == RMI_SUCCESS or ret0 == (RMI_ERROR_RTT, x)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000297 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100298#define SMC_RMI_RTT_DESTROY SMC64_RMI_FID(U(0xE))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000299
300/*
301 * arg0 == RD address
302 * arg1 == map address
303 * arg2 == level
304 * arg3 == s2tte
305 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100306#define SMC_RMI_RTT_MAP_UNPROTECTED SMC64_RMI_FID(U(0xF))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000307
308/*
309 * arg0 == RD address
310 * arg1 == map address
311 * arg2 == level
AlexeiFedorov697445b2023-04-25 15:27:57 +0100312 *
Soby Mathewb4c6df42022-11-09 11:13:29 +0000313 * ret1 == level
314 * ret2 == s2tte type
315 * ret3 == s2tte
316 * ret4 == ripas
AlexeiFedorov697445b2023-04-25 15:27:57 +0100317 * if ret0 == RMI_SUCCESS, otherwise, undefined.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000318 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100319#define SMC_RMI_RTT_READ_ENTRY SMC64_RMI_FID(U(0x11))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000320
321/*
322 * arg0 == RD address
323 * arg1 == map address
324 * arg2 == level
325 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100326#define SMC_RMI_RTT_UNMAP_UNPROTECTED SMC64_RMI_FID(U(0x12))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000327
328/*
329 * arg0 == calling rec address
330 * arg1 == target rec address
331 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100332#define SMC_RMI_PSCI_COMPLETE SMC64_RMI_FID(U(0x14))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000333
334/*
335 * arg0 == Feature register index
336 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100337#define SMC_RMI_FEATURES SMC64_RMI_FID(U(0x15))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000338
339/*
AlexeiFedorove2002be2023-04-19 17:20:12 +0100340 * arg0 == RD address
341 * arg1 == map address
342 * arg2 == level
343 *
344 * ret1 == Address(PA) of the RTT folded, if ret0 == RMI_SUCCESS
Soby Mathewb4c6df42022-11-09 11:13:29 +0000345 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100346#define SMC_RMI_RTT_FOLD SMC64_RMI_FID(U(0x16))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000347
348/*
349 * arg0 == RD address
350 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100351#define SMC_RMI_REC_AUX_COUNT SMC64_RMI_FID(U(0x17))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000352
353/*
AlexeiFedorovac923c82023-04-06 15:12:04 +0100354 * arg0 == RD address
AlexeiFedorov960d1612023-04-25 13:23:39 +0100355 * arg1 == start address
356 * arg2 == end address
357 *
358 * ret1 == Top of the address range where the RIPAS was updated,
359 * if ret0 == RMI_SUCCESS
Soby Mathewb4c6df42022-11-09 11:13:29 +0000360 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100361#define SMC_RMI_RTT_INIT_RIPAS SMC64_RMI_FID(U(0x18))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000362
363/*
364 * arg0 == RD address
365 * arg1 == REC address
AlexeiFedorov5cf35ba2023-04-25 10:02:20 +0100366 * arg2 == start address
367 * arg3 == end address
368 *
369 * ret1 == Top of the address range where the RIPAS was updated,
370 * if ret0 == RMI_SUCCESS
Soby Mathewb4c6df42022-11-09 11:13:29 +0000371 */
Arunachalam Ganapathy807dda82024-05-03 14:22:43 +0100372#define SMC_RMI_RTT_SET_RIPAS SMC64_RMI_FID(U(0x19))
Soby Mathewb4c6df42022-11-09 11:13:29 +0000373
374/* Size of Realm Personalization Value */
Mate Toth-Palc751c0d2023-11-14 16:56:41 +0100375#ifndef CBMC
Soby Mathewb4c6df42022-11-09 11:13:29 +0000376#define RPV_SIZE 64
Mate Toth-Palc751c0d2023-11-14 16:56:41 +0100377#else
378/*
379 * Small RPV size so that `struct rd` fits in the reduced sized granule defined
380 * for CBMC
381 */
382#define RPV_SIZE 1
383#endif
Soby Mathewb4c6df42022-11-09 11:13:29 +0000384
AlexeiFedorov18002922023-04-06 10:19:51 +0100385/* RmiRealmFlags format */
386#define RMI_REALM_FLAGS_LPA2_SHIFT UL(0)
387#define RMI_REALM_FLAGS_LPA2_WIDTH UL(1)
388
389#define RMI_REALM_FLAGS_SVE_SHIFT UL(1)
390#define RMI_REALM_FLAGS_SVE_WIDTH UL(1)
391
392#define RMI_REALM_FLAGS_PMU_SHIFT UL(2)
393#define RMI_REALM_FLAGS_PMU_WIDTH UL(1)
394
Soby Mathewc9b6ecd2023-01-17 03:40:44 +0000395#ifndef __ASSEMBLER__
Soby Mathewb4c6df42022-11-09 11:13:29 +0000396/*
Soby Mathewc414f2a2023-01-17 02:50:17 +0000397 * Defines member of structure and reserves space
398 * for the next member with specified offset.
399 */
400#define SET_MEMBER_RMI SET_MEMBER
401
402/*
Soby Mathewb4c6df42022-11-09 11:13:29 +0000403 * The Realm attribute parameters are shared by the Host via
404 * RMI_REALM_CREATE::params_ptr. The values can be observed or modified
405 * either by the Host or by the Realm.
406 */
407struct rmi_realm_params {
AlexeiFedorov18002922023-04-06 10:19:51 +0100408 /* Flags */
409 SET_MEMBER_RMI(unsigned long flags, 0, 0x8); /* Offset 0 */
410 /* Requested IPA width */
411 SET_MEMBER_RMI(unsigned int s2sz, 0x8, 0x10); /* 0x8 */
412 /* Requested SVE vector length */
413 SET_MEMBER_RMI(unsigned int sve_vl, 0x10, 0x18); /* 0x10 */
414 /* Requested number of breakpoints */
415 SET_MEMBER_RMI(unsigned int num_bps, 0x18, 0x20); /* 0x18 */
416 /* Requested number of watchpoints */
417 SET_MEMBER_RMI(unsigned int num_wps, 0x20, 0x28); /* 0x20 */
418 /* Requested number of PMU counters */
419 SET_MEMBER_RMI(unsigned int pmu_num_ctrs, 0x28, 0x30); /* 0x28 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000420 /* Measurement algorithm */
AlexeiFedorov56e1a8e2023-09-01 17:06:13 +0100421 SET_MEMBER_RMI(unsigned char algorithm, 0x30, 0x400); /* 0x30 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000422 /* Realm Personalization Value */
AlexeiFedorov18002922023-04-06 10:19:51 +0100423 SET_MEMBER_RMI(unsigned char rpv[RPV_SIZE], 0x400, 0x800); /* 0x400 */
Soby Mathewc414f2a2023-01-17 02:50:17 +0000424 SET_MEMBER_RMI(struct {
Soby Mathewb4c6df42022-11-09 11:13:29 +0000425 /* Virtual Machine Identifier */
426 unsigned short vmid; /* 0x800 */
427 /* Realm Translation Table base */
428 unsigned long rtt_base; /* 0x808 */
429 /* RTT starting level */
430 long rtt_level_start; /* 0x810 */
431 /* Number of starting level RTTs */
432 unsigned int rtt_num_start; /* 0x818 */
433 }, 0x800, 0x1000);
434};
435
Soby Mathewb4c6df42022-11-09 11:13:29 +0000436/*
437 * The REC attribute parameters are shared by the Host via
AlexeiFedorov70115132023-11-27 13:04:26 +0000438 * RMI_REC_CREATE::params_ptr. The values can be observed or modified
Soby Mathewb4c6df42022-11-09 11:13:29 +0000439 * either by the Host or by the Realm which owns the REC.
440 */
441struct rmi_rec_params {
442 /* Flags */
Soby Mathewc414f2a2023-01-17 02:50:17 +0000443 SET_MEMBER_RMI(unsigned long flags, 0, 0x100); /* Offset 0 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000444 /* MPIDR of the REC */
Soby Mathewc414f2a2023-01-17 02:50:17 +0000445 SET_MEMBER_RMI(unsigned long mpidr, 0x100, 0x200); /* 0x100 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000446 /* Program counter */
Soby Mathewc414f2a2023-01-17 02:50:17 +0000447 SET_MEMBER_RMI(unsigned long pc, 0x200, 0x300); /* 0x200 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000448 /* General-purpose registers */
Soby Mathewc414f2a2023-01-17 02:50:17 +0000449 SET_MEMBER_RMI(unsigned long gprs[REC_CREATE_NR_GPRS], 0x300, 0x800); /* 0x300 */
450 SET_MEMBER_RMI(struct {
Soby Mathewb4c6df42022-11-09 11:13:29 +0000451 /* Number of auxiliary Granules */
452 unsigned long num_aux; /* 0x800 */
453 /* Addresses of auxiliary Granules */
454 unsigned long aux[MAX_REC_AUX_GRANULES];/* 0x808 */
455 }, 0x800, 0x1000);
456};
457
Soby Mathewb4c6df42022-11-09 11:13:29 +0000458/*
459 * Structure contains data passed from the Host to the RMM on REC entry
460 */
AlexeiFedorov52912a62023-07-24 12:28:47 +0100461struct rmi_rec_enter {
Soby Mathewb4c6df42022-11-09 11:13:29 +0000462 /* Flags */
Soby Mathewc414f2a2023-01-17 02:50:17 +0000463 SET_MEMBER_RMI(unsigned long flags, 0, 0x200); /* Offset 0 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000464 /* General-purpose registers */
Soby Mathewc414f2a2023-01-17 02:50:17 +0000465 SET_MEMBER_RMI(unsigned long gprs[REC_EXIT_NR_GPRS], 0x200, 0x300); /* 0x200 */
466 SET_MEMBER_RMI(struct {
Soby Mathewb4c6df42022-11-09 11:13:29 +0000467 /* GICv3 Hypervisor Control Register */
468 unsigned long gicv3_hcr; /* 0x300 */
469 /* GICv3 List Registers */
470 unsigned long gicv3_lrs[REC_GIC_NUM_LRS]; /* 0x308 */
471 }, 0x300, 0x800);
472};
473
Soby Mathewb4c6df42022-11-09 11:13:29 +0000474/*
475 * Structure contains data passed from the RMM to the Host on REC exit
476 */
477struct rmi_rec_exit {
478 /* Exit reason */
Soby Mathewc414f2a2023-01-17 02:50:17 +0000479 SET_MEMBER_RMI(unsigned long exit_reason, 0, 0x100);/* Offset 0 */
480 SET_MEMBER_RMI(struct {
Soby Mathewb4c6df42022-11-09 11:13:29 +0000481 /* Exception Syndrome Register */
482 unsigned long esr; /* 0x100 */
483 /* Fault Address Register */
484 unsigned long far; /* 0x108 */
485 /* Hypervisor IPA Fault Address register */
486 unsigned long hpfar; /* 0x110 */
487 }, 0x100, 0x200);
488 /* General-purpose registers */
Soby Mathewc414f2a2023-01-17 02:50:17 +0000489 SET_MEMBER_RMI(unsigned long gprs[REC_EXIT_NR_GPRS], 0x200, 0x300); /* 0x200 */
490 SET_MEMBER_RMI(struct {
Soby Mathewb4c6df42022-11-09 11:13:29 +0000491 /* GICv3 Hypervisor Control Register */
492 unsigned long gicv3_hcr; /* 0x300 */
493 /* GICv3 List Registers */
494 unsigned long gicv3_lrs[REC_GIC_NUM_LRS]; /* 0x308 */
495 /* GICv3 Maintenance Interrupt State Register */
496 unsigned long gicv3_misr; /* 0x388 */
497 /* GICv3 Virtual Machine Control Register */
498 unsigned long gicv3_vmcr; /* 0x390 */
499 }, 0x300, 0x400);
Soby Mathewc414f2a2023-01-17 02:50:17 +0000500 SET_MEMBER_RMI(struct {
Soby Mathewb4c6df42022-11-09 11:13:29 +0000501 /* Counter-timer Physical Timer Control Register */
502 unsigned long cntp_ctl; /* 0x400 */
503 /* Counter-timer Physical Timer CompareValue Register */
504 unsigned long cntp_cval; /* 0x408 */
505 /* Counter-timer Virtual Timer Control Register */
506 unsigned long cntv_ctl; /* 0x410 */
507 /* Counter-timer Virtual Timer CompareValue Register */
508 unsigned long cntv_cval; /* 0x418 */
509 }, 0x400, 0x500);
Soby Mathewc414f2a2023-01-17 02:50:17 +0000510 SET_MEMBER_RMI(struct {
Soby Mathewb4c6df42022-11-09 11:13:29 +0000511 /* Base address of pending RIPAS change */
512 unsigned long ripas_base; /* 0x500 */
513 /* Size of pending RIPAS change */
AlexeiFedorovccce3ad2023-04-28 18:29:47 +0100514 unsigned long ripas_top; /* 0x508 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000515 /* RIPAS value of pending RIPAS change */
516 unsigned char ripas_value; /* 0x510 */
517 }, 0x500, 0x600);
518 /* Host call immediate value */
AlexeiFedoroveaec0c42023-02-01 18:13:32 +0000519 SET_MEMBER_RMI(unsigned int imm, 0x600, 0x700); /* 0x600 */
AlexeiFedorov4d4e7342023-06-12 12:10:06 +0100520 /* PMU overflow status */
521 SET_MEMBER_RMI(unsigned long pmu_ovf_status, 0x700, 0x800); /* 0x700 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000522};
523
Soby Mathewb4c6df42022-11-09 11:13:29 +0000524/*
525 * Structure contains shared information between RMM and Host
526 * during REC entry and REC exit.
527 */
528struct rmi_rec_run {
529 /* Entry information */
AlexeiFedorov52912a62023-07-24 12:28:47 +0100530 SET_MEMBER_RMI(struct rmi_rec_enter enter, 0, 0x800); /* Offset 0 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000531 /* Exit information */
AlexeiFedoroveaec0c42023-02-01 18:13:32 +0000532 SET_MEMBER_RMI(struct rmi_rec_exit exit, 0x800, 0x1000);/* 0x800 */
Soby Mathewb4c6df42022-11-09 11:13:29 +0000533};
534
Soby Mathewc9b6ecd2023-01-17 03:40:44 +0000535#endif /* __ASSEMBLER__ */
536
Soby Mathewb4c6df42022-11-09 11:13:29 +0000537#endif /* SMC_RMI_H */