Commit Graph

9 Commits

Author SHA1 Message Date
Donald Dutile 1c7ced2303 scripts: ftrace - move the sort-processing in ftrace_init
JIRA: https://issues.redhat.com/browse/RHEL-28063

commit 72b3942a173c387b27860ba1069636726e208777
Author: Yinan Liu <yinan@linux.alibaba.com>
Date:   Sun Dec 12 19:33:58 2021 +0800

    scripts: ftrace - move the sort-processing in ftrace_init

    When the kernel starts, the initialization of ftrace takes
    up a portion of the time (approximately 6~8ms) to sort mcount
    addresses. We can save this time by moving mcount-sorting to
    compile time.

    Link: https://lkml.kernel.org/r/20211212113358.34208-2-yinan@linux.alibaba.com

    Signed-off-by: Yinan Liu <yinan@linux.alibaba.com>
    Reported-by: kernel test robot <lkp@intel.com>
    Reported-by: kernel test robot <oliver.sang@intel.com>
    Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Signed-off-by: Donald Dutile <ddutile@redhat.com>
2024-06-17 14:17:12 -04:00
Baoquan He 2a597ed25b LoongArch: Add ELF-related definitions
JIRA: https://issues.redhat.com/browse/RHEL-32199

Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

Conflict: There's conflict in 1st hunk of scripts/sorttable.c.

commit 08145b087e4481458f6075f3af58021a3cf8a940
Author: Huacai Chen <chenhuacai@kernel.org>
Date:   Tue May 31 18:04:10 2022 +0800

    LoongArch: Add ELF-related definitions

    Add ELF-related definitions for LoongArch, including: EM_LOONGARCH,
    KEXEC_ARCH_LOONGARCH, AUDIT_ARCH_LOONGARCH32, AUDIT_ARCH_LOONGARCH64
    and NT_LOONGARCH_*.

    Reviewed-by: WANG Xuerui <git@xen0n.name>
    Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
    Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>

Signed-off-by: Baoquan He <bhe@redhat.com>
2024-05-15 13:58:51 +08:00
Chris von Recklinghausen a67b691469 s390/extable: convert to relative table with data
Bugzilla: https://bugzilla.redhat.com/2160210

commit 3d66718cd62d45f3210f047248eab9e76d227e47
Author: Heiko Carstens <hca@linux.ibm.com>
Date:   Mon Feb 28 14:52:42 2022 +0100

    s390/extable: convert to relative table with data

    Follow arm64, riscv, and x86 and change extable layout to common
    "relative table with data". This allows to get rid of s390 specific
    code in sorttable.c.

    The main difference to before is that extable entries do not contain a
    relative function pointer anymore. Instead data and type fields are
    added.

    The type field is used to indicate which exception handler needs to be
    called, while the data field is currently unused.

    Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
    Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
    Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>

Signed-off-by: Rafael Aquini <aquini@redhat.com>
Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
2023-03-24 11:18:38 -04:00
Chris von Recklinghausen c0d73096da scripts/sorttable: Unify arm64 & x86 sort functions
Bugzilla: https://bugzilla.redhat.com/2160210

commit e232333be69ee9ccd4281032af0d2416940cb98d
Author: Mark Rutland <mark.rutland@arm.com>
Date:   Mon Nov 8 11:42:20 2021 +0000

    scripts/sorttable: Unify arm64 & x86 sort functions

    The format of the arm64 and x86 exception table entries is essentially
    the same as of commits:

      46d28947d9876fc0 ("x86/extable: Rework the exception table mechanics")
      d6e2cc5647753825 ("arm64: extable: add `type` and `data` fields")

    Both use a 12-byte entry consisting of two 32-bit relative offsets and
    32 bits of (absolute) data, and their sort functions are identical aside
    from commentary, with arm64 saying:

       /* Don't touch the fixup type or data */

    ... and x86 saying:

      /* Don't touch the fixup type */

    Unify the two behind a common sort_relative_table_with_data() function,
    retaining the arm64 commentary.

    There should be no functional change as a result of this patch.

    Signed-off-by: Mark Rutland <mark.rutland@arm.com>
    Cc: Ard Biesheuvel <ardb@kernel.org>
    Cc: Borislav Petkov <bp@suse.de>
    Cc: Catalin Marinas <catalin.marinas@arm.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Will Deacon <will@kernel.org>
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>

Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
2023-03-24 11:18:32 -04:00
Mark Salter a2f408517b arm64: extable: add `type` and `data` fields
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2076088

