From 5e130c6d2ca4b99aedfbd6bb1198c32ac77e6ed6 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Sat, 10 Dec 2022 11:14:50 +0000 Subject: [PATCH] StrictProvenance: deorbit metadata mixins --- .../cheri_slabmetadata_mixin.h | 85 ------------------- .../backend_helpers/defaultpagemapentry.h | 15 +--- 2 files changed, 2 insertions(+), 98 deletions(-) delete mode 100644 src/snmalloc/backend_helpers/cheri_slabmetadata_mixin.h diff --git a/src/snmalloc/backend_helpers/cheri_slabmetadata_mixin.h b/src/snmalloc/backend_helpers/cheri_slabmetadata_mixin.h deleted file mode 100644 index 28e6f6ded..000000000 --- a/src/snmalloc/backend_helpers/cheri_slabmetadata_mixin.h +++ /dev/null @@ -1,85 +0,0 @@ -#pragma once -#include "../pal/pal.h" - -namespace snmalloc -{ - /** - * In CHERI, we must retain, internal to the allocator, the authority to - * entire backing arenas, as there is no architectural mechanism to splice - * together two capabilities. Additionally, these capabilities will retain - * the VMAP software permission, conveying our authority to manipulate the - * address space mappings for said arenas. - * - * We stash these pointers inside the SlabMetadata structures for parts of - * the address space for which SlabMetadata exists. (In other parts of the - * system, we will stash them directly in the pagemap.) This requires that - * we inherit from the FrontendSlabMetadata. - */ - template - class StrictProvenanceSlabMetadataMixin : public SlabMetadata - { - template - friend class BackendAllocator; - - capptr::Arena arena; - - /* Set the arena pointer */ - void arena_set(capptr::Arena a) - { - arena = a; - } - - /* - * Retrieve the stashed pointer for a chunk; the caller must ensure that - * this is the correct arena for the indicated chunk. The latter is unused - * except in debug builds, as there is no architectural amplification. - */ - capptr::Arena arena_get(capptr::Alloc c) - { - SNMALLOC_ASSERT(address_cast(arena) == address_cast(c)); - UNUSED(c); - return arena; - } - }; - - /** - * A dummy implementation of StrictProvenanceBackendSlabMetadata that has no - * computational content, for use on non-StrictProvenance architectures. - */ - template - struct LaxProvenanceSlabMetadataMixin : public SlabMetadata - { - /* On non-StrictProvenance architectures, there's nothing to do */ - void arena_set(capptr::Arena) {} - - /* Just a type sleight of hand, "amplifying" the non-existant bounds */ - capptr::Arena arena_get(capptr::Alloc c) - { - return capptr::Arena::unsafe_from(c.unsafe_ptr()); - } - }; - -#ifdef __cpp_concepts - /** - * Rather than having the backend test backend_strict_provenance in several - * places and doing sleights of hand with the type system, we encapsulate - * the amplification - */ - template - concept IsSlabMeta_Arena = requires(T* t, capptr::Arena p) - { - { - t->arena_set(p) - } - ->ConceptSame; - } - &&requires(T* t, capptr::Alloc p) - { - { - t->arena_get(p) - } - ->ConceptSame>; - }; -#endif - -} // namespace snmalloc diff --git a/src/snmalloc/backend_helpers/defaultpagemapentry.h b/src/snmalloc/backend_helpers/defaultpagemapentry.h index 034a2f0c5..2083db30e 100644 --- a/src/snmalloc/backend_helpers/defaultpagemapentry.h +++ b/src/snmalloc/backend_helpers/defaultpagemapentry.h @@ -1,7 +1,6 @@ #pragma once #include "../mem/mem.h" -#include "cheri_slabmetadata_mixin.h" namespace snmalloc { @@ -65,19 +64,9 @@ namespace snmalloc SNMALLOC_FAST_PATH DefaultPagemapEntryT() = default; }; - class StrictProvenanceSlabMetadata - : public StrictProvenanceSlabMetadataMixin< - FrontendSlabMetadata> + class DefaultSlabMetadata : public FrontendSlabMetadata {}; - class LaxProvenanceSlabMetadata - : public LaxProvenanceSlabMetadataMixin< - FrontendSlabMetadata> - {}; - - using DefaultPagemapEntry = DefaultPagemapEntryT>; + using DefaultPagemapEntry = DefaultPagemapEntryT; } // namespace snmalloc