Skip to content

Commit

Permalink
Simplify assertions in cap_set_sealed() and cap_set_unsealed()
Browse files Browse the repository at this point in the history
After the latest refactoring we can now drop the TARGET_MORELLO branch.
  • Loading branch information
arichardson committed Oct 12, 2021
1 parent 9d492ee commit 87a1dae
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions target/cheri-common/cheri_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,27 +243,18 @@ static inline bool cap_is_unsealed(const cap_register_t *c)

static inline void cap_set_sealed(cap_register_t *c, uint32_t type)
{
#ifdef TARGET_MORELLO
assert(0 && "Morello should be using generated TCG!");
#else
_Static_assert(CAP_LAST_NONRESERVED_OTYPE < CAP_OTYPE_UNSEALED, "");
#endif
assert(c->cr_tag);
assert(cap_get_otype_unsigned(c) == CAP_OTYPE_UNSEALED &&
"should not use this on caps with reserved otypes");
assert(type <= CAP_LAST_NONRESERVED_OTYPE);
assert(cap_is_unsealed(c) && "Should only use this with unsealed caps");
assert(!cap_otype_is_reserved(type) &&
"Can't use this to set reserved otypes");
CAP_cc(update_otype)(c, type);
}

static inline void cap_set_unsealed(cap_register_t *c)
{
#ifdef TARGET_MORELLO
assert(0 && "Morello should be using generated TCG!");
#endif
assert(c->cr_tag);
assert(cap_is_sealed_with_type(c));
assert(cap_get_otype_unsigned(c) <= CAP_LAST_NONRESERVED_OTYPE &&
"should not use this to unsealed reserved types");
assert(cap_is_sealed_with_type(c) &&
"should not use this to unseal reserved types");
CAP_cc(update_otype)(c, CAP_OTYPE_UNSEALED);
}

Expand Down

0 comments on commit 87a1dae

Please sign in to comment.