Skip to content

Commit 46f9d46

Browse files
committed
uVisor: Import v0.30.0
1 parent 0e63cd5 commit 46f9d46

File tree

23 files changed

+103
-23
lines changed

23 files changed

+103
-23
lines changed

features/FEATURE_UVISOR/AUTHORS.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
600 Alessandro Angelino
22
592 Milosch Meriac
3-
155 Jaeden Amero
3+
190 Jaeden Amero
44
89 Niklas Hauser
5+
10 Fangyi Zhou
6+
6 Michael Schwarcz
57
5 Irit Arkin
6-
3 JaredCJR
7-
3 AnotherButler
8+
5 Alexander Zilberkant
9+
4 Amir Cohen
810
3 Hugo Vincent
11+
3 AnotherButler
12+
3 Roman Kuznetsov
13+
3 JaredCJR
914
3 Jim Huang
1015
2 tonyyanxuan
1116
2 Amanda Butler
1217
2 Jan Jongboom
1318
2 Nathan Chong
19+
2 Oren Cohen
1420
2 Vincenzo Frascino
21+
2 ccli8
22+
1 Russ Butler
23+
1 Jethro Hsu
1524
1 Aksel Skauge Mellbye
16-
1 ccli8
17-
1 Michael Schwarcz
25+
1 Danny Shavit

features/FEATURE_UVISOR/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ To call the public secure entry point from any other box, you can use the `secur
396396
```cpp
397397
/* ~/code/uvisor-example/source/main.cpp */
398398

399-
#include "secure-box.h"
399+
#include "secure_box.h"
400400
```
401401

402402
Then replace the `main` function with:
@@ -451,17 +451,18 @@ Once the uVisor debug messages are enabled, your application fails. The failure
451451
BUS FAULT
452452
***********************************************************
453453
454-
...
454+
* Active Box ID: 0
455+
* FAULT SYNDROME REGISTERS
455456
456-
/* MEMORY MAP
457-
Address: 0x4004800C
458-
Region/Peripheral: SIM
459-
Base address: 0x40047000
460-
End address: 0x40048060
457+
CFSR: 0x00008200
458+
BFAR: 0x40048044
459+
--> PRECISERR: precise data access.
461460
462461
...
463462
```
464463

464+
Look up the faulty address (the value of BFAR) in the target device reference manual.
465+
465466
Once you know which peripheral is causing the fault (the `SIM` peripheral, in this example), add its entry to the ACLs list:
466467

