summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2021-10-07 22:04:48 +0000
committerCommit Bot <commit-bot@chromium.org>2021-11-12 23:47:39 +0000
commit1cdedb45fd67ec24df9ac8190ed5f202e35db5e8 (patch)
treea3495091a8586de2c1dc8a3ae624caad17f25270 /core
parente1dcf1af5c3af294ed4f69df0f335b37ee769d46 (diff)
downloadchrome-ec-1cdedb45fd67ec24df9ac8190ed5f202e35db5e8.tar.gz
core/cortex-m: Use symbolic name instead of r0
This assembly is supposed to force the compiler to use r0 for pregs and r12 for pstack. When compiling with clang, it uses r12 for pregs and r0 for pstack, so the "stmia r0" instruction is using the wrong value. Instead of assuming that pregs will be in r0 and pstack will be in r12, just use the symbolic name ("pregs") with the stmia instruction. This generates the correct behavior regardless of whether pregs or pstack use r0 or r12. With gcc, the generated assembly for exception_panic after this change removes the "mov r0, r0" instruction and adds a nop at the end: 00000000 <exception_panic>: 0: 480e ldr r0, [pc, #56] ; (3c <exception_panic+0x3c>) 2: f8df c03c ldr.w ip, [pc, #60] ; 40 <exception_panic+0x40> ; No more "mov r0, r0" here 6: f3ef 8109 mrs r1, PSP a: f3ef 8205 mrs r2, IPSR e: 466b mov r3, sp 10: 05d6 lsls r6, r2, #23 12: bf1c itt ne 14: 2400 movne r4, #0 16: 2500 movne r5, #0 18: f04f 0600 mov.w r6, #0 1c: f04f 0700 mov.w r7, #0 20: f04f 0800 mov.w r8, #0 24: f04f 0900 mov.w r9, #0 28: f04f 0a00 mov.w sl, #0 2c: f04f 0b00 mov.w fp, #0 30: e880 4ffe stmia.w r0, {r1, r2, r3, r4, r5, r6, r7, r8, r9, sl, fp, lr} 34: 46e5 mov sp, ip 36: f7ff fffe bl 0 <exception_panic> 3a: bf00 nop ; adds nop instruction BRANCH=none BUG=b:172020503 TEST=CC=clang make BOARD=bloonchipper TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I150d685bde701171630ae02b16e6050e1e0e77a6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3213606 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/cortex-m/panic.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/core/cortex-m/panic.c b/core/cortex-m/panic.c
index fd80061b95..d8e82a4e5d 100644
--- a/core/cortex-m/panic.c
+++ b/core/cortex-m/panic.c
@@ -363,7 +363,6 @@ void exception_panic(void)
{
/* Save registers and branch directly to panic handler */
asm volatile(
- "mov r0, %[pregs]\n"
"mrs r1, psp\n"
"mrs r2, ipsr\n"
"mov r3, sp\n"
@@ -394,7 +393,7 @@ void exception_panic(void)
"mov r10, #0\n"
"mov r11, #0\n"
#endif
- "stmia r0, {r1-r11, lr}\n"
+ "stmia %[pregs], {r1-r11, lr}\n"
"mov sp, %[pstack]\n"
"bl report_panic\n" : :
[pregs] "r" (pdata_ptr->cm.regs),