diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2016-02-16 12:33:56 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2016-02-16 19:28:39 -0500 |
commit | 8ff97fa31333e8d0f4f7029798d9c7d59359b05c (patch) | |
tree | 23903431f74033ab44908b48b16fb2380478aa10 | |
parent | d78114554939aec0344b494e759d0679224562db (diff) |
ARM: make the physical-relative calculation more obvious
The physical-relative calculation between the XIP text and data sections
introduced by the previous patch was far from obvious. Let's simplify it
by turning it into a macro which takes the two (virtual) addresses.
This allows us to arrange the calculation in a more obvious manner - we
can make it two sub-expressions which calculate the physical address for
each symbol, and then takes the difference of those physical addresses.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r-- | arch/arm/include/asm/memory.h | 15 | ||||
-rw-r--r-- | arch/arm/mm/proc-v7.S | 2 |
2 files changed, 12 insertions, 5 deletions
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h index ebdaaf7dd19f..51fc9b3b52ea 100644 --- a/arch/arm/include/asm/memory.h +++ b/arch/arm/include/asm/memory.h | |||
@@ -135,11 +135,18 @@ | |||
135 | #define PLAT_PHYS_OFFSET UL(CONFIG_PHYS_OFFSET) | 135 | #define PLAT_PHYS_OFFSET UL(CONFIG_PHYS_OFFSET) |
136 | 136 | ||
137 | #ifdef CONFIG_XIP_KERNEL | 137 | #ifdef CONFIG_XIP_KERNEL |
138 | #define PHYS_OFFSET_FIXUP \ | 138 | /* |
139 | ( XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR) - PAGE_OFFSET + \ | 139 | * When referencing data in RAM from the XIP region in a relative manner |
140 | PLAT_PHYS_OFFSET - CONFIG_XIP_PHYS_ADDR ) | 140 | * with the MMU off, we need the relative offset between the two physical |
141 | * addresses. The macro below achieves this, which is: | ||
142 | * __pa(v_data) - __xip_pa(v_text) | ||
143 | */ | ||
144 | #define PHYS_RELATIVE(v_data, v_text) \ | ||
145 | (((v_data) - PAGE_OFFSET + PLAT_PHYS_OFFSET) - \ | ||
146 | ((v_text) - XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR) + \ | ||
147 | CONFIG_XIP_PHYS_ADDR)) | ||
141 | #else | 148 | #else |
142 | #define PHYS_OFFSET_FIXUP 0 | 149 | #define PHYS_RELATIVE(v_data, v_text) ((v_data) - (v_text)) |
143 | #endif | 150 | #endif |
144 | 151 | ||
145 | #ifndef __ASSEMBLY__ | 152 | #ifndef __ASSEMBLY__ |
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S index 1595fb29ec12..0f8963a7e7d9 100644 --- a/arch/arm/mm/proc-v7.S +++ b/arch/arm/mm/proc-v7.S | |||
@@ -487,7 +487,7 @@ __errata_finish: | |||
487 | 487 | ||
488 | .align 2 | 488 | .align 2 |
489 | __v7_setup_stack_ptr: | 489 | __v7_setup_stack_ptr: |
490 | .word __v7_setup_stack - . + PHYS_OFFSET_FIXUP | 490 | .word PHYS_RELATIVE(__v7_setup_stack, .) |
491 | ENDPROC(__v7_setup) | 491 | ENDPROC(__v7_setup) |
492 | 492 | ||
493 | .bss | 493 | .bss |