Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * SPDX-License-Identifier: BSD-3-Clause |
| 3 | * SPDX-FileCopyrightText: Copyright TF-RMM Contributors. |
| 4 | */ |
| 5 | |
| 6 | #include <arch_helpers.h> |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 7 | #include <bitmap.h> |
| 8 | #include <buffer.h> |
| 9 | #include <gic.h> |
| 10 | #include <granule.h> |
| 11 | #include <memory_alloc.h> |
| 12 | #include <realm.h> |
| 13 | #include <ripas.h> |
| 14 | #include <smc.h> |
| 15 | #include <status.h> |
| 16 | #include <stddef.h> |
| 17 | #include <string.h> |
| 18 | #include <table.h> |
| 19 | |
| 20 | /* |
| 21 | * For prototyping we assume 4K pages |
| 22 | */ |
| 23 | #define BLOCK_L2_SIZE (GRANULE_SIZE * S2TTES_PER_S2TT) |
| 24 | |
| 25 | /* |
| 26 | * The maximum number of bits supported by the RMM for a stage 2 translation |
| 27 | * output address (including stage 2 table entries). |
| 28 | */ |
| 29 | #define S2TTE_OA_BITS 48 |
| 30 | |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 31 | #define DESC_TYPE_MASK 3UL |
| 32 | #define S2TTE_Lx_INVALID 0UL |
| 33 | #define S2TTE_L012_BLOCK 1UL |
| 34 | #define S2TTE_L012_TABLE 3UL |
| 35 | #define S2TTE_L3_PAGE 3UL |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 36 | |
| 37 | /* |
| 38 | * The following constants for the mapping attributes (S2_TTE_MEMATTR_*) |
| 39 | * assume that HCR_EL2.FWB is set. |
| 40 | */ |
| 41 | #define S2TTE_MEMATTR_SHIFT 2 |
| 42 | #define S2TTE_MEMATTR_MASK (0x7UL << S2TTE_MEMATTR_SHIFT) |
| 43 | #define S2TTE_MEMATTR_FWB_NORMAL_WB ((1UL << 4) | (2UL << 2)) |
| 44 | #define S2TTE_MEMATTR_FWB_RESERVED ((1UL << 4) | (0UL << 2)) |
| 45 | |
| 46 | #define S2TTE_AP_SHIFT 6 |
| 47 | #define S2TTE_AP_MASK (3UL << S2TTE_AP_SHIFT) |
| 48 | #define S2TTE_AP_RW (3UL << S2TTE_AP_SHIFT) |
| 49 | |
| 50 | #define S2TTE_SH_SHIFT 8 |
| 51 | #define S2TTE_SH_MASK (3UL << S2TTE_SH_SHIFT) |
| 52 | #define S2TTE_SH_NS (0UL << S2TTE_SH_SHIFT) |
| 53 | #define S2TTE_SH_RESERVED (1UL << S2TTE_SH_SHIFT) |
| 54 | #define S2TTE_SH_OS (2UL << S2TTE_SH_SHIFT) |
| 55 | #define S2TTE_SH_IS (3UL << S2TTE_SH_SHIFT) /* Inner Shareable */ |
| 56 | |
| 57 | /* |
| 58 | * We set HCR_EL2.FWB So we set bit[4] to 1 and bits[3:2] to 2 and force |
| 59 | * everyting to be Normal Write-Back |
| 60 | */ |
| 61 | #define S2TTE_MEMATTR_FWB_NORMAL_WB ((1UL << 4) | (2UL << 2)) |
| 62 | #define S2TTE_AF (1UL << 10) |
| 63 | #define S2TTE_XN (2UL << 53) |
| 64 | #define S2TTE_NS (1UL << 55) |
| 65 | |
| 66 | #define S2TTE_ATTRS (S2TTE_MEMATTR_FWB_NORMAL_WB | S2TTE_AP_RW | \ |
| 67 | S2TTE_SH_IS | S2TTE_AF) |
| 68 | |
| 69 | #define S2TTE_TABLE S2TTE_L012_TABLE |
| 70 | #define S2TTE_BLOCK (S2TTE_ATTRS | S2TTE_L012_BLOCK) |
| 71 | #define S2TTE_PAGE (S2TTE_ATTRS | S2TTE_L3_PAGE) |
| 72 | #define S2TTE_BLOCK_NS (S2TTE_NS | S2TTE_XN | S2TTE_AF | S2TTE_L012_BLOCK) |
| 73 | #define S2TTE_PAGE_NS (S2TTE_NS | S2TTE_XN | S2TTE_AF | S2TTE_L3_PAGE) |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 74 | #define S2TTE_INVALID S2TTE_Lx_INVALID |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 75 | |
| 76 | /* |
AlexeiFedorov | 5ceff35 | 2023-04-12 16:17:00 +0100 | [diff] [blame] | 77 | * The type of stage 2 translation table entry (s2tte) is defined by: |
| 78 | * 1. Table level where it resides |
| 79 | * 2. DESC_TYPE field[1:0] |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 80 | * 4. HIPAS field [4:2] |
| 81 | * 4. RIPAS field [6:5] |
AlexeiFedorov | 5ceff35 | 2023-04-12 16:17:00 +0100 | [diff] [blame] | 82 | * 5. NS field [55] |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 83 | * |
AlexeiFedorov | 63614ea | 2023-07-14 17:07:20 +0100 | [diff] [blame] | 84 | * ====================================================================================== |
| 85 | * s2tte type level DESC_TYPE[1:0] HIPAS[4:2] RIPAS[6:5] NS OA alignment |
| 86 | * ====================================================================================== |
| 87 | * unassigned_empty any invalid[0] unassigned[0] empty[0] 0 n/a |
| 88 | * -------------------------------------------------------------------------------------- |
| 89 | * unassigned_ram any invalid[0] unassigned[0] ram[1] 0 n/a |
| 90 | * -------------------------------------------------------------------------------------- |
| 91 | * unassigned_destroyed any invalid[0] unassigned[0] destroyed[2] 0 n/a |
| 92 | * -------------------------------------------------------------------------------------- |
| 93 | * assigned_empty 2,3 invalid[0] assigned[1] empty[0] 0 to level |
| 94 | * -------------------------------------------------------------------------------------- |
| 95 | * assigned_ram 3 page[3] n/a n/a 0 to level |
| 96 | * 2 block[1] n/a n/a 0 to level |
| 97 | * -------------------------------------------------------------------------------------- |
| 98 | * assigned_destroyed any invalid[0] assigned[1] destroyed[2] 0 n/a |
| 99 | * ====================================================================================== |
| 100 | * unassigned_ns any invalid[0] unassigned[0] n/a 1 n/a |
| 101 | * -------------------------------------------------------------------------------------- |
| 102 | * assigned_ns 3 page[3] n/a n/a 1 to level |
| 103 | * 2 block[1] n/a n/a 1 to level |
| 104 | * ====================================================================================== |
| 105 | * table <=2 table[3] n/a n/a n/a to 4K |
| 106 | * ====================================================================================== |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 107 | */ |
| 108 | |
| 109 | #define S2TTE_INVALID_HIPAS_SHIFT 2 |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 110 | #define S2TTE_INVALID_HIPAS_WIDTH 3 |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 111 | #define S2TTE_INVALID_HIPAS_MASK MASK(S2TTE_INVALID_HIPAS) |
| 112 | |
| 113 | #define S2TTE_INVALID_HIPAS_UNASSIGNED (INPLACE(S2TTE_INVALID_HIPAS, 0)) |
| 114 | #define S2TTE_INVALID_HIPAS_ASSIGNED (INPLACE(S2TTE_INVALID_HIPAS, 1)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 115 | |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 116 | #define S2TTE_INVALID_RIPAS_SHIFT 5 |
| 117 | #define S2TTE_INVALID_RIPAS_WIDTH 2 |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 118 | #define S2TTE_INVALID_RIPAS_MASK MASK(S2TTE_INVALID_RIPAS) |
| 119 | |
| 120 | #define S2TTE_INVALID_RIPAS_EMPTY (INPLACE(S2TTE_INVALID_RIPAS, 0)) |
| 121 | #define S2TTE_INVALID_RIPAS_RAM (INPLACE(S2TTE_INVALID_RIPAS, 1)) |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 122 | #define S2TTE_INVALID_RIPAS_DESTROYED (INPLACE(S2TTE_INVALID_RIPAS, 2)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 123 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 124 | #define S2TTE_INVALID_UNPROTECTED 0x0UL |
| 125 | |
| 126 | #define NR_RTT_LEVELS 4 |
| 127 | |
| 128 | /* |
| 129 | * Invalidates S2 TLB entries from [ipa, ipa + size] region tagged with `vmid`. |
| 130 | */ |
| 131 | static void stage2_tlbi_ipa(const struct realm_s2_context *s2_ctx, |
| 132 | unsigned long ipa, |
| 133 | unsigned long size) |
| 134 | { |
| 135 | /* |
| 136 | * Notes: |
| 137 | * |
| 138 | * - This follows the description provided in the Arm ARM on |
| 139 | * "Invalidation of TLB entries from stage 2 translations". |
| 140 | * |
| 141 | * - @TODO: Provide additional information to this primitive so that |
| 142 | * we can utilize: |
| 143 | * - The TTL level hint, see FEAT_TTL, |
| 144 | * - Final level lookup only invalidation, |
| 145 | * - Address range invalidation. |
| 146 | */ |
| 147 | |
| 148 | /* |
| 149 | * Save the current content of vttb_el2. |
| 150 | */ |
| 151 | unsigned long old_vttbr_el2 = read_vttbr_el2(); |
| 152 | |
| 153 | /* |
| 154 | * Make 'vmid' the `current vmid`. Note that the tlbi instructions |
| 155 | * bellow target the TLB entries that match the `current vmid`. |
| 156 | */ |
| 157 | write_vttbr_el2(INPLACE(VTTBR_EL2_VMID, s2_ctx->vmid)); |
| 158 | isb(); |
| 159 | |
| 160 | /* |
| 161 | * Invalidate entries in S2 TLB caches that |
| 162 | * match both `ipa` & the `current vmid`. |
| 163 | */ |
| 164 | while (size != 0UL) { |
| 165 | tlbiipas2e1is(ipa >> 12); |
| 166 | size -= GRANULE_SIZE; |
| 167 | ipa += GRANULE_SIZE; |
| 168 | } |
| 169 | dsb(ish); |
| 170 | |
| 171 | /* |
| 172 | * The architecture does not require TLB invalidation by IPA to affect |
| 173 | * combined Stage-1 + Stage-2 TLBs. Therefore we must invalidate all of |
| 174 | * Stage-1 (tagged with the `current vmid`) after invalidating Stage-2. |
| 175 | */ |
| 176 | tlbivmalle1is(); |
| 177 | dsb(ish); |
| 178 | isb(); |
| 179 | |
| 180 | /* |
| 181 | * Restore the old content of vttb_el2. |
| 182 | */ |
| 183 | write_vttbr_el2(old_vttbr_el2); |
| 184 | isb(); |
| 185 | } |
| 186 | |
| 187 | /* |
| 188 | * Invalidate S2 TLB entries with "addr" IPA. |
| 189 | * Call this function after: |
| 190 | * 1. A L3 page desc has been removed. |
| 191 | */ |
| 192 | void invalidate_page(const struct realm_s2_context *s2_ctx, unsigned long addr) |
| 193 | { |
| 194 | stage2_tlbi_ipa(s2_ctx, addr, GRANULE_SIZE); |
| 195 | } |
| 196 | |
| 197 | /* |
| 198 | * Invalidate S2 TLB entries with "addr" IPA. |
| 199 | * Call this function after: |
| 200 | * 1. A L2 block desc has been removed, or |
| 201 | * 2a. A L2 table desc has been removed, where |
| 202 | * 2b. All S2TTEs in L3 table that the L2 table desc was pointed to were invalid. |
| 203 | */ |
| 204 | void invalidate_block(const struct realm_s2_context *s2_ctx, unsigned long addr) |
| 205 | { |
| 206 | stage2_tlbi_ipa(s2_ctx, addr, GRANULE_SIZE); |
| 207 | } |
| 208 | |
| 209 | /* |
| 210 | * Invalidate S2 TLB entries with "addr" IPA. |
| 211 | * Call this function after: |
| 212 | * 1a. A L2 table desc has been removed, where |
| 213 | * 1b. Some S2TTEs in the table that the L2 table desc was pointed to were valid. |
| 214 | */ |
| 215 | void invalidate_pages_in_block(const struct realm_s2_context *s2_ctx, unsigned long addr) |
| 216 | { |
| 217 | stage2_tlbi_ipa(s2_ctx, addr, BLOCK_L2_SIZE); |
| 218 | } |
| 219 | |
| 220 | /* |
| 221 | * Return the index of the entry describing @addr in the translation table at |
| 222 | * level @level. This only works for non-concatenated page tables, so should |
| 223 | * not be called to get the index for the starting level. |
| 224 | * |
| 225 | * See the library pseudocode |
| 226 | * aarch64/translation/vmsa_addrcalc/AArch64.TTEntryAddress on which this is |
| 227 | * modeled. |
| 228 | */ |
| 229 | static unsigned long s2_addr_to_idx(unsigned long addr, long level) |
| 230 | { |
| 231 | int levels = RTT_PAGE_LEVEL - level; |
| 232 | int lsb = levels * S2TTE_STRIDE + GRANULE_SHIFT; |
| 233 | |
| 234 | addr >>= lsb; |
| 235 | addr &= (1UL << S2TTE_STRIDE) - 1; |
| 236 | return addr; |
| 237 | } |
| 238 | |
| 239 | /* |
| 240 | * Return the index of the entry describing @addr in the translation table |
| 241 | * starting level. This may return an index >= S2TTES_PER_S2TT when the |
| 242 | * combination of @start_level and @ipa_bits implies concatenated |
| 243 | * stage 2 tables. |
| 244 | * |
| 245 | * See the library pseudocode |
| 246 | * aarch64/translation/vmsa_addrcalc/AArch64.S2SLTTEntryAddress on which |
| 247 | * this is modeled. |
| 248 | */ |
| 249 | static unsigned long s2_sl_addr_to_idx(unsigned long addr, int start_level, |
| 250 | unsigned long ipa_bits) |
| 251 | { |
| 252 | int levels = RTT_PAGE_LEVEL - start_level; |
| 253 | int lsb = levels * S2TTE_STRIDE + GRANULE_SHIFT; |
| 254 | |
| 255 | addr &= (1UL << ipa_bits) - 1UL; |
| 256 | addr >>= lsb; |
| 257 | return addr; |
| 258 | } |
| 259 | |
AlexeiFedorov | 14d47ae | 2023-07-19 15:26:50 +0100 | [diff] [blame^] | 260 | unsigned long addr_level_mask(unsigned long addr, long level) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 261 | { |
| 262 | int levels = RTT_PAGE_LEVEL - level; |
| 263 | unsigned int lsb = levels * S2TTE_STRIDE + GRANULE_SHIFT; |
| 264 | unsigned int msb = S2TTE_OA_BITS - 1; |
| 265 | |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 266 | return (addr & BIT_MASK_ULL(msb, lsb)); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | static inline unsigned long table_entry_to_phys(unsigned long entry) |
| 270 | { |
| 271 | return addr_level_mask(entry, RTT_PAGE_LEVEL); |
| 272 | } |
| 273 | |
| 274 | static inline bool entry_is_table(unsigned long entry) |
| 275 | { |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 276 | return ((entry & DESC_TYPE_MASK) == S2TTE_L012_TABLE); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | static unsigned long __table_get_entry(struct granule *g_tbl, |
| 280 | unsigned long idx) |
| 281 | { |
| 282 | unsigned long *table, entry; |
| 283 | |
| 284 | table = granule_map(g_tbl, SLOT_RTT); |
| 285 | entry = s2tte_read(&table[idx]); |
| 286 | buffer_unmap(table); |
| 287 | |
| 288 | return entry; |
| 289 | } |
| 290 | |
| 291 | static struct granule *__find_next_level_idx(struct granule *g_tbl, |
| 292 | unsigned long idx) |
| 293 | { |
| 294 | const unsigned long entry = __table_get_entry(g_tbl, idx); |
| 295 | |
| 296 | if (!entry_is_table(entry)) { |
| 297 | return NULL; |
| 298 | } |
| 299 | |
| 300 | return addr_to_granule(table_entry_to_phys(entry)); |
| 301 | } |
| 302 | |
| 303 | static struct granule *__find_lock_next_level(struct granule *g_tbl, |
| 304 | unsigned long map_addr, |
| 305 | long level) |
| 306 | { |
| 307 | const unsigned long idx = s2_addr_to_idx(map_addr, level); |
| 308 | struct granule *g = __find_next_level_idx(g_tbl, idx); |
| 309 | |
| 310 | if (g != NULL) { |
| 311 | granule_lock(g, GRANULE_STATE_RTT); |
| 312 | } |
| 313 | |
| 314 | return g; |
| 315 | } |
| 316 | |
| 317 | /* |
| 318 | * Walk an RTT until level @level using @map_addr. |
| 319 | * @g_root is the root (level 0) table and must be locked before the call. |
| 320 | * @start_level is the initial lookup level used for the stage 2 translation |
| 321 | * tables which may depend on the configuration of the realm, factoring in the |
| 322 | * IPA size of the realm and the desired starting level (within the limits |
| 323 | * defined by the Armv8 VMSA including options for stage 2 table concatenation). |
| 324 | * The function uses hand-over-hand locking to avoid race conditions and allow |
| 325 | * concurrent access to RTT tree which is not part of the current walk; when a |
| 326 | * next level table is reached it is locked before releasing previously locked |
| 327 | * table. |
| 328 | * The walk stops when either: |
| 329 | * - The entry found is a leaf entry (not an RTT Table entry), or |
| 330 | * - Level @level is reached. |
| 331 | * |
| 332 | * On return: |
| 333 | * - rtt_walk::last_level is the last level that has been reached by the walk. |
| 334 | * - rtt_walk.g_llt points to the TABLE granule at level @rtt_walk::level. |
| 335 | * The granule is locked. |
| 336 | * - rtt_walk::index is the entry index at rtt_walk.g_llt for @map_addr. |
| 337 | */ |
| 338 | void rtt_walk_lock_unlock(struct granule *g_root, |
| 339 | int start_level, |
| 340 | unsigned long ipa_bits, |
| 341 | unsigned long map_addr, |
| 342 | long level, |
| 343 | struct rtt_walk *wi) |
| 344 | { |
| 345 | struct granule *g_tbls[NR_RTT_LEVELS] = { NULL }; |
| 346 | unsigned long sl_idx; |
| 347 | int i, last_level; |
| 348 | |
| 349 | assert(start_level >= MIN_STARTING_LEVEL); |
| 350 | assert(level >= start_level); |
| 351 | assert(map_addr < (1UL << ipa_bits)); |
| 352 | assert(wi != NULL); |
| 353 | |
| 354 | /* Handle concatenated starting level (SL) tables */ |
| 355 | sl_idx = s2_sl_addr_to_idx(map_addr, start_level, ipa_bits); |
| 356 | if (sl_idx >= S2TTES_PER_S2TT) { |
| 357 | unsigned int tt_num = (sl_idx >> S2TTE_STRIDE); |
| 358 | struct granule *g_concat_root = g_root + tt_num; |
| 359 | |
| 360 | granule_lock(g_concat_root, GRANULE_STATE_RTT); |
| 361 | granule_unlock(g_root); |
| 362 | g_root = g_concat_root; |
| 363 | } |
| 364 | |
| 365 | g_tbls[start_level] = g_root; |
| 366 | for (i = start_level; i < level; i++) { |
| 367 | /* |
| 368 | * Lock next RTT level. Correct locking order is guaranteed |
| 369 | * because reference is obtained from a locked granule |
| 370 | * (previous level). Also, hand-over-hand locking/unlocking is |
| 371 | * used to avoid race conditions. |
| 372 | */ |
| 373 | g_tbls[i + 1] = __find_lock_next_level(g_tbls[i], map_addr, i); |
| 374 | if (g_tbls[i + 1] == NULL) { |
| 375 | last_level = i; |
| 376 | goto out; |
| 377 | } |
| 378 | granule_unlock(g_tbls[i]); |
| 379 | } |
| 380 | |
| 381 | last_level = level; |
| 382 | out: |
| 383 | wi->last_level = last_level; |
| 384 | wi->g_llt = g_tbls[last_level]; |
| 385 | wi->index = s2_addr_to_idx(map_addr, last_level); |
| 386 | } |
| 387 | |
| 388 | /* |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 389 | * Creates an unassigned_empty s2tte. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 390 | */ |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 391 | unsigned long s2tte_create_unassigned_empty(void) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 392 | { |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 393 | return (S2TTE_INVALID_HIPAS_UNASSIGNED | S2TTE_INVALID_RIPAS_EMPTY); |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | /* |
| 397 | * Creates an unassigned_ram s2tte. |
| 398 | */ |
| 399 | unsigned long s2tte_create_unassigned_ram(void) |
| 400 | { |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 401 | return (S2TTE_INVALID_HIPAS_UNASSIGNED | S2TTE_INVALID_RIPAS_RAM); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | /* |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 405 | * Creates an unassigned_destroyed s2tte. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 406 | */ |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 407 | unsigned long s2tte_create_unassigned_destroyed(void) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 408 | { |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 409 | return (S2TTE_INVALID_HIPAS_UNASSIGNED | S2TTE_INVALID_RIPAS_DESTROYED); |
| 410 | } |
| 411 | |
| 412 | /* |
| 413 | * Creates an invalid s2tte with output address @pa, HIPAS=ASSIGNED and |
| 414 | * RIPAS=DESTROYED, at level @level. |
| 415 | */ |
| 416 | unsigned long s2tte_create_assigned_destroyed(unsigned long pa, long level) |
| 417 | { |
| 418 | assert(level >= RTT_MIN_BLOCK_LEVEL); |
| 419 | assert(addr_is_level_aligned(pa, level)); |
| 420 | return (pa | S2TTE_INVALID_HIPAS_ASSIGNED | S2TTE_INVALID_RIPAS_DESTROYED); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | /* |
| 424 | * Creates an invalid s2tte with output address @pa, HIPAS=ASSIGNED and |
| 425 | * RIPAS=EMPTY, at level @level. |
| 426 | */ |
| 427 | unsigned long s2tte_create_assigned_empty(unsigned long pa, long level) |
| 428 | { |
| 429 | assert(level >= RTT_MIN_BLOCK_LEVEL); |
| 430 | assert(addr_is_level_aligned(pa, level)); |
| 431 | return (pa | S2TTE_INVALID_HIPAS_ASSIGNED | S2TTE_INVALID_RIPAS_EMPTY); |
| 432 | } |
| 433 | |
| 434 | /* |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 435 | * Creates an assigned_ram s2tte with output address @pa. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 436 | */ |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 437 | unsigned long s2tte_create_assigned_ram(unsigned long pa, long level) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 438 | { |
| 439 | assert(level >= RTT_MIN_BLOCK_LEVEL); |
| 440 | assert(addr_is_level_aligned(pa, level)); |
| 441 | if (level == RTT_PAGE_LEVEL) { |
| 442 | return (pa | S2TTE_PAGE); |
| 443 | } |
| 444 | return (pa | S2TTE_BLOCK); |
| 445 | } |
| 446 | |
| 447 | /* |
AlexeiFedorov | 5ceff35 | 2023-04-12 16:17:00 +0100 | [diff] [blame] | 448 | * Creates an unassigned_ns s2tte. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 449 | */ |
AlexeiFedorov | 5ceff35 | 2023-04-12 16:17:00 +0100 | [diff] [blame] | 450 | unsigned long s2tte_create_unassigned_ns(void) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 451 | { |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 452 | return (S2TTE_NS | S2TTE_INVALID_HIPAS_UNASSIGNED | |
| 453 | S2TTE_INVALID_UNPROTECTED); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | /* |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 457 | * Creates an assigned_ns s2tte at level @level. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 458 | * |
| 459 | * The following S2 TTE fields are provided through @s2tte argument: |
| 460 | * - The physical address |
| 461 | * - MemAttr |
| 462 | * - S2AP |
| 463 | * - Shareability |
| 464 | */ |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 465 | unsigned long s2tte_create_assigned_ns(unsigned long s2tte, long level) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 466 | { |
| 467 | assert(level >= RTT_MIN_BLOCK_LEVEL); |
| 468 | if (level == RTT_PAGE_LEVEL) { |
| 469 | return (s2tte | S2TTE_PAGE_NS); |
| 470 | } |
| 471 | return (s2tte | S2TTE_BLOCK_NS); |
| 472 | } |
| 473 | |
| 474 | /* |
| 475 | * Validate the portion of NS S2TTE that is provided by the host. |
| 476 | */ |
| 477 | bool host_ns_s2tte_is_valid(unsigned long s2tte, long level) |
| 478 | { |
| 479 | unsigned long mask = addr_level_mask(~0UL, level) | |
| 480 | S2TTE_MEMATTR_MASK | |
| 481 | S2TTE_AP_MASK | |
| 482 | S2TTE_SH_MASK; |
| 483 | |
| 484 | /* |
| 485 | * Test that all fields that are not controlled by the host are zero |
| 486 | * and that the output address is correctly aligned. Note that |
| 487 | * the host is permitted to map any physical address outside PAR. |
| 488 | */ |
| 489 | if ((s2tte & ~mask) != 0UL) { |
| 490 | return false; |
| 491 | } |
| 492 | |
| 493 | /* |
| 494 | * Only one value masked by S2TTE_MEMATTR_MASK is invalid/reserved. |
| 495 | */ |
| 496 | if ((s2tte & S2TTE_MEMATTR_MASK) == S2TTE_MEMATTR_FWB_RESERVED) { |
| 497 | return false; |
| 498 | } |
| 499 | |
| 500 | /* |
| 501 | * Only one value masked by S2TTE_SH_MASK is invalid/reserved. |
| 502 | */ |
| 503 | if ((s2tte & S2TTE_SH_MASK) == S2TTE_SH_RESERVED) { |
| 504 | return false; |
| 505 | } |
| 506 | |
| 507 | /* |
| 508 | * Note that all the values that are masked by S2TTE_AP_MASK are valid. |
| 509 | */ |
| 510 | return true; |
| 511 | } |
| 512 | |
| 513 | /* |
| 514 | * Returns the portion of NS S2TTE that is set by the host. |
| 515 | */ |
| 516 | unsigned long host_ns_s2tte(unsigned long s2tte, long level) |
| 517 | { |
| 518 | unsigned long mask = addr_level_mask(~0UL, level) | |
| 519 | S2TTE_MEMATTR_MASK | |
| 520 | S2TTE_AP_MASK | |
| 521 | S2TTE_SH_MASK; |
| 522 | return (s2tte & mask); |
| 523 | } |
| 524 | |
| 525 | /* |
| 526 | * Creates a table s2tte at level @level with output address @pa. |
| 527 | */ |
| 528 | unsigned long s2tte_create_table(unsigned long pa, long level) |
| 529 | { |
| 530 | assert(level < RTT_PAGE_LEVEL); |
| 531 | assert(GRANULE_ALIGNED(pa)); |
| 532 | |
| 533 | return (pa | S2TTE_TABLE); |
| 534 | } |
| 535 | |
| 536 | /* |
AlexeiFedorov | 0fb4455 | 2023-04-14 15:37:58 +0100 | [diff] [blame] | 537 | * Returns true if s2tte has defined ripas value, namely if it is one of: |
| 538 | * - unassigned_empty |
| 539 | * - unassigned_ram |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 540 | * - unassigned_destroyed |
AlexeiFedorov | 0fb4455 | 2023-04-14 15:37:58 +0100 | [diff] [blame] | 541 | * - assigned_empty |
| 542 | * - assigned_ram |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 543 | * - assigned_destroyed |
AlexeiFedorov | 0fb4455 | 2023-04-14 15:37:58 +0100 | [diff] [blame] | 544 | */ |
| 545 | bool s2tte_has_ripas(unsigned long s2tte, long level) |
| 546 | { |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 547 | return (((s2tte & S2TTE_NS) == 0UL) && !s2tte_is_table(s2tte, level)); |
AlexeiFedorov | 0fb4455 | 2023-04-14 15:37:58 +0100 | [diff] [blame] | 548 | } |
| 549 | |
| 550 | /* |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 551 | * Returns true if @s2tte has HIPAS=@hipas. |
| 552 | */ |
| 553 | static bool s2tte_has_hipas(unsigned long s2tte, unsigned long hipas) |
| 554 | { |
| 555 | unsigned long desc_type = s2tte & DESC_TYPE_MASK; |
| 556 | unsigned long invalid_desc_hipas = s2tte & S2TTE_INVALID_HIPAS_MASK; |
| 557 | |
AlexeiFedorov | 63614ea | 2023-07-14 17:07:20 +0100 | [diff] [blame] | 558 | return ((desc_type == S2TTE_INVALID) && (invalid_desc_hipas == hipas)); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 559 | } |
| 560 | |
| 561 | /* |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 562 | * Returns true if @s2tte has HIPAS=UNASSIGNED and RIPAS=@ripas. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 563 | */ |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 564 | static bool s2tte_has_unassigned_ripas(unsigned long s2tte, unsigned long ripas) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 565 | { |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 566 | return (((s2tte & S2TTE_INVALID_RIPAS_MASK) == ripas) && |
| 567 | s2tte_has_hipas(s2tte, S2TTE_INVALID_HIPAS_UNASSIGNED)); |
| 568 | } |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 569 | |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 570 | /* |
| 571 | * Returns true if @s2tte has HIPAS=ASSIGNED and RIPAS=@ripas. |
| 572 | */ |
| 573 | static bool s2tte_has_assigned_ripas(unsigned long s2tte, unsigned long ripas) |
| 574 | { |
| 575 | return (((s2tte & S2TTE_INVALID_RIPAS_MASK) == ripas) && |
| 576 | s2tte_has_hipas(s2tte, S2TTE_INVALID_HIPAS_ASSIGNED)); |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | /* |
AlexeiFedorov | 0f9cd1f | 2023-07-10 17:04:58 +0100 | [diff] [blame] | 580 | * Returns true if @s2tte has HIPAS=UNASSIGNED. |
| 581 | */ |
| 582 | bool s2tte_is_unassigned(unsigned long s2tte) |
| 583 | { |
| 584 | return s2tte_has_hipas(s2tte, S2TTE_INVALID_HIPAS_UNASSIGNED); |
| 585 | } |
| 586 | |
| 587 | /* |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 588 | * Returns true if @s2tte is an unassigned_empty. |
| 589 | */ |
| 590 | bool s2tte_is_unassigned_empty(unsigned long s2tte) |
| 591 | { |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 592 | return (((s2tte & S2TTE_NS) == 0UL) && |
| 593 | s2tte_has_unassigned_ripas(s2tte, S2TTE_INVALID_RIPAS_EMPTY)); |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | /* |
| 597 | * Returns true if @s2tte is an unassigned_ram. |
| 598 | */ |
| 599 | bool s2tte_is_unassigned_ram(unsigned long s2tte) |
| 600 | { |
| 601 | return s2tte_has_unassigned_ripas(s2tte, S2TTE_INVALID_RIPAS_RAM); |
| 602 | } |
| 603 | |
| 604 | /* |
AlexeiFedorov | 5ceff35 | 2023-04-12 16:17:00 +0100 | [diff] [blame] | 605 | * Returns true if @s2tte is unassigned_ns. |
| 606 | */ |
| 607 | bool s2tte_is_unassigned_ns(unsigned long s2tte) |
| 608 | { |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 609 | return (((s2tte & S2TTE_NS) != 0UL) && |
| 610 | s2tte_has_hipas(s2tte, S2TTE_INVALID_HIPAS_UNASSIGNED)); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 611 | } |
| 612 | |
| 613 | /* |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 614 | * Returns true if @s2tte has RIPAS=DESTROYED. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 615 | */ |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 616 | bool s2tte_is_unassigned_destroyed(unsigned long s2tte) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 617 | { |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 618 | return s2tte_has_unassigned_ripas(s2tte, S2TTE_INVALID_RIPAS_DESTROYED); |
| 619 | } |
| 620 | |
| 621 | /* |
| 622 | * Returns true if @s2tte is an assigned_destroyed. |
| 623 | */ |
| 624 | bool s2tte_is_assigned_destroyed(unsigned long s2tte, long level) |
| 625 | { |
| 626 | (void)level; |
| 627 | |
| 628 | return s2tte_has_assigned_ripas(s2tte, S2TTE_INVALID_RIPAS_DESTROYED); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 629 | } |
| 630 | |
| 631 | /* |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 632 | * Returns true if @s2tte is an assigned_empty. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 633 | */ |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 634 | bool s2tte_is_assigned_empty(unsigned long s2tte, long level) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 635 | { |
| 636 | (void)level; |
| 637 | |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 638 | return s2tte_has_assigned_ripas(s2tte, S2TTE_INVALID_RIPAS_EMPTY); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 639 | } |
| 640 | |
| 641 | static bool s2tte_check(unsigned long s2tte, long level, unsigned long ns) |
| 642 | { |
| 643 | unsigned long desc_type; |
| 644 | |
| 645 | if ((s2tte & S2TTE_NS) != ns) { |
| 646 | return false; |
| 647 | } |
| 648 | |
| 649 | desc_type = s2tte & DESC_TYPE_MASK; |
| 650 | |
| 651 | /* Only pages at L3 and valid blocks at L2 allowed */ |
| 652 | if (((level == RTT_PAGE_LEVEL) && (desc_type == S2TTE_L3_PAGE)) || |
AlexeiFedorov | 80c2f04 | 2022-11-25 14:54:46 +0000 | [diff] [blame] | 653 | ((level == RTT_MIN_BLOCK_LEVEL) && (desc_type == S2TTE_L012_BLOCK))) { |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 654 | return true; |
| 655 | } |
| 656 | |
| 657 | return false; |
| 658 | } |
| 659 | |
| 660 | /* |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 661 | * Returns true if @s2tte is an assigned_ram. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 662 | */ |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 663 | bool s2tte_is_assigned_ram(unsigned long s2tte, long level) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 664 | { |
| 665 | return s2tte_check(s2tte, level, 0UL); |
| 666 | } |
| 667 | |
| 668 | /* |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 669 | * Returns true if @s2tte is an assigned_ns s2tte. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 670 | */ |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 671 | bool s2tte_is_assigned_ns(unsigned long s2tte, long level) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 672 | { |
| 673 | return s2tte_check(s2tte, level, S2TTE_NS); |
| 674 | } |
| 675 | |
| 676 | /* |
| 677 | * Returns true if @s2tte is a table at level @level. |
| 678 | */ |
| 679 | bool s2tte_is_table(unsigned long s2tte, long level) |
| 680 | { |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 681 | return ((level < RTT_PAGE_LEVEL) && |
| 682 | ((s2tte & DESC_TYPE_MASK) == S2TTE_L012_TABLE)); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 683 | } |
| 684 | |
| 685 | /* |
| 686 | * Returns RIPAS of @s2tte. |
| 687 | * |
| 688 | * Caller should ensure that HIPAS=UNASSIGNED or HIPAS=ASSIGNED. |
| 689 | * The s2tte must be not valid/invalid descriptor. |
| 690 | */ |
| 691 | enum ripas s2tte_get_ripas(unsigned long s2tte) |
| 692 | { |
| 693 | unsigned long desc_ripas = s2tte & S2TTE_INVALID_RIPAS_MASK; |
| 694 | |
| 695 | /* |
| 696 | * If valid s2tte descriptor is passed, then ensure S2AP[0] |
| 697 | * bit is 1 (S2AP is set to RW for lower EL), which corresponds |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 698 | * to RIPAS_RAM (bits[6:5] = b01) on a valid descriptor. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 699 | */ |
AlexeiFedorov | 63614ea | 2023-07-14 17:07:20 +0100 | [diff] [blame] | 700 | if (((s2tte & DESC_TYPE_MASK) != S2TTE_INVALID) && |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 701 | (desc_ripas != S2TTE_INVALID_RIPAS_RAM)) { |
| 702 | assert(false); |
| 703 | } |
| 704 | |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 705 | switch (desc_ripas) { |
| 706 | case S2TTE_INVALID_RIPAS_EMPTY: |
Yousuf A | 6280815 | 2022-10-31 10:35:42 +0000 | [diff] [blame] | 707 | return RIPAS_EMPTY; |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 708 | case S2TTE_INVALID_RIPAS_RAM: |
| 709 | return RIPAS_RAM; |
| 710 | default: |
| 711 | assert(desc_ripas == S2TTE_INVALID_RIPAS_DESTROYED); |
| 712 | return RIPAS_DESTROYED; |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 713 | } |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | /* |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 717 | * Populates @s2tt with unassigned_empty s2ttes. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 718 | * |
| 719 | * The granule is populated before it is made a table, |
| 720 | * hence, don't use s2tte_write for access. |
| 721 | */ |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 722 | void s2tt_init_unassigned_empty(unsigned long *s2tt) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 723 | { |
| 724 | for (unsigned int i = 0U; i < S2TTES_PER_S2TT; i++) { |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 725 | s2tt[i] = s2tte_create_unassigned_empty(); |
| 726 | } |
| 727 | |
| 728 | dsb(ish); |
| 729 | } |
| 730 | |
| 731 | /* |
| 732 | * Populates @s2tt with unassigned_ram s2ttes. |
| 733 | * |
| 734 | * The granule is populated before it is made a table, |
| 735 | * hence, don't use s2tte_write for access. |
| 736 | */ |
| 737 | void s2tt_init_unassigned_ram(unsigned long *s2tt) |
| 738 | { |
| 739 | for (unsigned int i = 0U; i < S2TTES_PER_S2TT; i++) { |
| 740 | s2tt[i] = s2tte_create_unassigned_ram(); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 741 | } |
| 742 | |
| 743 | dsb(ish); |
| 744 | } |
| 745 | |
| 746 | /* |
AlexeiFedorov | 5ceff35 | 2023-04-12 16:17:00 +0100 | [diff] [blame] | 747 | * Populates @s2tt with unassigned_ns s2ttes. |
| 748 | * |
| 749 | * The granule is populated before it is made a table, |
| 750 | * hence, don't use s2tte_write for access. |
| 751 | */ |
| 752 | void s2tt_init_unassigned_ns(unsigned long *s2tt) |
| 753 | { |
| 754 | for (unsigned int i = 0U; i < S2TTES_PER_S2TT; i++) { |
| 755 | s2tt[i] = s2tte_create_unassigned_ns(); |
| 756 | } |
| 757 | |
| 758 | dsb(ish); |
| 759 | } |
| 760 | |
| 761 | /* |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 762 | * Populates @s2tt with s2ttes which have HIPAS=DESTROYED. |
| 763 | * |
| 764 | * The granule is populated before it is made a table, |
| 765 | * hence, don't use s2tte_write for access. |
| 766 | */ |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 767 | void s2tt_init_unassigned_destroyed(unsigned long *s2tt) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 768 | { |
| 769 | for (unsigned int i = 0U; i < S2TTES_PER_S2TT; i++) { |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 770 | s2tt[i] = s2tte_create_unassigned_destroyed(); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 771 | } |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 772 | dsb(ish); |
| 773 | } |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 774 | |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 775 | /* |
| 776 | * Populates @s2tt with HIPAS=ASSIGNED, RIPAS=DESTROYED s2ttes that refer to a |
| 777 | * contiguous memory block starting at @pa, and mapped at level @level. |
| 778 | * |
| 779 | * The granule is populated before it is made a table, |
| 780 | * hence, don't use s2tte_write for access. |
| 781 | */ |
| 782 | void s2tt_init_assigned_destroyed(unsigned long *s2tt, unsigned long pa, long level) |
| 783 | { |
| 784 | const unsigned long map_size = s2tte_map_size(level); |
| 785 | |
| 786 | for (unsigned int i = 0U; i < S2TTES_PER_S2TT; i++) { |
| 787 | s2tt[i] = s2tte_create_assigned_destroyed(pa, level); |
| 788 | pa += map_size; |
| 789 | } |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 790 | dsb(ish); |
| 791 | } |
| 792 | |
| 793 | unsigned long s2tte_map_size(int level) |
| 794 | { |
| 795 | int levels, lsb; |
| 796 | |
| 797 | assert(level <= RTT_PAGE_LEVEL); |
| 798 | |
| 799 | levels = RTT_PAGE_LEVEL - level; |
| 800 | lsb = levels * S2TTE_STRIDE + GRANULE_SHIFT; |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 801 | return (1UL << lsb); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 802 | } |
| 803 | |
| 804 | /* |
| 805 | * Populates @s2tt with HIPAS=ASSIGNED, RIPAS=EMPTY s2ttes that refer to a |
| 806 | * contiguous memory block starting at @pa, and mapped at level @level. |
| 807 | * |
| 808 | * The granule is populated before it is made a table, |
| 809 | * hence, don't use s2tte_write for access. |
| 810 | */ |
| 811 | void s2tt_init_assigned_empty(unsigned long *s2tt, unsigned long pa, long level) |
| 812 | { |
| 813 | const unsigned long map_size = s2tte_map_size(level); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 814 | |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 815 | for (unsigned int i = 0U; i < S2TTES_PER_S2TT; i++) { |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 816 | s2tt[i] = s2tte_create_assigned_empty(pa, level); |
| 817 | pa += map_size; |
| 818 | } |
| 819 | dsb(ish); |
| 820 | } |
| 821 | |
| 822 | /* |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 823 | * Populates @s2tt with assigned_ram s2ttes that refer to a |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 824 | * contiguous memory block starting at @pa, and mapped at level @level. |
| 825 | * |
| 826 | * The granule is populated before it is made a table, |
| 827 | * hence, don't use s2tte_write for access. |
| 828 | */ |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 829 | void s2tt_init_assigned_ram(unsigned long *s2tt, unsigned long pa, long level) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 830 | { |
| 831 | const unsigned long map_size = s2tte_map_size(level); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 832 | |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 833 | for (unsigned int i = 0U; i < S2TTES_PER_S2TT; i++) { |
| 834 | s2tt[i] = s2tte_create_assigned_ram(pa, level); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 835 | pa += map_size; |
| 836 | } |
| 837 | dsb(ish); |
| 838 | } |
| 839 | |
| 840 | /* |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 841 | * Populates @s2tt with assigned_ns s2ttes that refer to a |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 842 | * contiguous memory block starting at @pa, and mapped at level @level. |
| 843 | * |
| 844 | * The granule is populated before it is made a table, |
| 845 | * hence, don't use s2tte_write for access. |
| 846 | */ |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 847 | void s2tt_init_assigned_ns(unsigned long *s2tt, unsigned long pa, long level) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 848 | { |
| 849 | const unsigned long map_size = s2tte_map_size(level); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 850 | |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 851 | for (unsigned int i = 0U; i < S2TTES_PER_S2TT; i++) { |
| 852 | s2tt[i] = s2tte_create_assigned_ns(pa, level); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 853 | pa += map_size; |
| 854 | } |
| 855 | dsb(ish); |
| 856 | } |
| 857 | |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 858 | /* |
| 859 | * Returns true if s2tte has 'output address' field, namely, if it is one of: |
| 860 | * - assigned_empty |
| 861 | * - assigned_ram |
| 862 | * - assigned_ns |
AlexeiFedorov | 3ebd462 | 2023-07-18 16:27:39 +0100 | [diff] [blame] | 863 | * - assigned_destroyed |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 864 | * - table |
| 865 | */ |
AlexeiFedorov | 917eabf | 2023-04-24 12:20:41 +0100 | [diff] [blame] | 866 | bool s2tte_has_pa(unsigned long s2tte, long level) |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 867 | { |
| 868 | unsigned long desc_type = s2tte & DESC_TYPE_MASK; |
| 869 | |
AlexeiFedorov | 3ebd462 | 2023-07-18 16:27:39 +0100 | [diff] [blame] | 870 | return ((desc_type != S2TTE_INVALID) || /* block, page or table */ |
| 871 | s2tte_is_assigned_empty(s2tte, level) || |
| 872 | s2tte_is_assigned_destroyed(s2tte, level)); |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 873 | } |
| 874 | |
AlexeiFedorov | 917eabf | 2023-04-24 12:20:41 +0100 | [diff] [blame] | 875 | /* |
| 876 | * Returns true if s2tte is a live RTTE entry. i.e., |
AlexeiFedorov | 3ebd462 | 2023-07-18 16:27:39 +0100 | [diff] [blame] | 877 | * HIPAS is ASSIGNED. |
AlexeiFedorov | 917eabf | 2023-04-24 12:20:41 +0100 | [diff] [blame] | 878 | * |
| 879 | * NOTE: For now, only the RTTE with PA are live. |
| 880 | * This could change with EXPORT/IMPORT support. |
| 881 | */ |
| 882 | bool s2tte_is_live(unsigned long s2tte, long level) |
| 883 | { |
| 884 | return s2tte_has_pa(s2tte, level); |
| 885 | } |
| 886 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 887 | /* Returns physical address of a page entry or block */ |
| 888 | unsigned long s2tte_pa(unsigned long s2tte, long level) |
| 889 | { |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 890 | if (!s2tte_has_pa(s2tte, level)) { |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 891 | assert(false); |
| 892 | } |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 893 | |
| 894 | if (s2tte_is_table(s2tte, level)) { |
| 895 | return addr_level_mask(s2tte, RTT_PAGE_LEVEL); |
| 896 | } |
| 897 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 898 | return addr_level_mask(s2tte, level); |
| 899 | } |
| 900 | |
| 901 | /* Returns physical address of a table entry */ |
| 902 | unsigned long s2tte_pa_table(unsigned long s2tte, long level) |
| 903 | { |
| 904 | assert(s2tte_is_table(s2tte, level)); |
| 905 | return addr_level_mask(s2tte, RTT_PAGE_LEVEL); |
| 906 | } |
| 907 | |
| 908 | bool addr_is_level_aligned(unsigned long addr, long level) |
| 909 | { |
| 910 | return (addr == addr_level_mask(addr, level)); |
| 911 | } |
| 912 | |
| 913 | typedef bool (*s2tte_type_checker)(unsigned long s2tte); |
| 914 | |
| 915 | static bool __table_is_uniform_block(unsigned long *table, |
AlexeiFedorov | 377d81f | 2023-04-14 16:29:12 +0100 | [diff] [blame] | 916 | s2tte_type_checker s2tte_is_x) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 917 | { |
AlexeiFedorov | 377d81f | 2023-04-14 16:29:12 +0100 | [diff] [blame] | 918 | for (unsigned int i = 0U; i < S2TTES_PER_S2TT; i++) { |
| 919 | unsigned long s2tte = s2tte_read(&table[i]); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 920 | |
| 921 | if (!s2tte_is_x(s2tte)) { |
| 922 | return false; |
| 923 | } |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 924 | } |
| 925 | |
| 926 | return true; |
| 927 | } |
| 928 | |
| 929 | /* |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 930 | * Returns true if all s2ttes in @table are unassigned_empty. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 931 | */ |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 932 | bool table_is_unassigned_empty_block(unsigned long *table) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 933 | { |
AlexeiFedorov | 377d81f | 2023-04-14 16:29:12 +0100 | [diff] [blame] | 934 | return __table_is_uniform_block(table, s2tte_is_unassigned_empty); |
AlexeiFedorov | c07a638 | 2023-04-14 11:59:18 +0100 | [diff] [blame] | 935 | } |
| 936 | |
| 937 | /* |
| 938 | * Returns true if all s2ttes in @table are unassigned_ram. |
| 939 | */ |
| 940 | bool table_is_unassigned_ram_block(unsigned long *table) |
| 941 | { |
AlexeiFedorov | 377d81f | 2023-04-14 16:29:12 +0100 | [diff] [blame] | 942 | return __table_is_uniform_block(table, s2tte_is_unassigned_ram); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 943 | } |
| 944 | |
| 945 | /* |
AlexeiFedorov | 5ceff35 | 2023-04-12 16:17:00 +0100 | [diff] [blame] | 946 | * Returns true if all s2ttes in @table are unassigned_ns |
| 947 | */ |
| 948 | bool table_is_unassigned_ns_block(unsigned long *table) |
| 949 | { |
AlexeiFedorov | 377d81f | 2023-04-14 16:29:12 +0100 | [diff] [blame] | 950 | return __table_is_uniform_block(table, s2tte_is_unassigned_ns); |
AlexeiFedorov | 5ceff35 | 2023-04-12 16:17:00 +0100 | [diff] [blame] | 951 | } |
| 952 | |
| 953 | /* |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 954 | * Returns true if all s2ttes in @table are unassigned_destroyed |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 955 | */ |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 956 | bool table_is_unassigned_destroyed_block(unsigned long *table) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 957 | { |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 958 | return __table_is_uniform_block(table, s2tte_is_unassigned_destroyed); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 959 | } |
| 960 | |
| 961 | typedef bool (*s2tte_type_level_checker)(unsigned long s2tte, long level); |
| 962 | |
| 963 | static bool __table_maps_block(unsigned long *table, |
| 964 | long level, |
| 965 | s2tte_type_level_checker s2tte_is_x) |
| 966 | { |
| 967 | unsigned long base_pa; |
| 968 | unsigned long map_size = s2tte_map_size(level); |
| 969 | unsigned long s2tte = s2tte_read(&table[0]); |
| 970 | unsigned int i; |
| 971 | |
| 972 | if (!s2tte_is_x(s2tte, level)) { |
| 973 | return false; |
| 974 | } |
| 975 | |
| 976 | base_pa = s2tte_pa(s2tte, level); |
| 977 | if (!addr_is_level_aligned(base_pa, level - 1L)) { |
| 978 | return false; |
| 979 | } |
| 980 | |
| 981 | for (i = 1U; i < S2TTES_PER_S2TT; i++) { |
| 982 | unsigned long expected_pa = base_pa + (i * map_size); |
| 983 | |
| 984 | s2tte = s2tte_read(&table[i]); |
| 985 | |
| 986 | if (!s2tte_is_x(s2tte, level)) { |
| 987 | return false; |
| 988 | } |
| 989 | |
| 990 | if (s2tte_pa(s2tte, level) != expected_pa) { |
| 991 | return false; |
| 992 | } |
| 993 | } |
| 994 | |
| 995 | return true; |
| 996 | } |
| 997 | |
| 998 | /* |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 999 | * Returns true if all s2ttes are assigned_empty |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1000 | * and refer to a contiguous block of granules aligned to @level - 1. |
| 1001 | */ |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 1002 | bool table_maps_assigned_empty_block(unsigned long *table, long level) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1003 | { |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 1004 | return __table_maps_block(table, level, s2tte_is_assigned_empty); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1005 | } |
| 1006 | |
| 1007 | /* |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 1008 | * Returns true if all s2ttes are assigned_ram and |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1009 | * refer to a contiguous block of granules aligned to @level - 1. |
| 1010 | */ |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 1011 | bool table_maps_assigned_ram_block(unsigned long *table, long level) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1012 | { |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 1013 | return __table_maps_block(table, level, s2tte_is_assigned_ram); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1014 | } |
| 1015 | |
| 1016 | /* |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 1017 | * Returns true if all s2ttes in @table are assigned_ns s2ttes and |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1018 | * refer to a contiguous block of granules aligned to @level - 1. |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 1019 | * |
| 1020 | * @pre: @table maps IPA outside PAR. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1021 | */ |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 1022 | bool table_maps_assigned_ns_block(unsigned long *table, long level) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1023 | { |
AlexeiFedorov | 3a73933 | 2023-04-13 13:54:04 +0100 | [diff] [blame] | 1024 | return __table_maps_block(table, level, s2tte_is_assigned_ns); |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1025 | } |
AlexeiFedorov | 917eabf | 2023-04-24 12:20:41 +0100 | [diff] [blame] | 1026 | |
| 1027 | /* |
AlexeiFedorov | 3f840a0 | 2023-07-19 10:55:05 +0100 | [diff] [blame] | 1028 | * Returns true if all s2ttes are assigned_destroyed and |
| 1029 | * refer to a contiguous block of granules aligned to @level - 1. |
| 1030 | */ |
| 1031 | bool table_maps_assigned_destroyed_block(unsigned long *table, long level) |
| 1032 | { |
| 1033 | return __table_maps_block(table, level, s2tte_is_assigned_destroyed); |
| 1034 | } |
| 1035 | |
| 1036 | /* |
AlexeiFedorov | 917eabf | 2023-04-24 12:20:41 +0100 | [diff] [blame] | 1037 | * Scan the RTT @s2tt (which is @wi.level), from the entry (@wi.index) and |
AlexeiFedorov | 3ebd462 | 2023-07-18 16:27:39 +0100 | [diff] [blame] | 1038 | * skip the non-live entries (i.e., HIPAS=UNASSIGNED). |
AlexeiFedorov | 917eabf | 2023-04-24 12:20:41 +0100 | [diff] [blame] | 1039 | * In other words, the scanning stops when a live RTTE is encountered or we |
| 1040 | * reach the end of this RTT. |
| 1041 | * |
| 1042 | * For now an RTTE can be considered non-live if it doesn't have a PA. |
| 1043 | * NOTE: This would change with EXPORT/IMPORT where we may have metadata stored |
| 1044 | * in the RTTE. |
| 1045 | * |
| 1046 | * @addr is not necessarily aligned to the wi.last_level (e.g., if we were called |
| 1047 | * with RMI_ERROR_RTT). |
| 1048 | * |
| 1049 | * Returns: |
| 1050 | * - If the entry @wi.index is live, returns @addr. |
| 1051 | * - If none of the entries in the @s2tt are "live", returns the address of the |
| 1052 | * first entry in the next table. |
| 1053 | * - Otherwise, the address of the first live entry in @s2tt |
| 1054 | */ |
| 1055 | unsigned long skip_non_live_entries(unsigned long addr, |
| 1056 | unsigned long *s2tt, |
| 1057 | const struct rtt_walk *wi) |
| 1058 | { |
| 1059 | unsigned int i, index = wi->index; |
| 1060 | long level = wi->last_level; |
| 1061 | unsigned long map_size; |
| 1062 | |
| 1063 | /* |
| 1064 | * If the entry for the map_addr is live, |
| 1065 | * return @addr. |
| 1066 | */ |
| 1067 | if (s2tte_is_live(s2tte_read(&s2tt[index]), level)) { |
| 1068 | return addr; |
| 1069 | } |
| 1070 | |
| 1071 | /* |
| 1072 | * Align the address DOWN to the map_size, as expected for the @level, |
| 1073 | * so that we can compute the correct address by using the index. |
| 1074 | */ |
| 1075 | map_size = s2tte_map_size(level); |
| 1076 | addr &= ~(map_size - 1UL); |
| 1077 | |
| 1078 | /* Skip the "index" */ |
| 1079 | for (i = index + 1U; i < S2TTES_PER_S2TT; i++) { |
| 1080 | unsigned long s2tte = s2tte_read(&s2tt[i]); |
| 1081 | |
| 1082 | if (s2tte_is_live(s2tte, level)) { |
| 1083 | break; |
| 1084 | } |
| 1085 | } |
| 1086 | |
AlexeiFedorov | c53b1f7 | 2023-07-04 15:37:03 +0100 | [diff] [blame] | 1087 | return (addr + (i - index) * map_size); |
AlexeiFedorov | 917eabf | 2023-04-24 12:20:41 +0100 | [diff] [blame] | 1088 | } |