Skip to content
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

Keep assembly functions in separate sections #1912

Merged
merged 4 commits into from
Nov 8, 2017
Merged
Show file tree
Hide file tree
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
24 changes: 13 additions & 11 deletions core/arch/arm/kernel/generic_entry_a32.S
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ panic_boot_file:
/*
* void assert_flat_mapped_range(uint32_t vaddr, uint32_t line)
*/
.section .text.init
LOCAL_FUNC __assert_flat_mapped_range , :
UNWIND( .fnstart)
UNWIND( .cantunwind)
Expand Down Expand Up @@ -96,18 +95,18 @@ UNWIND( .fnend)
END_FUNC plat_cpu_reset_early
KEEP_PAGER plat_cpu_reset_early

.section .text.boot
FUNC _start , :
b reset
.section .text.reset_vect_table
.align 5
LOCAL_FUNC reset_vect_table , :
b .
b . /* Undef */
b . /* Syscall */
b . /* Prefetch abort */
b . /* Data abort */
b . /* Reserved */
b . /* IRQ */
b . /* FIQ */
END_FUNC _start
KEEP_INIT _start
END_FUNC reset_vect_table

.macro cpu_is_ready
#ifdef CFG_BOOT_SYNC_CPU
Expand Down Expand Up @@ -231,7 +230,7 @@ KEEP_INIT _start
mov r7, r1
.endm

LOCAL_FUNC reset , :
FUNC _start , :
UNWIND( .fnstart)
UNWIND( .cantunwind)

Expand All @@ -243,7 +242,7 @@ UNWIND( .cantunwind)
set_sctlr
isb

ldr r0, =_start
ldr r0, =reset_vect_table
write_vbar r0

#if defined(CFG_WITH_ARM_TRUSTED_FW)
Expand All @@ -255,7 +254,8 @@ UNWIND( .cantunwind)
b reset_secondary
#endif
UNWIND( .fnend)
END_FUNC reset
END_FUNC _start
KEEP_INIT _start

/*
* Setup sp to point to the top of the tmp stack for the current CPU:
Expand Down Expand Up @@ -490,7 +490,6 @@ shadow_stack_access_ok:
UNWIND( .fnend)
END_FUNC reset_primary


LOCAL_FUNC unhandled_cpu , :
UNWIND( .fnstart)
wfi
Expand All @@ -509,7 +508,7 @@ UNWIND( .cantunwind)
set_sctlr
isb

ldr r0, =_start
ldr r0, =reset_vect_table
write_vbar r0

mov r4, lr
Expand All @@ -529,12 +528,15 @@ UNWIND( .cantunwind)
bx r6
UNWIND( .fnend)
END_FUNC cpu_on_handler
KEEP_PAGER cpu_on_handler

#else /* defined(CFG_WITH_ARM_TRUSTED_FW) */

LOCAL_FUNC reset_secondary , :
UNWIND( .fnstart)
UNWIND( .cantunwind)
ldr r0, =reset_vect_table
write_vbar r0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this an unrelated fix? (would deserve its own commit)


wait_primary

Expand Down
4 changes: 2 additions & 2 deletions core/arch/arm/kernel/generic_entry_a64.S
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
msr sctlr_el1, x0
.endm

.section .text.boot
FUNC _start , :
mov x19, x0 /* Save pagable part address */
mov x20, x2 /* Save DT address */
Expand Down Expand Up @@ -187,7 +186,6 @@ END_FUNC _start
KEEP_INIT _start


.section .text.cpu_on_handler
FUNC cpu_on_handler , :
mov x19, x0
mov x20, x1
Expand Down Expand Up @@ -216,6 +214,7 @@ FUNC cpu_on_handler , :
mov x30, x21
b generic_boot_cpu_on_handler
END_FUNC cpu_on_handler
KEEP_PAGER cpu_on_handler

LOCAL_FUNC unhandled_cpu , :
wfi
Expand All @@ -234,6 +233,7 @@ END_FUNC unhandled_cpu
.endif
.endm

.section .text.reset_vect_table
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed?

