From 87a1dae62683986f0fe5c5652fd199fde6777c69 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Tue, 12 Oct 2021 13:58:44 +0100 Subject: [PATCH] Simplify assertions in cap_set_sealed() and cap_set_unsealed() After the latest refactoring we can now drop the TARGET_MORELLO branch. --- target/cheri-common/cheri_utils.h | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/target/cheri-common/cheri_utils.h b/target/cheri-common/cheri_utils.h index f8886b886e1..e3f159c3001 100644 --- a/target/cheri-common/cheri_utils.h +++ b/target/cheri-common/cheri_utils.h @@ -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); }