mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4 0/5] LoongArch: Add kernel relocation and KASLR support
@ 2023-02-10  8:47 Youling Tang
  2023-02-10  8:47 ` [PATCH v4 1/5] LoongArch: Use la.pcrel instead of la.abs when it's trivially possible Youling Tang
                   ` (4 more replies)
  0 siblings, 5 replies; 22+ messages in thread
From: Youling Tang @ 2023-02-10  8:47 UTC (permalink / raw)
  To: Huacai Chen, Xi Ruoyao, Jinyang He; +Cc: Xuerui Wang, loongarch, linux-kernel

This patch series to support kernel relocation and KASLR (only 64bit).

Tested the kernel images built with new toolchain (Binutils-2.40 + patched
GCC-12.2) and old toolchain (kernel.org cross toolchain [1]) on a
3A5000-7A2000-EVB.

With CONFIG_RANDOMIZE_BASE=y, the results are:

1. first boot, new toolchain:

$ sudo cat /proc/iomem | grep Kernel
  01080000-0189ffff : Kernel code
  018a0000-01deb5ff : Kernel data
  01deb600-01ef6e9f : Kernel bss

2. second boot, new toolchain:

$ sudo cat /proc/iomem | grep Kernel
  012f0000-01b0ffff : Kernel code
  01b10000-0205b5ff : Kernel data
  0205b600-02166e9f : Kernel bss

3. first boot, old toolchain:
  010e0000-018fffff : Kernel code
  01900000-01e591ff : Kernel data
  01e59200-01f56dcf : Kernel bss

4. second boot, old toolchain:
  010b0000-018cffff : Kernel code
  018d0000-01e291ff : Kernel data
  01e29200-01f26dcf : Kernel bss

Changes from v3:

- JUMP_LINK_ADDR renamed to JUMP_VIRT_ADDR, and use the way of parameter
  passing.

- Reimplement kernel relocation, when the link address and load address
  are different, realize the effect of adaptive relocation (one of the
  usage scenarios is kdump operation).

- Reimplement KASLR.

Changes from v2:

- Correctly fixup pcaddi12i/ori/lu32i.d/lu52i.d sequence generated by
  GNU as <= 2.39 for la.pcrel.

Changes from v1 to v2:

- Relocate the handlers instead of using a trampoline, to avoid
  performance issue on NUMA systems.
- Fix compiler warnings.

Xi Ruoyao (2):
  LoongArch: Use la.pcrel instead of la.abs when it's trivially possible
  LoongArch: Use la.pcrel instead of la.abs for exception handlers

Youling Tang (3):
  LoongArch: Add JUMP_VIRT_ADDR macro implementation to avoid using
    la.abs
  LoongArch: Add support for kernel relocation
  LoongArch: Add support for kernel address space layout randomization
    (KASLR)

 arch/loongarch/Kconfig                  |  38 +++++
 arch/loongarch/Makefile                 |   5 +
 arch/loongarch/include/asm/inst.h       |   1 +
 arch/loongarch/include/asm/setup.h      |   6 +-
 arch/loongarch/include/asm/stackframe.h |  14 +-
 arch/loongarch/include/asm/uaccess.h    |   1 -
 arch/loongarch/kernel/Makefile          |   2 +
 arch/loongarch/kernel/entry.S           |   2 +-
 arch/loongarch/kernel/genex.S           |  40 ++++-
 arch/loongarch/kernel/head.S            |  31 +++-
 arch/loongarch/kernel/relocate.c        | 215 ++++++++++++++++++++++++
 arch/loongarch/kernel/traps.c           | 158 ++++++++++++++---
 arch/loongarch/kernel/vmlinux.lds.S     |  11 +-
 arch/loongarch/mm/tlb.c                 |  23 +--
 arch/loongarch/mm/tlbex.S               |  72 +++++++-
 arch/loongarch/power/suspend_asm.S      |   5 +-
 16 files changed, 560 insertions(+), 64 deletions(-)
 create mode 100644 arch/loongarch/kernel/relocate.c

-- 
2.37.3


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2023-02-17  8:24 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-10  8:47 [PATCH v4 0/5] LoongArch: Add kernel relocation and KASLR support Youling Tang
2023-02-10  8:47 ` [PATCH v4 1/5] LoongArch: Use la.pcrel instead of la.abs when it's trivially possible Youling Tang
2023-02-10  9:04   ` Huacai Chen
2023-02-10  8:47 ` [PATCH v4 2/5] LoongArch: Use la.pcrel instead of la.abs for exception handlers Youling Tang
2023-02-10  9:09   ` Huacai Chen
2023-02-10  9:18     ` Youling Tang
2023-02-16  2:32       ` Youling Tang
2023-02-16  6:56         ` Huacai Chen
2023-02-16  6:59         ` Jinyang He
2023-02-16  7:10           ` Xi Ruoyao
2023-02-16  8:03             ` Youling Tang
2023-02-16 11:18               ` Youling Tang
2023-02-16 11:29                 ` Youling Tang
2023-02-10  8:47 ` [PATCH v4 3/5] LoongArch: Add JUMP_VIRT_ADDR macro implementation to avoid using la.abs Youling Tang
2023-02-10  8:47 ` [PATCH v4 4/5] LoongArch: Add support for kernel relocation Youling Tang
2023-02-10  9:05   ` Huacai Chen
2023-02-10 18:01   ` kernel test robot
2023-02-10  8:47 ` [PATCH v4 5/5] LoongArch: Add support for kernel address space layout randomization (KASLR) Youling Tang
2023-02-10  9:06   ` Youling Tang
2023-02-10  9:37     ` Youling Tang
2023-02-17  8:09   ` Xi Ruoyao
2023-02-17  8:24     ` Youling Tang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®