.align 11
LOCAL_FUNC reset_vect_table , :
/* -----------------------------------------------------
Expand Down
7 changes: 4 additions & 3 deletions core/arch/arm/kernel/kern.ld.S
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ SECTIONS
__flatmap_unpg_rx_start = ROUNDDOWN(__text_start, SMALL_PAGE_SIZE);

.text : {
KEEP(*(.text.boot.vectab1))
KEEP(*(.text.boot.vectab2))
KEEP(*(.text.boot))
KEEP(*(.text._start))
KEEP(*(.text.init .text.plat_cpu_reset_early \
.text.reset .text.reset_primary .text.unhandled_cpu \
.text.__assert_flat_mapped_range))

. = ALIGN(8);
__initcall_start = .;
Expand Down
5 changes: 4 additions & 1 deletion core/arch/arm/kernel/thread_a32.S
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ UNWIND( .cantunwind)
b vector_system_reset_entry
UNWIND( .fnend)
END_FUNC thread_vector_table
KEEP_PAGER thread_vector_table

FUNC thread_set_abt_sp , :
UNWIND( .fnstart)
Expand All @@ -210,7 +211,7 @@ UNWIND( .cantunwind)
msr cpsr, r1
bx lr
UNWIND( .fnend)
END_FUNC thread_set_abt_sp
END_FUNC thread_set_und_sp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: unrelated fix, should be a separate commit


FUNC thread_set_irq_sp , :
UNWIND( .fnstart)
Expand Down Expand Up @@ -440,6 +441,7 @@ UNWIND( .save {r0})
pop {r4-r5, pc}
UNWIND( .fnend)
END_FUNC thread_rpc
KEEP_PAGER thread_rpc

/* The handler of native interrupt. */
.macro native_intr_handler mode:req
Expand Down Expand Up @@ -817,6 +819,7 @@ UNWIND( .cantunwind)
UNWIND( .fnend)
END_FUNC thread_svc_handler

.section .text.thread_vect_table
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed?

.align 5
LOCAL_FUNC thread_vect_table , :
UNWIND( .fnstart)
Expand Down
4 changes: 3 additions & 1 deletion core/arch/arm/kernel/thread_a64.S
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
madd x\res, x\tmp0, x\tmp1, x\res
.endm

.section .text.thread_asm
LOCAL_FUNC vector_std_smc_entry , :
sub sp, sp, #THREAD_SMC_ARGS_SIZE
store_xregs sp, THREAD_SMC_ARGS_X0, 0, 7
Expand Down Expand Up @@ -165,6 +164,7 @@ FUNC thread_vector_table , :
b vector_system_off_entry
b vector_system_reset_entry
END_FUNC thread_vector_table
KEEP_PAGER thread_vector_table


/* void thread_resume(struct thread_ctx_regs *regs) */
Expand Down Expand Up @@ -255,6 +255,7 @@ FUNC thread_rpc , :
store_wregs x16, 0, 0, 5 /* Store w0-w5 into rv[] */
ret
END_FUNC thread_rpc
KEEP_PAGER thread_rpc

FUNC thread_init_vbar , :
adr x0, thread_vect_table
Expand Down Expand Up @@ -345,6 +346,7 @@ END_FUNC thread_unwind_user_mode
.endm


.section .text.thread_vect_table
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed?

.align 11
LOCAL_FUNC thread_vect_table , :
/* -----------------------------------------------------
Expand Down
27 changes: 14 additions & 13 deletions core/arch/arm/sm/pm_a32.S
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,20 @@ UNWIND( .cantunwind)
UNWIND( .fnend)
END_FUNC sm_pm_cpu_resume

/*
* The following will be located in text section whose attribute is
* marked as readonly, but we only need to read here
* _suspend_sp stores the offset between thread_core_local to _suspend_sp.
* _core_pos stores the offset between get_core_pos to _core_pos.
*/
.align 2
.extern thread_core_local
_suspend_sp:
.long thread_core_local - .
.extern get_core_pos
_core_pos:
.long get_core_pos - .

/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why move this block here? Just cosmetic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's to avoid an assembler error, apparantly the adr instruction can only be performed on symbols in the same section.

* void sm_do_cpu_do_resume(paddr suspend_regs) __noreturn;
* Restore the registers stored when sm_pm_cpu_do_suspend
Expand Down Expand Up @@ -210,16 +224,3 @@ a7_resume:
UNWIND( .fnend)
END_FUNC sm_pm_cpu_do_resume

/*
* The following will be located in text section whose attribute is
* marked as readonly, but we only need to read here
* _suspend_sp stores the offset between thread_core_local to _suspend_sp.
* _core_pos stores the offset between get_core_pos to _core_pos.
*/
.align 2
.extern thread_core_local
_suspend_sp:
.long thread_core_local - .
.extern get_core_pos
_core_pos:
.long get_core_pos - .
1 change: 1 addition & 0 deletions core/arch/arm/sm/sm_a32.S
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ UNWIND( .cantunwind)
UNWIND( .fnend)
END_FUNC sm_fiq_entry

.section .text.sm_vect_table
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed?

.align 5
LOCAL_FUNC sm_vect_table , :
UNWIND( .fnstart)
Expand Down
2 changes: 2 additions & 0 deletions lib/libutils/ext/include/asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

.macro FUNC name colon
.section .text.\name
.global \name
.func \name
.type \name , %function
Expand All @@ -39,6 +40,7 @@
.endm

.macro LOCAL_FUNC name colon
.section .text.\name
.func \name
.type \name , %function
\name \colon
Expand Down