Skip to content

Commit

Permalink
Remove cap_is_revocable
Browse files Browse the repository at this point in the history
  • Loading branch information
HAKarlsson committed Nov 6, 2023
1 parent 5b91870 commit 3dbbf07
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 62 deletions.
1 change: 0 additions & 1 deletion kernel/inc/cap_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ static inline uint64_t pmp_napot_encode(uint64_t base, uint64_t size)
}

bool cap_is_valid(cap_t cap);
bool cap_is_revokable(cap_t parent, cap_t child);
bool cap_is_derivable(cap_t parent, cap_t child);
61 changes: 0 additions & 61 deletions kernel/src/cap_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,67 +84,6 @@ static inline bool is_bit_subset(uint64_t a, uint64_t b)
return (a & b) == a;
}

static bool cap_time_revokable(cap_t p, cap_t c)
{
return (c.type == CAPTY_TIME) && (p.time.hart == c.time.hart)
&& is_range_subset(p.time.bgn, p.time.end, c.time.bgn,
c.time.end);
}

static bool cap_mem_revokable(cap_t p, cap_t c)
{
if (c.type == CAPTY_PMP) {
uint64_t p_bgn, p_end, c_base, c_size;
p_bgn = tag_block_to_addr(p.mem.tag, p.mem.bgn);
p_end = tag_block_to_addr(p.mem.tag, p.mem.end);
pmp_napot_decode(c.pmp.addr, &c_base, &c_size);
return is_range_subset(p_bgn, p_end, c_base, c_base + c_size);
}
return (c.type == CAPTY_MEMORY) && (p.mem.tag == c.mem.tag)
&& is_range_subset(p.mem.bgn, p.mem.end, c.mem.bgn, c.mem.end);
}

static bool cap_mon_revokable(cap_t p, cap_t c)
{
return (c.type == CAPTY_MONITOR)
&& is_range_subset(p.mon.bgn, p.mon.end, c.mon.bgn, c.mon.end);
}

static bool cap_chan_revokable(cap_t p, cap_t c)
{
if (c.type == CAPTY_SOCKET) {
return is_range_subset(p.chan.bgn, p.chan.end, c.sock.chan,
c.sock.chan + 1);
}
return (c.type == CAPTY_CHANNEL)
&& is_range_subset(p.chan.bgn, p.chan.end, c.chan.bgn,
c.chan.end);
}

static bool cap_sock_revokable(cap_t p, cap_t c)
{
return (p.sock.tag == 0) && (c.sock.tag != 0)
&& (p.sock.chan == c.sock.chan);
}

bool cap_is_revokable(cap_t p, cap_t c)
{
switch (p.type) {
case CAPTY_TIME:
return cap_time_revokable(p, c);
case CAPTY_MEMORY:
return cap_mem_revokable(p, c);
case CAPTY_MONITOR:
return cap_mon_revokable(p, c);
case CAPTY_CHANNEL:
return cap_chan_revokable(p, c);
case CAPTY_SOCKET:
return cap_sock_revokable(p, c);
default:
return false;
}
}

bool cap_is_valid(cap_t c)
{
switch (c.type) {
Expand Down

0 comments on commit 3dbbf07

Please sign in to comment.