Skip to content

Commit d87abdc

Browse files
author
Alex Shi
committed
Merge branch 'lsk/kdump/for-v4.4' into linux-linaro-lsk-v4.4
2 parents 428ee0d + 8991296 commit d87abdc

33 files changed

Lines changed: 1587 additions & 172 deletions

File tree

Documentation/devicetree/bindings/chosen.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,48 @@ This property is set (currently only on PowerPC, and only needed on
5252
book3e) by some versions of kexec-tools to tell the new kernel that it
5353
is being booted by kexec, as the booting environment may differ (e.g.
5454
a different secondary CPU release mechanism)
55+
56+
linux,usable-memory-range
57+
-------------------------
58+
59+
This property (arm64 only) holds a base address and size, describing a
60+
limited region in which memory may be considered available for use by
61+
the kernel. Memory outside of this range is not available for use.
62+
63+
This property describes a limitation: memory within this range is only
64+
valid when also described through another mechanism that the kernel
65+
would otherwise use to determine available memory (e.g. memory nodes
66+
or the EFI memory map). Valid memory may be sparse within the range.
67+
e.g.
68+
69+
/ {
70+
chosen {
71+
linux,usable-memory-range = <0x9 0xf0000000 0x0 0x10000000>;
72+
};
73+
};
74+
75+
The main usage is for crash dump kernel to identify its own usable
76+
memory and exclude, at its boot time, any other memory areas that are
77+
part of the panicked kernel's memory.
78+
79+
While this property does not represent a real hardware, the address
80+
and the size are expressed in #address-cells and #size-cells,
81+
respectively, of the root node.
82+
83+
linux,elfcorehdr
84+
----------------
85+
86+
This property (currently used only on arm64) holds the memory range,
87+
the address and the size, of the elf core header which mainly describes
88+
the panicked kernel's memory layout as PT_LOAD segments of elf format.
89+
e.g.
90+
91+
/ {
92+
chosen {
93+
linux,elfcorehdr = <0x9 0xfffff000 0x0 0x800>;
94+
};
95+
};
96+
97+
While this property does not represent a real hardware, the address
98+
and the size are expressed in #address-cells and #size-cells,
99+
respectively, of the root node.

Documentation/kdump/kdump.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to
1818
a remote system.
1919

2020
Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
21-
s390x and arm architectures.
21+
s390x, arm and arm64 architectures.
2222

2323
When the system kernel boots, it reserves a small section of memory for
2424
the dump-capture kernel. This ensures that ongoing Direct Memory Access
@@ -249,6 +249,13 @@ Dump-capture kernel config options (Arch Dependent, arm)
249249

250250
AUTO_ZRELADDR=y
251251

252+
Dump-capture kernel config options (Arch Dependent, arm64)
253+
----------------------------------------------------------
254+
255+
- Please note that kvm of the dump-capture kernel will not be enabled
256+
on non-VHE systems even if it is configured. This is because the CPU
257+
will not be reset to EL2 on panic.
258+
252259
Extended crashkernel syntax
253260
===========================
254261

@@ -312,6 +319,8 @@ Boot into System Kernel
312319
any space below the alignment point may be overwritten by the dump-capture kernel,
313320
which means it is possible that the vmcore is not that precise as expected.
314321

322+
On arm64, use "crashkernel=Y[@X]". Note that the start address of
323+
the kernel, X if explicitly specified, must be aligned to 2MiB (0x200000).
315324

316325
Load the Dump-capture Kernel
317326
============================
@@ -334,6 +343,8 @@ For s390x:
334343
- Use image or bzImage
335344
For arm:
336345
- Use zImage
346+
For arm64:
347+
- Use vmlinux or Image
337348

338349
If you are using a uncompressed vmlinux image then use following command
339350
to load dump-capture kernel.
@@ -377,6 +388,9 @@ For s390x:
377388
For arm:
378389
"1 maxcpus=1 reset_devices"
379390

391+
For arm64:
392+
"1 maxcpus=1 reset_devices"
393+
380394
Notes on loading the dump-capture kernel:
381395

382396
* By default, the ELF headers are stored in ELF64 format to support

arch/arm64/Kconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,27 @@ config SECCOMP
598598
and the task is only allowed to execute a few safe syscalls
599599
defined by each seccomp mode.
600600

