Skip to content

Update uVisor to v0.30.0 #4907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions features/FEATURE_UVISOR/AUTHORS.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
600 Alessandro Angelino
592 Milosch Meriac
155 Jaeden Amero
190 Jaeden Amero
89 Niklas Hauser
10 Fangyi Zhou
6 Michael Schwarcz
5 Irit Arkin
3 JaredCJR
3 AnotherButler
5 Alexander Zilberkant
4 Amir Cohen
3 Hugo Vincent
3 AnotherButler
3 Roman Kuznetsov
3 JaredCJR
3 Jim Huang
2 tonyyanxuan
2 Amanda Butler
2 Jan Jongboom
2 Nathan Chong
2 Oren Cohen
2 Vincenzo Frascino
2 ccli8
1 Russ Butler
1 Jethro Hsu
1 Aksel Skauge Mellbye
1 ccli8
1 Michael Schwarcz
1 Danny Shavit
15 changes: 8 additions & 7 deletions features/FEATURE_UVISOR/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ To call the public secure entry point from any other box, you can use the `secur
```cpp
/* ~/code/uvisor-example/source/main.cpp */

#include "secure-box.h"
#include "secure_box.h"
```

Then replace the `main` function with:
Expand Down Expand Up @@ -451,17 +451,18 @@ Once the uVisor debug messages are enabled, your application fails. The failure
BUS FAULT
***********************************************************

...
* Active Box ID: 0
* FAULT SYNDROME REGISTERS

/* MEMORY MAP
Address: 0x4004800C
Region/Peripheral: SIM
Base address: 0x40047000
End address: 0x40048060
CFSR: 0x00008200
BFAR: 0x40048044
--> PRECISERR: precise data access.

...
```

Look up the faulty address (the value of BFAR) in the target device reference manual.

Once you know which peripheral is causing the fault (the `SIM` peripheral, in this example), add its entry to the ACLs list:

