-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use named constants in the switcher #339
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright CHERIoT Contributors. | ||
// SPDX-License-Identifier: MIT | ||
|
||
#pragma once | ||
#include <assembly-helpers.h> | ||
|
||
/* | ||
* Constant to represent the raw permissions of the compartment CSP. We use | ||
* this in the switcher, to verify the permissions of the CSP that comes from | ||
* the compartment are exactly what we expect. | ||
*/ | ||
EXPORT_ASSEMBLY_EXPRESSION(COMPARTMENT_STACK_PERMISSIONS, | ||
(CHERI::PermissionSet{ | ||
CHERI::Permission::Load, | ||
CHERI::Permission::Store, | ||
CHERI::Permission::LoadStoreCapability, | ||
CHERI::Permission::LoadMutable, | ||
CHERI::Permission::StoreLocal, | ||
CHERI::Permission::LoadGlobal} | ||
.as_raw()), | ||
0x7e) | ||
|
||
/** | ||
* Space reserved at the top of a stack on entry to the compartment. | ||
* | ||
* This *must* be a multiple of 16, which is the stack alignment. | ||
*/ | ||
#define STACK_ENTRY_RESERVED_SPACE 16 | ||
|
||
#ifdef __cplusplus | ||
using namespace priv; | ||
#endif | ||
|
||
EXPORT_ASSEMBLY_NAME(MCAUSE_THREAD_EXIT, 24) | ||
EXPORT_ASSEMBLY_NAME(MCAUSE_THREAD_INTERRUPT, 25) | ||
EXPORT_ASSEMBLY_NAME(MCAUSE_CHERI, 28) | ||
|
||
EXPORT_ASSEMBLY_EXPRESSION(SEAL_TYPE_SealedImportTableEntries, | ||
SealingType::SealedImportTableEntries, | ||
9) | ||
EXPORT_ASSEMBLY_EXPRESSION(SEAL_TYPE_SealedTrustedStacks, | ||
SealingType::SealedTrustedStacks, | ||
10) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,7 @@ namespace priv | |
constexpr size_t MCAUSE_LOAD_PAGE_FAULT = 13; | ||
constexpr size_t MCAUSE_STORE_PAGE_FAULT = 15; | ||
constexpr size_t MCAUSE_THREAD_EXIT = 24; | ||
constexpr size_t MCAUSE_THREAD_INTERRUPT = 25; | ||
constexpr size_t MCAUSE_CHERI = 28; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be a separate PR but these constants are needed in error handlers so we should make them more publicly available in the SDK. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a public heading (and this is why I don't like abbreviations in names of things: priv is short for 'privileged spec' not 'private'). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess there's nothing stopping users from include |
||
|
||
constexpr size_t MSTATUS_UIE = (1 << 0); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took me a minute to work out why we need both of these macros. I guess this one is just the same as
EXPORT_ASSEMBLY_EXPRESSION(name, name, val)
but without a name collision? That makes me think maybe we should use{}
around the definition below?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want the names available in C++, maybe, and the invoking source could, in principle, choose to put things in scope to hide them if desired, but because these are otherwise at top-level, just using
{}
doesn't do the trick, eliciting "expected unqualified-id" errors from the compiler.