Skip to content

[Backport v4.0-branch] arch: arm: cortex_m: Force literal pool placement in inline asm block #93125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: v4.0-branch
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions arch/arm/core/cortex_m/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,12 @@
"mov r3, #0\n"
"ldr r4, =z_thread_entry\n"
"bx r4\n" /* We don’t intend to return, so there is no need to link. */
/* Force a literal pool placement for the addresses referenced above */
".ltorg\n"
:
: "r" (_main), "r" (stack_ptr)
: "r0", "r1", "r2", "r3", "r4", "ip", "lr", "memory");

Check notice on line 594 in arch/arm/core/cortex_m/thread.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

arch/arm/core/cortex_m/thread.c:594 - __asm__ volatile ( - "mov r4, %0\n" /* force _main to be stored in a register */ - "msr PSP, %1\n" /* __set_PSP(stack_ptr) */ - - "mov r0, #0\n" /* arch_irq_unlock(0) */ - "ldr r3, =arch_irq_unlock_outlined\n" - "blx r3\n" - - "mov r0, r4\n" /* z_thread_entry(_main, NULL, NULL, NULL) */ - "mov r1, #0\n" - "mov r2, #0\n" - "mov r3, #0\n" - "ldr r4, =z_thread_entry\n" - "bx r4\n" /* We don’t intend to return, so there is no need to link. */ - /* Force a literal pool placement for the addresses referenced above */ - ".ltorg\n" - : - : "r" (_main), "r" (stack_ptr) - : "r0", "r1", "r2", "r3", "r4", "ip", "lr", "memory"); + __asm__ volatile("mov r4, %0\n" /* force _main to be stored in a register */ + "msr PSP, %1\n" /* __set_PSP(stack_ptr) */ + + "mov r0, #0\n" /* arch_irq_unlock(0) */ + "ldr r3, =arch_irq_unlock_outlined\n" + "blx r3\n" + + "mov r0, r4\n" /* z_thread_entry(_main, NULL, NULL, NULL) */ + "mov r1, #0\n" + "mov r2, #0\n" + "mov r3, #0\n" + "ldr r4, =z_thread_entry\n" + "bx r4\n" /* We don’t intend to return, so there is no need to link. */ + /* Force a literal pool placement for the addresses referenced above */ + ".ltorg\n" + : + : "r"(_main), "r"(stack_ptr) + : "r0", "r1", "r2", "r3", "r4", "ip", "lr", "memory");
CODE_UNREACHABLE;
}

Expand Down Expand Up @@ -653,6 +655,8 @@
"ldr r0, =arch_irq_lock_outlined\n"
"blx r0\n"
"loop: b loop\n\t" /* while (true); */
/* Force a literal pool placement for the addresses referenced above */
".ltorg\n"
:
: [_p1]"r" (p1), [_p2]"r" (p2), [_p3]"r" (p3),
[_psp]"r" (psp), [_main_entry]"r" (main_entry)
Expand All @@ -661,7 +665,7 @@
#endif
: "r0", "r1", "r2", "ip", "lr"
);

Check notice on line 668 in arch/arm/core/cortex_m/thread.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

arch/arm/core/cortex_m/thread.c:668 - __asm__ volatile ( + __asm__ volatile( #ifdef CONFIG_BUILTIN_STACK_GUARD - "msr PSPLIM, %[_psplim]\n" /* __set_PSPLIM(_psplim) */ -#endif - "msr PSP, %[_psp]\n" /* __set_PSP(psp) */ - "mov r0, #0\n" - "ldr r1, =arch_irq_unlock_outlined\n" - "blx r1\n" - - "mov r0, %[_p1]\n" - "mov r1, %[_p2]\n" - "mov r2, %[_p3]\n" - "blx %[_main_entry]\n" /* main_entry(p1, p2, p3) */ - - "ldr r0, =arch_irq_lock_outlined\n" - "blx r0\n" - "loop: b loop\n\t" /* while (true); */ - /* Force a literal pool placement for the addresses referenced above */ - ".ltorg\n" - : - : [_p1]"r" (p1), [_p2]"r" (p2), [_p3]"r" (p3), - [_psp]"r" (psp), [_main_entry]"r" (main_entry) + "msr PSPLIM, %[_psplim]\n" /* __set_PSPLIM(_psplim) */ +#endif + "msr PSP, %[_psp]\n" /* __set_PSP(psp) */ + "mov r0, #0\n" + "ldr r1, =arch_irq_unlock_outlined\n" + "blx r1\n" + + "mov r0, %[_p1]\n" + "mov r1, %[_p2]\n" + "mov r2, %[_p3]\n" + "blx %[_main_entry]\n" /* main_entry(p1, p2, p3) */ + + "ldr r0, =arch_irq_lock_outlined\n" + "blx r0\n" + "loop: b loop\n\t" /* while (true); */ + /* Force a literal pool placement for the addresses referenced above */ + ".ltorg\n" + : + : [_p1] "r"(p1), [_p2] "r"(p2), [_p3] "r"(p3), [_psp] "r"(psp), + [_main_entry] "r"(main_entry) #ifdef CONFIG_BUILTIN_STACK_GUARD - , [_psplim]"r" (psplim) -#endif - : "r0", "r1", "r2", "ip", "lr" - ); + , + [_psplim] "r"(psplim) +#endif + : "r0", "r1", "r2", "ip", "lr");
CODE_UNREACHABLE; /* LCOV_EXCL_LINE */
}
#endif /* !CONFIG_MULTITHREADING */
Loading