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
328
CHERIoT-Platform
rmn30
@@ -831,6 +865,7 @@ namespace false>(config.trustedStack); threadTStack->mepcc = pcc; threadTStack->cgp = cgp; + threadTStack->cra = initialCRA;
Please could you update `fail-simulator-on-error.h` to account for this? Should be able to delete some code :-)
cheriot-rtos
github_2023
cpp
328
CHERIoT-Platform
rmn30
@@ -93,5 +68,6 @@ compartment_error_handler(ErrorState *frame, size_t mcause, size_t mtval) DebugErrorHandler::log("Unhandled error {} at {}", mcause, frame->pcc); simulation_exit(1); } + return ErrorRecoveryBehaviour::ForceUnwind;
I don't think it matters but this return is now unreachable. You could bring `simulation_exit` below the `if`. It should be marked `noreturn`. Update: since `simulation_exit` is a cross compartment call to the scheduler it probably shouldn't be marked `noreturn` as it could fail (e.g. due to trusted stack overflow)....
cheriot-rtos
github_2023
others
328
CHERIoT-Platform
rmn30
@@ -589,7 +590,7 @@ exception_entry_asm: // See if we can find a handler:
This comment doesn't seem to apply the succeeding lines. Is that updated in another PR?
cheriot-rtos
github_2023
cpp
328
CHERIoT-Platform
davidchisnall
@@ -796,6 +823,13 @@ namespace // Space per thread for hazard pointers. static constexpr size_t HazardPointerSpace = HazardPointersPerThread * sizeof(void *); + + auto initialCRA =
What is CRA? Something return address?
cheriot-rtos
github_2023
others
328
CHERIoT-Platform
davidchisnall
@@ -162,6 +162,8 @@ SECTIONS LONG(.compartment_switcher_start); # Compartment switcher end SHORT(.compartment_switcher_end - .compartment_switcher_start); + # Cross-compartment call return path + SHORT(switcher_skip_compartment_call - .compartment_switcher_start);
Please can you generate a new magic value if you're changing the values?
cheriot-rtos
github_2023
cpp
328
CHERIoT-Platform
davidchisnall
@@ -328,6 +338,23 @@ namespace return ptr.seal(key); } + template<InterruptStatus Status, typename T> + T *seal_return(Capability<T> ptr) + { + static_assert((Status == InterruptStatus::Enabled) || + (Status == InterruptStatus::Disabled)); + +#pragma clang diagnostic push +#pragma clang diagnosti...
This makes me a bit nervous. I'd normally do this kind of compile-time map with a template so that we get a compile error if something is invalid.
cheriot-rtos
github_2023
others
325
CHERIoT-Platform
nwf
@@ -0,0 +1,313 @@ +Auditing compartments +===================== + +This example shows a simple use of the auditing tool. +The code in this is very simple: + + - A `caesar` compartment exposes interfaces to encrypt and decrypt data using a Caesar cypher. + - A `producer` compartment uses this to encrypt a value using a ...
```suggestion Piping the output to `jq` is optional, but will give pretty-printed output for valid JSON (remove it for places where you get an error: `undefined` is not rendered by `jq`). ```
cheriot-rtos
github_2023
others
325
CHERIoT-Platform
nwf
@@ -0,0 +1,313 @@ +Auditing compartments +===================== + +This example shows a simple use of the auditing tool. +The code in this is very simple: + + - A `caesar` compartment exposes interfaces to encrypt and decrypt data using a Caesar cypher. + - A `producer` compartment uses this to encrypt a value using a ...
```suggestion The underscores are distinct anonymous variables. ```
cheriot-rtos
github_2023
others
325
CHERIoT-Platform
nwf
@@ -0,0 +1,313 @@ +Auditing compartments +===================== + +This example shows a simple use of the auditing tool. +The code in this is very simple: + + - A `caesar` compartment exposes interfaces to encrypt and decrypt data using a Caesar cypher. + - A `producer` compartment uses this to encrypt a value using a ...
Do you want to link to it? (https://github.com/CHERIoT-Platform/cheriot-audit/blob/main/rtos.hh , I assume?)
cheriot-rtos
github_2023
cpp
324
CHERIoT-Platform
davidchisnall
@@ -34,7 +34,11 @@ typedef struct __jmp_buf jmp_buf[1]; * C `setjmp` function. Returns (up to) twice. First returns 0, returns a * value passed to `longjmp` on the second return. */ -__attribute__((returns_twice)) extern "C" int setjmp(jmp_buf env); +#if defined(__cplusplus) +extern "C" +#endif
Please use the __BEGIN_DECLS macro like every other header.
cheriot-rtos
github_2023
cpp
316
CHERIoT-Platform
nwf
@@ -69,16 +69,41 @@ SObj __cheri_compartment("alloc") size_t); /** - * Unseal the obj given the key. + * Unseal the object given the key. * - * The key must have the permit-unseal permission. + * The key may be either a static or dynamic key and the object may be either + * allocated dynamica...
```suggestion * The key should be a static sealing key and the object must be a statically ``` should? must? It won't work if given a dynamic sealing key, because the loader only seals static objects containing static key values, right?
cheriot-rtos
github_2023
cpp
316
CHERIoT-Platform
nwf
@@ -69,16 +69,41 @@ SObj __cheri_compartment("alloc") size_t); /** - * Unseal the obj given the key. + * Unseal the object given the key. * - * The key must have the permit-unseal permission. + * The key may be either a static or dynamic key and the object may be either + * allocated dynamica...
Do you want to say something about the permitted combinations, specifically that a dynamic key and static object won't work?
cheriot-rtos
github_2023
cpp
316
CHERIoT-Platform
nwf
@@ -668,29 +650,18 @@ __cheriot_minimum_stack(0xc0) int multiwaiter_wait(Timeout *timeout, namespace { /** - * + * An interrupt capability. */ - struct InterruptCapability : Handle + struct InterruptCapability : Handle</*IsDynamic=*/false> { - /** - * Type marker used by `Handle`, tells it to us...
I understand (now) that this is meant as "(dynamic type) marker", but maybe just call it `sealing_type` or `sealing_key` by similarity with `STATIC_SEALING_TYPE` or `SKey`/`InterruptKey`/`MultiWaiterKey`.
cheriot-rtos
github_2023
others
312
CHERIoT-Platform
davidchisnall
@@ -546,54 +546,67 @@ namespace CHERI return *this; } + private: + BoundsProxy &set_inexact_at_most_slow(size_t bounds) + { + ptraddr_t newBaseAddress = + static_cast<ptraddr_t>(reinterpret_cast<uintptr_t>(ptr()));
Can we use the address get intrinsic instead of these casts?
cheriot-rtos
github_2023
others
301
CHERIoT-Platform
rmn30
@@ -880,8 +933,21 @@ __Z22switcher_recover_stackv: // two instructions. cspecialr ca0, mtdc clhu a1, TrustedStack_offset_frameoffset(ca0) + addi a1, a1, -TrustedStackFrame_size cincoffset ca0, ca0, a1 clc ca0, TrustedStackFrame_offset_csp(ca0) + // I...
Please complete this comment. A bit more explanation of the lines below would be nice too. Why are these the correct bounds?
cheriot-rtos
github_2023
others
301
CHERIoT-Platform
rmn30
@@ -0,0 +1,9 @@ +Unwind error handler library +---------------------------- + +This library provides an error handler that unwinds using the APIs in [`unwind.h`](../../include/unwind.h). + +This error handler can work even in cases of stack overflow. + +Note: Unlike most libraries, this is *not* built as a shared libra...
Maybe mention why not?
cheriot-rtos
github_2023
cpp
301
CHERIoT-Platform
nwf
@@ -855,6 +855,8 @@ namespace // Stack pointer points to the top of the stack. stack.address() += config.stack.size(); + // Reserve space at the start of the stack for error handling and so on. + stack.address() -= 16;
This `16` needs to agree with the `16` at https://github.com/CHERIoT-Platform/cheriot-rtos/blob/e4ebccc60840de78a919c42e6dd7045c99b68245/sdk/core/switcher/entry.S#L231 . Can we get a named constant (`#define` is fine)?
cheriot-rtos
github_2023
cpp
301
CHERIoT-Platform
rmn30
@@ -59,7 +59,7 @@ compartment_error_handler(ErrorState *frame, size_t mcause, size_t mtval) if (registerNumber == CHERI::RegisterNumber::CRA && returnCapability.address() == 0 && exceptionCode == CHERI::CauseCode::TagViolation && - stackCapability.top() == stackCapability.address()) + (stackC...
```suggestion (stackCapability.top() - STACK_ENTRY_RESERVED_SPACE) == stackCapability.address()) ``` or at least a comment explaining the magic 16.
cheriot-rtos
github_2023
others
301
CHERIoT-Platform
rmn30
@@ -597,36 +597,86 @@ exception_entry_asm: // Load the interrupted thread's stack pointer into ct0 clc ct0, TrustedStack_offset_csp(csp) - // Fetch the base of compartment stack before cincoffset for later - // comparison. The subsequent cincoffset could cause the base to change, if - // the capabi...
```suggestion ``` Remove misleading comment.
cheriot-rtos
github_2023
others
301
CHERIoT-Platform
rmn30
@@ -13,7 +13,9 @@ SECTIONS # delta. The final layout will be the compartment import table # followed by the text segment. There won't be any padding, because # the compartment import table is more strongly aligned than text. - LONG(DEFINED(compartment_error_handler) ? compartment_error_handler - __compartme...
Would it be possible to get an error if this offset is truncated?
cheriot-rtos
github_2023
others
301
CHERIoT-Platform
rmn30
@@ -34,6 +36,7 @@ SECTIONS # If there is a compartment error handler, make sure that it is before # anything that can have linker relaxations so that its displacement # from __compartment_code_start is a constant. + *(.compartment_error_handler_stackless)); *(.compartment_error_handler);
If the stackless error handler contains a linker relaxation won't this violate the assertion in the comment for the (non-stackless) compartment_error_handler?
cheriot-rtos
github_2023
others
301
CHERIoT-Platform
rmn30
@@ -597,36 +597,85 @@ exception_entry_asm: // Load the interrupted thread's stack pointer into ct0 clc ct0, TrustedStack_offset_csp(csp) - // Fetch the base of compartment stack before cincoffset for later - // comparison. The subsequent cincoffset could cause the base to change, if - // the capabi...
Minor: I think you could lift this common code before the branch. If you need an extra register maybe you could use `a0` which only contains 1 or 0?
cheriot-rtos
github_2023
others
297
CHERIoT-Platform
marnovandermaas
@@ -164,7 +164,7 @@ switcher_scheduler_entry_csp: .p2align 2 .type __Z26compartment_switcher_entryz,@function __Z26compartment_switcher_entryz: - cincoffset csp, csp, -SPILL_SLOT_SIZE + cincoffset csp, csp, -(SPILL_SLOT_SIZE)
Is this a bug fix related to increasing the stack size?
cheriot-rtos
github_2023
cpp
297
CHERIoT-Platform
marnovandermaas
@@ -0,0 +1,98 @@ +#pragma once +#include <cdefs.h> +#include <setjmp.h> + +/** + * On-stack linked list of cleanup handlers. + */ +struct CleanupList +{ + /// Next pointer. + CleanupList *next; + /// Jump buffer to return to. + __jmp_buf env; +}; + +/** + * Head of the cleanup list. + * + * This is stored in the space ...
Nit: handling
cheriot-rtos
github_2023
cpp
297
CHERIoT-Platform
rmn30
@@ -0,0 +1,64 @@ +// Copyright Microsoft and CHERIoT Contributors. +// SPDX-License-Identifier: MIT +#pragma once + +/** + * This is a minimal implementation of setjmp/longjmp. + * + * CHERIoT cannot store a `jmp_buf` anywhere other than the stack without + * clearing tags (which will then cause `longjmp` to fail. + */...
Very minor nit: you've spelled this `cret` above and `cjr` here. I think I can see why but it's a bit weird...
cheriot-rtos
github_2023
cpp
297
CHERIoT-Platform
nwf
@@ -0,0 +1,97 @@ +#pragma once +#include <cdefs.h> +#include <setjmp.h> + +/** + * On-stack linked list of cleanup handlers. + */ +struct CleanupList +{ + /// Next pointer. + CleanupList *next; + /// Jump buffer to return to. + __jmp_buf env; +}; + +/** + * Head of the cleanup list. + * + * This is stored in the space ...
Add some commentary about this being guaranteed to be zero'd because it's managed by the switcher? Otherwise it looks, from C, like the head is on stack and never initialized.
cheriot-rtos
github_2023
cpp
297
CHERIoT-Platform
nwf
@@ -0,0 +1,64 @@ +// Copyright Microsoft and CHERIoT Contributors. +// SPDX-License-Identifier: MIT +#pragma once + +/** + * This is a minimal implementation of setjmp/longjmp. + * + * CHERIoT cannot store a `jmp_buf` anywhere other than the stack without + * clearing tags (which will then cause `longjmp` to fail.
Missing close paren.
cheriot-rtos
github_2023
cpp
297
CHERIoT-Platform
rmn30
@@ -0,0 +1,98 @@ +#pragma once +#include <cdefs.h> +#include <setjmp.h> + +/** + * On-stack linked list of cleanup handlers. + */ +struct CleanupList +{ + /// Next pointer. + CleanupList *next; + /// Jump buffer to return to. + __jmp_buf env; +}; + +/** + * Head of the cleanup list. + * + * This is stored in the space ...
Does the first invocation of a thread entry go through the switcher path that reserves the space on stack? If not this might overwrite stack pointer and link register stored by the entry function. Maybe no big deal but perhaps unexpected.
cheriot-rtos
github_2023
others
289
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,350 @@ +#pragma once +#include <debug.hh> +#include <stdint.h> +#include <utils.hh> + +/** + * A simple driver for Sonata's XADC (Xilinx Analogue to Digital Converter). + * + * Documentation source can be found at: + * https://github.com/lowRISC/sonata-system/blob/97a525c48f7bf051b999d0178dba04859819bc5e/doc...
I think the overall approach is good, but this is an anti pattern. You are loading from the import table and then storing it in the memory here. Accessing the field is about as expensive as the original initialisation was. The typical pattern here is to add an always-inline function that wraps the macro.
cheriot-rtos
github_2023
cpp
295
CHERIoT-Platform
nwf
@@ -0,0 +1,19 @@ +#pragma once +// SPDX-License-Identifier: MIT +// Copyright CHERIoT Contributors + +/** + * This header is part of C11 (and supported for compatibility in older + * versions) but is gone in C23 because the C keywords were moved out of the + * reserved-for-the-implementation namespace into the global o...
```suggestion * C++-compatible spelling for `_Noreturn`. ```
cheriot-rtos
github_2023
cpp
295
CHERIoT-Platform
nwf
@@ -0,0 +1,27 @@ +#pragma once +// SPDX-License-Identifier: MIT +// Copyright CHERIoT Contributors + +/** + * This header is part of C11 (and supported for compatibility in older + * versions) but is gone in C23 because the C keywords matching their C++ + * equivalents were added. + */ +#ifdef __STDC_VERSION__ +# if __...
```suggestion * C++-compatible spelling for `_Alignas`. ```
cheriot-rtos
github_2023
cpp
295
CHERIoT-Platform
nwf
@@ -0,0 +1,27 @@ +#pragma once +// SPDX-License-Identifier: MIT +// Copyright CHERIoT Contributors + +/** + * This header is part of C11 (and supported for compatibility in older + * versions) but is gone in C23 because the C keywords matching their C++ + * equivalents were added. + */ +#ifdef __STDC_VERSION__ +# if __...
```suggestion * C++-compatible spelling for `_Alignof`. ```
cheriot-rtos
github_2023
others
288
CHERIoT-Platform
HU90m
@@ -0,0 +1,66 @@ +#pragma once +#include <debug.hh> +#include <stdint.h> + +/** + * A driver for Sonata's PWM. + * + * Documentation source can be found at: + * https://github.com/lowRISC/sonata-system/blob/97a525c48f7bf051b999d0178dba04859819bc5e/doc/ip/pwm.md + * + * Rendered documentation is served from: + * https:/...
Since 255 is the maximum PWM period, I think it would be nicer to have `period` and `dutyCycle` be `uint8_t` and remove the `MaxPwmPeriod`. We don't need this to be parameterised.
cheriot-rtos
github_2023
others
288
CHERIoT-Platform
HU90m
@@ -0,0 +1,66 @@ +#pragma once +#include <debug.hh> +#include <stdint.h> + +/** + * A driver for Sonata's PWM. + * + * Documentation source can be found at: + * https://github.com/lowRISC/sonata-system/blob/97a525c48f7bf051b999d0178dba04859819bc5e/doc/ip/pwm.md + * + * Rendered documentation is served from: + * https:/...
```suggestion * The number of PWM outputs available. ```
cheriot-rtos
github_2023
others
288
CHERIoT-Platform
HU90m
@@ -0,0 +1,66 @@ +#pragma once +#include <debug.hh> +#include <stdint.h> + +/** + * A driver for Sonata's PWM. + * + * Documentation source can be found at: + * https://github.com/lowRISC/sonata-system/blob/97a525c48f7bf051b999d0178dba04859819bc5e/doc/ip/pwm.md + * + * Rendered documentation is served from: + * https:/...
A little more here would be nice. Something like: "The period of the output, set with the number of clock cycles a period should last."
cheriot-rtos
github_2023
others
288
CHERIoT-Platform
HU90m
@@ -0,0 +1,66 @@ +#pragma once +#include <debug.hh> +#include <stdint.h> + +/** + * A driver for Sonata's PWM. + * + * Documentation source can be found at: + * https://github.com/lowRISC/sonata-system/blob/97a525c48f7bf051b999d0178dba04859819bc5e/doc/ip/pwm.md + * + * Rendered documentation is served from: + * https:/...
Please could you document the parameters of the function.
cheriot-rtos
github_2023
others
288
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,66 @@ +#pragma once +#include <debug.hh> +#include <stdint.h> + +/** + * A driver for Sonata's PWM.
High-level comment: Our [coding style](https://github.com/CHERIoT-Platform/cheriot-rtos/blob/main/docs/CodingConventions.md) asks you to avoid abbreviations. I had to look up that PWM stood for pulse-width-modulator. Expanding the name prevents the next person having to do this.
cheriot-rtos
github_2023
others
288
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,66 @@ +#pragma once +#include <debug.hh> +#include <stdint.h> + +/** + * A driver for Sonata's PWM. + * + * Documentation source can be found at: + * https://github.com/lowRISC/sonata-system/blob/97a525c48f7bf051b999d0178dba04859819bc5e/doc/ip/pwm.md + * + * Rendered documentation is served from: + * https:/...
We don't need a Pwm suffix on everything that's implicitly namespaced by being part of this class.
cheriot-rtos
github_2023
others
288
CHERIoT-Platform
davidchisnall
@@ -63,6 +63,10 @@ "plic": { "start" : 0x88000000, "end" : 0x88400000 + }, + "pwm": {
@HU90m Is this also present in the 0.2 release?
cheriot-rtos
github_2023
others
283
CHERIoT-Platform
nwf
@@ -683,6 +683,36 @@ rule("firmware") end end) + local shared_objects = {} + visit_all_dependencies(function (target) + local globals = target:values("shared_objects") + if globals then + for name, size in pairs(globals) do + if not (name == "__wrap_locked__") then + if shared_objects[global]...
Could we generalize the template to permit `__export_mem_hazard_pointers` and `__export_mem_allocator_epoch` to also be included in the `shared_objects` table, so that they get sorted for size along with the user defined ones? Or, could we make those objects use this generic mechanism instead?
cheriot-rtos
github_2023
cpp
283
CHERIoT-Platform
nwf
@@ -78,6 +98,44 @@ #define MMIO_CAPABILITY(type, name) \ MMIO_CAPABILITY_WITH_PERMISSIONS(type, name, true, true, false, false) +/** + * Provide a capability of the type `type *` referring to the pre-shared object + * with `name` as its name. This macro can be used only ...
I don't see any commentary about the necessary corresponding `xmake` bits. There's a worked example down in `tests/` but I think some prose might be in order?
cheriot-rtos
github_2023
others
279
CHERIoT-Platform
nwf-msr
@@ -43,3 +45,24 @@ Any of these can be cleared from a copy of the pointer before passing it to othe For example, if you remove `W` and `M` permissions from a pointer that you pass as a parameter then you have a guarantee that nothing reachable from the pointer will be mutated. Similarly, if you remove `G` and `L` the...
Perhaps hyphenate, here and throughout? ```suggestion The next three use cases show the handling of a sub-object, a capability that references a sub-range of the allocation. ```
cheriot-rtos
github_2023
others
279
CHERIoT-Platform
nwf-msr
@@ -43,3 +45,24 @@ Any of these can be cleared from a copy of the pointer before passing it to othe For example, if you remove `W` and `M` permissions from a pointer that you pass as a parameter then you have a guarantee that nothing reachable from the pointer will be mutated. Similarly, if you remove `G` and `L` the...
Hm. I might expand that a bit. Something like... ```suggestion In the first of these the sub object is passed to free(). As no claims have been made, free() would take action only if a cap to the entire object were passed in. Thus, this call to free() has no effect on the heap or on the pointers held by the cli...
cheriot-rtos
github_2023
others
279
CHERIoT-Platform
nwf-msr
@@ -43,3 +45,24 @@ Any of these can be cleared from a copy of the pointer before passing it to othe For example, if you remove `W` and `M` permissions from a pointer that you pass as a parameter then you have a guarantee that nothing reachable from the pointer will be mutated. Similarly, if you remove `G` and `L` the...
"is freed" might mean several things. Perhaps... ```suggestion In the second use case a claim is made on the sub object. This charges the claimant's quota and ensures that the sub-object (and, indeed, the entire object) remains allocated for the duration of the claim, even when the enclosing allocation is passed ...
cheriot-rtos
github_2023
others
279
CHERIoT-Platform
nwf-msr
@@ -43,3 +45,24 @@ Any of these can be cleared from a copy of the pointer before passing it to othe For example, if you remove `W` and `M` permissions from a pointer that you pass as a parameter then you have a guarantee that nothing reachable from the pointer will be mutated. Similarly, if you remove `G` and `L` the...
This might be good motivation to finally rename "fast" claims, perhaps before landing an updated version of this PR? @davidchisnall?
cheriot-rtos
github_2023
others
279
CHERIoT-Platform
nwf-msr
@@ -43,3 +45,24 @@ Any of these can be cleared from a copy of the pointer before passing it to othe For example, if you remove `W` and `M` permissions from a pointer that you pass as a parameter then you have a guarantee that nothing reachable from the pointer will be mutated. Similarly, if you remove `G` and `L` the...
```suggestion Each thread may hold only at most one fast claim (on up to two objects). ```
cheriot-rtos
github_2023
others
279
CHERIoT-Platform
nwf-msr
@@ -43,3 +45,24 @@ Any of these can be cleared from a copy of the pointer before passing it to othe For example, if you remove `W` and `M` permissions from a pointer that you pass as a parameter then you have a guarantee that nothing reachable from the pointer will be mutated. Similarly, if you remove `G` and `L` the...
```suggestion The final use case shows how an object initially allocated in one compartment may be claimed by (add counted against the quota) of a second compartment. ```
cheriot-rtos
github_2023
others
279
CHERIoT-Platform
nwf-msr
@@ -43,3 +45,24 @@ Any of these can be cleared from a copy of the pointer before passing it to othe For example, if you remove `W` and `M` permissions from a pointer that you pass as a parameter then you have a guarantee that nothing reachable from the pointer will be mutated. Similarly, if you remove `G` and `L` the...
```suggestion This allows, for example, a zero-copy data buffer pattern. ```
cheriot-rtos
github_2023
others
279
CHERIoT-Platform
nwf-msr
@@ -43,3 +45,24 @@ Any of these can be cleared from a copy of the pointer before passing it to othe For example, if you remove `W` and `M` permissions from a pointer that you pass as a parameter then you have a guarantee that nothing reachable from the pointer will be mutated. Similarly, if you remove `G` and `L` the...
```suggestion Even when the allocation is freed by (and removed from the quota of) the original compartment, it remains valid, because it is now claimed by the second compartment. ```
cheriot-rtos
github_2023
others
279
CHERIoT-Platform
nwf-msr
@@ -43,3 +45,24 @@ Any of these can be cleared from a copy of the pointer before passing it to othe For example, if you remove `W` and `M` permissions from a pointer that you pass as a parameter then you have a guarantee that nothing reachable from the pointer will be mutated. Similarly, if you remove `G` and `L` the...
```suggestion Note that the quota charge for a claim on an object is slightly larger than the size of the object itself, because a small amount of additional heap is required for the claim headers. ```
cheriot-rtos
github_2023
cpp
279
CHERIoT-Platform
nwf-msr
@@ -5,17 +5,141 @@ #include <debug.hh> #include <fail-simulator-on-error.h> +#include "claimant.h" + /// Expose debugging features unconditionally for this compartment. using Debug = ConditionalDebug<true, "Allocating compartment">; /// Thread entry point. void __cheri_compartment("allocate") entry() { - voi...
I know the original didn't, but it might be nice to sprinkle in some executable assertions about what the user should see, in addition to the commentary.
cheriot-rtos
github_2023
cpp
279
CHERIoT-Platform
nwf-msr
@@ -5,17 +5,141 @@ #include <debug.hh> #include <fail-simulator-on-error.h> +#include "claimant.h" + /// Expose debugging features unconditionally for this compartment. using Debug = ConditionalDebug<true, "Allocating compartment">; /// Thread entry point. void __cheri_compartment("allocate") entry() { - voi...
Belatedly... Strictly speaking, FWIW, you don't need to have a separate compartment here; it would suffice to have a 2nd malloc capability. I think maybe an aside in a comment to that effect would be useful, but also having it be an actual compartment is more reflective of how users will actually see this used in prac...
cheriot-rtos
github_2023
cpp
272
CHERIoT-Platform
rmn30
@@ -140,9 +140,10 @@ int memory_safety_inner_entry(MemorySafetyBugClass operation) volatilePointer = buf; Capability tmp = volatilePointer; Debug::log("tmp: {}", tmp); - Debug::Assert(!tmp.is_valid(), - "Code after storing stack pointer into global should " - "be unreachab...
This message still needs fixing....
cheriot-rtos
github_2023
cpp
270
CHERIoT-Platform
rmn30
@@ -136,11 +137,13 @@ int memory_safety_inner_entry(MemorySafetyBugClass operation) char buf[0x10]; Debug::log("Trigger storing a stack pointer {} into global", Capability{buf}); - allocation = buf; - - Debug::Assert(false, + volatilePointer = buf; + Capability tmp = volatilePointer; + ...
This message needs updating.
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
HU90m
@@ -0,0 +1,639 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
Try to avoid abbreviations in names ```suggestion TransmitControl = 0x70, ```
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
HU90m
@@ -0,0 +1,639 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
```suggestion enum [[clang::flag_enum]] RxFrameHeaderStatus : uint16_t ```
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
HU90m
@@ -0,0 +1,639 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
If everything is public, could this just be a `struct`?
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
HU90m
@@ -0,0 +1,639 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
Would it be better to have debug messages switched off by default?
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
The firewall does not check because the threat model assumes that a DoS on the firewall by the T P/IP stack does not make sense. The hardware-interface layer of a driver should not be defining a threat model.
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
hlef
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
Having a comment to explain what the function does would be nice (though the name of the function is quite clear)
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
hlef
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
Do these need to be `uint32_t` or could we make them `uint8_t`?
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
hlef
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
It would be great to have a comment here to tell me what is going on, because there are a lot of magic values
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
hlef
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
Same here, it would be great to have a comment to explain what is being done
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
hlef
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
How about using a `sizeof` here, instead of `2`?
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
hlef
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
Same here, I think that we can use a `sizeof`?
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
hlef
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
Same comment here regarding the `sizeof`
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
hlef
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
Same comment here regarding the `sizeof`
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
hlef
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
It would be great to have a comment telling what this global is used for.
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
hlef
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
Where is the 150ms coming from?
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
hlef
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
What is the reason why we omit it?
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
hlef
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
This will set `buffer` to a null pointer if the allocator runs out of memory
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
hlef
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
I suspect that this will crash if the allocation of `buffer` failed (`blocking_read` does not check the pointer).
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
hlef
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
I am not sure what is being done here, it would be great to add a comment!
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
hlef
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
This allocation may fail and should be checked
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
hlef
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
This will crash if the allocation above failed
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
hlef
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
Just like in the Arty A7 driver, I think that we need to restrict the permissions of the capability before returning it to the caller (remove all permissions except load).
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
hlef
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
You may want to wrap the `transmitBuffer` into a smart pointer with a delete function to avoid manually calling `delete` at all exits.
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
hlef
@@ -0,0 +1,633 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
I am confused by what this is doing. How is this padding to 4 bytes? Shouldn't this happen after adding the 5 other bytes for header and transmission command?
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,662 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
As below, please see [the naming rules in the style guide](https://github.com/microsoft/cheriot-rtos/blob/main/docs/CodingConventions.md#use-full-words). These are also missing doc comments.
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,662 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
```suggestion /** ```
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,662 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
These should be doc comments (either `///` or `/**`, generally preferring the former for single-line comments and the latter for multi-line ones).
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,662 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
Missing doc comments.
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,662 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
It would be nice to explain what that means somewhere.
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,662 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
There are a lot of magic numbers here (0x4000, 0x00EE, and so on) that would benefit from being symbolic.
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,662 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
I get the byte order confused sometimes, but this doesn't look like a locally administered MAC address. Where did this number come from?
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,662 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
Shouldn't we be querying the device for this value, rather than using a cached value that may now be stale here?
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,662 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
Ugh. Level-triggered interrupts are annoying. Is this possible to fix?
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,662 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
Why not use a `std::unique_ptr` here and avoid the explicit delete? Raw `new` and `delete` is bad style (explicitly disallowed by the C++ Core Guidelines). That said, it's fine for this code to reuse memory, so we don't need a heap allocation here at all, just a single receive buffer that's large enough for an Et...
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,662 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
This is unconditionally true (from the && above)
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,662 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
This is a lot of heap churn for no purpose. The firewall will check the packet and then either discard it (immediate free) or pass a local (no-capture) capability to it to the TCP/IP compartment. The TCP/IP compartment will then either drop it or allocate a new buffer to copy it into. This happens sequentially and...
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,662 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
More magic numbers. `0b10 << 6` is especially weird. Why is it not `0b10000000` or `1 << 7`? Presumably if I read the datasheet, I'd determine that there's a 2-bit field somewhere and a value of `0b10` means something? But I shouldn't have to read the datasheet to read this code.
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,662 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
sizeof again.
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,662 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
As above, I don't think that you need a heap buffer here. You only ever have one outgoing frame in flight at a time, so you can safely reuse a static buffer. I don't see a security benefit from using the heap here and it adds extra failure modes.
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,662 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <optional> +#include <platform-gpio.hh> +#include <platform-spi.hh> +#include <platform/concepts/ethernet.hh> +#include <thread.h> +#i...
What does this mean. It looks as if you're doing PIO, not DMA here?
cheriot-rtos
github_2023
others
257
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,817 @@ +#pragma once +#include <array> +#include <cheri.hh> +#include <cstddef> +#include <cstdint> +#include <debug.hh> +#include <futex.h> +#include <interrupt.h> +#include <locks.hh> +#include <optional> +#include <platform/concepts/ethernet.hh> +#include <platform/sunburst/platform-gpio.hh> +#include <pl...
```suggestion DataBurst4Bytes = 0b000 << 5, DataBurst8Bytes = 0b001 << 5, DataBurst16Bytes = 0b010 << 5, DataBurst32Bytes = 0b011 << 5, ``` We don't use underscore-prefixes anywhere else (except in t...
cheriot-rtos
github_2023
cpp
264
CHERIoT-Platform
davidchisnall
@@ -0,0 +1,61 @@ +// Copyright Microsoft and CHERIoT Contributors. +// SPDX-License-Identifier: MIT + +// Contributed by Configured Things Ltd + +#include "cdefs.h" +#include "compartment-macros.h" +#include "token.h" +#include <compartment.h> + +typedef char ConfigId[16]; +#define MAX_CONFIG_IDS 8 + +struct ConfigToke...
This can be a variable length thing. We do that [in the network stack](https://github.com/CHERIoT-Platform/network-stack/blob/eeeecc2946a6c591ca259d36f8c0df53fe09440f/include/NetAPI.h#L250). This is the [accompanying rego policy](https://github.com/CHERIoT-Platform/network-stack/blob/eeeecc2946a6c591ca259d36f8c0df5...
cheriot-rtos
github_2023
cpp
264
CHERIoT-Platform
nwf-msr
@@ -0,0 +1,275 @@ +// Copyright Microsoft and CHERIoT Contributors. +// SPDX-License-Identifier: MIT + +// Contributed by Configured Things Ltd + +#include "cdefs.h" +#include "cheri.hh" +#include <compartment.h> +#include <cstdlib> +#include <debug.hh> +#include <fail-simulator-on-error.h> +#include <futex.h> +#includ...
```suggestion futex_wake(&pending); ``` The default value for `futex_wait`'s 2nd parameter is `std::numeric_limits<uint32_t>::max()` already.
cheriot-rtos
github_2023
cpp
264
CHERIoT-Platform
nwf-msr
@@ -0,0 +1,275 @@ +// Copyright Microsoft and CHERIoT Contributors. +// SPDX-License-Identifier: MIT + +// Contributed by Configured Things Ltd + +#include "cdefs.h" +#include "cheri.hh" +#include <compartment.h> +#include <cstdlib> +#include <debug.hh> +#include <fail-simulator-on-error.h> +#include <futex.h> +#includ...
```suggestion // count of un-sent updates; used as futex ```
cheriot-rtos
github_2023
cpp
264
CHERIoT-Platform
nwf-msr
@@ -0,0 +1,275 @@ +// Copyright Microsoft and CHERIoT Contributors. +// SPDX-License-Identifier: MIT + +// Contributed by Configured Things Ltd + +#include "cdefs.h" +#include "cheri.hh" +#include <compartment.h> +#include <cstdlib> +#include <debug.hh> +#include <fail-simulator-on-error.h> +#include <futex.h> +#includ...
_Extremely_ minor, but just to avoid the `for / strcmp` search below, maybe `name` should be an index into the `token->configId` array?
cheriot-rtos
github_2023
cpp
264
CHERIoT-Platform
nwf-msr
@@ -0,0 +1,275 @@ +// Copyright Microsoft and CHERIoT Contributors. +// SPDX-License-Identifier: MIT + +// Contributed by Configured Things Ltd + +#include "cdefs.h" +#include "cheri.hh" +#include <compartment.h> +#include <cstdlib> +#include <debug.hh> +#include <fail-simulator-on-error.h> +#include <futex.h> +#includ...
This can fail if `MALLOC_CAPABILITY` does not have sufficient quota. (Sadly, the current APIs imply needing a make-before-break approach to replacing a claim like this. We can probably do better, but that'd be another PR, at least.)