Skip to content

Commit

Permalink
Merge patch-axel-12
Browse files Browse the repository at this point in the history
  • Loading branch information
axel-h committed Apr 15, 2024
2 parents 9059b21 + 070911a commit fb49721
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
39 changes: 22 additions & 17 deletions libsel4allocman/src/bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,19 @@ int bootstrap_add_untypeds_from_bootinfo(bootstrap_info_t *bs, seL4_BootInfo *bi

static int bootstrap_add_untypeds_from_simple(bootstrap_info_t *bs, simple_t *simple) {
int error;
int i;
/* if we do not have a boot cspace, or we have added some uts that aren't in the
* current space then just bail */
if (!bs->have_boot_cspace || (bs->uts && !bs->uts_in_current_cspace)) {
return 1;
}
for (i = 0; i < simple_get_untyped_count(simple); i++) {

int cnt = simple_get_untyped_count(simple);
if (cnt < 0) {
ZF_LOGW("Could not get untyped count (%d)", cnt);
return 1;
}

for (int i = 0; i < cnt; i++) {
size_t size_bits;
uintptr_t paddr;
bool device;
Expand Down Expand Up @@ -1005,10 +1011,7 @@ static int handle_device_untyped_cap(add_untypeds_state_t *state, uintptr_t padd
bool cap_tainted = false;
int error;
uintptr_t ut_end = paddr + BIT(size_bits);
int num_regions = 0;
if (state != NULL) {
num_regions = state->num_regions;
}
int num_regions = state ? state->num_regions : 0;
for (int i = 0; i < num_regions; i++) {
pmem_region_t *region = &state->regions[i];
uint64_t region_end = region->base_addr + region->length;
Expand Down Expand Up @@ -1111,23 +1114,25 @@ int allocman_add_simple_untypeds_with_regions(allocman_t *alloc, simple_t *simpl
int error = prepare_handle_device_untyped_cap(alloc, simple, &state, num_regions, region_list);
ZF_LOGF_IF(error, "bootstrap_prepare_handle_device_untyped_cap Failed");

size_t i;
size_t total_untyped = simple_get_untyped_count(simple);
int total_untyped = simple_get_untyped_count(simple);
if (total_untyped < 0) {
ZF_LOGW("Could not get untyped count (%d)", total_untyped);
return 0; /* don't report an error, just do nothing */
}

for(i = 0; i < total_untyped; i++) {
for(int i = 0; i < total_untyped; i++) {
size_t size_bits;
uintptr_t paddr;
bool device;
cspacepath_t path = allocman_cspace_make_path(alloc, simple_get_nth_untyped(simple, i, &size_bits, &paddr, &device));
int dev_type = device ? ALLOCMAN_UT_DEV : ALLOCMAN_UT_KERNEL;
// If it is regular UT memory, then we add cap and move on.
if (dev_type == ALLOCMAN_UT_KERNEL) {
error = allocman_utspace_add_uts(alloc, 1, &path, &size_bits, &paddr, dev_type);
ZF_LOGF_IF(error, "Could not add kernel untyped.");
} else {
// Otherwise we are Device untyped.
if (device) {
// Separates device RAM memory into separate untyped caps
error = handle_device_untyped_cap(state, paddr, size_bits, &path, alloc);
ZF_LOGF_IF(error, "bootstrap_arch_handle_device_untyped_cap failed.");
ZF_LOGF_IF(error, "handle_device_untyped_cap failed (%d).", error);
} else {
// for regular UT memory we add cap
error = allocman_utspace_add_uts(alloc, 1, &path, &size_bits, &paddr, ALLOCMAN_UT_KERNEL);
ZF_LOGF_IF(error, "Could not add kernel untyped (%d).", error);
}
}
if (state) {
Expand Down
8 changes: 6 additions & 2 deletions libsel4simple/src/simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@

bool simple_is_untyped_cap(simple_t *simple, seL4_CPtr pos)
{
int i;
int cnt = simple_get_untyped_count(simple);
if (cnt < 0) {
ZF_LOGW("Could not get untyped count (%d)", cnt);
return false;
}

for (i = 0; i < simple_get_untyped_count(simple); i++) {
for (int i = 0; i < cnt; i++) {
seL4_CPtr ut_pos = simple_get_nth_untyped(simple, i, NULL, NULL, NULL);
if (ut_pos == pos) {
return true;
Expand Down

0 comments on commit fb49721

Please sign in to comment.