blob: a6260e4c96523085ab64bbe2c993f30ffb72d94a [file] [log] [blame]
nabkah01002e5692022-10-10 12:36:46 +01001/*
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +00002 * Copyright (c) 2022-2025, Arm Limited. All rights reserved.
nabkah01002e5692022-10-10 12:36:46 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef REALM_RSI_H
9#define REALM_RSI_H
10
Shruti Gupta5abab762024-11-27 04:57:53 +000011#include <arch.h>
nabkah01002e5692022-10-10 12:36:46 +010012#include <stdint.h>
AlexeiFedorov2f30f102023-03-13 19:37:46 +000013#include <host_shared_data.h>
nabkah01002e5692022-10-10 12:36:46 +010014#include <tftf_lib.h>
15
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +000016#define SMC64_RSI_CALL_BASE (0xC4000190)
17#define SMC64_RSI_FID(_x) (SMC64_RSI_CALL_BASE + (_x))
18
19/*
20 * Defines member of structure and reserves space
21 * for the next member with specified offset.
22 */
23#define SET_MEMBER_RSI SET_MEMBER
24
nabkah01002e5692022-10-10 12:36:46 +010025/*
26 * This file describes the Realm Services Interface (RSI) Application Binary
27 * Interface (ABI) for SMC calls made from within the Realm to the RMM and
28 * serviced by the RMM.
29 *
30 * See doc/rmm_interface.md for more details.
31 */
32
33/*
34 * The major version number of the RSI implementation. Increase this whenever
35 * the binary format or semantics of the SMC calls change.
36 */
Shruti Gupta40de8ec2023-10-12 21:45:12 +010037#define RSI_ABI_VERSION_MAJOR 1U
nabkah01002e5692022-10-10 12:36:46 +010038
39/*
40 * The minor version number of the RSI implementation. Increase this when
41 * a bug is fixed, or a feature is added without breaking binary compatibility.
42 */
43#define RSI_ABI_VERSION_MINOR 0U
44
45#define RSI_ABI_VERSION_VAL ((RSI_ABI_VERSION_MAJOR << 16U) | \
46 RSI_ABI_VERSION_MINOR)
47
48#define RSI_ABI_VERSION_GET_MAJOR(_version) ((_version) >> 16U)
49#define RSI_ABI_VERSION_GET_MINOR(_version) ((_version) & 0xFFFFU)
50
51
52/* RSI Status code enumeration as per Section D4.3.6 of the RMM Spec */
53typedef enum {
54 /* Command completed successfully */
55 RSI_SUCCESS = 0U,
56
57 /*
58 * The value of a command input value
59 * caused the command to fail
60 */
61 RSI_ERROR_INPUT = 1U,
62
63 /*
64 * The state of the current Realm or current REC
65 * does not match the state expected by the command
66 */
67 RSI_ERROR_STATE = 2U,
68
69 /* The operation requested by the command is not complete */
70 RSI_INCOMPLETE = 3U,
71
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +000072 /* The operation requested by the command failed for an unknown reason */
73 RSI_ERROR_UNKNOWN = 4U,
74
75 /*
76 * The state of a Realm device does not match the state expected by the
77 * command.
78 */
79 RSI_ERROR_DEVICE = 5U,
80
81 RSI_ERROR_COUNT_MAX
nabkah01002e5692022-10-10 12:36:46 +010082} rsi_status_t;
83
Shruti Gupta55d5db82025-03-03 12:56:04 +000084#define RSI_EXIT_SYNC 0U
85
AlexeiFedorovdff904b2024-08-05 17:11:18 +010086/* Size of Realm Personalization Value */
87#define RSI_RPV_SIZE 64U
88
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +000089/* RsiRealmConfig structure containing realm configuration */
nabkah01002e5692022-10-10 12:36:46 +010090struct rsi_realm_config {
91 /* IPA width in bits */
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +000092 SET_MEMBER_RSI(unsigned long ipa_width, 0, 8);
AlexeiFedorovdff904b2024-08-05 17:11:18 +010093 /* Hash algorithm */
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +000094 SET_MEMBER_RSI(unsigned char algorithm, 0x8, 0x10);
Shruti Gupta5abab762024-11-27 04:57:53 +000095 /* Number of auxiliary Planes */
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +000096 SET_MEMBER_RSI(unsigned long num_aux_planes, 0x10, 0x18);
97 /* GICv3 VGIC Type Register value */
98 SET_MEMBER_RSI(unsigned long gicv3_vtr, 0x18, 0x20);
99 /*
100 * If ATS is enabled, determines the stage 2 translation used by devices
101 * assigned to the Realm
102 */
103 SET_MEMBER_RSI(unsigned long ats_plane, 0x20, 0x200);
104
AlexeiFedorovdff904b2024-08-05 17:11:18 +0100105 /* Realm Personalization Value */
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000106 SET_MEMBER_RSI(unsigned char rpv[RSI_RPV_SIZE], 0x200, 0x1000);
nabkah01002e5692022-10-10 12:36:46 +0100107};
108
AlexeiFedorov3d3dea22023-04-06 15:36:27 +0100109#define RSI_HOST_CALL_NR_GPRS 31U
nabkah01002e5692022-10-10 12:36:46 +0100110
111struct rsi_host_call {
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000112 SET_MEMBER_RSI(struct {
nabkah01002e5692022-10-10 12:36:46 +0100113 /* Immediate value */
114 unsigned int imm; /* Offset 0 */
115 /* Registers */
116 unsigned long gprs[RSI_HOST_CALL_NR_GPRS];
117 }, 0, 0x100);
118};
119
120/*
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000121 * FID: 0xC4000190
122 *
123 * Returns RSI version.
124 * arg1: Requested interface version
AlexeiFedorov9a60ecb2024-08-06 16:39:00 +0100125 * ret0: Status / error
126 * ret1: Lower implemented interface revision
127 * ret2: Higher implemented interface revision
128 */
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000129#define SMC_RSI_VERSION SMC64_RSI_FID(U(0x0))
AlexeiFedorov2f30f102023-03-13 19:37:46 +0000130
nabkah01002e5692022-10-10 12:36:46 +0100131/*
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000132 * FID: 0xC4000191
133 *
134 * Returns RSI Feature register requested by index.
135 * arg1: Feature register index
136 * ret0: Status / error
137 * ret1: Feature register value
138 */
139#define SMC_RSI_FEATURES SMC64_RSI_FID(U(0x1))
140
141/*
142 * FID: 0xC4000192
143 *
144 * Returns a measurement.
145 * arg1: Measurement index (0..4), measurement (RIM or REM) to read
146 * ret0: Status / error
147 * ret1: Measurement value, bytes: 0 - 7
148 * ret2: Measurement value, bytes: 8 - 15
149 * ret3: Measurement value, bytes: 16 - 23
150 * ret4: Measurement value, bytes: 24 - 31
151 * ret5: Measurement value, bytes: 32 - 39
152 * ret6: Measurement value, bytes: 40 - 47
153 * ret7: Measurement value, bytes: 48 - 55
154 * ret8: Measurement value, bytes: 56 - 63
155 */
156#define SMC_RSI_MEASUREMENT_READ SMC64_RSI_FID(U(0x2))
157
158/*
159 * FID: 0xC4000193
160 *
161 * Extends a REM.
162 * arg1: Measurement index (1..4), measurement (REM) to extend
163 * arg2: Measurement size in bytes
164 * arg3: Challenge value, bytes: 0 - 7
165 * arg4: Challenge value, bytes: 8 - 15
166 * arg5: Challenge value, bytes: 16 - 23
167 * arg6: Challenge value, bytes: 24 - 31
168 * arg7: Challenge value, bytes: 32 - 39
169 * arg8: Challenge value, bytes: 40 - 47
170 * arg9: Challenge value, bytes: 48 - 55
171 * arg10: Challenge value, bytes: 56 - 63
172 * ret0: Status / error
173 */
174#define SMC_RSI_MEASUREMENT_EXTEND SMC64_RSI_FID(U(0x3))
175
176/*
177 * FID: 0xC4000194
178 *
179 * Initialize the operation to retrieve an attestation token.
180 * arg1: Challenge value, bytes: 0 - 7
181 * arg2: Challenge value, bytes: 8 - 15
182 * arg3: Challenge value, bytes: 16 - 23
183 * arg4: Challenge value, bytes: 24 - 31
184 * arg5: Challenge value, bytes: 32 - 39
185 * arg6: Challenge value, bytes: 40 - 47
186 * arg7: Challenge value, bytes: 48 - 55
187 * arg8: Challenge value, bytes: 56 - 63
188 * ret0: Status / error
189 * ret1: Upper bound on attestation token size in bytes
190 */
191#define SMC_RSI_ATTEST_TOKEN_INIT SMC64_RSI_FID(U(0x4))
192
193/*
194 * FID: 0xC4000195
195 *
196 * Continue the operation to retrieve an attestation token.
197 * arg1: IPA of the Granule to which the token will be written
198 * arg2: Offset within Granule to start of buffer in bytes
199 * arg3: Size of buffer in bytes
200 * ret0: Status / error
201 * ret1: Number of bytes written to buffer
202 */
203#define SMC_RSI_ATTEST_TOKEN_CONTINUE SMC64_RSI_FID(U(0x5))
204
205/*
206 * FID: 0xC4000196
207 *
208 * Read configuration for the current Realm.
209 * arg1 == IPA of the Granule to which the configuration data will be written
AlexeiFedorov9a60ecb2024-08-06 16:39:00 +0100210 * ret0 == Status / error
nabkah01002e5692022-10-10 12:36:46 +0100211 */
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000212#define SMC_RSI_REALM_CONFIG SMC64_RSI_FID(U(0x6))
AlexeiFedorov9a60ecb2024-08-06 16:39:00 +0100213
214/*
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000215 * FID: 0xC4000197
216 *
217 * arg1 == Base IPA address of target region
218 * arg2 == Top address of target region
219 * arg3 == RIPAS value
220 * arg4 == flags
AlexeiFedorov9a60ecb2024-08-06 16:39:00 +0100221 * ret0 == Status / error
222 * ret1 == Base of IPA region which was not modified by the command
223 * ret2 == RSI response
224 */
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000225#define SMC_RSI_IPA_STATE_SET SMC64_RSI_FID(U(0x7))
AlexeiFedorov9a60ecb2024-08-06 16:39:00 +0100226
227/*
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000228 * FID: 0xC4000198
229 *
230 * arg1 == Base of target IPA region
231 * arg2 == End of target IPA region
AlexeiFedorov9a60ecb2024-08-06 16:39:00 +0100232 * ret0 == Status / error
233 * ret1 == Top of IPA region which has the reported RIPAS value
234 * ret2 == RIPAS value
235 */
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000236#define SMC_RSI_IPA_STATE_GET SMC64_RSI_FID(U(0x8))
Shruti Guptabb772192023-10-09 16:08:28 +0100237
Juan Pablo Conde88ffad22024-10-11 21:22:29 -0500238/*
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000239 * FID: 0xC4000199
240 *
241 * arg1 == IPA of the Host call data structure
Juan Pablo Conde88ffad22024-10-11 21:22:29 -0500242 * ret0 == Status / error
Juan Pablo Conde88ffad22024-10-11 21:22:29 -0500243 */
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000244#define SMC_RSI_HOST_CALL SMC64_RSI_FID(U(0x9))
Juan Pablo Conde88ffad22024-10-11 21:22:29 -0500245
246/*
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000247 * TODO: Update the documentation of new FIDs once the 1.1 spec has stabilized.
Juan Pablo Conde88ffad22024-10-11 21:22:29 -0500248 */
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000249
250/*
251 * FID: 0xC400019A
252 */
253#define SMC_RSI_VSMMU_GET_INFO SMC64_RSI_FID(U(0xA))
254
255/*
256 * FID: 0xC400019B
257 */
258#define SMC_RSI_VSMMU_ACTIVATE SMC64_RSI_FID(U(0xB))
259
260/*
261 * FID: 0xC400019C
262 */
263#define SMC_RSI_RDEV_GET_INSTANCE_ID SMC64_RSI_FID(U(0xC))
264
265/*
266 * FID: 0xC400019D - 0xC400019F are not used.
267 */
268
269/*
270 * FID: 0xC40001A0
271 *
272 * arg1 == plane index
273 * arg2 == perm index
274 *
275 * ret0 == status
276 * ret1 == perm value
277 */
278#define SMC_RSI_MEM_GET_PERM_VALUE SMC64_RSI_FID(U(0x10))
279
280/*
281 * FID: 0xC40001A1
282 *
283 * arg1 == base adr
284 * arg2 == top adr
285 * arg3 == perm index
286 * arg4 == cookie
287 *
288 * ret0 == status
289 * ret1 == new_base
290 * ret2 == response
291 * ret3 == new_cookie
292 */
293#define SMC_RSI_MEM_SET_PERM_INDEX SMC64_RSI_FID(U(0x11))
294
295/*
296 * FID: 0xC40001A2
297 *
298 * arg1 == plane index
299 * arg2 == perm index
300 *
301 * ret0 == status
302 */
303#define SMC_RSI_MEM_SET_PERM_VALUE SMC64_RSI_FID(U(0x12))
304
305/*
306 * FID: 0xC40001A3
307 */
308#define SMC_RSI_PLANE_ENTER SMC64_RSI_FID(U(0x13))
309
310/*
311 * FID: 0xC40001A4
312 */
313#define SMC_RSI_RDEV_CONTINUE SMC64_RSI_FID(U(0x14))
314
315/*
316 * FID: 0xC40001A5
317 */
318#define SMC_RSI_RDEV_GET_INFO SMC64_RSI_FID(U(0x15))
319
320/*
321 * FID: 0xC40001A6
322 */
323#define SMC_RSI_RDEV_GET_INTERFACE_REPORT SMC64_RSI_FID(U(0x16))
324
325/*
326 * FID: 0xC40001A7
327 */
328#define SMC_RSI_RDEV_GET_MEASUREMENTS SMC64_RSI_FID(U(0x17))
329
330/*
331 * FID: 0xC40001A8
332 */
333#define SMC_RSI_RDEV_GET_STATE SMC64_RSI_FID(U(0x18))
334
335/*
336 * FID: 0xC40001A9
337 */
338#define SMC_RSI_RDEV_LOCK SMC64_RSI_FID(U(0x19))
339
340/*
341 * FID: 0xC40001AA
342 */
343#define SMC_RSI_RDEV_START SMC64_RSI_FID(U(0x1A))
344
345/*
346 * FID: 0xC40001AB
347 */
348#define SMC_RSI_RDEV_STOP SMC64_RSI_FID(U(0x1B))
349
350/*
351 * FID: 0xC40001AC
352 */
353#define SMC_RSI_RDEV_VALIDATE_MAPPING SMC64_RSI_FID(U(0x1C))
354
355/*
356 * FID: 0xC40001AD is not used.
357 */
358
359/*
360 * FID: 0xC40001AE
361 */
362#define SMC_RSI_PLANE_REG_READ SMC64_RSI_FID(U(0x1E))
363
364/*
365 * FID: 0xC40001AF
366 */
367#define SMC_RSI_PLANE_REG_WRITE SMC64_RSI_FID(U(0x1F))
Juan Pablo Conde88ffad22024-10-11 21:22:29 -0500368
Shruti Guptabb772192023-10-09 16:08:28 +0100369typedef enum {
370 RSI_EMPTY = 0U,
371 RSI_RAM,
AlexeiFedorovdff904b2024-08-05 17:11:18 +0100372 RSI_DESTROYED,
373 RSI_DEV
Shruti Guptabb772192023-10-09 16:08:28 +0100374} rsi_ripas_type;
375
376typedef enum {
377 RSI_ACCEPT = 0U,
378 RSI_REJECT
AlexeiFedorov08a5f162025-05-09 17:29:13 +0100379} rsi_response_type;
Shruti Guptabb772192023-10-09 16:08:28 +0100380
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000381/*
382 * RsiRipasChangeDestroyed:
383 * RIPAS change from DESTROYED should not be permitted
384 */
385#define RSI_NO_CHANGE_DESTROYED U(0)
386
387/* A RIPAS change from DESTROYED should be permitted */
388#define RSI_CHANGE_DESTROYED U(1)
389
Shruti Guptabb772192023-10-09 16:08:28 +0100390
Shruti Gupta5abab762024-11-27 04:57:53 +0000391/*
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000392 * RsiFeature
393 * Represents whether a feature is enabled.
394 * Width: 1 bit
Shruti Gupta5abab762024-11-27 04:57:53 +0000395 */
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000396#define RSI_FEATURE_FALSE U(0)
397#define RSI_FEATURE_TRUE U(1)
Shruti Gupta5abab762024-11-27 04:57:53 +0000398
399/*
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000400 * RsiFeatureRegister0
401 * Fieldset contains feature register 0
402 * Width: 64 bits
Shruti Gupta5abab762024-11-27 04:57:53 +0000403 */
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000404#define RSI_FEATURE_REGISTER_0_INDEX UL(0)
405#define RSI_FEATURE_REGISTER_0_DA_SHIFT UL(0)
406#define RSI_FEATURE_REGISTER_0_DA_WIDTH UL(1)
407#define RSI_FEATURE_REGISTER_0_MRO_SHIFT UL(1)
408#define RSI_FEATURE_REGISTER_0_MRO_WIDTH UL(1)
409#define RSI_FEATURE_REGISTER_0_ATS_SHIFT UL(2)
410#define RSI_FEATURE_REGISTER_0_ATS_WIDTH UL(1)
Shruti Gupta5abab762024-11-27 04:57:53 +0000411
412/*
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000413 * RsiDevMemShared
414 * Represents whether an device memory mapping is shared.
415 * Width: 1 bit
Shruti Gupta5abab762024-11-27 04:57:53 +0000416 */
Arunachalam Ganapathy51135c82025-01-27 11:17:32 +0000417#define RSI_DEV_MEM_MAPPING_PRIVATE U(0)
418#define RSI_DEV_MEM_MAPPING_SHARED U(1)
419
420/*
421 * RsiDevMemCoherent
422 * Represents whether a device memory location is within the system coherent
423 * memory space.
424 * Width: 1 bit
425 */
426#define RSI_DEV_MEM_NON_COHERENT U(0)
427#define RSI_DEV_MEM_COHERENT U(1)
428
429/*
430 * RsiRdevValidateIoFlags
431 * Fieldset contains flags provided when requesting validation of an IO mapping.
432 * Width: 64 bits
433 */
434/* RsiDevMemShared: Bits 0 to 1 */
435#define RSI_RDEV_VALIDATE_IO_FLAGS_SHARE_SHIFT UL(0)
436#define RSI_RDEV_VALIDATE_IO_FLAGS_SHARE_WIDTH UL(1)
437/* RsiDevMemCoherent: Bits 1 to 2 */
438#define RSI_RDEV_VALIDATE_IO_FLAGS_COH_SHIFT UL(1)
439#define RSI_RDEV_VALIDATE_IO_FLAGS_COH_WIDTH UL(1)
440
441/*
442 * RsiDeviceState
443 * This enumeration represents state of an assigned Realm device.
444 * Width: 64 bits.
445 */
446#define RSI_RDEV_STATE_UNLOCKED U(0)
447#define RSI_RDEV_STATE_UNLOCKED_BUSY U(1)
448#define RSI_RDEV_STATE_LOCKED U(2)
449#define RSI_RDEV_STATE_LOCKED_BUSY U(3)
450#define RSI_RDEV_STATE_STARTED U(4)
451#define RSI_RDEV_STATE_STARTED_BUSY U(5)
452#define RSI_RDEV_STATE_STOPPING U(6)
453#define RSI_RDEV_STATE_STOPPED U(7) /* unused will be removed */
454#define RSI_RDEV_STATE_ERROR U(8)
455
456/*
457 * RsiDevFlags
458 * Fieldset contains flags which describe properties of a device.
459 * Width: 64 bits
460 */
461#define RSI_DEV_FLAGS_P2P_SHIFT UL(0)
462#define RSI_DEV_FLAGS_P2P_WIDTH UL(1)
463
464/*
465 * RsiDevAttestType
466 * This enumeration represents attestation type of a device.
467 * Width: 64 bits.
468 */
469#define RSI_DEV_ATTEST_TYPE_INDEPENDENTLY_ATTESTED U(0)
470#define RSI_DEV_ATTEST_TYPE_PLATFORM_ATTESTED U(1)
471
472/*
473 * RsiDevInfo
474 * Contains device configuration information.
475 * Width: 512 (0x200) bytes.
476 */
477struct rsi_dev_info {
478 /* RsiDevFlags: Flags */
479 SET_MEMBER_RSI(unsigned long flags, 0, 0x8);
480 /* RsiDevAttestType: Attestation type */
481 SET_MEMBER_RSI(unsigned long attest_type, 0x8, 0x10);
482 /* UInt64: Certificate identifier */
483 SET_MEMBER_RSI(unsigned long cert_id, 0x10, 0x18);
484 /* RsiHashAlgorithm: Algorithm used to generate device digests */
485 SET_MEMBER_RSI(unsigned char hash_algo, 0x18, 0x40);
486
487 /* Bits512: Certificate digest */
488 SET_MEMBER_RSI(unsigned char cert_digest[64], 0x40, 0x80);
489 /* Bits512: Measurement block digest */
490 SET_MEMBER_RSI(unsigned char meas_digest[64], 0x80, 0xc0);
491 /* Bits512: Interface report digest */
492 SET_MEMBER_RSI(unsigned char report_digest[64], 0xc0, 0x200);
493};
494
495/*
496 * RsiDevMeasureAll
497 * Represents whether all device measurements should be returned.
498 * Width: 1 bit
499 */
500#define RSI_DEV_MEASURE_NOT_ALL U(0)
501#define RSI_DEV_MEASURE_ALL U(1)
502
503/*
504 * RsiDevMeasureSigned
505 * Represents whether a device measurement is signed.
506 * Width: 1 bit
507 */
508#define RSI_DEV_MEASURE_NOT_SIGNED U(0)
509#define RSI_DEV_MEASURE_SIGNED U(1)
510
511/*
512 * RsiDevMeasureRaw
513 * Represents whether a device measurement is a raw bitstream.
514 * Width: 1 bit
515 */
516#define RSI_DEV_MEASURE_NOT_RAW U(0)
517#define RSI_DEV_MEASURE_RAW U(1)
518
519/*
520 * RsiDevMeasureFlags
521 * Fieldset contains flags which describe properties of device measurements.
522 * Width: 64 bits
523 */
524/* RsiDevMeasureAll */
525#define RSI_DEV_MEASURE_FLAGS_ALL_SHIFT U(0)
526#define RSI_DEV_MEASURE_FLAGS_ALL_WIDTH U(1)
527/* RsiDevMeasureSigned */
528#define RSI_DEV_MEASURE_FLAGS_SIGNED_SHIFT U(1)
529#define RSI_DEV_MEASURE_FLAGS_SIGNED_WIDTH U(1)
530/* RsiDevMeasureRaw */
531#define RSI_DEV_MEASURE_FLAGS_RAW_SHIFT U(2)
532#define RSI_DEV_MEASURE_FLAGS_RAW_WIDTH U(1)
533
534/*
535 * RsiDevMeasureParams
536 * This structure contains device measurement parameters.
537 * Width: 4096 (0x1000) bytes.
538 */
539struct rsi_dev_measure_params {
540 /* RsiDevMeasureFlags: Properties of device measurements */
541 SET_MEMBER_RSI(unsigned long flags, 0, 0x8);
542
543 /* RsiBoolean[256]: Measurement indices */
544 SET_MEMBER_RSI(unsigned char indices[32], 0x100, 0x200);
545 /* RsiBoolean[256]: Nonce value used in measurement requests */
546 SET_MEMBER_RSI(unsigned char nonce[32], 0x200, 0x1000);
547};
Shruti Gupta5abab762024-11-27 04:57:53 +0000548
549#define RSI_PLANE_NR_GPRS 31U
550#define RSI_PLANE_GIC_NUM_LRS 16U
551
552/*
553 * Flags provided by the Primary Plane to the secondary ones upon
554 * plane entry.
555 */
556#define RSI_PLANE_ENTRY_FLAG_TRAP_WFI U(1UL << 0)
557#define RSI_PLANE_ENTRY_FLAG_TRAP_WFE U(1UL << 1)
558#define RSI_PLANE_ENTRY_FLAG_TRAP_HC U(1UL << 2)
559
560/* Data structure used to pass values from P0 to the RMM on Plane entry */
561struct rsi_plane_entry {
562 /* Flags */
563 SET_MEMBER(u_register_t flags, 0, 0x8); /* Offset 0 */
564 /* PC */
565 SET_MEMBER(u_register_t pc, 0x8, 0x100); /* Offset 0x8 */
566 /* General-purpose registers */
567 SET_MEMBER(u_register_t gprs[RSI_PLANE_NR_GPRS], 0x100, 0x200); /* 0x100 */
568 /* EL1 system registers */
569 SET_MEMBER(struct {
570 /* GICv3 Hypervisor Control Register */
571 u_register_t gicv3_hcr; /* 0x200 */
572 /* GICv3 List Registers */
573 u_register_t gicv3_lrs[RSI_PLANE_GIC_NUM_LRS]; /* 0x208 */
574 }, 0x200, 0x800);
575};
576
577/* Data structure used to pass values from the RMM to P0 on Plane exit */
578struct rsi_plane_exit {
579 /* Exit reason */
580 SET_MEMBER(u_register_t exit_reason, 0, 0x100);/* Offset 0 */
581 SET_MEMBER(struct {
582 /* Exception Link Register */
583 u_register_t elr; /* 0x100 */
584 /* Exception Syndrome Register */
585 u_register_t esr; /* 0x108 */
586 /* Fault Address Register */
587 u_register_t far; /* 0x108 */
588 /* Hypervisor IPA Fault Address register */
589 u_register_t hpfar; /* 0x110 */
590 }, 0x100, 0x200);
591 /* General-purpose registers */
592 SET_MEMBER(u_register_t gprs[RSI_PLANE_NR_GPRS], 0x200, 0x300); /* 0x200 */
593 SET_MEMBER(struct {
594 /* GICv3 Hypervisor Control Register */
595 u_register_t gicv3_hcr; /* 0x300 */
596 /* GICv3 List Registers */
597 u_register_t gicv3_lrs[RSI_PLANE_GIC_NUM_LRS]; /* 0x308 */
598 /* GICv3 Maintenance Interrupt State Register */
599 u_register_t gicv3_misr; /* 0x388 */
600 /* GICv3 Virtual Machine Control Register */
601 u_register_t gicv3_vmcr; /* 0x390 */
602 }, 0x300, 0x600);
603};
604
605typedef struct {
606 /* Entry information */
607 SET_MEMBER(struct rsi_plane_entry enter, 0, 0x800); /* Offset 0 */
608 /* Exit information */
609 SET_MEMBER(struct rsi_plane_exit exit, 0x800, 0x1000);/* 0x800 */
610} rsi_plane_run;
611
612/*
613 * arg1 == plane index
614 * arg2 == run pointer
615 *
616 * ret0 == status
617 */
618#define RSI_PLANE_ENTER SMC_RSI_FID(0x13U)
619
620/*
621 * arg1 == plane index
622 * arg2 == register encoding
623 *
624 * ret0 == status
625 * ret1 = register value
626 */
627#define RSI_PLANE_REG_READ SMC_RSI_FID(0x1EU)
628
Shruti Gupta41434682024-12-05 14:57:48 +0000629u_register_t rsi_plane_reg_read(u_register_t plane_index, u_register_t register_encoding,
630 u_register_t *value);
631
632u_register_t rsi_plane_reg_write(u_register_t plane_index, u_register_t register_encoding,
633 u_register_t value);
634
Shruti Gupta5abab762024-11-27 04:57:53 +0000635/*
636 * arg1 == plane index
637 * arg2 == register encoding
638 * arg3 == register value
639 *
640 * ret0 == status
641 */
642#define RSI_PLANE_REG_WRITE SMC_RSI_FID(0x1FU)
643
644/*
645 * Function to set overlay permission value for a specified
646 * (plane index, overlay permission index) tuple
647 */
648u_register_t rsi_mem_set_perm_value(u_register_t plane_index,
649 u_register_t perm_index,
650 u_register_t perm);
651
652/*
653 * Function to Get overlay permission value for a specified
654 * (plane index, overlay permission index) tuple
655 */
656u_register_t rsi_mem_get_perm_value(u_register_t plane_index,
657 u_register_t perm_index,
658 u_register_t *perm);
659
660/* Function to Set overlay permission index for a specified IPA range See RSI_MEM_SET_PERM_INDEX */
661u_register_t rsi_mem_set_perm_index(u_register_t base,
662 u_register_t top,
663 u_register_t perm_index,
664 u_register_t cookie,
665 u_register_t *new_base,
666 u_register_t *response,
667 u_register_t *new_cookie);
668
AlexeiFedorov08a5f162025-05-09 17:29:13 +0100669/* Request RIPAS of a target IPA range to be changed to a specified value */
Shruti Guptabb772192023-10-09 16:08:28 +0100670u_register_t rsi_ipa_state_set(u_register_t base,
AlexeiFedorov9a60ecb2024-08-06 16:39:00 +0100671 u_register_t top,
672 rsi_ripas_type ripas,
673 u_register_t flag,
674 u_register_t *new_base,
AlexeiFedorov08a5f162025-05-09 17:29:13 +0100675 rsi_response_type *response);
Shruti Guptabb772192023-10-09 16:08:28 +0100676
AlexeiFedorov9a60ecb2024-08-06 16:39:00 +0100677/* Request RIPAS of a target IPA range */
678u_register_t rsi_ipa_state_get(u_register_t base,
679 u_register_t top,
680 u_register_t *out_top,
681 rsi_ripas_type *ripas);
nabkah01002e5692022-10-10 12:36:46 +0100682
683/* This function return RSI_ABI_VERSION */
Shruti Gupta40de8ec2023-10-12 21:45:12 +0100684u_register_t rsi_get_version(u_register_t req_ver);
nabkah01002e5692022-10-10 12:36:46 +0100685
Arunachalam Ganapathyc58e4692025-01-28 12:28:59 +0000686/* This function returns RSI feature register at 'feature_reg_index' */
687u_register_t rsi_features(u_register_t feature_reg_index,
688 u_register_t *feature_reg_value_ret);
689
Juan Pablo Conde88ffad22024-10-11 21:22:29 -0500690/* This function will initialize the attestation context */
691u_register_t rsi_attest_token_init(u_register_t challenge_0,
692 u_register_t challenge_1,
693 u_register_t challenge_2,
694 u_register_t challenge_3,
695 u_register_t challenge_4,
696 u_register_t challenge_5,
697 u_register_t challenge_6,
698 u_register_t challenge_7,
699 u_register_t *out_token_upper_bound);
700
701/* This function will retrieve the (or part of) attestation token */
702u_register_t rsi_attest_token_continue(u_register_t buffer_addr,
703 u_register_t offset,
704 u_register_t buffer_size,
705 u_register_t *bytes_copied);
706
nabkah01002e5692022-10-10 12:36:46 +0100707/* This function call Host and request to exit Realm with proper exit code */
Shruti Gupta91105082024-11-27 05:29:55 +0000708u_register_t rsi_exit_to_host(enum host_call_cmd exit_code);
nabkah01002e5692022-10-10 12:36:46 +0100709
Shruti Gupta5abab762024-11-27 04:57:53 +0000710/* Function to get Realm configuration. See RSI_REALM_CONFIG */
711u_register_t rsi_realm_config(struct rsi_realm_config *s);
712
713/* Function to enter aux plane. See RSI_PLANE_ENTER */
714u_register_t rsi_plane_enter(u_register_t plane_index, u_register_t run);
715
Arunachalam Ganapathyc58e4692025-01-28 12:28:59 +0000716u_register_t rsi_rdev_get_instance_id(u_register_t rdev_id,
717 u_register_t *rdev_inst_id);
718
719u_register_t rsi_rdev_get_state(u_register_t rdev_id, u_register_t rdev_inst_id,
720 u_register_t *rdev_rsi_state);
721
722u_register_t rsi_rdev_get_measurements(u_register_t rdev_id,
723 u_register_t rdev_inst_id,
724 u_register_t meas_params_ptr);
725
726u_register_t rsi_rdev_get_info(u_register_t rdev_id, u_register_t rdev_inst_id,
727 u_register_t rdev_info_ptr);
728
729u_register_t rsi_rdev_lock(u_register_t rdev_id, u_register_t rdev_inst_id);
730
731u_register_t rsi_rdev_get_interface_report(u_register_t rdev_id,
732 u_register_t rdev_inst_id,
733 u_register_t tdisp_version_max);
734
735u_register_t rsi_rdev_start(u_register_t rdev_id, u_register_t rdev_inst_id);
736
737u_register_t rsi_rdev_stop(u_register_t rdev_id, u_register_t rdev_inst_id);
738
739u_register_t rsi_rdev_continue(u_register_t rdev_id, u_register_t rdev_inst_id);
740
nabkah01002e5692022-10-10 12:36:46 +0100741#endif /* REALM_RSI_H */