diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2021-04-07 19:27:22 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2021-04-07 19:59:57 +0100 |
commit | 4b263725912939748427faa105f8b2745999a627 (patch) | |
tree | d4711faa6326c7c97e67d498146f8670747875d3 /bootloader | |
parent | 213d372c929668417e7c89468a0adf284377b161 (diff) | |
download | rockbox-4b263725912939748427faa105f8b2745999a627.tar.gz rockbox-4b263725912939748427faa105f8b2745999a627.zip |
MIPS: make sure to fill 'jr' branch delay slot with 'nop'
Inline assembly in RoLO and the FiiO M3K bootloader used 'jr' to
jump to a newly loaded Rockbox binary, but incorrectly left the
branch delay slot open. That gives GCC an opening to place illegal
instrutions, etc, which might cause an unhandled exception.
Change-Id: Ia7a561fe530e94a41189d25f18a767c448177960
Diffstat (limited to 'bootloader')
-rw-r--r-- | bootloader/fiiom3k-spl.c | 4 | ||||
-rw-r--r-- | bootloader/fiiom3k.c | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/bootloader/fiiom3k-spl.c b/bootloader/fiiom3k-spl.c index ec532d5789..67b4b0a59c 100644 --- a/bootloader/fiiom3k-spl.c +++ b/bootloader/fiiom3k-spl.c | |||
@@ -199,6 +199,8 @@ void spl_main(void) | |||
199 | /* Flush caches and jump to address */ | 199 | /* Flush caches and jump to address */ |
200 | void* execaddr = (void*)opt->exec_addr; | 200 | void* execaddr = (void*)opt->exec_addr; |
201 | commit_discard_idcache(); | 201 | commit_discard_idcache(); |
202 | __asm__ __volatile__ ("jr %0" :: "r"(execaddr)); | 202 | __asm__ __volatile__ ("jr %0\n" |
203 | "nop\n" | ||
204 | :: "r"(execaddr)); | ||
203 | __builtin_unreachable(); | 205 | __builtin_unreachable(); |
204 | } | 206 | } |
diff --git a/bootloader/fiiom3k.c b/bootloader/fiiom3k.c index 6108a37efc..93010e86d2 100644 --- a/bootloader/fiiom3k.c +++ b/bootloader/fiiom3k.c | |||
@@ -47,7 +47,9 @@ void exec(void* dst, const void* src, int bytes) | |||
47 | { | 47 | { |
48 | memcpy(dst, src, bytes); | 48 | memcpy(dst, src, bytes); |
49 | commit_discard_idcache(); | 49 | commit_discard_idcache(); |
50 | __asm__ __volatile__ ("jr %0" :: "r"(dst)); | 50 | __asm__ __volatile__ ("jr %0\n" |
51 | "nop\n" | ||
52 | :: "r"(dst)); | ||
51 | __builtin_unreachable(); | 53 | __builtin_unreachable(); |
52 | } | 54 | } |
53 | 55 | ||