switcher: move some constants to misc-assembly.h These are not really "trusted stack", and we're about to have some more. While here, tweak a comment as per Robert's suggestion. Co-authored-by: Robert Norton <robert.norton@microsoft.com>
diff --git a/sdk/core/loader/boot.cc b/sdk/core/loader/boot.cc index 5bcb70c..332a491 100644 --- a/sdk/core/loader/boot.cc +++ b/sdk/core/loader/boot.cc
@@ -11,6 +11,7 @@ #include <string.h> #include "../switcher/tstack.h" +#include "../switcher/misc-assembly.h" #include "constants.h" #include "debug.hh" #include "defines.h"
diff --git a/sdk/core/switcher/entry.S b/sdk/core/switcher/entry.S index 3a3eeb1..eb85ef7 100644 --- a/sdk/core/switcher/entry.S +++ b/sdk/core/switcher/entry.S
@@ -3,6 +3,7 @@ #include "export-table-assembly.h" #include "trusted-stack-assembly.h" +#include "misc-assembly.h" #include <errno.h> .include "assembly-helpers.s"
diff --git a/sdk/core/switcher/misc-assembly.h b/sdk/core/switcher/misc-assembly.h new file mode 100644 index 0000000..f48e59f --- /dev/null +++ b/sdk/core/switcher/misc-assembly.h
@@ -0,0 +1,28 @@ +// 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
diff --git a/sdk/core/switcher/trusted-stack-assembly.h b/sdk/core/switcher/trusted-stack-assembly.h index 660a010..7969662 100644 --- a/sdk/core/switcher/trusted-stack-assembly.h +++ b/sdk/core/switcher/trusted-stack-assembly.h
@@ -57,18 +57,3 @@ #define TSTACKOFFSET_FIRSTFRAME \ (TrustedStack_offset_frameoffset + TSTACK_HEADER_SZ) - -/* Constant to represent the raw permissions of the compartment CSP. - * We use this in the switcher, to verify the CSP comes from the - * compartment is exactly what we expect. - * This represents the following permissions: - * Load, Store, LoadStoreCapability, LoadMutable StoreLocal and LoadGlobal - */ -#define COMPARTMENT_STACK_PERMISSIONS 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
diff --git a/sdk/core/switcher/tstack.h b/sdk/core/switcher/tstack.h index d782af8..dc8338b 100644 --- a/sdk/core/switcher/tstack.h +++ b/sdk/core/switcher/tstack.h
@@ -77,13 +77,3 @@ using TrustedStack = TrustedStackGeneric<0>; #include "trusted-stack-assembly.h" - -static_assert( - CheckSize<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()>::value);