Skip to content

Commit ddfd481

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 ad97547 commit ddfd481

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,16 @@ 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,
222+
platform.mmio_regions[i].base,
223+
NUM_PAGES(platform.mmio_regions[i].size));
224+
}
225+
}
226+
217227
void as_init(struct addr_space* as, enum AS_TYPE type, asid_t id, colormap_t colors)
218228
{
219229
UNUSED_ARG(colors);
@@ -229,6 +239,13 @@ void as_init(struct addr_space* as, enum AS_TYPE type, asid_t id, colormap_t col
229239
for (size_t i = 0; i < VMPU_NUM_ENTRIES; i++) {
230240
mem_vmpu_free_entry(as, i);
231241
}
242+
243+
/* For architectures with slave-side mmio protection, we map all the
244+
mmio regions to be accessible to all address spaces */
245+
if (DEFINED(MMIO_SLAVE_SIDE_PROT)) {
246+
mem_mmio_init_regions(as);
247+
}
248+
232249
}
233250

234251
static void mem_free_ppages(struct ppages* ppages)

0 commit comments

Comments
 (0)