linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Add kernel relocation and KASLR support
@ 2022-09-02 10:08 Youling Tang
  2022-09-02 10:08 ` [PATCH 1/3] LoongArch: tools: Add relocs tool support Youling Tang
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Youling Tang @ 2022-09-02 10:08 UTC (permalink / raw)
  To: Huacai Chen; +Cc: linux-kernel, loongarch, Xuerui Wang, Xi Ruoyao, Jiaxun Yang

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 2353 bytes --]

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

When CONFIG_RELOCATABLE is enabled add --emit-relocs to vmlinux LDFLAGS so
that fully linked vmlinux contains relocation information. Run the previously
added relocs tool to fill in the .data.relocs section of vmlinux with a table
of relocations. 

Call relocate_kernel(),the kernel makes a copy of itself at the new address.
It uses the relocation table inserted by the relocs tool to fix symbol
references within the new image. This function will return the entry point
of the relocated kernel if copy/relocate is successful or the original entry
point if not. The stack pointer must then be pointed into the new image.

This feature is supported in both old and new toolchains, note that patches
need to be applied [1] when building with old toolchains.

[1] link: https://lore.kernel.org/loongarch/1662030659-21558-1-git-send-email-tangyouling@loongson.cn/T/#u

Youling Tang (3):
  LoongArch: tools: Add relocs tool support
  LoongArch: Add support for kernel relocation
  LoongArch: Add support for kernel address space layout randomization
    (KASLR)

 arch/loongarch/Kconfig                  |  51 +++
 arch/loongarch/Makefile                 |   7 +
 arch/loongarch/Makefile.postlink        |  33 ++
 arch/loongarch/boot/.gitignore          |   1 +
 arch/loongarch/boot/tools/Makefile      |   8 +
 arch/loongarch/boot/tools/relocs.c      | 544 ++++++++++++++++++++++++
 arch/loongarch/boot/tools/relocs.h      |  55 +++
 arch/loongarch/boot/tools/relocs_64.c   |  18 +
 arch/loongarch/boot/tools/relocs_main.c |  82 ++++
 arch/loongarch/include/asm/page.h       |   6 +
 arch/loongarch/kernel/Makefile          |   2 +
 arch/loongarch/kernel/head.S            |  17 +
 arch/loongarch/kernel/relocate.c        | 328 ++++++++++++++
 arch/loongarch/kernel/setup.c           |   3 +
 arch/loongarch/kernel/vmlinux.lds.S     |  25 ++
 15 files changed, 1180 insertions(+)
 create mode 100644 arch/loongarch/Makefile.postlink
 create mode 100644 arch/loongarch/boot/tools/Makefile
 create mode 100644 arch/loongarch/boot/tools/relocs.c
 create mode 100644 arch/loongarch/boot/tools/relocs.h
 create mode 100644 arch/loongarch/boot/tools/relocs_64.c
 create mode 100644 arch/loongarch/boot/tools/relocs_main.c
 create mode 100644 arch/loongarch/kernel/relocate.c

-- 
2.36.1


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

end of thread, other threads:[~2022-09-23  9:57 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-02 10:08 [PATCH 0/3] Add kernel relocation and KASLR support Youling Tang
2022-09-02 10:08 ` [PATCH 1/3] LoongArch: tools: Add relocs tool support Youling Tang
2022-09-02 11:10   ` Xi Ruoyao
2022-09-02 11:27     ` Xi Ruoyao
2022-09-03  1:57       ` Youling Tang
2022-09-03 10:49         ` Xi Ruoyao
2022-09-03 16:23           ` Jinyang He
2022-09-03 16:53             ` Xi Ruoyao
2022-09-05  2:52               ` Youling Tang
2022-09-06  2:16                 ` Youling Tang
2022-09-06  5:17                   ` Xi Ruoyao
2022-09-07 10:19                     ` Youling Tang
2022-09-08  2:44                       ` Youling Tang
2022-09-08  8:01                         ` Youling Tang
2022-09-22 11:19                           ` Xi Ruoyao
2022-09-23  9:56                             ` Youling Tang
2022-09-05  1:52             ` Youling Tang
2022-09-02 10:08 ` [PATCH 2/3] LoongArch: Add support for kernel relocation Youling Tang
2022-09-02 10:08 ` [PATCH 3/3] LoongArch: Add support for kernel address space layout randomization (KASLR) Youling Tang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).