Skip to content

Commit

Permalink
Add checks to simple_init
Browse files Browse the repository at this point in the history
  • Loading branch information
0152la committed Feb 9, 2022
1 parent 1e2604d commit aa89a67
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/manager.S
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 18 additions & 2 deletions tests/simple_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

0 comments on commit aa89a67

Please sign in to comment.