NFC CHERI: move sealing type definitions to C Extract the source of truth from loader/boot.cc to a new C enum in cheri.h and redefine the loader's enum in terms of the latter.
diff --git a/sdk/core/loader/boot.cc b/sdk/core/loader/boot.cc index 01e4ca7..e41038a 100644 --- a/sdk/core/loader/boot.cc +++ b/sdk/core/loader/boot.cc
@@ -68,12 +68,12 @@ /** * 0 represents unsealed. */ - Unsealed = 0, + Unsealed = CheriSealTypeUnsealed, /** * Sentry that inherits interrupt status. */ - SentryInheriting, + SentryInheriting = CheriSealTypeSentryInheriting, /// Alternative name: the default sentry type. Sentry = SentryInheriting, @@ -81,32 +81,32 @@ /** * Sentry that disables interrupts on calls. */ - SentryDisabling, + SentryDisabling = CheriSealTypeSentryDisabling, /** * Sentry that enables interrupts on calls. */ - SentryEnabling, + SentryEnabling = CheriSealTypeSentryEnabling, /** * Return sentry that disables interrupts on return */ - ReturnSentryDisabling, + ReturnSentryDisabling = CheriSealTypeReturnSentryDisabling, /** * Return sentry that enables interrupts on return */ - ReturnSentryEnabling, + ReturnSentryEnabling = CheriSealTypeReturnSentryEnabling, /** * Marker for the first sealing type that's valid for data capabilities. */ - FirstDataSealingType = 9, + FirstDataSealingType = CheriSealTypeFirstDataSealingType, /** * The sealing type used for sealed export table entries. */ - SealedImportTableEntries = FirstDataSealingType, + SealedImportTableEntries = CheriSealTypeSealedImportTableEntries, /** * The compartment switcher has a sealing type for the trusted stack. @@ -114,13 +114,13 @@ * This must be the second data sealing type so that we can also permit * the switcher to unseal sentries and export table entries. */ - SealedTrustedStacks, + SealedTrustedStacks = CheriSealTypeSealedTrustedStacks, /** * The allocator has a sealing type for the software sealing mechanism * with dynamically allocated objects. */ - Allocator, + Allocator = CheriSealTypeAllocator, /** * The loader reserves a sealing type for the software sealing @@ -129,19 +129,19 @@ * type was present in the original firmware image. The token library * has the only permit-unseal capability for this type. */ - StaticToken, + StaticToken = CheriSealTypeStaticToken, /** * The first sealing key that is reserved for use by the allocator's * software sealing mechanism and used for static sealing types, */ - FirstStaticSoftware = 16, + FirstStaticSoftware = CheriSealTypeFirstStaticSoftware, /** * The first sealing key in the space that the allocator will * dynamically allocate for sealing types. */ - FirstDynamicSoftware = 0x1000000, + FirstDynamicSoftware = CheriSealTypeFirstDynamicSoftware, }; // The switcher assembly includes the types of import table entries and
diff --git a/sdk/include/cheri.h b/sdk/include/cheri.h index 59385d1..b10d059 100644 --- a/sdk/include/cheri.h +++ b/sdk/include/cheri.h
@@ -269,6 +269,99 @@ }; /** + * Sealing types. + */ +enum CHERISealingType +{ + /** + * 0 represents unsealed. + */ + CheriSealTypeUnsealed = 0, + + /** + * Sentry that inherits interrupt status. + */ + CheriSealTypeSentryInheriting, + + /** + * Sentry that disables interrupts on calls. + */ + CheriSealTypeSentryDisabling, + + /** + * Sentry that enables interrupts on calls. + */ + CheriSealTypeSentryEnabling, + + /** + * Return sentry that disables interrupts on return + */ + CheriSealTypeReturnSentryDisabling, + + /** + * Return sentry that enables interrupts on return + */ + CheriSealTypeReturnSentryEnabling, + + /** + * Marker for the first sealing type that's valid for data capabilities. + */ + CheriSealTypeFirstDataSealingType = 9, + + /** + * The sealing type used for sealed export table entries. + * + * This is RTOS- and not CHERIoT-specific. + */ + CheriSealTypeSealedImportTableEntries = CheriSealTypeFirstDataSealingType, + + /** + * The compartment switcher has a sealing type for the trusted stack. + * + * This must be the second data sealing type so that we can also permit + * the switcher to unseal sentries and export table entries. + * + * This is RTOS- and not CHERIoT-specific. + */ + CheriSealTypeSealedTrustedStacks, + + /** + * The allocator has a sealing type for the software sealing mechanism + * with dynamically allocated objects. + * + * This is RTOS- and not CHERIoT-specific. + */ + CheriSealTypeAllocator, + + /** + * The loader reserves a sealing type for the software sealing + * mechanism. The permit-unseal capability for this is destroyed after + * the loader has run, which guarantees that anything sealed with this + * type was present in the original firmware image. The token library + * has the only permit-unseal capability for this type. + * + * This is RTOS- and not CHERIoT-specific. + */ + CheriSealTypeStaticToken, + + /** + * The first sealing key that is reserved for use by the allocator's + * software sealing mechanism and used for static sealing types, + * + * Architecturally, this is the smallest non-interpreted sealing type. + */ + CheriSealTypeFirstStaticSoftware = 16, + + /** + * The first sealing key in the space that the allocator will + * dynamically allocate for sealing types. + * + * This is RTOS- and not CHERIoT-specific. + */ + CheriSealTypeFirstDynamicSoftware = 0x1000000 +}; + +/** * Checks that `ptr` is valid, unsealed, has at least `rawPermissions`, and has * at least `space` bytes after the current offset. *