Unverified Commit c098198d authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!766 LoongArch: add kexec&kdump support

Merge Pull Request from: @Hongchen_Zhang 
 


```
This series of patches adds the kexec/kdump feature of the LoongArch
architecture.

The production kernel and capture kernel can be the same kernel with
the same binary implementation added. However, this implementation
depends on the kernel relocation function, so the kernel relocation
implementation and KASLR features are added to this series of patches.

In order to be able to be used normally in machines compatible with the
old interface specification, compatibility with the old interface
specification has also been added.

Manual command line test:
kexec:
 $ sudo kexec -l vmlinuz --reuse-cmdline --initrd=initrd
 $ sudo kexec -e

kdump:
Add crashkernel=512M parameter in grub.cfg,
 $ sudo kexec -p vmlinuz --reuse-cmdline --initrd=initrd
 # echo c > /proc/sysrq-trigger


kdump service mode test:
kexec:
 $ sudo kexec -l vmlinuz --reuse-cmdline --initrd=initrd
 $ sudo kexec -e

kdump:
Add crashkernel=512M parameter in grub.cfg,
 $ sudo systemctl enable kdump
 $ sudo systemctl restart kdump
 # echo c > /proc/sysrq-trigger

```
 
 
Link:https://gitee.com/openeuler/kernel/pulls/766

 

Reviewed-by: default avatarGuo Dongtai <guodongtai@kylinos.cn>
Reviewed-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents 36c3e5ca f45a5a99
Loading
Loading
Loading
Loading
+56 −0
Original line number Diff line number Diff line
@@ -463,6 +463,62 @@ config ARCH_IOREMAP
	  protection support. However, you can enable LoongArch DMW-based
	  ioremap() for better performance.

config KEXEC
	bool "Kexec system call"
	select KEXEC_CORE
	help
	  kexec is a system call that implements the ability to shutdown your
	  current kernel, and to start another kernel.  It is like a reboot
	  but it is independent of the system firmware.   And like a reboot
	  you can start any kernel with it, not just Linux.

	  The name comes from the similarity to the exec system call.

config CRASH_DUMP
	bool "Build kdump crash kernel"
	select RELOCATABLE
	help
	  Generate crash dump after being started by kexec. This should
	  be normally only set in special crash dump kernels which are
	  loaded in the main kernel with kexec-tools into a specially
	  reserved region and then later executed after a crash by
	  kdump/kexec.

	  For more details see Documentation/admin-guide/kdump/kdump.rst

config RELOCATABLE
	bool "Relocatable kernel"
	help
	  This builds the kernel as a Position Independent Executable (PIE),
	  which retains all relocation metadata required, so as to relocate
	  the kernel binary at runtime to a different virtual address from
	  its link address.

config RANDOMIZE_BASE
	bool "Randomize the address of the kernel (KASLR)"
	depends on RELOCATABLE
	help
	   Randomizes the physical and virtual address at which the
	   kernel image is loaded, as a security feature that
	   deters exploit attempts relying on knowledge of the location
	   of kernel internals.

	   The kernel will be offset by up to RANDOMIZE_BASE_MAX_OFFSET.

	   If unsure, say N.

config RANDOMIZE_BASE_MAX_OFFSET
	hex "Maximum KASLR offset" if EXPERT
	depends on RANDOMIZE_BASE
	range 0x0 0x10000000
	default "0x01000000"
	help
	  When KASLR is active, this provides the maximum offset that will
	  be applied to the kernel image. It should be set according to the
	  amount of physical RAM available in the target system.

	  This is limited by the size of the lower address memory, 256MB.

config SECCOMP
	bool "Enable seccomp to safely compute untrusted bytecode"
	depends on PROC_FS
+5 −0
Original line number Diff line number Diff line
@@ -63,6 +63,11 @@ KBUILD_AFLAGS_MODULE += -Wa,-mla-global-with-abs
KBUILD_CFLAGS_MODULE		+= -fplt -Wa,-mla-global-with-abs,-mla-local-with-abs
endif

ifeq ($(CONFIG_RELOCATABLE),y)
KBUILD_CFLAGS_KERNEL		+= -fPIE
LDFLAGS_vmlinux			+= -static -pie --no-dynamic-linker -z notext
endif

cflags-y += -ffreestanding
cflags-y += $(call cc-option, -mno-check-zero-division)

+2 −0
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ CONFIG_PERF_EVENTS=y
CONFIG_CPU_HAS_LSX=y
CONFIG_CPU_HAS_LASX=y
CONFIG_NUMA=y
CONFIG_KEXEC=y
CONFIG_CRASH_DUMP=y
CONFIG_HIBERNATION=y
CONFIG_ACPI_SPCR_TABLE=y
CONFIG_ACPI_DOCK=y
+2 −0
Original line number Diff line number Diff line
@@ -126,4 +126,6 @@ extern unsigned long vm_map_base;
#define IO_SPACE_LIMIT	(PCI_IOSIZE - 1)
#define ISA_PHY_IOBASE  LOONGSON_LIO_BASE

#define PHYS_LINK_KADDR	PHYSADDR(VMLINUX_LOAD_ADDRESS)

#endif /* _ASM_ADDRSPACE_H */
+17 −0
Original line number Diff line number Diff line
@@ -898,4 +898,21 @@
	nor	\dst, \src, zero
.endm

.macro la_abs reg, sym
#ifndef CONFIG_RELOCATABLE
	la.abs	\reg, \sym
#else
	766:
	lu12i.w	\reg, 0
	ori	\reg, \reg, 0
	lu32i.d	\reg, 0
	lu52i.d	\reg, \reg, 0
	.pushsection ".la_abs", "aw", %progbits
	768:
	.dword	768b-766b
	.dword	\sym
	.popsection
#endif
.endm

#endif /* _ASM_ASMMACRO_H */
Loading