601+
config KEXEC
602+
depends on PM_SLEEP_SMP
603+
select KEXEC_CORE
604+
bool "kexec system call"
605+
---help---
606+
kexec is a system call that implements the ability to shutdown your
607+
current kernel, and to start another kernel. It is like a reboot
608+
but it is independent of the system firmware. And like a reboot
609+
you can start any kernel with it, not just Linux.
610+
611+
config CRASH_DUMP
612+
bool "Build kdump crash kernel"
613+
help
614+
Generate crash dump after being started by kexec. This should
615+
be normally only set in special crash dump kernels which are
616+
loaded in the main kernel with kexec-tools into a specially
617+
reserved region and then later executed after a crash by
618+
kdump/kexec.
619+
620+
For more details see Documentation/kdump/kdump.txt
621+
601622
config XEN_DOM0
602623
def_bool y
603624
depends on XEN

arch/arm64/configs/defconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ CONFIG_PREEMPT=y
5858
CONFIG_KSM=y
5959
CONFIG_TRANSPARENT_HUGEPAGE=y
6060
CONFIG_CMA=y
61+
CONFIG_KEXEC=y
62+
CONFIG_CRASH_DUMP=y
6163
CONFIG_CMDLINE="console=ttyAMA0"
6264
# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
6365
CONFIG_COMPAT=y

arch/arm64/include/asm/cacheflush.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,6 @@ int set_memory_ro(unsigned long addr, int numpages);
155155
int set_memory_rw(unsigned long addr, int numpages);
156156
int set_memory_x(unsigned long addr, int numpages);
157157
int set_memory_nx(unsigned long addr, int numpages);
158+
int set_memory_valid(unsigned long addr, unsigned long size, int enable);
158159

159160
#endif

arch/arm64/include/asm/hardirq.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <linux/threads.h>
2121
#include <asm/irq.h>
2222

23-
#define NR_IPI 6
23+
#define NR_IPI 7
2424

2525
typedef struct {
2626
unsigned int __softirq_pending;

arch/arm64/include/asm/kexec.h

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
* kexec for arm64
3+
*
4+
* Copyright (C) Linaro.
5+
* Copyright (C) Huawei Futurewei Technologies.
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License version 2 as
9+
* published by the Free Software Foundation.
10+
*/
11+
12+
#ifndef _ARM64_KEXEC_H
13+
#define _ARM64_KEXEC_H
14+
15+
/* Maximum physical address we can use pages from */
16+
17+
#define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
18+
19+
/* Maximum address we can reach in physical address mode */
20+
21+
#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
22+
23+
/* Maximum address we can use for the control code buffer */
24+
25+
#define KEXEC_CONTROL_MEMORY_LIMIT (-1UL)
26+
27+
#define KEXEC_CONTROL_PAGE_SIZE 4096
28+
29+
#define KEXEC_ARCH KEXEC_ARCH_AARCH64
30+
31+
#ifndef __ASSEMBLY__
32+
33+
/**
34+
* crash_setup_regs() - save registers for the panic kernel
35+
*
36+
* @newregs: registers are saved here
37+
* @oldregs: registers to be saved (may be %NULL)
38+
*/
39+
40+
static inline void crash_setup_regs(struct pt_regs *newregs,
41+
struct pt_regs *oldregs)
42+
{
43+
if (oldregs) {
44+
memcpy(newregs, oldregs, sizeof(*newregs));
45+
} else {
46+
u64 tmp1, tmp2;
47+
48+
__asm__ __volatile__ (
49+
"stp x0, x1, [%2, #16 * 0]\n"
50+
"stp x2, x3, [%2, #16 * 1]\n"
51+
"stp x4, x5, [%2, #16 * 2]\n"
52+
"stp x6, x7, [%2, #16 * 3]\n"
53+
"stp x8, x9, [%2, #16 * 4]\n"
54+
"stp x10, x11, [%2, #16 * 5]\n"
55+
"stp x12, x13, [%2, #16 * 6]\n"
56+
"stp x14, x15, [%2, #16 * 7]\n"
57+
"stp x16, x17, [%2, #16 * 8]\n"
58+
"stp x18, x19, [%2, #16 * 9]\n"
59+
"stp x20, x21, [%2, #16 * 10]\n"
60+
"stp x22, x23, [%2, #16 * 11]\n"
61+
"stp x24, x25, [%2, #16 * 12]\n"
62+
"stp x26, x27, [%2, #16 * 13]\n"
63+
"stp x28, x29, [%2, #16 * 14]\n"
64+
"mov %0, sp\n"
65+
"stp x30, %0, [%2, #16 * 15]\n"
66+
67+
"/* faked current PSTATE */\n"
68+
"mrs %0, CurrentEL\n"
69+
"mrs %1, SPSEL\n"
70+
"orr %0, %0, %1\n"
71+
"mrs %1, DAIF\n"
72+
"orr %0, %0, %1\n"
73+
"mrs %1, NZCV\n"
74+
"orr %0, %0, %1\n"
75+
/* pc */
76+
"adr %1, 1f\n"
77+
"1:\n"
78+
"stp %1, %0, [%2, #16 * 16]\n"
79+
: "=&r" (tmp1), "=&r" (tmp2)
80+
: "r" (newregs)
81+
: "memory"
82+
);
83+
}
84+
}
85+
86+
#if defined(CONFIG_KEXEC_CORE) && defined(CONFIG_HIBERNATION)
87+
extern bool crash_is_nosave(unsigned long pfn);
88+
extern void crash_prepare_suspend(void);
89+
extern void crash_post_resume(void);
90+
#else
91+
static inline bool crash_is_nosave(unsigned long pfn) {return false; }
92+
static inline void crash_prepare_suspend(void) {}
93+
static inline void crash_post_resume(void) {}
94+
#endif
95+
96+
#endif /* __ASSEMBLY__ */
97+
98+
#endif

arch/arm64/include/asm/mmu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ extern void __iomem *early_io_map(phys_addr_t phys, unsigned long virt);
3333
extern void init_mem_pgprot(void);
3434
extern void create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys,
3535
unsigned long virt, phys_addr_t size,
36-
pgprot_t prot);
36+
pgprot_t prot, bool allow_block_mappings);
3737
extern void *fixmap_remap_fdt(phys_addr_t dt_phys);
3838

