Skip to content

Commit a411e60

Browse files
feat(slave-side-prot): add mmio regions to platform description
The mmio regions present in the platform description are to be mapped accessible for all address spaces. Signed-off-by: Miguel Silva <[email protected]>
1 parent 787ac35 commit a411e60

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/core/inc/platform.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ struct platform {
2121
size_t region_num;
2222
struct mem_region* regions;
2323

24+
size_t mmio_region_num;
25+
struct mem_region* mmio_regions;
2426
struct {
2527
paddr_t base;
2628
} console;

src/core/mpu/mem.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,15 @@ size_t mem_cpu_boot_alloc_size()
214214
return size;
215215
}
216216

217+
static void mem_mmio_init_regions(struct addr_space* as)
218+
{
219+
for (unsigned long i = 0; i < platform.mmio_region_num; i++) {
220+
mem_alloc_map_dev(as, as->type == AS_VM ? SEC_VM_ANY : SEC_HYP_ANY,
221+
platform.mmio_regions[i].base, platform.mmio_regions[i].base,
222+
NUM_PAGES(platform.mmio_regions[i].size));
223+
}
224+
}
225+
217226
void as_init(struct addr_space* as, enum AS_TYPE type, asid_t id, colormap_t colors)
218227
{
219228
UNUSED_ARG(colors);
@@ -229,6 +238,12 @@ void as_init(struct addr_space* as, enum AS_TYPE type, asid_t id, colormap_t col
229238
for (size_t i = 0; i < VMPU_NUM_ENTRIES; i++) {
230239
mem_vmpu_free_entry(as, i);
231240
}
241+
242+
/* For architectures with slave-side mmio protection, we map all the
243+
mmio regions to be accessible to all address spaces */
244+
if (DEFINED(MMIO_SLAVE_SIDE_PROT)) {
245+
mem_mmio_init_regions(as);
246+
}
232247
}
233248

234249
static void mem_free_ppages(struct ppages* ppages)

0 commit comments

Comments
 (0)