Skip to content

Commit 80121e5

Browse files
Merge pull request #4648 from Patater/uvisor-tests-sync
Update uVisor to v0.29.0
2 parents 692d905 + 6f1bb67 commit 80121e5

File tree

18 files changed

+27
-29
lines changed

18 files changed

+27
-29
lines changed

features/FEATURE_UVISOR/AUTHORS.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
597 Alessandro Angelino
1+
600 Alessandro Angelino
22
592 Milosch Meriac
3-
144 Jaeden Amero
4-
80 Niklas Hauser
3+
155 Jaeden Amero
4+
89 Niklas Hauser
55
5 Irit Arkin
66
3 JaredCJR
77
3 AnotherButler
@@ -12,5 +12,6 @@
1212
2 Jan Jongboom
1313
2 Nathan Chong
1414
2 Vincenzo Frascino
15-
1 ccli8
1615
1 Aksel Skauge Mellbye
16+
1 ccli8
17+
1 Michael Schwarcz

features/FEATURE_UVISOR/README.md

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ typedef struct {
197197

198198
/* ACLs list for the secure box: Timer (PIT). */
199199
static const UvisorBoxAclItem g_private_button_acls[] = {
200-
{PORTC, sizeof(*PORTC), UVISOR_TACLDEF_PERIPH}, /* Private peripheral */
200+
{PORTC, sizeof(*PORTC), UVISOR_TACLDEF_PERIPH}, /* Private peripheral */
201+
{(void *) PORTC_IRQn, 0, UVISOR_TACL_IRQ}, /* Private IRQ */
201202
};
202203

203204
static void private_button_main_thread(const void *);
@@ -257,8 +258,9 @@ static void private_button_main_thread(const void *)
257258
{
258259
/* Allocate serial port to ensure that code in this secure box
259260
* won't touch handle in the default security context when printing */
260-
if (!(uvisor_ctx->pc = new RawSerial(USBTX, USBRX)))
261+
if (!(uvisor_ctx->pc = new RawSerial(USBTX, USBRX))) {
261262
return;
263+
}
262264
263265
/* Create the buffer and cache its pointer to the private static memory. */
264266
uvisor_ctx->buffer = (uint32_t *) malloc(PRIVATE_BUTTON_BUFFER_COUNT * sizeof(uint32_t));
@@ -286,7 +288,7 @@ A few things to note in the code above:
286288

287289
- If code runs in the context of `private_button`, then any object instantiated inside that code belongs to the `private_button` heap and stack. This means that in the example above, the `InterruptIn` object is private to the `private_button` box. The same applies to the dynamically allocated buffer `uvisor_ctx->buffer`.
288290
- You can access the content of the private memory `PrivateButtonStaticMemory` using the `void * const __uvisor_ctx` pointer, which uVisor maintains. You need to cast this pointer to your own context type. In this example we used a pre-processor symbol to improve readability.
289-
- The `InterruptIn` object triggers the registration of an interrupt slot. Because that code runs in the context of the `private_button` box, the push-button IRQ belongs to that box. If you want to use the IRQ APIs directly, read the [NVIC APIs section](#the-nvic-apis) below.
291+
- The `InterruptIn` object triggers the registration of an interrupt slot using the NVIC APIs. If you want to use the IRQ APIs directly, read the [NVIC APIs section](#the-nvic-apis) below. We registered the push-button IRQ to the `private_button` box through an IRQ ACL, and hence only code from this box can access it. Changing the push-button IRQ state from the public box causes a uVisor fault.
290292
- Even if the `private_button_on_press` function runs in the context of `private_button`, you can still use the `printf` function, which accesses the `UART0` peripheral, owned by the public box. This is because all ACLs declared in the public box are by default shared with all the other secure boxes. This also means that the messages we are printing on the serial port are not secure because other boxes have access to that peripheral.
291293

292294
> **Warning**: Instantiating an object in the `secure_box.cpp` global scope automatically maps it to the public box context, not the `private_button` one. If you want an object to be private to a box, you need to instantiate it inside the code that runs in the context of that box (such as the `InterruptIn` object), or alternatively statically initialize it in the box private static memory (such as the `buffer`, `index` and `counter` variables in `PrivateButtonStaticMemory`).
@@ -422,26 +424,12 @@ When the uVisor is enabled, all NVIC APIs are rerouted to the corresponding uVis
422424
423425
- The uVisor owns the interrupt vector table.
424426
- All ISRs are relocated to SRAM.
425-
- Code in a box can only change the state of an IRQ (enable it, change its priority, etc.) if the box registered that IRQ with uVisor at runtime, using the `NVIC_SetVector` API.
427+
- Code in a box can only change the state of an IRQ (enable it, change its priority and so on) if the box registered that IRQ with uVisor through an IRQ ACL.
426428
- An IRQ that belongs to a box can only be modified when that box context is active.
427429
428-
Although this behavior is different from that of the original NVIC, it is backward compatible. Legacy code (such as a device HAL) still works after uVisor is enabled. The general use case is the following:
429-
430-
```C
431-
#define MY_IRQ 42
432-
433-
/* Set the ISR for MY_IRQ at runtime.
434-
* Without uVisor: Relocate the interrupt vector table to SRAM and set my_isr as
435-
the ISR for MY_IRQ.
436-
* With uVisor: Register MY_IRQ for the current box with my_isr as ISR. */
437-
NVIC_SetVector(MY_IRQ, &my_isr);
438-
439-
/* Change the IRQ state. */
440-
NVIC_SetPriority(MY_IRQ, 3);
441-
NVIC_EnableIRQ(MY_IRQ);
442-
```
430+
Although this behavior is different from that of the original NVIC, it is backward compatible. Legacy code (such as a device HAL) still works after uVisor is enabled.
443431
444-
> **Note**: In this model, a call to `NVIC_SetVector` must happen before an IRQ state changes. In platforms that don't relocate the interrupt vector table, such a call might be absent and must be added to work with uVisor.
432+
All IRQ slots that are not listed in any box ACL list are considered unclaimed. Boxes can gain exclusive ownership of unclaimed IRQs on a first-come first-served basis through the use of the NVIC APIs.
445433
446434
## The *public box* ACLs
447435

features/FEATURE_UVISOR/VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.28.1
1+
v0.29.0

features/FEATURE_UVISOR/importer/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ publish: TARGET_M3 TARGET_M4
111111
#
112112
# Updated list of authors, sorted by contributions
113113
git -C $(UVISOR_DIR) shortlog -s -n > $(TARGET_PREFIX)AUTHORS.txt
114+
# Updated version of uvisor-tests
115+
cp $(UVISOR_DIR)/tools/uvisor-tests.txt $(TARGET_PREFIX)uvisor-tests.txt
114116

115117
uvisor-compile: $(UVISOR_GIT_CFG)
116118
make -C $(UVISOR_DIR)

features/FEATURE_UVISOR/includes/uvisor/api/inc/api.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ typedef struct {
5858
int (*page_free)(const UvisorPageTable * const table);
5959

6060
int (*box_namespace)(int box_id, char *box_namespace, size_t length);
61+
int (*box_id_for_namespace)(int * const box_id, const char * const box_namespace);
6162

6263
void (*debug_init)(const TUvisorDebugDriver * const driver);
6364
void (*error)(THaltUserError reason);

features/FEATURE_UVISOR/includes/uvisor/api/inc/box_id.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ static UVISOR_FORCEINLINE int uvisor_box_namespace(int box_id, char *box_namespa
4040
return uvisor_api.box_namespace(box_id, box_namespace, length);
4141
}
4242

43+
static UVISOR_FORCEINLINE int uvisor_box_id_for_namespace(int * const box_id, const char * const box_namespace)
44+
{
45+
return uvisor_api.box_id_for_namespace(box_id, box_namespace);
46+
}
47+
4348
UVISOR_EXTERN_C_END
4449

4550
#endif /* __UVISOR_API_BOX_ID_H__ */

features/FEATURE_UVISOR/includes/uvisor/api/inc/ipc_exports.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ typedef enum uvisor_ipc_io_state {
4646
UVISOR_IPC_IO_STATE_VALID, /* uVisor has copied the message */
4747
} uvisor_ipc_io_state_t;
4848

49-
/* IPC Descriptor Structure */
50-
/* When sending:
49+
/* IPC Descriptor Structure
50+
* When sending:
5151
* @param[in] box_id the ID of the destination box
5252
* @param[in] port the port to send the message to
5353
* @param[in] len the length of the message
5454
* @param[out] token a token that can be used to wait at a later time for
5555
* the send to complete
56-
*/
57-
/* When receiving before a message has been received:
56+
*
57+
* When receiving before a message has been received:
5858
* @param[in] box_id an ID of a box that is allowed to send to this box, or
5959
* UVISOR_BOX_ID_ANY to allow messages from any box
6060
* @param[in] port the port to listen for messages on
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
209b261bb6d34b657fb699eb22669eb5c9055219

0 commit comments

Comments
 (0)