repo_name
stringlengths
1
62
dataset
stringclasses
1 value
lang
stringclasses
11 values
pr_id
int64
1
20.1k
owner
stringlengths
2
34
reviewer
stringlengths
2
39
diff_hunk
stringlengths
15
262k
code_review_comment
stringlengths
1
99.6k
cheriot-rtos
github_2023
cpp
473
CHERIoT-Platform
nwf
@@ -67,10 +67,14 @@ __always_inline static int futex_wait(const uint32_t *address, * Wakes up to `count` threads that are sleeping with `futex[_timed]_wait` on * `address`. * - * The `address` argument must permit storing four bytes of data after the - * address. This call does not store to the address but requir...
May be worth more fully enumerating what `check_pointer` is going to ask for: valid, unsealed, and length >= 4.
cheriot-rtos
github_2023
cpp
481
CHERIoT-Platform
rmn30
@@ -77,11 +77,23 @@ compartment_error_handler(struct ErrorState *frame, size_t mcause, size_t mtval) return ErrorRecoveryBehaviour::InstallContext; } +__attribute__((noinline, weak)) void *pcc_as_sentry() +{ + return __builtin_return_address(0); +} + /** * Test suite entry point. Runs all of the tests that we ...
Shouldn't it always be a return sentry? Why do you need the `||`?
cheriot-rtos
github_2023
cpp
481
CHERIoT-Platform
rmn30
@@ -77,11 +77,23 @@ compartment_error_handler(struct ErrorState *frame, size_t mcause, size_t mtval) return ErrorRecoveryBehaviour::InstallContext; } +__attribute__((noinline, weak)) void *pcc_as_sentry() +{ + return __builtin_return_address(0); +} + /** * Test suite entry point. Runs all of the tests that we ...
This will only apply to the top level test runner, right? All the tests that run in compartments will default to interrupts enabled?
cheriot-rtos
github_2023
cpp
462
CHERIoT-Platform
rmn30
@@ -25,11 +25,8 @@ struct CleanupList */ __always_inline static inline struct CleanupList **cleanup_list_head() { - void *csp = __builtin_cheri_stack_get(); - ptraddr_t top = __builtin_cheri_top_get(csp); - csp = __builtin_cheri_address_set( - csp, top - INVOCATION_LOCAL_UNWIND_LIST_OFFSET...
This seems like a very convoluted way of spelling `0`. I had to look up the definitions of both `invocation_state_slot` and `INVOCATION_LOCAL_UNWIND_LIST_OFFSET` to figure out what's going on. Maybe hide it in a macro `INVOCATION_LOCAL_UNWIND_SLOT` with a suitable comment?
cheriot-rtos
github_2023
others
462
CHERIoT-Platform
davidchisnall
@@ -1407,7 +1407,7 @@ namespace CHERI }; /** - * Register numbers as reported in cap idx field of `mtval` CSR when + * Register numbers as reported in cap idx field of `mtval` CSR when
```suggestion * Register numbers as reported in the cap idx field of `mtval` CSR when ```
cheriot-rtos
github_2023
cpp
474
CHERIoT-Platform
rmn30
@@ -363,5 +368,10 @@ int test_misc() 4, {Permission::Global, Permission::Load}); check_odd_memcmp(); + TEST_EQUAL( + strnlen(*volatileString, 3), 3, "Incorrect length from short strnlen"); + TEST_EQUAL(strnlen(*volatileString, SIZE_MAX), + 11, + "Inc...
```suggestion "Incorrect length from SIZE_MAX strnlen"); ```
cheriot-rtos
github_2023
cpp
464
CHERIoT-Platform
nwf
@@ -238,4 +238,18 @@ __always_inline T *token_unseal(SKey key, Sealed<T> sealed) { return static_cast<T *>(token_obj_unseal(key, sealed)); } + #endif // __cplusplus + +#if __has_extension(cheri_sealed_pointers) +# ifdef __cplusplus +template<typename T> +__always_inline T *token_unseal(SKey key, T *__sealed_capabi...
Why won't this clash with the `token_unseal` function above, since its `T` is inferrable and so its invocations can be spelled without wakas before parens?
cheriot-rtos
github_2023
cpp
414
CHERIoT-Platform
nwf
@@ -73,7 +73,7 @@ namespace { assert(high == LockBit); high = 0; - futex_wake(&high, std::numeric_limits<uint32_t>::max()); + (void)futex_wake(&high, std::numeric_limits<uint32_t>::max());
This is https://github.com/CHERIoT-Platform/cheriot-rtos/pull/404
cheriot-rtos
github_2023
cpp
414
CHERIoT-Platform
nwf
@@ -2,18 +2,20 @@ // SPDX-License-Identifier: MIT #include "hello.h" +#include <debug.hh> #include <fail-simulator-on-error.h> /// Thread entry point. -void __cheri_compartment("hello") entry() +int __cheri_compartment("hello") entry() { // Try writing a string with a missing null terminator char malicious...
Should this check for `ECOMPARTMENTFAIL`?
cheriot-rtos
github_2023
cpp
414
CHERIoT-Platform
nwf
@@ -34,7 +35,10 @@ void __cheri_compartment("allocbench") run() auto quota = heap_quota_remaining(MALLOC_CAPABILITY); Debug::Invariant(quota == MALLOC_QUOTA, "Quota remaining {}, should be {}", quota, MALLOC_QUOTA); Debug::log("Flushing quarantine"); - heap_quarantine_empty(); + Debug::Invariant(heap_quarant...
I think in _benchmark_ code, these might want to be `Debug::Assert`, so that they compile away in release mode when we're measuring cycles?
cheriot-rtos
github_2023
cpp
414
CHERIoT-Platform
nwf
@@ -34,7 +35,10 @@ void __cheri_compartment("allocbench") run() auto quota = heap_quota_remaining(MALLOC_CAPABILITY); Debug::Invariant(quota == MALLOC_QUOTA, "Quota remaining {}, should be {}", quota, MALLOC_QUOTA); Debug::log("Flushing quarantine"); - heap_quarantine_empty(); + Debug::Invariant(heap_quarant...
Hm. I worry that "Unable to call" is potentially misleading... In many cases, the callees indeed cannot fail, so it's accurate, but in the case where they _can_ fail?
cheriot-rtos
github_2023
cpp
414
CHERIoT-Platform
rmn30
@@ -9,12 +9,13 @@ using Debug = ConditionalDebug<DEBUG_ALLOCBENCH, "Allocator benchmark">; * Try allocating 1 MiB of memory in allocation sizes ranging from 32 - 4096 * bytes, report how long it takes. */ -void __cheri_compartment("allocbench") run() +int __cheri_compartment("allocbench") run() { // Make sure ...
```suggestion Debug::Invariant(heap_quarantine_empty() == 0, ``` This invariant is not strong enough as, according to the comment on `heap_quarantine_empty`, other failures such as `ENOTENOUGHSTACK` and `ENOTENOUGHTRUSTEDSTACK` are possible. This applies to all other calls to this and perhaps other compartment call...
cheriot-rtos
github_2023
cpp
414
CHERIoT-Platform
rmn30
@@ -271,7 +272,8 @@ namespace * failure we see below isn't because we aren't allowing the revocation * state machine to advance. */ - heap_quarantine_empty(); + TEST(heap_quarantine_empty() != -ECOMPARTMENTFAIL, + "Compartment call to heap_quarantine_empty failed");
```suggestion TEST_EQUAL(heap_quarantine_empty(), 0, "Compartment call to heap_quarantine_empty failed"); ``` As per previous comment but in the test suite we have this handy macro.
cheriot-rtos
github_2023
cpp
448
CHERIoT-Platform
davidchisnall
@@ -94,7 +94,7 @@ using _Bool = bool; * other places) to avoid the namespace pollution from including `string.h` but * is either constant folded in the front end or expanded to a libcall. */ -unsigned __builtin_strlen(const char *str) __asm__("_Z6strlenPKc"); +unsigned __builtin_strlen(const char *str);
I believe you can remove this declaration entirely. Without it, clang will use the built-in definition.
cheriot-rtos
github_2023
cpp
448
CHERIoT-Platform
davidchisnall
@@ -6,27 +6,37 @@ #include <stddef.h> #include <stdint.h> -int __cheri_libcall memcmp(const void *str1, - const void *str2, - size_t count) __asm__("memcmp"); -void *__cheri_libcall memcpy(void *dest, - const void ...
It would be good to have a comment here for what this is doing (declaring libcall functions with unmangled names) and why it exists (to permit compiler optimisations). Minor naming nit, but are all of the things where we care about compiler libcalls optimisations string functions? If not, we should maybe call this ...
cheriot-rtos
github_2023
cpp
448
CHERIoT-Platform
davidchisnall
@@ -6,27 +6,37 @@ #include <stddef.h> #include <stdint.h> -int __cheri_libcall memcmp(const void *str1, - const void *str2, - size_t count) __asm__("memcmp"); -void *__cheri_libcall memcpy(void *dest, - const void ...
If you add a CHERIOT prefix on this, we can move it into cdefs.h. There's a similar macro in lib/atomic and it would be nice to refactor that to use this one at the same time.
cheriot-rtos
github_2023
others
438
CHERIoT-Platform
rmn30
@@ -592,26 +666,31 @@ namespace * using Debug = ConditionalDebug<DebugFoo, "Foo">;
Does this comment need updating?
cheriot-rtos
github_2023
others
438
CHERIoT-Platform
rmn30
@@ -592,26 +666,31 @@ namespace * using Debug = ConditionalDebug<DebugFoo, "Foo">; * ``` */ - template<bool Enabled, DebugContext Context> + template<DebugLevelTemplateArgument Threshold, DebugContext Context> class ConditionalDebug { + static constexpr bool Enabled = Threshold != DebugLevel::None;
Where is this used?
cheriot-rtos
github_2023
others
438
CHERIoT-Platform
rmn30
@@ -676,6 +755,7 @@ namespace } } }; + /** * Function-like class for assertions that is expected to be used via * the deduction guide as:
Would it be useful to give Assertions a DebugLevel, like log messages?
cheriot-rtos
github_2023
others
437
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,143 @@ +#pragma once +#include <cdefs.h> +#include <stdint.h> + +/** + * Represents the state of the Sonata's joystick. + * + * Note, that up to three of the bits may be asserted at any given time. + * There may be up to two cardinal directions asserted when the joystick is + * pushed in a diagonal and the j...
This probably isn't needed since this is just 0.2 now.
cheriot-rtos
github_2023
others
437
CHERIoT-Platform
nwf
@@ -0,0 +1,444 @@ +#pragma once +#include <cdefs.h> +#include <stdint.h> +#include <utils.hh> + +/** + * Represents the state of Sonata's joystick, where each possible input + * corresponds to a given bit in the General GPIO's input register. + * + * Note that up to 3 of these bits may be asserted at any given time: pr...
Should this be within the `struct SonataGpioBoard` rather than at top-level?
cheriot-rtos
github_2023
others
437
CHERIoT-Platform
nwf
@@ -0,0 +1,444 @@ +#pragma once +#include <cdefs.h> +#include <stdint.h> +#include <utils.hh> + +/** + * Represents the state of Sonata's joystick, where each possible input + * corresponds to a given bit in the General GPIO's input register. + * + * Note that up to 3 of these bits may be asserted at any given time: pr...
Perhaps examples in the documentation of the right `MMIO_CAPABILITY` invocation for these would be useful? (Or even static factory methods, since they are backed by singletons in Sonata hardware?)
cheriot-rtos
github_2023
others
437
CHERIoT-Platform
davidchisnall
@@ -138,6 +292,153 @@ struct SonataGPIO */ SonataJoystick read_joystick() volatile { - return static_cast<SonataJoystick>(input & 0x1f); + return static_cast<SonataJoystick>(input & Inputs::Joystick); + } +}; + +/** + * A driver for Sonata's Raspberry Pi HAT Header GPIO. + * + * Documentation source: + * https...
I think this doesn't do what you think. You probably want to either make this virtual (not ideal) or use CRTP so that the superclass can use it.
cheriot-rtos
github_2023
others
437
CHERIoT-Platform
AlexJones0
@@ -0,0 +1,444 @@ +#pragma once +#include <cdefs.h> +#include <stdint.h> +#include <utils.hh> + +/** + * Represents the state of Sonata's joystick, where each possible input + * corresponds to a given bit in the General GPIO's input register. + * + * Note that up to 3 of these bits may be asserted at any given time: pr...
Nit: I think I forgot to remove this last sentence from the comment when I removed the CRTP pattern from this driver; it doesn't make sense any more. The previous sentence should also probably say "three static mask ~attributes~ methods". *Edit: Though also see David's comment above; perhaps the CRTP needs to be re-...
cheriot-rtos
github_2023
others
437
CHERIoT-Platform
rmn30
@@ -1,78 +1,186 @@ #pragma once #include <cdefs.h> #include <stdint.h> +#include <utils.hh> /** - * Represents the state of the Sonata's joystick. - * - * Note, that up to three of the bits may be asserted at any given time. - * There may be up to two cardinal directions asserted when the joystick is - * pushed i...
This comment doesn't make sense.
cheriot-rtos
github_2023
others
437
CHERIoT-Platform
rmn30
@@ -1,78 +1,186 @@ #pragma once #include <cdefs.h> #include <stdint.h> +#include <utils.hh> /** - * Represents the state of the Sonata's joystick. - * - * Note, that up to three of the bits may be asserted at any given time. - * There may be up to two cardinal directions asserted when the joystick is - * pushed i...
```suggestion * Returns a mask with a single bit set corresponding to the given GPIO index * or 0 if that bit is not set in mask. ```
cheriot-rtos
github_2023
others
437
CHERIoT-Platform
rmn30
@@ -1,78 +1,186 @@ #pragma once #include <cdefs.h> #include <stdint.h> +#include <utils.hh> /** - * Represents the state of the Sonata's joystick. - * - * Note, that up to three of the bits may be asserted at any given time. - * There may be up to two cardinal directions asserted when the joystick is - * pushed i...
```suggestion * to `1` (i.e. output) in the `output_enable` register, and if the pin ``` This appears to contradict the comment and code for `set_output_enable` below.
cheriot-rtos
github_2023
others
437
CHERIoT-Platform
rmn30
@@ -1,78 +1,186 @@ #pragma once #include <cdefs.h> #include <stdint.h> +#include <utils.hh> /** - * Represents the state of the Sonata's joystick. - * - * Note, that up to three of the bits may be asserted at any given time. - * There may be up to two cardinal directions asserted when the joystick is - * pushed i...
```suggestion * Read the debounced input value for a given GPIO pin index. For this ```
cheriot-rtos
github_2023
others
437
CHERIoT-Platform
rmn30
@@ -1,78 +1,186 @@ #pragma once #include <cdefs.h> #include <stdint.h> +#include <utils.hh> /** - * Represents the state of the Sonata's joystick. - * - * Note, that up to three of the bits may be asserted at any given time. - * There may be up to two cardinal directions asserted when the joystick is - * pushed i...
```suggestion enum class [[clang::flag_enum]] SonataJoystick : uint16_t ``` As this can have more than one value we should tell the compiler that. I would also prefer the name `SonataJoystickDirection` or similar. `SonataJoystick` sounds to me like the actual GPIO register, which this isn't.
cheriot-rtos
github_2023
others
437
CHERIoT-Platform
rmn30
@@ -1,78 +1,186 @@ #pragma once #include <cdefs.h> #include <stdint.h> +#include <utils.hh> /** - * Represents the state of the Sonata's joystick. - * - * Note, that up to three of the bits may be asserted at any given time. - * There may be up to two cardinal directions asserted when the joystick is - * pushed i...
Should this be negated?
cheriot-rtos
github_2023
others
437
CHERIoT-Platform
rmn30
@@ -138,6 +246,13 @@ struct SonataGPIO */ SonataJoystick read_joystick() volatile { - return static_cast<SonataJoystick>(input & 0x1f); + return static_cast<SonataJoystick>(input & Inputs::Joystick); } }; + +using SonataGpioRaspberryPiHat = SonataGpioBase<0x0FFF'FFFF>; +using SonataGpioArduinoShield = Sona...
Why don't these aliases specify the InputMask and OutputEnableMask? Maybe it's because the InputMask is supposed to be the negation of the OutputMask but that's not what the template does right now.
cheriot-rtos
github_2023
others
437
CHERIoT-Platform
nwf
@@ -136,8 +294,15 @@ struct SonataGPIO /** * Returns the state of the joystick. */ - SonataJoystick read_joystick() volatile + JoystickValue read_joystick() volatile { - return static_cast<SonataJoystick>(input & 0x1f); + return {static_cast<JoystickDirection>(input & Inputs::Joystick)}; } }; + +using So...
Perhaps these should be structs inheriting from their current definitions and providing static factory methods for the singletons on Sonata. I'm content to leave that for a later PR, tho'.
cheriot-rtos
github_2023
others
437
CHERIoT-Platform
nwf
@@ -1,78 +1,236 @@ #pragma once #include <cdefs.h> #include <stdint.h> +#include <utils.hh> /** - * Represents the state of the Sonata's joystick. + * A simple driver for the Sonata's GPIO. This struct represents a single + * GPIO instance, and the methods available to interact with that GPIO. + * This class shou...
"enabled"? Maybe "active"?
cheriot-rtos
github_2023
cpp
435
CHERIoT-Platform
davidchisnall
@@ -19,5 +20,9 @@ int test_stdio() TEST(strcmp(buffer, "-42") == 0, "snprintf(\"%d\", -42) gave {}", std::string_view{buffer, BufferSize}); + sprintf(buffer, "%x", 6 * 9); + TEST(strcmp(buffer, "36") == 0, + "sprintf(\"%x\", 6 * 9) gave {}", + std::string_view{buffer, BufferSize});
If you're going to create a string view anyway, you can just use operator == in the comparison rather than strcmp.
cheriot-rtos
github_2023
others
425
CHERIoT-Platform
nwf
@@ -568,7 +568,22 @@ rule("firmware") mmio = format("__mmio_region_start = 0x%x;\n%s__mmio_region_end = 0x%x;\n__export_mem_heap_end = 0x%x;\n", mmio_start, mmio, mmio_end, board.heap["end"]) - local code_start = format("0x%x", board.instruction_memory.start) + local code_start = format("0x%x", board.instruc...
```suggestion local rwdata_ldscript = path.join(config.buildir(), target:name() .. "-firmware.rwdata.ldscript") local rocode_ldscript = path.join(config.buildir(), target:name() .. "-firmware.rocode.ldscript") ``` with `import("core.project.config")` up after line 457.
cheriot-rtos
github_2023
others
425
CHERIoT-Platform
davidchisnall
@@ -0,0 +1 @@ +All tests finished
This file won't be needed after rebase on #428
cheriot-rtos
github_2023
others
428
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,25 @@ +// Copyright Microsoft and CHERIoT Contributors. +// SPDX-License-Identifier: MIT + +#pragma once + +#ifdef SIMULATION +# include <stdint.h> +# include <platform-uart.hh> +# include <string_view> + +static void platform_simulation_exit(uint32_t code) +{ +# if DEVICE_EXISTS(uart0) + auto uart = MMIO_CA...
Our normal style for this is to move the `auto UART=` out of the ifdef block. This makes it clearer that the existence of the variable is not conditional.
cheriot-rtos
github_2023
others
428
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,25 @@ +// Copyright Microsoft and CHERIoT Contributors. +// SPDX-License-Identifier: MIT + +#pragma once + +#ifdef SIMULATION +# include <stdint.h> +# include <platform-uart.hh> +# include <string_view> + +static void platform_simulation_exit(uint32_t code) +{ +# if DEVICE_EXISTS(uart0) + auto uart = MMIO_CA...
I am not convinced that this is more readable (it’s definitely longer) than just using the long-form constructor.
cheriot-rtos
github_2023
others
428
CHERIoT-Platform
davidchisnall
@@ -25,27 +25,20 @@ fi # Remove old uart log rm -f "${SONATA_SIMULATOR_UART_LOG}" -# If a second argument is provided, check content of UART log. -if [ -n "$2" ] ; then - # Run the simulator in the background. - ${SONATA_SIMULATOR} -E "${SONATA_SIMULATOR_BOOT_STUB}" -E "$1" & - LOOP_TRACKER=0 - while (( LOOP_TRACKE...
Please don't depend on non-POSIX things. If we need to use timeout in CI, that's fine (it's a known environment) but requiring developers to install GPLv3 things is mean.
cheriot-rtos
github_2023
others
337
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,633 @@ +#pragma once
Please can you add the license header?
cheriot-rtos
github_2023
others
337
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,633 @@ +#pragma once +#include <cdefs.h> +#include <stdint.h> +#include <utils.hh> + +/** + * A driver for OpenTitan USB Device, which is used in the Sonata system. + * + * This peripheral's source and documentation can be found at: + * https://github.com/lowRISC/opentitan/tree/ab878b5d3578939a04db72d4ed966a...
It's a shame that they aren't at the end, or you'd be able to expose USB and debugUSB in the board description JSON, where one is a subset of the other and audit whether anyone is using the debug one.
cheriot-rtos
github_2023
others
337
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,633 @@ +#pragma once +#include <cdefs.h> +#include <stdint.h> +#include <utils.hh> + +/** + * A driver for OpenTitan USB Device, which is used in the Sonata system. + * + * This peripheral's source and documentation can be found at: + * https://github.com/lowRISC/opentitan/tree/ab878b5d3578939a04db72d4ed966a...
```suggestion constexpr uint32_t SetupFullBit = uint32_t(UsbStatusField::AvailableSetupFull); ``` Same below. Cosmetic, but I find reading less makes it easier to read.
cheriot-rtos
github_2023
others
337
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,633 @@ +#pragma once +#include <cdefs.h> +#include <stdint.h> +#include <utils.hh> + +/** + * A driver for OpenTitan USB Device, which is used in the Sonata system. + * + * This peripheral's source and documentation can be found at: + * https://github.com/lowRISC/opentitan/tree/ab878b5d3578939a04db72d4ed966a...
I think this would benefit from a bit of high-level detail. I think, from reading the code, that the USB device has a pool of buffers that can be configured for sending and receiving, and you can read / write data from them, mark them as ready to send / receive, and get an interrupt when that's happened. The buffers ...
cheriot-rtos
github_2023
others
337
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,633 @@ +#pragma once +#include <cdefs.h> +#include <stdint.h> +#include <utils.hh> + +/** + * A driver for OpenTitan USB Device, which is used in the Sonata system. + * + * This peripheral's source and documentation can be found at: + * https://github.com/lowRISC/opentitan/tree/ab878b5d3578939a04db72d4ed966a...
Setup is a noun. I think you mean 'Set up'
cheriot-rtos
github_2023
others
337
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,633 @@ +#pragma once +#include <cdefs.h> +#include <stdint.h> +#include <utils.hh> + +/** + * A driver for OpenTitan USB Device, which is used in the Sonata system. + * + * This peripheral's source and documentation can be found at: + * https://github.com/lowRISC/opentitan/tree/ab878b5d3578939a04db72d4ed966a...
As above.
cheriot-rtos
github_2023
others
337
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,633 @@ +#pragma once +#include <cdefs.h> +#include <stdint.h> +#include <utils.hh> + +/** + * A driver for OpenTitan USB Device, which is used in the Sonata system. + * + * This peripheral's source and documentation can be found at: + * https://github.com/lowRISC/opentitan/tree/ab878b5d3578939a04db72d4ed966a...
I'm not sure how important it is, given that code using it will be quite specific to this driver, but this and the one above are not great names. We generally prefer to start with the object (endpoint) so that autocomplete finds related things. I am not a huge fan of `in` here either because it's not clear whether th...
cheriot-rtos
github_2023
others
337
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,633 @@ +#pragma once +#include <cdefs.h> +#include <stdint.h> +#include <utils.hh> + +/** + * A driver for OpenTitan USB Device, which is used in the Sonata system. + * + * This peripheral's source and documentation can be found at: + * https://github.com/lowRISC/opentitan/tree/ab878b5d3578939a04db72d4ed966a...
As above.
cheriot-rtos
github_2023
others
337
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,633 @@ +#pragma once +#include <cdefs.h> +#include <stdint.h> +#include <utils.hh> + +/** + * A driver for OpenTitan USB Device, which is used in the Sonata system. + * + * This peripheral's source and documentation can be found at: + * https://github.com/lowRISC/opentitan/tree/ab878b5d3578939a04db72d4ed966a...
Can we assert something to check that this has happened?
cheriot-rtos
github_2023
others
337
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,633 @@ +#pragma once +#include <cdefs.h> +#include <stdint.h> +#include <utils.hh> + +/** + * A driver for OpenTitan USB Device, which is used in the Sonata system. + * + * This peripheral's source and documentation can be found at: + * https://github.com/lowRISC/opentitan/tree/ab878b5d3578939a04db72d4ed966a...
Under what circumstances can this fail? This and `connect` look as if they unconditionally return 0?
cheriot-rtos
github_2023
others
337
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,633 @@ +#pragma once +#include <cdefs.h> +#include <stdint.h> +#include <utils.hh> + +/** + * A driver for OpenTitan USB Device, which is used in the Sonata system. + * + * This peripheral's source and documentation can be found at: + * https://github.com/lowRISC/opentitan/tree/ab878b5d3578939a04db72d4ed966a...
Is it possible to probe for the endpoint here? If I were writing a driver in a compartment to service multiple USB devices in other compartments, I'd want them to provide an allocation capability to hold the next packet for their stream and then, when a packet is received, wake whichever thread should handle it.
cheriot-rtos
github_2023
others
337
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,633 @@ +#pragma once +#include <cdefs.h> +#include <stdint.h> +#include <utils.hh> + +/** + * A driver for OpenTitan USB Device, which is used in the Sonata system. + * + * This peripheral's source and documentation can be found at: + * https://github.com/lowRISC/opentitan/tree/ab878b5d3578939a04db72d4ed966a...
Missing braces.
cheriot-rtos
github_2023
others
337
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,633 @@ +#pragma once +#include <cdefs.h> +#include <stdint.h> +#include <utils.hh> + +/** + * A driver for OpenTitan USB Device, which is used in the Sonata system. + * + * This peripheral's source and documentation can be found at: + * https://github.com/lowRISC/opentitan/tree/ab878b5d3578939a04db72d4ed966a...
I don't really like the manual loop unrolling here. Is there a reason that this isn't just a memcpy? The memcpy loop will do each copy as a capability, so even without unrolling it will be a fairly similar speed to this. With the current compiler, this structure actually hits one of the pathological cases for miss...
cheriot-rtos
github_2023
others
337
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,633 @@ +#pragma once +#include <cdefs.h> +#include <stdint.h> +#include <utils.hh> + +/** + * A driver for OpenTitan USB Device, which is used in the Sonata system. + * + * This peripheral's source and documentation can be found at: + * https://github.com/lowRISC/opentitan/tree/ab878b5d3578939a04db72d4ed966a...
I don't think that these actually need to be volatile. They're writes to memory-mapped buffers, not to MMIO registers, so it doesn't matter if the compiler reorders them (or even duplicates stores).
cheriot-rtos
github_2023
others
423
CHERIoT-Platform
nwf
@@ -253,21 +253,143 @@ target("cheriot.software_revoker") target:set("cheriot.ldscript", "software_revoker.ldscript") end) --- Helper to get the board file for a given target -local board_file = function(target) - local boardfile = target:values("board") - if not boardfile then - raise("target " .. target:name(...
Hrm. This function isn't just `tonumber(value) or value` (numeric 0 is _true_ in Lua, and `tonumber` won't return `false`) because we want to keep things Lua can't exactly represent as strings? I don't think we're likely to _notice_ the difference in practice, but defense in depth is probably a good idea.
cheriot-rtos
github_2023
others
423
CHERIoT-Platform
nwf
@@ -253,21 +253,143 @@ target("cheriot.software_revoker") target:set("cheriot.ldscript", "software_revoker.ldscript") end) --- Helper to get the board file for a given target -local board_file = function(target) - local boardfile = target:values("board") - if not boardfile then - raise("target " .. target:name(...
The manual sayeth "The order in which the indices are enumerated is not specified, _even for numeric indices_" (emphasis theirs). I think you want to test for the existence of a "border" at each `k`, and check that you've only seen one by the end of the loop. Of course, a non-numeric `k` means that this isn't a table...
cheriot-rtos
github_2023
others
423
CHERIoT-Platform
nwf
@@ -253,21 +253,143 @@ target("cheriot.software_revoker") target:set("cheriot.ldscript", "software_revoker.ldscript") end) --- Helper to get the board file for a given target -local board_file = function(target) - local boardfile = target:values("board") - if not boardfile then - raise("target " .. target:name(...
The bit about numeric path components might be somewhat easy to solve with `is_marked_as_array`? Might not be worth doing yet, but just a comment with the name so we don't forget, perhaps.
cheriot-rtos
github_2023
others
423
CHERIoT-Platform
nwf
@@ -339,9 +460,10 @@ rule("firmware") visit_all_dependencies_of(target, callback) end - local boarddir, boardfile = board_file(target); - local board = json.loadfile(boardfile) - + local boarddir, boardfile = board_file_for_target(target); + local board = load_board_file(json, boardfile) + print("Board fi...
Oh thank you. It's so obnoxious when build systems hide their computed state. :)
cheriot-rtos
github_2023
others
423
CHERIoT-Platform
rmn30
@@ -0,0 +1,15 @@ +{ + "base": "sonata-prerelease", + "patch": [ + { + "op": "replace", + "path": "/simulation", + "value": true + }, + { + "op": "replace", + "path": "/simulator",
Shouldn't there be a run here somewhere?
cheriot-rtos
github_2023
others
410
CHERIoT-Platform
nwf
@@ -79,6 +79,42 @@ struct DebugWriter * Write a 64-bit signed integer. */ virtual void write(int64_t) = 0; + /** + * Write a single byte as hex with no leading 0x. + */ + virtual void write_hex_byte(uint8_t) = 0; + /** + * Write an integer as hex. + */ + template<typename T> + __always_inline void write_hex...
In order that negative values of signed types `T` narrower than `uint{32,64}_t` don't end up prefixed with a bunch of `F`s, do the signedness conversion at the same width and then zero-extend. Because we don't print leading zeros either, this should result in things appearing to be the right width. ```suggestion ...
cheriot-rtos
github_2023
others
391
CHERIoT-Platform
davidchisnall
@@ -121,7 +121,11 @@ namespace Ibex } /** - * Queries whether the specified revocation epoch has finished. + * Queries whether the specified revocation epoch has finished, or, + * if `AllowPartial` is true, that it has (at least) started. + * + * `epoch` must be even, as memory leaves quarantine only ...
Do we have any users of this template parameter left?
cheriot-rtos
github_2023
cpp
404
CHERIoT-Platform
davidchisnall
@@ -1,12 +1,14 @@ // Copyright Microsoft and CHERIoT Contributors. // SPDX-License-Identifier: MIT -#include <cassert> #include <cdefs.h> +#include <debug.hh> #include <futex.h> #include <limits> #include <stdint.h> +using Debug = ConditionalDebug<DEBUG_CXXRT, "cxxrt">;
I don’t see the xmake option that sets this, so I’m a bit confused about how it compiles at all.
cheriot-rtos
github_2023
cpp
404
CHERIoT-Platform
davidchisnall
@@ -54,6 +56,8 @@ namespace /** * Acquire the lock. + * + * This is safe only in IRQ-deferred context.
Why?
cheriot-rtos
github_2023
cpp
404
CHERIoT-Platform
davidchisnall
@@ -62,7 +66,7 @@ namespace { futex_wait(&high, LockBit); } - assert(high == 0); + Debug::Assert(high == 0, "Corrupt guard word");
It would be nice to log the address of the guard word here, so someone can look up that address. It will have a symbol name that matches the global being described.
cheriot-rtos
github_2023
cpp
404
CHERIoT-Platform
davidchisnall
@@ -71,9 +75,10 @@ namespace */ void unlock() { - assert(high == LockBit); - high = 0; - futex_wake(&high, std::numeric_limits<uint32_t>::max()); + Debug::Assert(high == LockBit, "Corrupt guard word"); + high = 0; + int res = futex_wake(&high, std::numeric_limits<uint32_t>::max()); + Debug::I...
I’m not sure I like having this as an invariant. If a compartment is single threaded or otherwise ensures that statics are not concurrently initialised, it’s fine for this to fail. In this function, we don’t know if that is the case.
cheriot-rtos
github_2023
cpp
412
CHERIoT-Platform
davidchisnall
@@ -170,243 +170,235 @@ namespace } // namespace -namespace sched
These things should all be moved to an anonymous namespace, not exported functions in the global namespace. Ideally, the `priv` namespace should also be removed.
cheriot-rtos
github_2023
cpp
405
CHERIoT-Platform
rmn30
@@ -34,5 +34,15 @@ constexpr StackCheckMode StackMode = #endif ; -#define STACK_CHECK(expected) \ - StackUsageCheck<StackMode, expected, __PRETTY_FUNCTION__> stackCheck +#if __CHERIOT__ >= 20250108
```suggestion #if defined(__CHERIOT__) && (__CHERIOT__ >= 20250108) ```
cheriot-rtos
github_2023
cpp
413
CHERIoT-Platform
rmn30
@@ -163,8 +182,22 @@ namespace MultiWaiterInternal::wake_waiters(key, count); count -= multiwaitersWoken; woke += multiwaitersWoken; - shouldYield |= (multiwaitersWoken > 0); } + Debug::log("futex_wake on {} woke {} waiters", key, woke); + + auto *thread = Thread::current_get(); + Fut...
```suggestion Debug::log("futex_wake yielding? {}", shouldYield); ```
cheriot-rtos
github_2023
cpp
413
CHERIoT-Platform
nwf
@@ -530,7 +553,28 @@ __cheriot_minimum_stack(0xa0) int futex_wake(uint32_t *address, uint32_t count) } ptraddr_t key = Capability{address}.address(); - auto [shouldYield, shouldResetPrioirity, woke] = futex_wake(key, count); + auto [shouldResetPrioirity, woke] = futex_wake(key, count); + + FutexWakeKind shouldYie...
Just to confirm my understanding: this is the case of `exception_entry` calling `futex_wake`?
cheriot-rtos
github_2023
cpp
413
CHERIoT-Platform
nwf
@@ -551,12 +595,19 @@ __cheriot_minimum_stack(0xa0) int futex_wake(uint32_t *address, uint32_t count) priority_boost_for_thread(currentThread->id_get())); // If we have dropped priority below that of another runnable thread, we // should yield now. - shouldYield |= !currentThread->is_highest_priority(); }...
Purely a stylistic question: why not `break;`?
cheriot-rtos
github_2023
cpp
413
CHERIoT-Platform
nwf
@@ -543,6 +539,17 @@ namespace return next != this; } + /** + * Returns true if the thread has run for a complete tick. This must + * be called only on the currently running thread. + */ + bool has_run_for_full_tick() + { + Debug::Assert(this == current, + "Only the current thread i...
That's a bit of a tautology, isn't it? ```suggestion "Ask only about currently running thread"); ```
cheriot-rtos
github_2023
cpp
413
CHERIoT-Platform
nwf
@@ -564,8 +571,12 @@ namespace ///@} /// Pointer to the list of the resource this thread is blocked on. ThreadImpl **sleepQueue; - /// If suspended, when will this thread expire. The maximum value is - /// special-cased to mean blocked indefinitely. + /** + * If suspended, when will this thread expire. Th...
Again, just to check my understanding: Time of the _last_ scheduling event and not the time of any _upcoming_ scheduling event because there might not actually be one, if this is the only runnable thread in the system, and besides it's cheaper to not do the addition unless someone asks in `has_run...`?
cheriot-rtos
github_2023
cpp
403
CHERIoT-Platform
nwf
@@ -1364,7 +1364,7 @@ extern "C" SchedulerEntryInfo loader_entry_point(const ImgHdr &imgHdr, build<ExportEntry>( imgHdr.scheduler().exportTable, LA_ABS( - __export_sched__ZN5sched15exception_entryEP19TrustedStackGenericILj0EEjjj)) + __export_scheduler__ZN5sched15exception_entryEP19TrustedSta...
While you're here, do you want to change the `namespace sched` in `scheduler/main.cc` to `namespace scheduler`, too?
cheriot-rtos
github_2023
others
398
CHERIoT-Platform
davidchisnall
@@ -75,6 +75,7 @@ "ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM=1", "ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM=1" ], + "cflags": "-enable-machine-outliner=never",
I *think* this is not needed on 0.2. I'll check, but I believe 0.2 has an old enough version of Ibex that it doesn't introduce the problem that the latest one fixes.
cheriot-rtos
github_2023
cpp
401
CHERIoT-Platform
davidchisnall
@@ -1183,7 +1190,11 @@ __cheriot_minimum_stack(0x280) SObj return sealed;
```suggestion ```
cheriot-rtos
github_2023
cpp
401
CHERIoT-Platform
davidchisnall
@@ -1183,7 +1190,11 @@ __cheriot_minimum_stack(0x280) SObj return sealed; } } - heap_free(heapCapability, obj); + /* + * We get here only if we have failed to store the unsealed handle through + * the out parameter. Destroy the allocation we just made. + */ + token_obj_destroy(heapCapability, key, sealed);...
```suggestion return sealed; ```
cheriot-rtos
github_2023
cpp
401
CHERIoT-Platform
rmn30
@@ -1175,16 +1175,24 @@ __cheriot_minimum_stack(0x280) SObj auto [sealed, obj] = allocate_sealed_unsealed( timeout, heapCapability, key, sz, {Permission::Seal, Permission::Unseal}); { + /* + * Write the unsealed capability through the out parameter, while + * holding the allocator lock. That's a little he...
What am I missing? This doesn't seem right.
cheriot-rtos
github_2023
cpp
379
CHERIoT-Platform
davidchisnall
@@ -1183,7 +1192,7 @@ __cheriot_minimum_stack(0x280) SObj return sealed; } } - heap_free(heapCapability, obj); + (void)heap_free(heapCapability, obj);
Would be nice to have a comment here. This can happen only if the caller gives us a malicious output value. Actually, we probably can elide this and return sealed unconditionally. If you give us a valid `unsealed` pointer and we don't write through it, you can still free with the sealed pointer.
cheriot-rtos
github_2023
cpp
379
CHERIoT-Platform
davidchisnall
@@ -1460,6 +1460,7 @@ extern "C" SchedulerEntryInfo loader_entry_point(const ImgHdr &imgHdr, // invoke the exception entry point. auto exportEntry = build<ExportEntry>( imgHdr.scheduler().exportTable, + // XXX NWF
???
cheriot-rtos
github_2023
cpp
379
CHERIoT-Platform
davidchisnall
@@ -31,9 +31,10 @@ using namespace CHERI; /** * Exit simulation, reporting the error code given as the argument. */ -void simulation_exit(uint32_t code) +int simulation_exit(uint32_t code)
Why is this an `int`? I don't think any code should ever be expected to handle this returning. The fallback mode should probably be to infinite loop.
cheriot-rtos
github_2023
cpp
379
CHERIoT-Platform
davidchisnall
@@ -67,7 +67,7 @@ compartment_error_handler(ErrorState *frame, size_t mcause, size_t mtval) DebugErrorHandler::log("Unhandled error {} at {}", mcause, frame->pcc); } - simulation_exit(1); + (void)simulation_exit(1);
As above, so far every call to this function has discarded the return result. It either exits (and doesn't return) or doesn't exit (and we're not in a simulator that can exit). We get no information from the non-void return.
cheriot-rtos
github_2023
cpp
379
CHERIoT-Platform
davidchisnall
@@ -3,14 +3,18 @@ #pragma once #include <compartment.h> +#include <errno.h> #include <stdint.h> #ifdef SIMULATION /** * Exit simulation, reporting the error code given as the argument. */ -[[cheri::interrupt_state(disabled)]] void __cheri_compartment("sched") +[[cheri::interrupt_state(disabled)]] int __che...
We can just silence the warning here, I think. Or we can rename this to `scheduler_exit_simulation` and have a `void` wrapper that calls it.
cheriot-rtos
github_2023
cpp
379
CHERIoT-Platform
davidchisnall
@@ -282,7 +282,7 @@ ssize_t __cheri_compartment("alloc") * state. It can block indefinitely if another thread is allocating and * freeing memory while this runs. */ -void __cheri_compartment("alloc") heap_quarantine_empty(void); +int __cheri_compartment("alloc") heap_quarantine_empty(void);
Please update the comment to say that this returns 0 or -ECOMPARTMENTFAIL.
cheriot-rtos
github_2023
cpp
379
CHERIoT-Platform
davidchisnall
@@ -72,8 +72,9 @@ namespace void unlock() { assert(high == LockBit); - high = 0; - futex_wake(&high, std::numeric_limits<uint32_t>::max()); + high = 0; + int res = futex_wake(&high, std::numeric_limits<uint32_t>::max()); + assert(res >= 0);
Please don't use `assert`, I don't think we use it anywhere else in the codebase. It is there *purely* because C99 requires it, not because we should use it.
cheriot-rtos
github_2023
cpp
379
CHERIoT-Platform
rmn30
@@ -224,7 +224,10 @@ namespace // Release the lock before sleeping g.unlock(); Timeout smallSleep{1}; - thread_sleep(&smallSleep); + if (thread_sleep(&smallSleep) < 0)
Not going to block merge but would be nice to have a union type for this. Did you audit all calls to `thread_sleep`, even ones that didn't trigger the `nodiscard` warning?
cheriot-rtos
github_2023
cpp
379
CHERIoT-Platform
rmn30
@@ -9,7 +9,7 @@ * revocation pass, it will scan a region of memory and then return.
Ought to have a comment here describing the return value. Not a blocker.
cheriot-rtos
github_2023
cpp
379
CHERIoT-Platform
rmn30
@@ -159,15 +159,17 @@ namespace } // namespace -void revoker_tick() +int revoker_tick() { // If we've been asked to run, make sure that we're running. if (state == State::NotRunning) { advance(); } // Do some work. - return scan_range();
Why was there a return in a void function!?
cheriot-rtos
github_2023
cpp
379
CHERIoT-Platform
rmn30
@@ -94,7 +94,14 @@ namespace thread_pool return; } (*fn)(); - token_obj_destroy(MALLOC_CAPABILITY, key, static_cast<SObj>(rawFn)); + /* + * This fails only if the thread pool runner compartment can't make + * cross-compartment calls to the allocator at all, since we're + * in its initial trust...
Worthy of a debug assertion?
cheriot-rtos
github_2023
cpp
379
CHERIoT-Platform
rmn30
@@ -471,21 +499,19 @@ namespace ptr2); state = 2; // Yield to allow the hazards to be dropped. - Timeout t{1}; - thread_sleep(&t); + TEST(sleep(1) >= 0, "Failed to yield to drop hazards"); // Try a double free. This may logically succeed, but should not affect // our quota. - heap_free(SECOND_H...
Why doesn't this one test the return value of `heap_free`?
cheriot-rtos
github_2023
cpp
400
CHERIoT-Platform
davidchisnall
@@ -34,5 +34,12 @@ constexpr StackCheckMode StackMode = #endif ; -#define STACK_CHECK(expected) \ - StackUsageCheck<StackMode, expected, __PRETTY_FUNCTION__> stackCheck + +#if __CHERIOT__ >= 20250102
```suggestion #if __has_builtin(__builtin_cheriot_get_specified_minimum_stack) ```
cheriot-rtos
github_2023
cpp
400
CHERIoT-Platform
davidchisnall
@@ -34,5 +34,12 @@ constexpr StackCheckMode StackMode = #endif ; -#define STACK_CHECK(expected) \ - StackUsageCheck<StackMode, expected, __PRETTY_FUNCTION__> stackCheck + +#if __CHERIOT__ >= 20250102 + #define STACK_CHECK(expected) ...
```suggestion static_assert(__builtin_cheriot_get_specified_minimum_stack() == expected, "expected value does not match value provided as function argument"); \ ```
cheriot-rtos
github_2023
others
400
CHERIoT-Platform
nwf
@@ -819,20 +819,20 @@ namespace * StackUsageCheck<DebugFlag, 128, __PRETTY_FUNCTION__> stackCheck; * ``` */ - template<StackCheckMode Mode, size_t Expected, DebugContext Fn> + template<StackCheckMode Mode, DebugContext Fn> class StackUsageCheck { /** * The expected maximum. This class is templated ...
```suggestion size_t stackUsage; ``` The change from a template parameter to a constructor parameter is... incomplete? On both the "old" llvm-13 and new compiler, as it stands, this PR... 1. creates and *mutates* a `static` object in globals, and 2. stores a pointer to that static object on the stack, which...
cheriot-rtos
github_2023
others
357
CHERIoT-Platform
nwf
@@ -0,0 +1,403 @@ +#pragma once +#include <cdefs.h> +#include <debug.hh> +#include <stdint.h> +#include <utils.hh> + +namespace SonataSpi +{ + /// Sonata SPI Interrupts + typedef enum [[clang::flag_enum]] + : uint32_t{ + /// Raised when a SPI operation completes and the block has become idle. + InterruptComplet...
Er, perhaps this is just a polarity thing, but I'd expect the `InterruptTransmitWatermark` to fire when the transmit FIFO is _below_ its watermark (that is, it has room to accept a positive natural number of bytes before overflow) and, dually, `InterruptReceiveWatermakr` to fire when the receive FIFO is _above_ its wat...
cheriot-rtos
github_2023
others
357
CHERIoT-Platform
nwf
@@ -0,0 +1,403 @@ +#pragma once +#include <cdefs.h> +#include <debug.hh> +#include <stdint.h> +#include <utils.hh> + +namespace SonataSpi +{ + /// Sonata SPI Interrupts + typedef enum [[clang::flag_enum]] + : uint32_t{ + /// Raised when a SPI operation completes and the block has become idle. + InterruptComplet...
Stale comment, given the code below?
cheriot-rtos
github_2023
others
357
CHERIoT-Platform
nwf
@@ -0,0 +1,403 @@ +#pragma once +#include <cdefs.h> +#include <debug.hh> +#include <stdint.h> +#include <utils.hh> + +namespace SonataSpi +{ + /// Sonata SPI Interrupts + typedef enum [[clang::flag_enum]] + : uint32_t{ + /// Raised when a SPI operation completes and the block has become idle. + InterruptComplet...
What happens if this has a population count other than 1?
cheriot-rtos
github_2023
others
395
CHERIoT-Platform
davidchisnall
@@ -6,9 +6,6 @@ resources: - pipeline: LLVM project: CHERI-MCU source: LLVM
I think we can lose this file entirely.
cheriot-rtos
github_2023
cpp
377
CHERIoT-Platform
davidchisnall
@@ -2807,4 +2807,155 @@ class MState { ABORT(); } + +#ifndef NDEBUG
Please don't gate things on this macro. Use feature flags.
cheriot-rtos
github_2023
cpp
377
CHERIoT-Platform
davidchisnall
@@ -1268,3 +1268,10 @@ size_t heap_available() { return gm->heapFreeSize; } + +#ifndef NDEBUG
Same here. This should be controlled by an option, not a global flag that we don't use for any other purpose but that is defined by the C spec.
cheriot-rtos
github_2023
cpp
377
CHERIoT-Platform
rmn30
@@ -2811,4 +2811,163 @@ class MState { ABORT(); } + +#if HEAP_RENDER + public: + /** + * "Render" the heap for debugging. + */ + template<bool Asserts = false, bool Chatty = true>
I think Asserts should default to `true`. They don't look that expensive compared to the debug logs (I guess `ds::linked_list::is_well_formed` may be linear in length of list?).
cheriot-rtos
github_2023
cpp
363
CHERIoT-Platform
rmn30
@@ -240,13 +240,56 @@ namespace } } // namespace +void check_sealed_scoping() +{ + Capability<void> o{switcher_current_thread()}; + TEST(o.is_valid() && (o.type() == CheriSealTypeSealedTrustedStacks), + "Shared object cap not as expected: {}", + o); + + // Take the address of the o cap, requiring that it...
I would suggest separating clauses into differnt `TEST` / `TEST_EQUAL` as that will provide a clearer error if anything goes wrong.
cheriot-rtos
github_2023
cpp
363
CHERIoT-Platform
rmn30
@@ -240,13 +240,56 @@ namespace } } // namespace +void check_sealed_scoping() +{ + Capability<void> o{switcher_current_thread()}; + TEST(o.is_valid() && (o.type() == CheriSealTypeSealedTrustedStacks), + "Shared object cap not as expected: {}", + o); + + // Take the address of the o cap, requiring that it...
I think we should add a `drop_perms` method to `Capability` to do this. The architectural permissions were ordered to optimize dropping specific permissions in this way for common permissions to drop (e.g. LM, LG).