467468
```C

features/FEATURE_UVISOR/VERSION.txt

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

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
UVISOR_EXTERN_C_BEGIN
3434

3535
extern void uvisor_init(void);
36+
/* This method is an api method which initializes the g_semihosting_magic variable.
37+
* This function will only work if called in privileged mode or from secure code,
38+
* it is only intended to be called by debugger after reset.
39+
*/
40+
void debug_semihosting_enable(void);
3641

3742
typedef struct {
3843
uint32_t magic;
@@ -68,17 +73,25 @@ typedef struct {
6873
int (*pool_init)(uvisor_pool_t *, void *, size_t, size_t);
6974
int (*pool_queue_init)(uvisor_pool_queue_t *, uvisor_pool_t *, void *, size_t, size_t);
7075
uvisor_pool_slot_t (*pool_allocate)(uvisor_pool_t *);
76+
uvisor_pool_slot_t (*pool_try_allocate)(uvisor_pool_t *);
7177
void (*pool_queue_enqueue)(uvisor_pool_queue_t *, uvisor_pool_slot_t);
78+
int (*pool_queue_try_enqueue)(uvisor_pool_queue_t *, uvisor_pool_slot_t);
7279
uvisor_pool_slot_t (*pool_free)(uvisor_pool_t *, uvisor_pool_slot_t);
80+
uvisor_pool_slot_t (*pool_try_free)(uvisor_pool_t *, uvisor_pool_slot_t);
7381
uvisor_pool_slot_t (*pool_queue_dequeue)(uvisor_pool_queue_t *, uvisor_pool_slot_t);
82+
uvisor_pool_slot_t (*pool_queue_try_dequeue)(uvisor_pool_queue_t *, uvisor_pool_slot_t);
7483
uvisor_pool_slot_t (*pool_queue_dequeue_first)(uvisor_pool_queue_t *);
84+
uvisor_pool_slot_t (*pool_queue_try_dequeue_first)(uvisor_pool_queue_t *);
7585
uvisor_pool_slot_t (*pool_queue_find_first)(uvisor_pool_queue_t *, TQueryFN_Ptr, void *);
86+
uvisor_pool_slot_t (*pool_queue_try_find_first)(uvisor_pool_queue_t *, TQueryFN_Ptr, void *);
7687

7788
void (*spin_init)(UvisorSpinlock * spinlock);
7889
bool (*spin_trylock)(UvisorSpinlock * spinlock);
7990
void (*spin_lock)(UvisorSpinlock * spinlock);
8091
void (*spin_unlock)(UvisorSpinlock * spinlock);
8192

93+
void (*debug_semihosting_enable)(void);
94+
8295
OsEventObserver os_event_observer;
8396
} UVISOR_PACKED UvisorApi;
8497

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
#ifndef __UVISOR_API_DEBUG_EXPORTS_H__
1818
#define __UVISOR_API_DEBUG_EXPORTS_H__
1919

20+
#include "api/inc/halt_exports.h"
2021
#include <stdint.h>
2122

2223
/* Debug box driver -- Version 0
2324
* A constant instance of this struct must be instantiated by the unprivileged
2425
* code to setup a debug box.*/
2526
typedef struct TUvisorDebugDriver {
2627
uint32_t (*get_version)(void);
27-
void (*halt_error)(int);
28+
void (*halt_error)(THaltError, const THaltInfo *);
2829
} TUvisorDebugDriver;
2930

3031
/* Number of handlers in the debug box driver */

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,52 @@ typedef enum {
5353
__THALTERROR_MAX /* always keep as the last element of the enum */
5454
} THaltError;
5555

56+
/** A basic exception frame
57+
*
58+
* This struct contains the registers always saved during an exception in the
59+
* order they are placed in the memory.
60+
* If FPU state is also saved it's placed after this register block.
61+
* On ARMv8-M in certain cases an additional state context may be placed on
62+
* the stack before this block.
63+
*/
64+
typedef struct {
65+
uint32_t r0;
66+
uint32_t r1;
67+
uint32_t r2;
68+
uint32_t r3;
69+
uint32_t r12;
70+
uint32_t lr;
71+
uint32_t retaddr;
72+
uint32_t retpsr;
73+
} UVISOR_PACKED exception_frame_t;
74+
75+
/* A pointer to this structure will be given to halt_error() handler
76+
* of the debug box driver. */
77+
typedef struct {
78+
/* A basic exception stack frame that is always present with a valid stack. */
79+
exception_frame_t stack_frame;
80+
81+
/* A few registers that may be useful for debug. */
82+
uint32_t lr;
83+
uint32_t control;
84+
uint32_t ipsr;
85+
86+
/* Fault status registers. */
87+
uint32_t mmfar;
88+
uint32_t bfar;
89+
uint32_t cfsr;
90+
uint32_t hfsr;
91+
uint32_t dfsr;
92+
uint32_t afsr;
93+
94+
/* Bitmask telling which of the above regions are valid. */
95+
uint32_t valid_data;
96+
} UVISOR_PACKED THaltInfo;
97+
98+
/* Bitmask to specify which HaltInfo regions are valid. */
99+
typedef enum {
100+
HALT_INFO_STACK_FRAME = 0x1,
101+
HALT_INFO_REGISTERS = 0x2
102+
} THaltInfoValidMask;
103+
56104
#endif /* __UVISOR_API_HALT_EXPORTS_H__ */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ typedef struct {
3333
void (*priv_svc_0)(void);
3434
void (*priv_pendsv)(void);
3535
void (*priv_systick)(void);
36-
uint32_t (*priv_os_suspend)(void);
36+
int32_t (*priv_os_suspend)(void);
3737
int (*priv_uvisor_semaphore_post)(UvisorSemaphore * semaphore);
3838
} UvisorPrivSystemHooks;
3939

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,19 @@
7777
/** Static Assertion Macro
7878
*
7979
* This macro works from both inside and outside function scope.
80-
*
81-
* FIXME This is currently not implemented. This issue is tracked at
82-
* https://github.com/ARMmbed/uvisor/issues/288
83-
*/
84-
#define UVISOR_STATIC_ASSERT(cond, msg)
80+
* The implementations differ due to compilation differences, C++ static_assert
81+
* is known from C++11 (__cplusplus > 199711L) while mbed-os compiles with c++98,
82+
* and C _Static_assert is known from GCC version 4.6.0. */
83+
#define GCC_VERSION (__GNUC__ * 10000 \
84+
+ __GNUC_MINOR__ * 100 \
85+
+ __GNUC_PATCHLEVEL__)
86+
#if (__cplusplus > 199711L)
87+
#define UVISOR_STATIC_ASSERT(cond, msg) static_assert(cond, #msg)
88+
#elif (!__cplusplus && GCC_VERSION > 40600)
89+
#define UVISOR_STATIC_ASSERT(cond, msg) _Static_assert(cond, #msg)
90+
#else
91+
#define UVISOR_STATIC_ASSERT(cond, msg) typedef char STATIC_ASSERT_##msg[(cond)?1:-1]
92+
#endif
8593

8694
/* convert macro argument to string */
8795
/* note: this needs one level of indirection, accomplished with the helper macro

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ typedef struct {
243243
#if defined(UVISOR_PRESENT) && UVISOR_PRESENT == 1
244244
static UVISOR_FORCEINLINE int vmpu_bits(uint32_t size)
245245
{
246-
return 32 - __builtin_clz(size);
246+
/* If size is 0, the result of __builtin_clz is undefined */
247+
return (0 == size) ? 0: 32 - __builtin_clz(size);
247248
}
248249
#endif /* defined(UVISOR_PRESENT) && UVISOR_PRESENT == 1 */
249250

features/FEATURE_UVISOR/source/rtx/box_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
extern void SVC_Handler(void);
3030
extern void PendSV_Handler(void);
3131
extern void SysTick_Handler(void);
32-
extern uint32_t svcRtxKernelLock(void);
32+
extern int32_t svcRtxKernelLock(void);
3333

3434
UVISOR_SET_PRIV_SYS_HOOKS(SVC_Handler, PendSV_Handler, SysTick_Handler, svcRtxKernelLock, __uvisor_semaphore_post);
3535

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
209b261bb6d34b657fb699eb22669eb5c9055219
1+
e3b1385c7facc7fdab472440293c4c87ed2b2999

0 commit comments

Comments
 (0)