arm64: {adr,ldr}_l cleanup
Mark Rutland
reviewercover arm64: {adr,ldr}_l cleanup
Hi,
While looking at the way we use adrp, I spotted that there are still a few open-coded instances of adr_l and ldr_l.
These patches clean those up, making the code a little easier to follow.
Thanks,
Mark.
Mark Rutland (3):
arm64: head.S: avoid open-coded adr_l
arm64: efi-entry.S: avoid open-coded adr_l
arm64: entry-ftrace.S: avoid open-coded {adr,ldr}_l
arch/arm64/kernel/efi-entry.S | 9 +++------ arch/arm64/kernel/entry-ftrace.S | 12 ++++-------- arch/arm64/kernel/head.S | 3 +-- 3 files changed, 8 insertions(+), 16 deletions(-)
Signature · 1 line
1.9.1
Mark Rutland
reviewerPATCH 1/3 arm64: head.S: avoid open-coded adr_l
Some places in the kernel open-code sequences using ADRP for a symbol another instruction using a :lo12: relocation for that same symbol. These sequences are easy to get wrong, and more painful to read than is necessary. For these reasons, it is preferable to use the {adr,ldr,str}_l macros for these cases.
This patch makes use of adr_l these in head.S, removing an open-coded sequence using adrp.
--- arch/arm64/kernel/head.S | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/kernel/head.S +1 -2
@@ -613,8 +613,7 @@ CPU_LE( movk x0, #0x30d0, lsl #16 ) // Clear EE and E0E on LE systems install_el2_stub: /* Hypervisor stub */ - adrp x0, __hyp_stub_vectors - add x0, x0, #:lo12:__hyp_stub_vectors + adr_l x0, __hyp_stub_vectors msr vbar_el2, x0 /* spsr */
Signature · 1 line
1.9.1
Mark Rutland
reviewerPATCH 2/3 arm64: efi-entry.S: avoid open-coded adr_l
In reply to Mark RutlandSome places in the kernel open-code sequences using ADRP for a symbol another instruction using a :lo12: relocation for that same symbol. These sequences are easy to get wrong, and more painful to read than is necessary. For these reasons, it is preferable to use the {adr,ldr,str}_l macros for these cases.
This patch makes use of these in efi-entry.S, removing open-coded sequences using adrp.
--- arch/arm64/kernel/efi-entry.S | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
arch/arm64/kernel/efi-entry.S +3 -6
@@ -46,8 +46,7 @@ ENTRY(entry) * efi_system_table_t *sys_table, * unsigned long *image_addr) ; */ - adrp x8, _text - add x8, x8, #:lo12:_text + adr_l x8, _text add x2, sp, 16 str x8, [x2] bl efi_entry
@@ -68,10 +67,8 @@ ENTRY(entry) /* * Calculate size of the kernel Image (same for original and copy). */ - adrp x1, _text - add x1, x1, #:lo12:_text - adrp x2, _edata - add x2, x2, #:lo12:_edata + adr_l x1, _text + adr_l x2, _edata sub x1, x2, x1 /*
Signature · 1 line
1.9.1
Mark Rutland
reviewerPATCH 3/3 arm64: entry-ftrace.S: avoid open-coded {adr,ldr}_l
In reply to Mark RutlandSome places in the kernel open-code sequences using ADRP for a symbol another instruction using a :lo12: relocation for that same symbol. These sequences are easy to get wrong, and more painful to read than is necessary. For these reasons, it is preferable to use the {adr,ldr,str}_l macros for these cases.
This patch makes use of these in entry-ftrace.S, removing open-coded sequences using adrp. This results in a minor code change, since a temporary register is not used when generating the address for some symbols, but this is fine, as the value of the temporary register is not used elsewhere.
--- arch/arm64/kernel/entry-ftrace.S | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
arch/arm64/kernel/entry-ftrace.S +4 -8
@@ -98,8 +98,7 @@ ENTRY(_mcount) mcount_enter - adrp x0, ftrace_trace_function - ldr x2, [x0, #:lo12:ftrace_trace_function] + ldr_l x2, ftrace_trace_function adr x0, ftrace_stub cmp x0, x2 // if (ftrace_trace_function b.eq skip_ftrace_call // != ftrace_stub) {
@@ -115,15 +114,12 @@ skip_ftrace_call: // return; mcount_exit // return; // } skip_ftrace_call: - adrp x1, ftrace_graph_return - ldr x2, [x1, #:lo12:ftrace_graph_return] + ldr_l x2, ftrace_graph_return cmp x0, x2 // if ((ftrace_graph_return b.ne ftrace_graph_caller // != ftrace_stub) - adrp x1, ftrace_graph_entry // || (ftrace_graph_entry - adrp x0, ftrace_graph_entry_stub // != ftrace_graph_entry_stub)) - ldr x2, [x1, #:lo12:ftrace_graph_entry] - add x0, x0, #:lo12:ftrace_graph_entry_stub + ldr_l x2, ftrace_graph_entry // || (ftrace_graph_entry + adr_l x0, ftrace_graph_entry_stub // != ftrace_graph_entry_stub)) cmp x0, x2 b.ne ftrace_graph_caller // ftrace_graph_caller();
Signature · 1 line
1.9.1
cover arm64: {adr,ldr}_l cleanup
In reply to Mark RutlandQuoted 7 lines · Mark Rutland
Hi,
While looking at the way we use adrp, I spotted that there are still a few open-coded instances of
adr_landldr_l.These patches clean those up, making the code a little easier to follow.
For the series:
Quoted 16 lines
Thanks,
Mark.Mark Rutland (3):
arm64:head.S: avoid open-codedadr_l
arm64:efi-entry.S: avoid open-codedadr_l
arm64:entry-ftrace.S: avoid open-coded {adr,ldr}_larch/arm64/kernel/efi-entry.S | 9 +++------ arch/arm64/kernel/entry-ftrace.S | 12 ++++-------- arch/arm64/kernel/head.S | 3 +-- 3 files changed, 8 insertions(+), 16 deletions(-)--
1.9.1
cover arm64: {adr,ldr}_l cleanup
In reply to Mark RutlandQuoted 4 lines · Mark Rutland
While looking at the way we use adrp, I spotted that there are still a few open-coded instances of
adr_landldr_l.These patches clean those up, making the code a little easier to follow.
Thanks, queued for 4.11.
Will