Commit 31b96cae authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Russell King

ARM: 8515/2: move .vectors and .stubs sections back into the kernel VMA

Commit b9b32bf7 ("ARM: use linker magic for vectors and vector stubs")
updated the linker script to emit the .vectors and .stubs sections into a
VMA range that is zero based and disjoint from the normal static kernel
region. The reason for that was that this way, the sections can be placed
exactly 4 KB apart, while the payload of the .vectors section is only 32
bytes.

Since the symbols that are part of the .stubs section are emitted into the
kallsyms table, they appear with zero based addresses as well, e.g.,

  00001004 t vector_rst
  00001020 t vector_irq
  000010a0 t vector_dabt
  00001120 t vector_pabt
  000011a0 t vector_und
  00001220 t vector_addrexcptn
  00001240 t vector_fiq
  00001240 T vector_fiq_offset

As this confuses perf when it accesses the kallsyms tables, commit
7122c3e9 ("scripts/link-vmlinux.sh: only filter kernel symbols for
arm") implemented a somewhat ugly special case for ARM, where the value
of CONFIG_PAGE_OFFSET is passed to scripts/kallsyms, and symbols whose
addresses are below it are filtered out. Note that this special case only
applies to CONFIG_XIP_KERNEL=n, not because the issue the patch addresses
exists only in that case, but because finding a limit below which to apply
the filtering is not entirely straightforward.

Since the .vectors and .stubs sections contain position independent code
that is never executed in place, we can emit it at its most likely runtime
VMA (for more recent CPUs), which is 0xffff0000 for the vector table and
0xffff1000 for the stubs. Not only does this fix the perf issue with
kallsyms, allowing us to drop the special case in scripts/kallsyms
entirely, it also gives debuggers a more realistic view of the address
space, and setting breakpoints or single stepping through code in the
vector table or the stubs is more likely to work as expected on CPUs that
use a high vector address. E.g.,

  00001240 A vector_fiq_offset
  ...
  c0c35000 T __init_begin
  c0c35000 T __vectors_start
  c0c35020 T __stubs_start
  c0c35020 T __vectors_end
  c0c352e0 T _sinittext
  c0c352e0 T __stubs_end
  ...
  ffff1004 t vector_rst
  ffff1020 t vector_irq
  ffff10a0 t vector_dabt
  ffff1120 t vector_pabt
  ffff11a0 t vector_und
  ffff1220 t vector_addrexcptn
  ffff1240 T vector_fiq

(Note that vector_fiq_offset is now an absolute symbol, which kallsyms
already ignores by default)

The LMA footprint is identical with or without this change, only the VMAs
are different:

  Before:
  Idx Name          Size      VMA       LMA       File off  Algn
   ...
   14 .notes        00000024  c0c34020  c0c34020  00a34020  2**2
                    CONTENTS, ALLOC, LOAD, READONLY, CODE
   15 .vectors      00000020  00000000  c0c35000  00a40000  2**1
                    CONTENTS, ALLOC, LOAD, READONLY, CODE
   16 .stubs        000002c0  00001000  c0c35020  00a41000  2**5
                    CONTENTS, ALLOC, LOAD, READONLY, CODE
   17 .init.text    0006b1b8  c0c352e0  c0c352e0  00a452e0  2**5
                    CONTENTS, ALLOC, LOAD, READONLY, CODE
   ...

  After:
  Idx Name          Size      VMA       LMA       File off  Algn
   ...
   14 .notes        00000024  c0c34020  c0c34020  00a34020  2**2
                    CONTENTS, ALLOC, LOAD, READONLY, CODE
   15 .vectors      00000020  ffff0000  c0c35000  00a40000  2**1
                    CONTENTS, ALLOC, LOAD, READONLY, CODE
   16 .stubs        000002c0  ffff1000  c0c35020  00a41000  2**5
                    CONTENTS, ALLOC, LOAD, READONLY, CODE
   17 .init.text    0006b1b8  c0c352e0  c0c352e0  00a452e0  2**5
                    CONTENTS, ALLOC, LOAD, READONLY, CODE
   ...
Acked-by: default avatarNicolas Pitre <nico@linaro.org>
Acked-by: default avatarChris Brandt <chris.brandt@renesas.com>
Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent b48da558
...@@ -1201,8 +1201,7 @@ vector_addrexcptn: ...@@ -1201,8 +1201,7 @@ vector_addrexcptn:
.long __fiq_svc @ e .long __fiq_svc @ e
.long __fiq_svc @ f .long __fiq_svc @ f
.globl vector_fiq_offset .globl vector_fiq
.equ vector_fiq_offset, vector_fiq
.section .vectors, "ax", %progbits .section .vectors, "ax", %progbits
.L__vectors_start: .L__vectors_start:
......
...@@ -154,19 +154,21 @@ SECTIONS ...@@ -154,19 +154,21 @@ SECTIONS
* only thing that matters is their relative offsets * only thing that matters is their relative offsets
*/ */
__vectors_start = .; __vectors_start = .;
.vectors 0 : AT(__vectors_start) { .vectors 0xffff0000 : AT(__vectors_start) {
*(.vectors) *(.vectors)
} }
. = __vectors_start + SIZEOF(.vectors); . = __vectors_start + SIZEOF(.vectors);
__vectors_end = .; __vectors_end = .;
__stubs_start = .; __stubs_start = .;
.stubs 0x1000 : AT(__stubs_start) { .stubs ADDR(.vectors) + 0x1000 : AT(__stubs_start) {
*(.stubs) *(.stubs)
} }
. = __stubs_start + SIZEOF(.stubs); . = __stubs_start + SIZEOF(.stubs);
__stubs_end = .; __stubs_end = .;
PROVIDE(vector_fiq_offset = vector_fiq - ADDR(.vectors));
INIT_TEXT_SECTION(8) INIT_TEXT_SECTION(8)
.exit.text : { .exit.text : {
ARM_EXIT_KEEP(EXIT_TEXT) ARM_EXIT_KEEP(EXIT_TEXT)
......
...@@ -164,19 +164,21 @@ SECTIONS ...@@ -164,19 +164,21 @@ SECTIONS
* only thing that matters is their relative offsets * only thing that matters is their relative offsets
*/ */
__vectors_start = .; __vectors_start = .;
.vectors 0 : AT(__vectors_start) { .vectors 0xffff0000 : AT(__vectors_start) {
*(.vectors) *(.vectors)
} }
. = __vectors_start + SIZEOF(.vectors); . = __vectors_start + SIZEOF(.vectors);
__vectors_end = .; __vectors_end = .;
__stubs_start = .; __stubs_start = .;
.stubs 0x1000 : AT(__stubs_start) { .stubs ADDR(.vectors) + 0x1000 : AT(__stubs_start) {
*(.stubs) *(.stubs)
} }
. = __stubs_start + SIZEOF(.stubs); . = __stubs_start + SIZEOF(.stubs);
__stubs_end = .; __stubs_end = .;
PROVIDE(vector_fiq_offset = vector_fiq - ADDR(.vectors));
INIT_TEXT_SECTION(8) INIT_TEXT_SECTION(8)
.exit.text : { .exit.text : {
ARM_EXIT_KEEP(EXIT_TEXT) ARM_EXIT_KEEP(EXIT_TEXT)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment