Skip to content

Commit d0faa31

Browse files
author
Wayne Ren
committed
libsecureshield: add securshield_excpt_bit_clear
this function is used to clear the internal protection bit of exception regs (ECR, BTA, ERRET)
1 parent 8b25a5e commit d0faa31

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

arc/startup/arc_startup.s

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
#define __ASSEMBLY__
4747
#include "arc.h"
4848

49-
.file "arc_startup.s"
49+
.file "arc_startup.s"
5050

5151
.weak _f_sdata /* start of small data, defined in link script */
5252
.weak init_hardware_hook /* app hardware init hook */
@@ -205,6 +205,9 @@ _arc_reset_call_main:
205205
/* init cache */
206206
jl arc_cache_init
207207
jl secureshield_start
208+
#if SECURESHIELD_VERSION == 2
209+
jl secureshield_except_bit_clear
210+
#endif
208211
#else
209212
/* early init of interrupt and exception */
210213
jl exc_int_init
@@ -229,7 +232,7 @@ _arc_reset_call_main:
229232
.align 4
230233
_exit_halt:
231234
_exit_loop:
232-
flag 0x1
235+
flag AUX_STATUS_MASK_HALT
233236
nop
234237
nop
235238
nop

library/secureshield/export/inc/secureshield_sys_ops_exports.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ extern void secureshield_perf_start(void);
4646
extern uint32_t secureshield_perf_end(void);
4747
#elif SECURESHIELD_VERSION == 2
4848

49+
extern void secureshield_except_bit_clear(void);
50+
4951
#endif
5052

5153
extern uint32_t secureshield_arc_lr_reg(uint32_t addr);

library/secureshield/export/src/sys_ops.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,32 @@ int32_t secureshield_container_id_caller(void)
102102
{
103103
return SECURESHIELD_SECURE_CALL(SECURESHIELD_SECURE_CALL_SYS, "", SECURESHIELD_SYS_CONTAINER_ID_CALLER);
104104
}
105+
106+
static void temp_trap_handler(void)
107+
{
108+
109+
}
110+
111+
/**
112+
* \brief
113+
* The exception state registers (ERET, ECR, ERSTATUS, ERBTA, EFA, ESYN) will be protected by a new internal bit.
114+
* This will be set on exception entry if the exception is triggered on a secure mode instruction and cleared on
115+
* exception entry if the exception is triggered on a non-secure instruction. If set, this bit will prevent
116+
* read/write access to these registers from non-secure mode. Any attempt to access these registers in NS mode
117+
* while protected will result in an EV_PriviligeV exception.
118+
*
119+
* this function is used to clear this bit.
120+
*/
121+
void secureshield_except_bit_clear(void)
122+
{
123+
EXC_HANDLER prev_trap_handler;
124+
125+
exc_nest_count = 1;
126+
prev_trap_handler = exc_handler_get(EXC_NO_TRAP);
127+
exc_handler_install(EXC_NO_TRAP, (EXC_HANDLER)temp_trap_handler);
128+
Asm("trap_s 0");
129+
exc_nest_count = 0;
130+
exc_handler_install(EXC_NO_TRAP, prev_trap_handler);
131+
}
132+
105133
#endif

0 commit comments

Comments
 (0)