```C
Expand Down
2 changes: 1 addition & 1 deletion features/FEATURE_UVISOR/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.29.0
v0.30.0
2 changes: 1 addition & 1 deletion features/FEATURE_UVISOR/importer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ GDB:=$(PREFIX)gdb
OBJDUMP:=$(PREFIX)objdump

# Translate between uVisor namespace and mbed namespace
TARGET_TRANSLATION:=MCU_K64F.kinetis EFM32.efm32 STM32F4.stm32 ARM_BEETLE_SOC.beetle
TARGET_TRANSLATION:=MCU_K64F.kinetis EFM32.efm32 STM32F4.stm32 ARM_BEETLE_SOC.beetle M480.m480
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Patater It should be NUMAKER_PFM_M487.m480?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same uVisor binary should work with all M480 targets. If you know of a reason why this isn't the case, please let me know.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Patater Yes, you are right.

TARGET_PREFIX:=../
TARGET_SUPPORTED:=$(TARGET_PREFIX)targets/TARGET_UVISOR_SUPPORTED
TARGET_UNSUPPORTED:=$(TARGET_PREFIX)targets/TARGET_UVISOR_UNSUPPORTED
Expand Down
13 changes: 13 additions & 0 deletions features/FEATURE_UVISOR/includes/uvisor/api/inc/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
UVISOR_EXTERN_C_BEGIN

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

typedef struct {
uint32_t magic;
Expand Down Expand Up @@ -68,17 +73,25 @@ typedef struct {
int (*pool_init)(uvisor_pool_t *, void *, size_t, size_t);
int (*pool_queue_init)(uvisor_pool_queue_t *, uvisor_pool_t *, void *, size_t, size_t);
uvisor_pool_slot_t (*pool_allocate)(uvisor_pool_t *);
uvisor_pool_slot_t (*pool_try_allocate)(uvisor_pool_t *);
void (*pool_queue_enqueue)(uvisor_pool_queue_t *, uvisor_pool_slot_t);
int (*pool_queue_try_enqueue)(uvisor_pool_queue_t *, uvisor_pool_slot_t);
uvisor_pool_slot_t (*pool_free)(uvisor_pool_t *, uvisor_pool_slot_t);
uvisor_pool_slot_t (*pool_try_free)(uvisor_pool_t *, uvisor_pool_slot_t);
uvisor_pool_slot_t (*pool_queue_dequeue)(uvisor_pool_queue_t *, uvisor_pool_slot_t);
uvisor_pool_slot_t (*pool_queue_try_dequeue)(uvisor_pool_queue_t *, uvisor_pool_slot_t);
uvisor_pool_slot_t (*pool_queue_dequeue_first)(uvisor_pool_queue_t *);
uvisor_pool_slot_t (*pool_queue_try_dequeue_first)(uvisor_pool_queue_t *);
uvisor_pool_slot_t (*pool_queue_find_first)(uvisor_pool_queue_t *, TQueryFN_Ptr, void *);
uvisor_pool_slot_t (*pool_queue_try_find_first)(uvisor_pool_queue_t *, TQueryFN_Ptr, void *);

void (*spin_init)(UvisorSpinlock * spinlock);
bool (*spin_trylock)(UvisorSpinlock * spinlock);
void (*spin_lock)(UvisorSpinlock * spinlock);
void (*spin_unlock)(UvisorSpinlock * spinlock);

void (*debug_semihosting_enable)(void);

OsEventObserver os_event_observer;
} UVISOR_PACKED UvisorApi;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
#ifndef __UVISOR_API_DEBUG_EXPORTS_H__
#define __UVISOR_API_DEBUG_EXPORTS_H__

#include "api/inc/halt_exports.h"
#include <stdint.h>

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

/* Number of handlers in the debug box driver */
Expand Down
48 changes: 48 additions & 0 deletions features/FEATURE_UVISOR/includes/uvisor/api/inc/halt_exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,52 @@ typedef enum {
__THALTERROR_MAX /* always keep as the last element of the enum */
} THaltError;

/** A basic exception frame
*
* This struct contains the registers always saved during an exception in the
* order they are placed in the memory.
* If FPU state is also saved it's placed after this register block.
* On ARMv8-M in certain cases an additional state context may be placed on
* the stack before this block.
*/
typedef struct {
uint32_t r0;
uint32_t r1;
uint32_t r2;
uint32_t r3;
uint32_t r12;
uint32_t lr;
uint32_t retaddr;
uint32_t retpsr;
} UVISOR_PACKED exception_frame_t;

/* A pointer to this structure will be given to halt_error() handler
* of the debug box driver. */
typedef struct {
/* A basic exception stack frame that is always present with a valid stack. */
exception_frame_t stack_frame;

/* A few registers that may be useful for debug. */
uint32_t lr;
uint32_t control;
uint32_t ipsr;

/* Fault status registers. */
uint32_t mmfar;
uint32_t bfar;
uint32_t cfsr;
uint32_t hfsr;
uint32_t dfsr;
uint32_t afsr;

/* Bitmask telling which of the above regions are valid. */
uint32_t valid_data;
} UVISOR_PACKED THaltInfo;

/* Bitmask to specify which HaltInfo regions are valid. */
typedef enum {
HALT_INFO_STACK_FRAME = 0x1,
HALT_INFO_REGISTERS = 0x2
} THaltInfoValidMask;

#endif /* __UVISOR_API_HALT_EXPORTS_H__ */
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ typedef struct {
void (*priv_svc_0)(void);
void (*priv_pendsv)(void);
void (*priv_systick)(void);
uint32_t (*priv_os_suspend)(void);
int32_t (*priv_os_suspend)(void);
int (*priv_uvisor_semaphore_post)(UvisorSemaphore * semaphore);
} UvisorPrivSystemHooks;

Expand Down
18 changes: 13 additions & 5 deletions features/FEATURE_UVISOR/includes/uvisor/api/inc/uvisor_exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,19 @@
/** Static Assertion Macro
*
* This macro works from both inside and outside function scope.
*
* FIXME This is currently not implemented. This issue is tracked at
* https://github.com/ARMmbed/uvisor/issues/288
*/
#define UVISOR_STATIC_ASSERT(cond, msg)
* The implementations differ due to compilation differences, C++ static_assert
* is known from C++11 (__cplusplus > 199711L) while mbed-os compiles with c++98,
* and C _Static_assert is known from GCC version 4.6.0. */
#define GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)
#if (__cplusplus > 199711L)
#define UVISOR_STATIC_ASSERT(cond, msg) static_assert(cond, #msg)
#elif (!__cplusplus && GCC_VERSION > 40600)
#define UVISOR_STATIC_ASSERT(cond, msg) _Static_assert(cond, #msg)
#else
#define UVISOR_STATIC_ASSERT(cond, msg) typedef char STATIC_ASSERT_##msg[(cond)?1:-1]
#endif

/* convert macro argument to string */
/* note: this needs one level of indirection, accomplished with the helper macro
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ typedef struct {
#if defined(UVISOR_PRESENT) && UVISOR_PRESENT == 1
static UVISOR_FORCEINLINE int vmpu_bits(uint32_t size)
{
return 32 - __builtin_clz(size);
/* If size is 0, the result of __builtin_clz is undefined */
return (0 == size) ? 0: 32 - __builtin_clz(size);
}
#endif /* defined(UVISOR_PRESENT) && UVISOR_PRESENT == 1 */

Expand Down
2 changes: 1 addition & 1 deletion features/FEATURE_UVISOR/source/rtx/box_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
extern void SVC_Handler(void);
extern void PendSV_Handler(void);
extern void SysTick_Handler(void);
extern uint32_t svcRtxKernelLock(void);
extern int32_t svcRtxKernelLock(void);

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

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion features/FEATURE_UVISOR/uvisor-tests.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
209b261bb6d34b657fb699eb22669eb5c9055219
e3b1385c7facc7fdab472440293c4c87ed2b2999