From 3c39e55ab1ada5eb1aa44ae6808bbee9ce76becc Mon Sep 17 00:00:00 2001 From: Benjamin Walsh Date: Thu, 12 Jan 2017 16:49:58 -0500 Subject: [PATCH] arc: fix unaligned variables resulting in unaligned k_cpu_sleep_mode Force-align all variables defined via asm .word to ensure 4-byte alignment. The straddled_tick_on_idle_enter variable was a bool, which resolved in an one-byte quantity. Changing it to a 32-bit integer. It would have occupied 4 bytes anyway with alignment. Fixes ZEP-1549. Change-Id: If5e0aa1a75dbc73d896b44616f059d221fe191c6 Signed-off-by: Benjamin Walsh --- arch/arc/core/cpu_idle.S | 1 + arch/arc/core/fault_s.S | 1 + arch/arc/core/isr_wrapper.S | 1 + drivers/timer/arcv2_timer0.c | 6 +++--- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/arc/core/cpu_idle.S b/arch/arc/core/cpu_idle.S index 3cdf0f33c71..08e34c2f765 100644 --- a/arch/arc/core/cpu_idle.S +++ b/arch/arc/core/cpu_idle.S @@ -33,6 +33,7 @@ GTEXT(k_cpu_idle) GTEXT(k_cpu_atomic_idle) GDATA(k_cpu_sleep_mode) + .balign 4 SECTION_VAR(BSS, k_cpu_sleep_mode) .word 0 diff --git a/arch/arc/core/fault_s.S b/arch/arc/core/fault_s.S index 77496212bf2..cc6ce830123 100644 --- a/arch/arc/core/fault_s.S +++ b/arch/arc/core/fault_s.S @@ -45,6 +45,7 @@ GTEXT(__ev_div_zero) GTEXT(__ev_dc_error) GTEXT(__ev_maligned) + .balign 4 SECTION_VAR(BSS, saved_stack_pointer) .word 0 diff --git a/arch/arc/core/isr_wrapper.S b/arch/arc/core/isr_wrapper.S index c3950d12b1e..a7fef580ebd 100644 --- a/arch/arc/core/isr_wrapper.S +++ b/arch/arc/core/isr_wrapper.S @@ -38,6 +38,7 @@ GTEXT(_isr_demux) #if CONFIG_RGF_NUM_BANKS == 1 GDATA(saved_r0) + .balign 4 SECTION_VAR(BSS, saved_r0) .word 0 #endif diff --git a/drivers/timer/arcv2_timer0.c b/drivers/timer/arcv2_timer0.c index 7ccb81363d8..d5d6734a742 100644 --- a/drivers/timer/arcv2_timer0.c +++ b/drivers/timer/arcv2_timer0.c @@ -82,7 +82,7 @@ static uint32_t accumulated_cycle_count; static uint32_t __noinit max_system_ticks; static uint32_t __noinit programmed_limit; static uint32_t __noinit programmed_ticks; -static bool straddled_tick_on_idle_enter = false; +static int straddled_tick_on_idle_enter; extern int32_t _sys_idle_elapsed_ticks; #endif @@ -251,7 +251,7 @@ void _timer_idle_enter(int32_t ticks) status = timer0_control_register_get(); if (status & _ARC_V2_TMR_CTRL_IP) { - straddled_tick_on_idle_enter = true; + straddled_tick_on_idle_enter = 1; } __ASSERT_EVAL({}, uint32_t timer_count = timer0_count_register_get(), @@ -273,7 +273,7 @@ void _timer_idle_exit(void) { if (straddled_tick_on_idle_enter) { /* Aborting the tickless idle due to a straddled tick. */ - straddled_tick_on_idle_enter = false; + straddled_tick_on_idle_enter = 0; __ASSERT_EVAL({}, uint32_t timer_count = timer0_count_register_get(), timer_count <= programmed_limit,