diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/el3_runtime/aarch64/context_mgmt.c | 22 | ||||
-rw-r--r-- | lib/locks/bakery/bakery_lock_coherent.c | 16 | ||||
-rw-r--r-- | lib/locks/bakery/bakery_lock_normal.c | 16 | ||||
-rw-r--r-- | lib/psci/psci_common.c | 2 | ||||
-rw-r--r-- | lib/semihosting/semihosting.c | 34 |
5 files changed, 55 insertions, 35 deletions
diff --git a/lib/el3_runtime/aarch64/context_mgmt.c b/lib/el3_runtime/aarch64/context_mgmt.c index b7908adec..dc4717abe 100644 --- a/lib/el3_runtime/aarch64/context_mgmt.c +++ b/lib/el3_runtime/aarch64/context_mgmt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -66,7 +66,7 @@ void __init cm_init(void) void cm_setup_context(cpu_context_t *ctx, const entry_point_info_t *ep) { unsigned int security_state; - uint32_t scr_el3; + u_register_t scr_el3; el3_state_t *state; gp_regs_t *gp_regs; u_register_t sctlr_elx, actlr_elx; @@ -87,7 +87,7 @@ void cm_setup_context(cpu_context_t *ctx, const entry_point_info_t *ep) * the required value depending on the state of the SPSR_EL3 and the * Security state and entrypoint attributes of the next EL. */ - scr_el3 = (uint32_t)read_scr(); + scr_el3 = read_scr(); scr_el3 &= ~(SCR_NS_BIT | SCR_RW_BIT | SCR_FIQ_BIT | SCR_IRQ_BIT | SCR_ST_BIT | SCR_HCE_BIT); /* @@ -326,7 +326,7 @@ void cm_init_my_context(const entry_point_info_t *ep) ******************************************************************************/ void cm_prepare_el3_exit(uint32_t security_state) { - uint32_t sctlr_elx, scr_el3, mdcr_el2; + u_register_t sctlr_elx, scr_el3, mdcr_el2; cpu_context_t *ctx = cm_get_context(security_state); bool el2_unused = false; uint64_t hcr_el2 = 0U; @@ -334,11 +334,11 @@ void cm_prepare_el3_exit(uint32_t security_state) assert(ctx != NULL); if (security_state == NON_SECURE) { - scr_el3 = (uint32_t)read_ctx_reg(get_el3state_ctx(ctx), + scr_el3 = read_ctx_reg(get_el3state_ctx(ctx), CTX_SCR_EL3); if ((scr_el3 & SCR_HCE_BIT) != 0U) { /* Use SCTLR_EL1.EE value to initialise sctlr_el2 */ - sctlr_elx = (uint32_t)read_ctx_reg(get_sysregs_ctx(ctx), + sctlr_elx = read_ctx_reg(get_sysregs_ctx(ctx), CTX_SCTLR_EL1); sctlr_elx &= SCTLR_EE_BIT; sctlr_elx |= SCTLR_EL2_RES1; @@ -618,7 +618,7 @@ void cm_write_scr_el3_bit(uint32_t security_state, { cpu_context_t *ctx; el3_state_t *state; - uint32_t scr_el3; + u_register_t scr_el3; ctx = cm_get_context(security_state); assert(ctx != NULL); @@ -634,9 +634,9 @@ void cm_write_scr_el3_bit(uint32_t security_state, * and set it to its new value. */ state = get_el3state_ctx(ctx); - scr_el3 = (uint32_t)read_ctx_reg(state, CTX_SCR_EL3); + scr_el3 = read_ctx_reg(state, CTX_SCR_EL3); scr_el3 &= ~(1U << bit_pos); - scr_el3 |= value << bit_pos; + scr_el3 |= (u_register_t)value << bit_pos; write_ctx_reg(state, CTX_SCR_EL3, scr_el3); } @@ -644,7 +644,7 @@ void cm_write_scr_el3_bit(uint32_t security_state, * This function retrieves SCR_EL3 member of 'cpu_context' pertaining to the * given security state. ******************************************************************************/ -uint32_t cm_get_scr_el3(uint32_t security_state) +u_register_t cm_get_scr_el3(uint32_t security_state) { cpu_context_t *ctx; el3_state_t *state; @@ -654,7 +654,7 @@ uint32_t cm_get_scr_el3(uint32_t security_state) /* Populate EL3 state so that ERET jumps to the correct entry */ state = get_el3state_ctx(ctx); - return (uint32_t)read_ctx_reg(state, CTX_SCR_EL3); + return read_ctx_reg(state, CTX_SCR_EL3); } /******************************************************************************* diff --git a/lib/locks/bakery/bakery_lock_coherent.c b/lib/locks/bakery/bakery_lock_coherent.c index 1634e3af6..748eeddf4 100644 --- a/lib/locks/bakery/bakery_lock_coherent.c +++ b/lib/locks/bakery/bakery_lock_coherent.c @@ -137,10 +137,11 @@ void bakery_lock_get(bakery_lock_t *bakery) } /* - * Lock acquired. Ensure that any reads from a shared resource in the - * critical section read values after the lock is acquired. + * Lock acquired. Ensure that any reads and writes from a shared + * resource in the critical section read/write values after the lock is + * acquired. */ - dmbld(); + dmbish(); } @@ -154,11 +155,14 @@ void bakery_lock_release(bakery_lock_t *bakery) /* * Ensure that other observers see any stores in the critical section - * before releasing the lock. Release the lock by resetting ticket. - * Then signal other waiting contenders. + * before releasing the lock. Also ensure all loads in the critical + * section are complete before releasing the lock. Release the lock by + * resetting ticket. Then signal other waiting contenders. */ - dmbst(); + dmbish(); bakery->lock_data[me] = 0U; + + /* Required to ensure ordering of the following sev */ dsb(); sev(); } diff --git a/lib/locks/bakery/bakery_lock_normal.c b/lib/locks/bakery/bakery_lock_normal.c index f906f51ea..caced8f46 100644 --- a/lib/locks/bakery/bakery_lock_normal.c +++ b/lib/locks/bakery/bakery_lock_normal.c @@ -219,10 +219,11 @@ void bakery_lock_get(bakery_lock_t *lock) } /* - * Lock acquired. Ensure that any reads from a shared resource in the - * critical section read values after the lock is acquired. + * Lock acquired. Ensure that any reads and writes from a shared + * resource in the critical section read/write values after the lock is + * acquired. */ - dmbld(); + dmbish(); } void bakery_lock_release(bakery_lock_t *lock) @@ -240,11 +241,14 @@ void bakery_lock_release(bakery_lock_t *lock) /* * Ensure that other observers see any stores in the critical section - * before releasing the lock. Release the lock by resetting ticket. - * Then signal other waiting contenders. + * before releasing the lock. Also ensure all loads in the critical + * section are complete before releasing the lock. Release the lock by + * resetting ticket. Then signal other waiting contenders. */ - dmbst(); + dmbish(); my_bakery_info->lock_data = 0U; write_cache_op((uintptr_t)my_bakery_info, is_cached); + + /* This sev is ordered by the dsbish in write_cahce_op */ sev(); } diff --git a/lib/psci/psci_common.c b/lib/psci/psci_common.c index ea1a01de9..5ab15c6ee 100644 --- a/lib/psci/psci_common.c +++ b/lib/psci/psci_common.c @@ -775,7 +775,7 @@ void psci_warmboot_entrypoint(void) * suspend. */ if (psci_get_aff_info_state() == AFF_STATE_OFF) { - ERROR("Unexpected affinity info state"); + ERROR("Unexpected affinity info state.\n"); panic(); } diff --git a/lib/semihosting/semihosting.c b/lib/semihosting/semihosting.c index 051dd008b..60fc52a00 100644 --- a/lib/semihosting/semihosting.c +++ b/lib/semihosting/semihosting.c @@ -15,7 +15,7 @@ #endif long semihosting_call(unsigned long operation, - void *system_block_address); + uintptr_t system_block_address); typedef struct { const char *file_name; @@ -53,7 +53,7 @@ long semihosting_file_open(const char *file_name, size_t mode) open_block.name_length = strlen(file_name); return semihosting_call(SEMIHOSTING_SYS_OPEN, - (void *) &open_block); + (uintptr_t) &open_block); } long semihosting_file_seek(long file_handle, ssize_t offset) @@ -65,7 +65,7 @@ long semihosting_file_seek(long file_handle, ssize_t offset) seek_block.location = offset; result = semihosting_call(SEMIHOSTING_SYS_SEEK, - (void *) &seek_block); + (uintptr_t) &seek_block); if (result) result = semihosting_call(SEMIHOSTING_SYS_ERRNO, 0); @@ -86,7 +86,7 @@ long semihosting_file_read(long file_handle, size_t *length, uintptr_t buffer) read_block.length = *length; result = semihosting_call(SEMIHOSTING_SYS_READ, - (void *) &read_block); + (uintptr_t) &read_block); if (result == *length) { return -EINVAL; @@ -112,7 +112,7 @@ long semihosting_file_write(long file_handle, write_block.length = *length; result = semihosting_call(SEMIHOSTING_SYS_WRITE, - (void *) &write_block); + (uintptr_t) &write_block); *length = result; @@ -122,28 +122,28 @@ long semihosting_file_write(long file_handle, long semihosting_file_close(long file_handle) { return semihosting_call(SEMIHOSTING_SYS_CLOSE, - (void *) &file_handle); + (uintptr_t) &file_handle); } long semihosting_file_length(long file_handle) { return semihosting_call(SEMIHOSTING_SYS_FLEN, - (void *) &file_handle); + (uintptr_t) &file_handle); } char semihosting_read_char(void) { - return semihosting_call(SEMIHOSTING_SYS_READC, NULL); + return semihosting_call(SEMIHOSTING_SYS_READC, 0); } void semihosting_write_char(char character) { - semihosting_call(SEMIHOSTING_SYS_WRITEC, (void *) &character); + semihosting_call(SEMIHOSTING_SYS_WRITEC, (uintptr_t) &character); } void semihosting_write_string(char *string) { - semihosting_call(SEMIHOSTING_SYS_WRITE0, (void *) string); + semihosting_call(SEMIHOSTING_SYS_WRITE0, (uintptr_t) string); } long semihosting_system(char *command_line) @@ -154,7 +154,7 @@ long semihosting_system(char *command_line) system_block.command_length = strlen(command_line); return semihosting_call(SEMIHOSTING_SYS_SYSTEM, - (void *) &system_block); + (uintptr_t) &system_block); } long semihosting_get_flen(const char *file_name) @@ -216,3 +216,15 @@ semihosting_fail: semihosting_file_close(file_handle); return ret; } + +void semihosting_exit(uint32_t reason, uint32_t subcode) +{ +#ifdef __aarch64__ + uint64_t parameters[] = {reason, subcode}; + + (void) semihosting_call(SEMIHOSTING_SYS_EXIT, (uintptr_t) ¶meters); +#else + /* The subcode is not supported on AArch32. */ + (void) semihosting_call(SEMIHOSTING_SYS_EXIT, reason); +#endif +} |