commit d6e2cc56477538255160ed02fdb11b0da60356cc
Author: Mark Rutland <mark.rutland@arm.com>
Date: Tue, 19 Oct 2021 17:02:16 +0100

    Subsequent patches will add specialized handlers for fixups, in addition
    to the simple PC fixup and BPF handlers we have today. In preparation,
    this patch adds a new `type` field to struct exception_table_entry, and
    uses this to distinguish the fixup and BPF cases. A `data` field is also
    added so that subsequent patches can associate data specific to each
    exception site (e.g. register numbers).

    Handlers are named ex_handler_*() for consistency, following the exmaple
    of x86. At the same time, get_ex_fixup() is split out into a helper so
    that it can be used by other ex_handler_*() functions ins subsequent
    patches.

    This patch will increase the size of the exception tables, which will be
    remedied by subsequent patches removing redundant fixup code. There
    should be no functional change as a result of this patch.

    Since each entry is now 12 bytes in size, we must reduce the alignment
    of each entry from `.align 3` (i.e. 8 bytes) to `.align 2` (i.e. 4
    bytes), which is the natrual alignment of the `insn` and `fixup` fields.
    The current 8-byte alignment is a holdover from when the `insn` and
    `fixup` fields was 8 bytes, and while not harmful has not been necessary
    since commit:

      6c94f27ac8 ("arm64: switch to relative exception tables")

    Similarly, RO_EXCEPTION_TABLE_ALIGN is dropped to 4 bytes.

    Concurrently with this patch, x86's exception table entry format is
    being updated (similarly to a 12-byte format, with 32-bytes of absolute
    data). Once both have been merged it should be possible to unify the
    sorttable logic for the two.

    Signed-off-by: Mark Rutland <mark.rutland@arm.com>
    Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
    Cc: Alexei Starovoitov <ast@kernel.org>
    Cc: Andrii Nakryiko <andrii@kernel.org>
    Cc: Catalin Marinas <catalin.marinas@arm.com>
    Cc: Daniel Borkmann <daniel@iogearbox.net>
    Cc: James Morse <james.morse@arm.com>
    Cc: Jean-Philippe Brucker <jean-philippe@linaro.org>
    Cc: Robin Murphy <robin.murphy@arm.com>
    Cc: Will Deacon <will@kernel.org>
    Link: https://lore.kernel.org/r/20211019160219.5202-11-mark.rutland@arm.com
    Signed-off-by: Will Deacon <will@kernel.org>

Signed-off-by: Mark Salter <msalter@redhat.com>
2022-04-18 10:05:55 -04:00
David Arcari a59ba22605 x86/extable: Rework the exception table mechanics
Bugzilla: http://bugzilla.redhat.com/2004190

commit 46d28947d9876fc0f8f93d3c69813ef6e9852595
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Sep 8 15:29:18 2021 +0200

    x86/extable: Rework the exception table mechanics

    The exception table entries contain the instruction address, the fixup
    address and the handler address. All addresses are relative. Storing the
    handler address has a few downsides:

     1) Most handlers need to be exported

     2) Handlers can be defined everywhere and there is no overview about the
        handler types

     3) MCE needs to check the handler type to decide whether an in kernel #MC
        can be recovered. The functionality of the handler itself is not in any
        way special, but for these checks there need to be separate functions
        which in the worst case have to be exported.

        Some of these 'recoverable' exception fixups are pretty obscure and
        just reuse some other handler to spare code. That obfuscates e.g. the
        #MC safe copy functions. Cleaning that up would require more handlers
        and exports

    Rework the exception fixup mechanics by storing a fixup type number instead
    of the handler address and invoke the proper handler for each fixup
    type. Also teach the extable sort to leave the type field alone.

    This makes most handlers static except for special cases like the MCE
    MSR fixup and the BPF fixup. This allows to add more types for cleaning up
    the obscure places without adding more handler code and exports.

    There is a marginal code size reduction for a production config and it
    removes _eight_ exported symbols.

    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Acked-by: Alexei Starovoitov <ast@kernel.org>
    Link: https://lkml.kernel.org/r/20210908132525.211958725@linutronix.de

Signed-off-by: David Arcari <darcari@redhat.com>
2021-11-22 14:35:38 -05:00
Ilya Leoshkevich 05a68e892e s390/kernel: expand exception table logic to allow new handling options
This is a s390 port of commit 548acf1923 ("x86/mm: Expand the
exception table logic to allow new handling options"), which is needed
for implementing BPF_PROBE_MEM on s390.

The new handler field is made 64-bit in order to allow pointing from
dynamically allocated entries to handlers in kernel text. Unlike on x86,
NULL is used instead of ex_handler_default. This is because exception
tables are used by boot/text_dma.S, and it would be a pain to preserve
ex_handler_default.

The new infrastructure is ignored in early_pgm_check_handler, since
there is no pt_regs.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2020-07-20 10:55:50 +02:00
Shile Zhang 57fa189942 scripts/sorttable: Implement build-time ORC unwind table sorting
The ORC unwinder has two tables: .orc_unwind_ip and .orc_unwind, which
need to be sorted for binary search. Previously this sorting was done
during bootup.

Sort them at build time to speed up booting.

Add the ORC tables sorting in a parallel build process to speed up the build.

[ mingo: Rewrote the changelog and fixed some comments. ]

Suggested-by: Andy Lutomirski <luto@amacapital.net>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Shile Zhang <shile.zhang@linux.alibaba.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: linux-kbuild@vger.kernel.org
Link: https://lkml.kernel.org/r/20191204004633.88660-7-shile.zhang@linux.alibaba.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2019-12-13 10:47:58 +01:00
Shile Zhang 1091670637 scripts/sorttable: Rename 'sortextable' to 'sorttable'
Use a more generic name for additional table sorting usecases,
such as the upcoming ORC table sorting feature. This tool is
not tied to exception table sorting anymore.

No functional changes intended.

[ mingo: Rewrote the changelog. ]

Signed-off-by: Shile Zhang <shile.zhang@linux.alibaba.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: linux-kbuild@vger.kernel.org
Link: https://lkml.kernel.org/r/20191204004633.88660-6-shile.zhang@linux.alibaba.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2019-12-13 10:47:58 +01:00