3939
#endif

arch/arm64/include/asm/smp.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@
1616
#ifndef __ASM_SMP_H
1717
#define __ASM_SMP_H
1818

19+
/* Values for secondary_data.status */
20+
21+
#define CPU_MMU_OFF (-1)
22+
#define CPU_BOOT_SUCCESS (0)
23+
/* The cpu invoked ops->cpu_die, synchronise it with cpu_kill */
24+
#define CPU_KILL_ME (1)
25+
/* The cpu couldn't die gracefully and is looping in the kernel */
26+
#define CPU_STUCK_IN_KERNEL (2)
27+
/* Fatal system error detected by secondary CPU, crash the system */
28+
#define CPU_PANIC_KERNEL (3)
29+
30+
#ifndef __ASSEMBLY__
31+
1932
#include <linux/threads.h>
2033
#include <linux/cpumask.h>
2134
#include <linux/thread_info.h>
@@ -54,11 +67,17 @@ asmlinkage void secondary_start_kernel(void);
5467

5568
/*
5669
* Initial data for bringing up a secondary CPU.
70+
* @stack - sp for the secondary CPU
71+
* @status - Result passed back from the secondary CPU to
72+
* indicate failure.
5773
*/
5874
struct secondary_data {
5975
void *stack;
76+
long status;
6077
};
78+
6179
extern struct secondary_data secondary_data;
80+
extern long __early_cpu_boot_status;
6281
extern void secondary_entry(void);
6382

6483
extern void arch_send_call_function_single_ipi(int cpu);
@@ -77,5 +96,38 @@ extern int __cpu_disable(void);
7796

7897
extern void __cpu_die(unsigned int cpu);
7998
extern void cpu_die(void);
99+
extern void cpu_die_early(void);
100+
101+
static inline void cpu_park_loop(void)
102+
{
103+
for (;;) {
104+
wfe();
105+
wfi();
106+
}
107+
}
108+
109+
static inline void update_cpu_boot_status(int val)
110+
{
111+
WRITE_ONCE(secondary_data.status, val);
112+
/* Ensure the visibility of the status update */
113+
dsb(ishst);
114+
}
115+
116+
/*
117+
* If a secondary CPU enters the kernel but fails to come online,
118+
* (e.g. due to mismatched features), and cannot exit the kernel,
119+
* we increment cpus_stuck_in_kernel and leave the CPU in a
120+
* quiesecent loop within the kernel text. The memory containing
121+
* this loop must not be re-used for anything else as the 'stuck'
122+
* core is executing it.
123+
*
124+
* This function is used to inhibit features like kexec and hibernate.
125+
*/
126+
bool cpus_are_stuck_in_kernel(void);
127+
128+
extern void smp_send_crash_stop(void);
129+
extern bool smp_crash_stop_failed(void);
130+
131+
#endif /* ifndef __ASSEMBLY__ */
80132

81133
#endif /* ifndef __ASM_SMP_H */

arch/arm64/include/asm/virt.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
*/
3535
#define HVC_SET_VECTORS 1
3636

37+
/*
38+
* HVC_SOFT_RESTART - CPU soft reset, used by the cpu_soft_restart routine.
39+
*/
40+
#define HVC_SOFT_RESTART 2
41+
3742
#define BOOT_CPU_MODE_EL1 (0xe11)
3843
#define BOOT_CPU_MODE_EL2 (0xe12)
3944

0 commit comments

Comments
 (0)