From d9a7a641f1ba2763d46b996056a24574942be01d Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Sun, 29 Oct 2017 07:42:37 -0400 Subject: Mark reset and panic functions as noreturn gcc 6.3 (as provided by coreboot-sdk) needs that to know which code paths end early. Also add a loop after the command that is "supposed" to reset the machine so that the compiler believes it (and in case that assumption fails). BRANCH=none BUG=b:65441143 TEST=none Change-Id: Idb87253ec7880d66ffec30d75f4d007f02f63aab Signed-off-by: Patrick Georgi Reviewed-on: https://chromium-review.googlesource.com/742916 Commit-Ready: Patrick Georgi Tested-by: Patrick Georgi Reviewed-by: Stefan Reinauer (cherry picked from commit 887e3962ca19cc7e8c3c474f8c82b4240eb63416) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3229786 Reviewed-by: Vadim Bendebury Reviewed-by: Andrey Pronin Tested-by: Mary Ruthven Commit-Queue: Mary Ruthven --- chip/g/system.c | 3 ++- chip/host/reboot.c | 3 +++ chip/host/reboot.h | 1 + chip/mec1322/system.c | 1 + include/panic.h | 4 ++-- include/system.h | 2 +- 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/chip/g/system.c b/chip/g/system.c index da14c3fbed..8e7b0d03cb 100644 --- a/chip/g/system.c +++ b/chip/g/system.c @@ -170,7 +170,8 @@ void system_reset(int flags) #endif /* ^^^^^^^ CHIP_FAMILY_CR50 Not defined */ /* Wait for reboot; should never return */ - asm("wfi"); + while (1) + asm("wfi"); } const char *system_get_chip_vendor(void) diff --git a/chip/host/reboot.c b/chip/host/reboot.c index 526276aede..7fdb6f7f8e 100644 --- a/chip/host/reboot.c +++ b/chip/host/reboot.c @@ -12,9 +12,12 @@ #include "reboot.h" #include "test_util.h" +__attribute__((noreturn)) void emulator_reboot(void) { char *argv[] = {strdup(__get_prog_name()), NULL}; emulator_flush(); execv(__get_prog_name(), argv); + while (1) + ; } diff --git a/chip/host/reboot.h b/chip/host/reboot.h index e391866497..113569bb9b 100644 --- a/chip/host/reboot.h +++ b/chip/host/reboot.h @@ -8,6 +8,7 @@ #ifndef __CROS_EC_REBOOT_H #define __CROS_EC_REBOOT_H +__attribute__((noreturn)) void emulator_reboot(void); #endif diff --git a/chip/mec1322/system.c b/chip/mec1322/system.c index a3262944ac..50f2ed973a 100644 --- a/chip/mec1322/system.c +++ b/chip/mec1322/system.c @@ -96,6 +96,7 @@ void chip_save_reset_flags(int flags) MEC1322_VBAT_RAM(HIBDATA_INDEX_SAVED_RESET_FLAGS) = flags; } +__attribute__((noreturn)) void _system_reset(int flags, int wake_from_hibernate) { uint32_t save_flags = 0; diff --git a/include/panic.h b/include/panic.h index 3a3bb7db9b..f5e179acf5 100644 --- a/include/panic.h +++ b/include/panic.h @@ -135,12 +135,12 @@ void panic_assert_fail(const char *msg, const char *func, const char *fname, * * @param msg Panic message */ -void panic(const char *msg); +void panic(const char *msg) __attribute__((noreturn)); /** * Display a default message and reset */ -void panic_reboot(void); +void panic_reboot(void) __attribute__((noreturn)); #ifdef CONFIG_SOFTWARE_PANIC /** diff --git a/include/system.h b/include/system.h index 7c04387a09..aed803e54d 100644 --- a/include/system.h +++ b/include/system.h @@ -231,7 +231,7 @@ const char *system_get_build_info(void); * * @param flags Reset flags; see SYSTEM_RESET_* above. */ -void system_reset(int flags); +void system_reset(int flags) __attribute__((noreturn)); /** * Set a scratchpad register to the specified value. -- cgit v1.2.1