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