Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1 | /* |
| 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 Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 10 | #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 Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 16 | */ |
| 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 | */ |
Soby Mathew | c9b6ecd | 2023-01-17 03:40:44 +0000 | [diff] [blame] | 22 | #define RMI_ABI_VERSION_MAJOR U(56) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 23 | |
| 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 | */ |
Soby Mathew | c9b6ecd | 2023-01-17 03:40:44 +0000 | [diff] [blame] | 28 | #define RMI_ABI_VERSION_MINOR U(0) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 29 | |
Soby Mathew | c9b6ecd | 2023-01-17 03:40:44 +0000 | [diff] [blame] | 30 | #define RMI_ABI_VERSION ((RMI_ABI_VERSION_MAJOR << U(16)) | \ |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 31 | RMI_ABI_VERSION_MINOR) |
| 32 | |
Soby Mathew | c9b6ecd | 2023-01-17 03:40:44 +0000 | [diff] [blame] | 33 | #define RMI_ABI_VERSION_GET_MAJOR(_version) ((_version) >> U(16)) |
| 34 | #define RMI_ABI_VERSION_GET_MINOR(_version) ((_version) & U(0xFFFF)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 35 | |
| 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 A | 0ec040d | 2022-10-31 12:30:57 +0000 | [diff] [blame] | 40 | /* 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 | /* |
| 69 | * An operation cannot be completed because a resource is in use. |
| 70 | * Index is zero. |
| 71 | */ |
| 72 | #define RMI_ERROR_IN_USE U(5) |
| 73 | |
| 74 | /* |
| 75 | * Number of RMI Status Errors. |
| 76 | */ |
| 77 | #define RMI_ERROR_COUNT U(6) |
| 78 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 79 | /* |
| 80 | * The number of GPRs (starting from X0) that are |
| 81 | * configured by the host when a REC is created. |
| 82 | */ |
Soby Mathew | c9b6ecd | 2023-01-17 03:40:44 +0000 | [diff] [blame] | 83 | #define REC_CREATE_NR_GPRS U(8) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 84 | |
Soby Mathew | c9b6ecd | 2023-01-17 03:40:44 +0000 | [diff] [blame] | 85 | #define REC_PARAMS_FLAG_RUNNABLE (UL(1) << 0) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 86 | |
| 87 | /* |
| 88 | * The number of GPRs (starting from X0) per voluntary exit context. |
| 89 | * Per SMCCC. |
| 90 | */ |
Soby Mathew | c9b6ecd | 2023-01-17 03:40:44 +0000 | [diff] [blame] | 91 | #define REC_EXIT_NR_GPRS U(31) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 92 | |
| 93 | /* RmiHashAlgorithm type */ |
Soby Mathew | 3f56a4c | 2023-01-17 02:35:10 +0000 | [diff] [blame] | 94 | #define RMI_HASH_ALGO_SHA256 0 |
| 95 | #define RMI_HASH_ALGO_SHA512 1 |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 96 | |
| 97 | /* Maximum number of Interrupt Controller List Registers */ |
Soby Mathew | c9b6ecd | 2023-01-17 03:40:44 +0000 | [diff] [blame] | 98 | #define REC_GIC_NUM_LRS U(16) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 99 | |
| 100 | /* Maximum number of auxiliary granules required for a REC */ |
Soby Mathew | c9b6ecd | 2023-01-17 03:40:44 +0000 | [diff] [blame] | 101 | #define MAX_REC_AUX_GRANULES U(16) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 102 | |
Soby Mathew | c9b6ecd | 2023-01-17 03:40:44 +0000 | [diff] [blame] | 103 | #define REC_ENTRY_FLAG_EMUL_MMIO (UL(1) << 0) |
| 104 | #define REC_ENTRY_FLAG_INJECT_SEA (UL(1) << 1) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 105 | |
| 106 | /* Flags to specify if WFI/WFE should be trapped to host */ |
Soby Mathew | c9b6ecd | 2023-01-17 03:40:44 +0000 | [diff] [blame] | 107 | #define REC_ENTRY_FLAG_TRAP_WFI (UL(1) << 2) |
| 108 | #define REC_ENTRY_FLAG_TRAP_WFE (UL(1) << 3) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 109 | |
| 110 | /* |
| 111 | * RmiRecExitReason represents the reason for a REC exit. |
| 112 | * This is returned to NS hosts via RMI_REC_ENTER::run_ptr. |
| 113 | */ |
Soby Mathew | c9b6ecd | 2023-01-17 03:40:44 +0000 | [diff] [blame] | 114 | #define RMI_EXIT_SYNC U(0) |
| 115 | #define RMI_EXIT_IRQ U(1) |
| 116 | #define RMI_EXIT_FIQ U(2) |
| 117 | #define RMI_EXIT_PSCI U(3) |
| 118 | #define RMI_EXIT_RIPAS_CHANGE U(4) |
| 119 | #define RMI_EXIT_HOST_CALL U(5) |
| 120 | #define RMI_EXIT_SERROR U(6) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 121 | |
| 122 | /* RmiRttEntryState represents the state of an RTTE */ |
Soby Mathew | c9b6ecd | 2023-01-17 03:40:44 +0000 | [diff] [blame] | 123 | #define RMI_UNASSIGNED U(0) |
| 124 | #define RMI_DESTROYED U(1) |
| 125 | #define RMI_ASSIGNED U(2) |
| 126 | #define RMI_TABLE U(3) |
| 127 | #define RMI_VALID_NS U(4) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 128 | |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 129 | /* RmiFeature enumerations */ |
AlexeiFedorov | c09b165 | 2023-04-04 15:41:37 +0100 | [diff] [blame] | 130 | #define RMI_FEATURE_FALSE UL(0) |
| 131 | #define RMI_FEATURE_TRUE UL(1) |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 132 | |
Yousuf A | a297b9b | 2022-10-13 13:54:21 +0100 | [diff] [blame] | 133 | /* RmiFeatureRegister0 format */ |
| 134 | #define RMM_FEATURE_REGISTER_0_INDEX UL(0) |
| 135 | |
| 136 | #define RMM_FEATURE_REGISTER_0_S2SZ_SHIFT UL(0) |
| 137 | #define RMM_FEATURE_REGISTER_0_S2SZ_WIDTH UL(8) |
| 138 | |
| 139 | #define RMM_FEATURE_REGISTER_0_LPA2_SHIFT UL(8) |
| 140 | #define RMM_FEATURE_REGISTER_0_LPA2_WIDTH UL(1) |
Yousuf A | a297b9b | 2022-10-13 13:54:21 +0100 | [diff] [blame] | 141 | |
AlexeiFedorov | 1800292 | 2023-04-06 10:19:51 +0100 | [diff] [blame] | 142 | #define RMM_FEATURE_REGISTER_0_SVE_EN_SHIFT UL(9) |
| 143 | #define RMM_FEATURE_REGISTER_0_SVE_EN_WIDTH UL(1) |
Yousuf A | a297b9b | 2022-10-13 13:54:21 +0100 | [diff] [blame] | 144 | |
AlexeiFedorov | 1800292 | 2023-04-06 10:19:51 +0100 | [diff] [blame] | 145 | #define RMM_FEATURE_REGISTER_0_SVE_VL_SHIFT UL(10) |
| 146 | #define RMM_FEATURE_REGISTER_0_SVE_VL_WIDTH UL(4) |
Yousuf A | a297b9b | 2022-10-13 13:54:21 +0100 | [diff] [blame] | 147 | |
AlexeiFedorov | 1800292 | 2023-04-06 10:19:51 +0100 | [diff] [blame] | 148 | #define RMM_FEATURE_REGISTER_0_NUM_BPS_SHIFT UL(14) |
| 149 | #define RMM_FEATURE_REGISTER_0_NUM_BPS_WIDTH UL(4) |
| 150 | |
| 151 | #define RMM_FEATURE_REGISTER_0_NUM_WPS_SHIFT UL(18) |
| 152 | #define RMM_FEATURE_REGISTER_0_NUM_WPS_WIDTH UL(4) |
| 153 | |
| 154 | #define RMM_FEATURE_REGISTER_0_PMU_EN_SHIFT UL(22) |
| 155 | #define RMM_FEATURE_REGISTER_0_PMU_EN_WIDTH UL(1) |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 156 | |
| 157 | #define RMM_FEATURE_REGISTER_0_PMU_NUM_CTRS_SHIFT UL(23) |
| 158 | #define RMM_FEATURE_REGISTER_0_PMU_NUM_CTRS_WIDTH UL(5) |
| 159 | |
AlexeiFedorov | 1800292 | 2023-04-06 10:19:51 +0100 | [diff] [blame] | 160 | #define RMM_FEATURE_REGISTER_0_HASH_SHA_256_SHIFT UL(28) |
| 161 | #define RMM_FEATURE_REGISTER_0_HASH_SHA_256_WIDTH UL(1) |
| 162 | |
| 163 | #define RMM_FEATURE_REGISTER_0_HASH_SHA_512_SHIFT UL(29) |
| 164 | #define RMM_FEATURE_REGISTER_0_HASH_SHA_512_WIDTH UL(1) |
Arunachalam Ganapathy | f649121 | 2023-02-23 16:04:34 +0000 | [diff] [blame] | 165 | |
Yousuf A | 6280815 | 2022-10-31 10:35:42 +0000 | [diff] [blame] | 166 | /* The RmmRipas enumeration representing realm IPA state */ |
| 167 | #define RMI_EMPTY (0) |
| 168 | #define RMI_RAM (1) |
| 169 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 170 | /* no parameters */ |
| 171 | #define SMC_RMM_VERSION SMC64_RMI_FID(U(0x0)) |
| 172 | |
| 173 | /* |
| 174 | * arg0 == target granule address |
| 175 | */ |
| 176 | #define SMC_RMM_GRANULE_DELEGATE SMC64_RMI_FID(U(0x1)) |
| 177 | |
| 178 | /* |
| 179 | * arg0 == target granule address |
| 180 | */ |
| 181 | #define SMC_RMM_GRANULE_UNDELEGATE SMC64_RMI_FID(U(0x2)) |
| 182 | |
| 183 | /* RmiDataMeasureContent type */ |
| 184 | #define RMI_NO_MEASURE_CONTENT 0 |
| 185 | #define RMI_MEASURE_CONTENT 1 |
| 186 | |
| 187 | /* |
AlexeiFedorov | ac923c8 | 2023-04-06 15:12:04 +0100 | [diff] [blame^] | 188 | * arg0 == RD address |
| 189 | * arg1 == data address |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 190 | * arg2 == map address |
| 191 | * arg3 == SRC address |
| 192 | * arg4 == flags |
| 193 | */ |
| 194 | #define SMC_RMM_DATA_CREATE SMC64_RMI_FID(U(0x3)) |
| 195 | |
| 196 | /* |
AlexeiFedorov | ac923c8 | 2023-04-06 15:12:04 +0100 | [diff] [blame^] | 197 | * arg0 == RD address |
| 198 | * arg1 == data address |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 199 | * arg2 == map address |
| 200 | */ |
| 201 | #define SMC_RMM_DATA_CREATE_UNKNOWN SMC64_RMI_FID(U(0x4)) |
| 202 | |
| 203 | /* |
| 204 | * arg0 == RD address |
| 205 | * arg1 == map address |
| 206 | */ |
| 207 | #define SMC_RMM_DATA_DESTROY SMC64_RMI_FID(U(0x5)) |
| 208 | |
| 209 | /* |
| 210 | * arg0 == RD address |
| 211 | */ |
| 212 | #define SMC_RMM_REALM_ACTIVATE SMC64_RMI_FID(U(0x7)) |
| 213 | |
| 214 | /* |
| 215 | * arg0 == RD address |
AlexeiFedorov | ac923c8 | 2023-04-06 15:12:04 +0100 | [diff] [blame^] | 216 | * arg1 == struct rmi_realm_params address |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 217 | */ |
| 218 | #define SMC_RMM_REALM_CREATE SMC64_RMI_FID(U(0x8)) |
| 219 | |
| 220 | /* |
| 221 | * arg0 == RD address |
| 222 | */ |
| 223 | #define SMC_RMM_REALM_DESTROY SMC64_RMI_FID(U(0x9)) |
| 224 | |
| 225 | /* |
AlexeiFedorov | ac923c8 | 2023-04-06 15:12:04 +0100 | [diff] [blame^] | 226 | * arg0 == RD address |
| 227 | * arg1 == REC address |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 228 | * arg2 == struct rmm_rec address |
| 229 | */ |
| 230 | #define SMC_RMM_REC_CREATE SMC64_RMI_FID(U(0xA)) |
| 231 | |
| 232 | /* |
| 233 | * arg0 == REC address |
| 234 | */ |
| 235 | #define SMC_RMM_REC_DESTROY SMC64_RMI_FID(U(0xB)) |
| 236 | |
| 237 | /* |
| 238 | * arg0 == rec address |
AlexeiFedorov | ac923c8 | 2023-04-06 15:12:04 +0100 | [diff] [blame^] | 239 | * arg1 == struct rec_run address |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 240 | */ |
| 241 | #define SMC_RMM_REC_ENTER SMC64_RMI_FID(U(0xC)) |
| 242 | |
| 243 | /* |
AlexeiFedorov | ac923c8 | 2023-04-06 15:12:04 +0100 | [diff] [blame^] | 244 | * arg0 == RD address |
| 245 | * arg1 == RTT address |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 246 | * arg2 == map address |
| 247 | * arg3 == level |
| 248 | */ |
| 249 | #define SMC_RMM_RTT_CREATE SMC64_RMI_FID(U(0xD)) |
| 250 | |
| 251 | /* |
| 252 | * arg0 == RTT address |
| 253 | * arg1 == RD address |
| 254 | * arg2 == map address |
| 255 | * arg3 == level |
| 256 | */ |
| 257 | #define SMC_RMM_RTT_DESTROY SMC64_RMI_FID(U(0xE)) |
| 258 | |
| 259 | /* |
| 260 | * arg0 == RD address |
| 261 | * arg1 == map address |
| 262 | * arg2 == level |
| 263 | * arg3 == s2tte |
| 264 | */ |
| 265 | #define SMC_RMM_RTT_MAP_UNPROTECTED SMC64_RMI_FID(U(0xF)) |
| 266 | |
| 267 | /* |
| 268 | * arg0 == RD address |
| 269 | * arg1 == map address |
| 270 | * arg2 == level |
| 271 | * ret1 == level |
| 272 | * ret2 == s2tte type |
| 273 | * ret3 == s2tte |
| 274 | * ret4 == ripas |
| 275 | */ |
| 276 | #define SMC_RMM_RTT_READ_ENTRY SMC64_RMI_FID(U(0x11)) |
| 277 | |
| 278 | /* |
| 279 | * arg0 == RD address |
| 280 | * arg1 == map address |
| 281 | * arg2 == level |
| 282 | */ |
| 283 | #define SMC_RMM_RTT_UNMAP_UNPROTECTED SMC64_RMI_FID(U(0x12)) |
| 284 | |
| 285 | /* |
| 286 | * arg0 == calling rec address |
| 287 | * arg1 == target rec address |
| 288 | */ |
| 289 | #define SMC_RMM_PSCI_COMPLETE SMC64_RMI_FID(U(0x14)) |
| 290 | |
| 291 | /* |
| 292 | * arg0 == Feature register index |
| 293 | */ |
| 294 | #define SMC_RMM_FEATURES SMC64_RMI_FID(U(0x15)) |
| 295 | |
| 296 | /* |
| 297 | * arg0 == RTT address |
| 298 | * arg1 == RD address |
| 299 | * arg2 == map address |
| 300 | * arg3 == level |
| 301 | */ |
| 302 | #define SMC_RMM_RTT_FOLD SMC64_RMI_FID(U(0x16)) |
| 303 | |
| 304 | /* |
| 305 | * arg0 == RD address |
| 306 | */ |
| 307 | #define SMC_RMM_REC_AUX_COUNT SMC64_RMI_FID(U(0x17)) |
| 308 | |
| 309 | /* |
AlexeiFedorov | ac923c8 | 2023-04-06 15:12:04 +0100 | [diff] [blame^] | 310 | * arg0 == RD address |
| 311 | * arg1 == map address |
| 312 | * arg2 == level |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 313 | */ |
| 314 | #define SMC_RMM_RTT_INIT_RIPAS SMC64_RMI_FID(U(0x18)) |
| 315 | |
| 316 | /* |
| 317 | * arg0 == RD address |
| 318 | * arg1 == REC address |
| 319 | * arg2 == map address |
| 320 | * arg3 == level |
| 321 | * arg4 == ripas |
| 322 | */ |
| 323 | #define SMC_RMM_RTT_SET_RIPAS SMC64_RMI_FID(U(0x19)) |
| 324 | |
| 325 | /* Size of Realm Personalization Value */ |
| 326 | #define RPV_SIZE 64 |
| 327 | |
AlexeiFedorov | 1800292 | 2023-04-06 10:19:51 +0100 | [diff] [blame] | 328 | /* RmiRealmFlags format */ |
| 329 | #define RMI_REALM_FLAGS_LPA2_SHIFT UL(0) |
| 330 | #define RMI_REALM_FLAGS_LPA2_WIDTH UL(1) |
| 331 | |
| 332 | #define RMI_REALM_FLAGS_SVE_SHIFT UL(1) |
| 333 | #define RMI_REALM_FLAGS_SVE_WIDTH UL(1) |
| 334 | |
| 335 | #define RMI_REALM_FLAGS_PMU_SHIFT UL(2) |
| 336 | #define RMI_REALM_FLAGS_PMU_WIDTH UL(1) |
| 337 | |
Soby Mathew | c9b6ecd | 2023-01-17 03:40:44 +0000 | [diff] [blame] | 338 | #ifndef __ASSEMBLER__ |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 339 | /* |
Soby Mathew | c414f2a | 2023-01-17 02:50:17 +0000 | [diff] [blame] | 340 | * Defines member of structure and reserves space |
| 341 | * for the next member with specified offset. |
| 342 | */ |
| 343 | #define SET_MEMBER_RMI SET_MEMBER |
| 344 | |
| 345 | /* |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 346 | * The Realm attribute parameters are shared by the Host via |
| 347 | * RMI_REALM_CREATE::params_ptr. The values can be observed or modified |
| 348 | * either by the Host or by the Realm. |
| 349 | */ |
| 350 | struct rmi_realm_params { |
AlexeiFedorov | 1800292 | 2023-04-06 10:19:51 +0100 | [diff] [blame] | 351 | /* Flags */ |
| 352 | SET_MEMBER_RMI(unsigned long flags, 0, 0x8); /* Offset 0 */ |
| 353 | /* Requested IPA width */ |
| 354 | SET_MEMBER_RMI(unsigned int s2sz, 0x8, 0x10); /* 0x8 */ |
| 355 | /* Requested SVE vector length */ |
| 356 | SET_MEMBER_RMI(unsigned int sve_vl, 0x10, 0x18); /* 0x10 */ |
| 357 | /* Requested number of breakpoints */ |
| 358 | SET_MEMBER_RMI(unsigned int num_bps, 0x18, 0x20); /* 0x18 */ |
| 359 | /* Requested number of watchpoints */ |
| 360 | SET_MEMBER_RMI(unsigned int num_wps, 0x20, 0x28); /* 0x20 */ |
| 361 | /* Requested number of PMU counters */ |
| 362 | SET_MEMBER_RMI(unsigned int pmu_num_ctrs, 0x28, 0x30); /* 0x28 */ |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 363 | /* Measurement algorithm */ |
AlexeiFedorov | 1800292 | 2023-04-06 10:19:51 +0100 | [diff] [blame] | 364 | SET_MEMBER_RMI(unsigned char hash_algo, 0x30, 0x400); /* 0x30 */ |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 365 | /* Realm Personalization Value */ |
AlexeiFedorov | 1800292 | 2023-04-06 10:19:51 +0100 | [diff] [blame] | 366 | SET_MEMBER_RMI(unsigned char rpv[RPV_SIZE], 0x400, 0x800); /* 0x400 */ |
Soby Mathew | c414f2a | 2023-01-17 02:50:17 +0000 | [diff] [blame] | 367 | SET_MEMBER_RMI(struct { |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 368 | /* Virtual Machine Identifier */ |
| 369 | unsigned short vmid; /* 0x800 */ |
| 370 | /* Realm Translation Table base */ |
| 371 | unsigned long rtt_base; /* 0x808 */ |
| 372 | /* RTT starting level */ |
| 373 | long rtt_level_start; /* 0x810 */ |
| 374 | /* Number of starting level RTTs */ |
| 375 | unsigned int rtt_num_start; /* 0x818 */ |
| 376 | }, 0x800, 0x1000); |
| 377 | }; |
| 378 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 379 | /* |
| 380 | * The REC attribute parameters are shared by the Host via |
| 381 | * MI_REC_CREATE::params_ptr. The values can be observed or modified |
| 382 | * either by the Host or by the Realm which owns the REC. |
| 383 | */ |
| 384 | struct rmi_rec_params { |
| 385 | /* Flags */ |
Soby Mathew | c414f2a | 2023-01-17 02:50:17 +0000 | [diff] [blame] | 386 | SET_MEMBER_RMI(unsigned long flags, 0, 0x100); /* Offset 0 */ |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 387 | /* MPIDR of the REC */ |
Soby Mathew | c414f2a | 2023-01-17 02:50:17 +0000 | [diff] [blame] | 388 | SET_MEMBER_RMI(unsigned long mpidr, 0x100, 0x200); /* 0x100 */ |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 389 | /* Program counter */ |
Soby Mathew | c414f2a | 2023-01-17 02:50:17 +0000 | [diff] [blame] | 390 | SET_MEMBER_RMI(unsigned long pc, 0x200, 0x300); /* 0x200 */ |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 391 | /* General-purpose registers */ |
Soby Mathew | c414f2a | 2023-01-17 02:50:17 +0000 | [diff] [blame] | 392 | SET_MEMBER_RMI(unsigned long gprs[REC_CREATE_NR_GPRS], 0x300, 0x800); /* 0x300 */ |
| 393 | SET_MEMBER_RMI(struct { |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 394 | /* Number of auxiliary Granules */ |
| 395 | unsigned long num_aux; /* 0x800 */ |
| 396 | /* Addresses of auxiliary Granules */ |
| 397 | unsigned long aux[MAX_REC_AUX_GRANULES];/* 0x808 */ |
| 398 | }, 0x800, 0x1000); |
| 399 | }; |
| 400 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 401 | /* |
| 402 | * Structure contains data passed from the Host to the RMM on REC entry |
| 403 | */ |
| 404 | struct rmi_rec_entry { |
| 405 | /* Flags */ |
Soby Mathew | c414f2a | 2023-01-17 02:50:17 +0000 | [diff] [blame] | 406 | SET_MEMBER_RMI(unsigned long flags, 0, 0x200); /* Offset 0 */ |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 407 | /* General-purpose registers */ |
Soby Mathew | c414f2a | 2023-01-17 02:50:17 +0000 | [diff] [blame] | 408 | SET_MEMBER_RMI(unsigned long gprs[REC_EXIT_NR_GPRS], 0x200, 0x300); /* 0x200 */ |
| 409 | SET_MEMBER_RMI(struct { |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 410 | /* GICv3 Hypervisor Control Register */ |
| 411 | unsigned long gicv3_hcr; /* 0x300 */ |
| 412 | /* GICv3 List Registers */ |
| 413 | unsigned long gicv3_lrs[REC_GIC_NUM_LRS]; /* 0x308 */ |
| 414 | }, 0x300, 0x800); |
| 415 | }; |
| 416 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 417 | /* |
| 418 | * Structure contains data passed from the RMM to the Host on REC exit |
| 419 | */ |
| 420 | struct rmi_rec_exit { |
| 421 | /* Exit reason */ |
Soby Mathew | c414f2a | 2023-01-17 02:50:17 +0000 | [diff] [blame] | 422 | SET_MEMBER_RMI(unsigned long exit_reason, 0, 0x100);/* Offset 0 */ |
| 423 | SET_MEMBER_RMI(struct { |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 424 | /* Exception Syndrome Register */ |
| 425 | unsigned long esr; /* 0x100 */ |
| 426 | /* Fault Address Register */ |
| 427 | unsigned long far; /* 0x108 */ |
| 428 | /* Hypervisor IPA Fault Address register */ |
| 429 | unsigned long hpfar; /* 0x110 */ |
| 430 | }, 0x100, 0x200); |
| 431 | /* General-purpose registers */ |
Soby Mathew | c414f2a | 2023-01-17 02:50:17 +0000 | [diff] [blame] | 432 | SET_MEMBER_RMI(unsigned long gprs[REC_EXIT_NR_GPRS], 0x200, 0x300); /* 0x200 */ |
| 433 | SET_MEMBER_RMI(struct { |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 434 | /* GICv3 Hypervisor Control Register */ |
| 435 | unsigned long gicv3_hcr; /* 0x300 */ |
| 436 | /* GICv3 List Registers */ |
| 437 | unsigned long gicv3_lrs[REC_GIC_NUM_LRS]; /* 0x308 */ |
| 438 | /* GICv3 Maintenance Interrupt State Register */ |
| 439 | unsigned long gicv3_misr; /* 0x388 */ |
| 440 | /* GICv3 Virtual Machine Control Register */ |
| 441 | unsigned long gicv3_vmcr; /* 0x390 */ |
| 442 | }, 0x300, 0x400); |
Soby Mathew | c414f2a | 2023-01-17 02:50:17 +0000 | [diff] [blame] | 443 | SET_MEMBER_RMI(struct { |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 444 | /* Counter-timer Physical Timer Control Register */ |
| 445 | unsigned long cntp_ctl; /* 0x400 */ |
| 446 | /* Counter-timer Physical Timer CompareValue Register */ |
| 447 | unsigned long cntp_cval; /* 0x408 */ |
| 448 | /* Counter-timer Virtual Timer Control Register */ |
| 449 | unsigned long cntv_ctl; /* 0x410 */ |
| 450 | /* Counter-timer Virtual Timer CompareValue Register */ |
| 451 | unsigned long cntv_cval; /* 0x418 */ |
| 452 | }, 0x400, 0x500); |
Soby Mathew | c414f2a | 2023-01-17 02:50:17 +0000 | [diff] [blame] | 453 | SET_MEMBER_RMI(struct { |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 454 | /* Base address of pending RIPAS change */ |
| 455 | unsigned long ripas_base; /* 0x500 */ |
| 456 | /* Size of pending RIPAS change */ |
| 457 | unsigned long ripas_size; /* 0x508 */ |
| 458 | /* RIPAS value of pending RIPAS change */ |
| 459 | unsigned char ripas_value; /* 0x510 */ |
| 460 | }, 0x500, 0x600); |
| 461 | /* Host call immediate value */ |
AlexeiFedorov | eaec0c4 | 2023-02-01 18:13:32 +0000 | [diff] [blame] | 462 | SET_MEMBER_RMI(unsigned int imm, 0x600, 0x700); /* 0x600 */ |
| 463 | |
| 464 | /* PMU overflow */ |
| 465 | SET_MEMBER_RMI(unsigned long pmu_ovf, 0x700, 0x708); /* 0x700 */ |
| 466 | |
| 467 | /* PMU interrupt enable */ |
| 468 | SET_MEMBER_RMI(unsigned long pmu_intr_en, 0x708, 0x710); /* 0x708 */ |
| 469 | |
| 470 | /* PMU counter enable */ |
| 471 | SET_MEMBER_RMI(unsigned long pmu_cntr_en, 0x710, 0x800); /* 0x710 */ |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 472 | }; |
| 473 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 474 | /* |
| 475 | * Structure contains shared information between RMM and Host |
| 476 | * during REC entry and REC exit. |
| 477 | */ |
| 478 | struct rmi_rec_run { |
| 479 | /* Entry information */ |
Soby Mathew | c414f2a | 2023-01-17 02:50:17 +0000 | [diff] [blame] | 480 | SET_MEMBER_RMI(struct rmi_rec_entry entry, 0, 0x800); /* Offset 0 */ |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 481 | /* Exit information */ |
AlexeiFedorov | eaec0c4 | 2023-02-01 18:13:32 +0000 | [diff] [blame] | 482 | SET_MEMBER_RMI(struct rmi_rec_exit exit, 0x800, 0x1000);/* 0x800 */ |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 483 | }; |
| 484 | |
Soby Mathew | c9b6ecd | 2023-01-17 03:40:44 +0000 | [diff] [blame] | 485 | #endif /* __ASSEMBLER__ */ |
| 486 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 487 | #endif /* SMC_RMI_H */ |