diff --git a/src/manager.S b/src/manager.S index df3e044..5eb6b19 100644 --- a/src/manager.S +++ b/src/manager.S @@ -48,6 +48,8 @@ asm_call_wrapper: * memory region for use by switcher code, to contain required capabilities, * and deriving appropriate PCC/DDC values containing the executable switcher * code, and the aforementioned memory region, respectively. + * + * @return Pointer to newly allocated memory region */ .type init_compartments, "function" init_compartments: diff --git a/tests/simple_init.c b/tests/simple_init.c index d343fea..a07f5f8 100644 --- a/tests/simple_init.c +++ b/tests/simple_init.c @@ -16,7 +16,10 @@ static_assert(COMP_OFFSET_STK_ADDR == sizeof(void* __capability) * 2, "Invalid ` ******************************************************************************/ extern void* init_compartments(); -extern void* switcher_caps; +extern void* __capability * switcher_caps; + +extern void switcher_entry(); +extern void switch_compartment_end(); /******************************************************************************* * Main @@ -26,7 +29,20 @@ int main() { void* inner_addr = init_compartments(); - assert(switcher_caps != MAP_FAILED); + + assert(inner_addr != MAP_FAILED); + assert(switcher_caps == inner_addr); + + void* __capability switcher_ddc = switcher_caps[0]; + assert(cheri_is_valid(switcher_ddc)); + assert(cheri_length_get(switcher_ddc) == + COMP_SIZE * MAX_COMP_COUNT + 2 * sizeof(void* __capability)); + + void* __capability switcher_pcc = switcher_caps[1]; + assert(cheri_is_valid(switcher_pcc)); + assert(cheri_address_get(switcher_pcc) == (unsigned long) switcher_entry); + assert(cheri_address_get(switcher_pcc) + cheri_length_get(switcher_pcc) == + (unsigned long) switch_compartment_end); return 0; }