Skip to contentSkip to conversation

arm64 kexec kernel patches v13

PATCH In review Geoff Levand 11 participants 87 messages Jan 15, 2016 – Mar 2, 2016 1 message not in the archive

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

cover arm64 kexec kernel patches v13

This series adds the core support for kexec re-boot and kdump on ARM64. This version of the series combines Takahiro's kdump patches with my kexec patches. Please consider all patches for inclusion.

I just tested all the endian combinations of kexec LE->LE, LE->BE, BE->BE, BE->LE, and both LE an BE kdump, and all work as expected.

To load a second stage kernel and execute a kexec re-boot or to work with kdump on ARM64 systems a series of patches to kexec-tools [2], which have not yet been merged upstream, are needed.

To examine vmcore (/proc/vmcore), you should use
- gdb v7.7 or later
- crash v7.1.1 or later

[1] https://git.kernel.org/cgit/linux/kernel/git/geoff/linux-kexec.git
[2] https://git.kernel.org/cgit/linux/kernel/git/geoff/kexec-tools.git

Changes for v13 (Jan 15, 2016, 20m):

o Rebase to Linux-4.4.
o Remove align directive from cpu_reset.c.
o Use inline C wrapper for cpu_soft_restart.
o Revert the new image d-cache flush changes of v10.
o Add SCTLR cleanup patch.
o Change pr_devel to pr_debug.
o Call flush_icache_range() for reboot_code_buffer.
o Add .ltorg directive to arm64_relocate_new_kernel.
o Make new asm macro copy_page.
o Change cache maintenence from inner-shareable to non-shareable.
o Rename KEXEC_ARCH_ARM64 to KEXEC_ARCH_AARCH64.

o arm64: kvm: allows kvm cpu hotplug
- remove some garbage code from kvm_host.h
o arm64: kdump: reserve memory for crash dump kernel
- change CONFIG_KEXEC to CONFIG_KEXEC_CORE
- don't panic on crash kernel alloc failure
(thanks to Mark Salter, RH)
o arm64: kdump: implement machine_crash_shutdown()
- change "boot/non-boot cpu" to "crashing/non-crashing cpu"
- introduce is_in_crash_kexec() for readability
- re-introduce machine_kexec_mask_interrupts(), as arch/arm has, to discard unexpected interrupts
- call crash_save_cpu() before making cpus offline to avoid a possible race (thanks to Pratyush Anand/Mark Salter, RH)
o arm64: kdump: update a kernel doc
- clarify that we support "Image" format as well as vmlinux in kdump.txt
o arm64: kdump: relax BUG_ON() if more than one cpus are still active
- change a warning message at the failure of shooting down non-crahsing cpus

Changes for v12 (Nov 24, 2015, 18m):

o No changes, rebase to Linux-4.4-rc2.

Changes for v11 (Nov 6, 2015, 18m):

o Rebase to Linux-4.3.
o Move the new image d-cache flush from arm64_relocate_new_kernel to machine_kexec.
o Pass values to arm64_relocate_new_kernel in registers, not in global variables.
o Fixups to setting the sctlr_el1 and sctlr_el2 flags.

Changes for v10 (Oct 18, 2015, 17m):

o Rebase to Linux-4.3-rc6.
o Move tcr_set_idmap_t0sz to assembler.h.
o Add back simplified cpu_reset routines.
o Combine kexec + kdump patches.

Changes for v9 (Apr 7, 2015, 11m):

o Use new upstream flag IND_FLAGS.

Changes for v8 (Mar 19, 2015, 10m):

o Rebase to Linux-4.0-rc4.
o Re-boot using purgatory only.

Changes for v7 (Jan 16, 2015, 8m):

o Rebase to Linux-3.19-rc4.
o Change from ESR_EL2_ to ESR_ELx_.
o Remove work-arounds for EFI systems.

Changes for v6 (Dec 2, 2014, 7m):

o Rebase to Linux-3.18-rc2

Changes for v5 (Nov 16, 2014, 6m):

Changes for v4 (Oct 3, 2014, 5m):

Changes for v3 (Sept 23, 2014, 4m):

Changes for v2 (Sep 9, 2014, 4m):

o Rebase to Linux-3.17-rc4.
o Move macros from proc-macros.S to assembler.h.
o Convert hcalls to use ISS field.
o Add new hcall HVC_CALL_FUNC.
o Add EL2 switch to soft_restart.

First submission v1 (May 13, 2014):

o Based on Linux-3.15-rc4.

-Geoff

The following changes since commit afd2ff9b7e1b367172f18ba7f693dfb62bdcb2dc:

Linux 4.4 (2016-01-10 15:01:32 -0800)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/geoff/linux-kexec.git kexec-v13

for you to fetch changes up to e52b39c76d2a967bdecc376daee07d6edd47b01a:

arm64: kdump: relax BUG_ON() if more than one cpus are still active (2016-01-15 10:22:45 -0800)

----------------------------------------------------------------
AKASHI Takahiro (7):
arm64: kvm: allows kvm cpu hotplug
arm64: kdump: reserve memory for crash dump kernel
arm64: kdump: implement machine_crash_shutdown()
arm64: kdump: add kdump support
arm64: kdump: enable kdump in the arm64 defconfig
arm64: kdump: update a kernel doc
arm64: kdump: relax BUG_ON() if more than one cpus are still active

Geoff Levand (11):
arm64: Fold proc-macros.S into assembler.h
arm64: Add new asm macro copy_page
arm64: Cleanup SCTLR flags
arm64: Convert hcalls to use HVC immediate value
arm64: Add new hcall HVC_CALL_FUNC
arm64: Add back cpu_reset routines
Revert "arm64: mm: remove unused cpu_set_idmap_tcr_t0sz function" Revert "arm64: remove dead code"
arm64/kexec: Add core kexec support
arm64/kexec: Enable kexec in the arm64 defconfig arm64/kexec: Add pr_debug output

James Morse (1):
arm64: kernel: Include _AC definition in page.h

 Documentation/kdump/kdump.txt        |  23 ++-
 arch/arm/include/asm/kvm_host.h      |  10 +-
 arch/arm/include/asm/kvm_mmu.h       |   1 +
 arch/arm/kvm/arm.c                   |  93 +++++++-----
 arch/arm/kvm/mmu.c                   |   5 +
 arch/arm64/Kconfig                   |  21 +++
 arch/arm64/configs/defconfig         |   2 +
 arch/arm64/include/asm/assembler.h   |  67 +++++++-
 arch/arm64/include/asm/kexec.h       |  93 ++++++++++++
 arch/arm64/include/asm/kvm_arm.h     |  11 --
 arch/arm64/include/asm/kvm_host.h    |  11 +-
 arch/arm64/include/asm/kvm_mmu.h     |   1 +
 arch/arm64/include/asm/mmu.h         |   1 +
 arch/arm64/include/asm/mmu_context.h |  35 +++--
 arch/arm64/include/asm/page.h        |   2 +
 arch/arm64/include/asm/sysreg.h      |  19 ++-
 arch/arm64/include/asm/virt.h        |  49 ++++++
 arch/arm64/kernel/Makefile           |   3 +
 arch/arm64/kernel/cpu-reset.S        |  57 +++++++
 arch/arm64/kernel/cpu-reset.h        |  29 ++++
 arch/arm64/kernel/crash_dump.c       |  71 +++++++++
 arch/arm64/kernel/hyp-stub.S         |  43 ++++--
 arch/arm64/kernel/machine_kexec.c    | 285 +++++++++++++++++++++++++++++++++++
 arch/arm64/kernel/relocate_kernel.S  | 131 ++++++++++++++++
 arch/arm64/kernel/setup.c            |   7 +-
 arch/arm64/kernel/smp.c              |  18 ++-
 arch/arm64/kvm/hyp-init.S            |  39 ++++-
 arch/arm64/kvm/hyp.S                 |  44 ++++--
 arch/arm64/mm/cache.S                |   2 -
 arch/arm64/mm/init.c                 |  89 +++++++++++
 arch/arm64/mm/mmu.c                  |  11 ++
 arch/arm64/mm/proc-macros.S          |  64 --------
 arch/arm64/mm/proc.S                 |   3 -
 include/uapi/linux/kexec.h           |   1 +
 34 files changed, 1175 insertions(+), 166 deletions(-)
 create mode 100644 arch/arm64/include/asm/kexec.h
 create mode 100644 arch/arm64/kernel/cpu-reset.S
 create mode 100644 arch/arm64/kernel/cpu-reset.h
 create mode 100644 arch/arm64/kernel/crash_dump.c
 create mode 100644 arch/arm64/kernel/machine_kexec.c
 create mode 100644 arch/arm64/kernel/relocate_kernel.S
 delete mode 100644 arch/arm64/mm/proc-macros.S
Signature · 7 lines
2.5.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw

PATCH 1/19 arm64: Fold proc-macros.S into assembler.h

To allow the assembler macros defined in arch/arm64/mm/proc-macros.S to be used outside the mm code move the contents of proc-macros.S to asm/assembler.h. Also, delete proc-macros.S, and fix up all references to proc-macros.S.

---
 arch/arm64/include/asm/assembler.h | 48 +++++++++++++++++++++++++++-
 arch/arm64/mm/cache.S              |  2 --
 arch/arm64/mm/proc-macros.S        | 64 --------------------------------------
 arch/arm64/mm/proc.S               |  3 --
 4 files changed, 47 insertions(+), 70 deletions(-)
 delete mode 100644 arch/arm64/mm/proc-macros.S
arch/arm64/include/asm/assembler.h +47 -1
index 12eff92..21979a4 100644
@@ -1,5 +1,5 @@
 /*
- * Based on arch/arm/include/asm/assembler.h
+ * Based on arch/arm/include/asm/assembler.h, arch/arm/mm/proc-macros.S
  *
  * Copyright (C) 1996-2000 Russell King
  * Copyright (C) 2012 ARM Ltd.
@@ -23,6 +23,8 @@
 #ifndef __ASM_ASSEMBLER_H
 #define __ASM_ASSEMBLER_H
 
+#include <asm/asm-offsets.h>
+#include <asm/pgtable-hwdef.h>
 #include <asm/ptrace.h>
 #include <asm/thread_info.h>
 
@@ -194,6 +196,50 @@ lr	.req	x30		// link register
 	.endm
 
 /*
+ * vma_vm_mm - get mm pointer from vma pointer (vma->vm_mm)
+ */
+	.macro	vma_vm_mm, rd, rn
+	ldr	\rd, [\rn, #VMA_VM_MM]
+	.endm
+
+/*
+ * mmid - get context id from mm pointer (mm->context.id)
+ */
+	.macro	mmid, rd, rn
+	ldr	\rd, [\rn, #MM_CONTEXT_ID]
+	.endm
+
+/*
+ * dcache_line_size - get the minimum D-cache line size from the CTR register.
+ */
+	.macro	dcache_line_size, reg, tmp
+	mrs	\tmp, ctr_el0			// read CTR
+	ubfm	\tmp, \tmp, #16, #19		// cache line size encoding
+	mov	\reg, #4			// bytes per word
+	lsl	\reg, \reg, \tmp		// actual cache line size
+	.endm
+
+/*
+ * icache_line_size - get the minimum I-cache line size from the CTR register.
+ */
+	.macro	icache_line_size, reg, tmp
+	mrs	\tmp, ctr_el0			// read CTR
+	and	\tmp, \tmp, #0xf		// cache line size encoding
+	mov	\reg, #4			// bytes per word
+	lsl	\reg, \reg, \tmp		// actual cache line size
+	.endm
+
+/*
+ * tcr_set_idmap_t0sz - update TCR.T0SZ so that we can load the ID map
+ */
+	.macro	tcr_set_idmap_t0sz, valreg, tmpreg
+#ifndef CONFIG_ARM64_VA_BITS_48
+	ldr_l	\tmpreg, idmap_t0sz
+	bfi	\valreg, \tmpreg, #TCR_T0SZ_OFFSET, #TCR_TxSZ_WIDTH
+#endif
+	.endm
+
+/*
  * Annotate a function as position independent, i.e., safe to be called before
  * the kernel virtual mapping is activated.
  */
arch/arm64/mm/cache.S +0 -2
index cfa44a6..f49041d 100644
@@ -24,8 +24,6 @@
 #include <asm/cpufeature.h>
 #include <asm/alternative.h>
 
-#include "proc-macros.S"
-
 /*
  *	flush_icache_range(start,end)
  *
arch/arm64/mm/proc-macros.S deleted +0 -64

64 lines not on this page · raw message

arch/arm64/mm/proc.S +0 -3
index cacecc4..7ab3a90 100644
@@ -23,11 +23,8 @@
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
 #include <asm/hwcap.h>
-#include <asm/pgtable-hwdef.h>
 #include <asm/pgtable.h>
 
-#include "proc-macros.S"
-
 #ifdef CONFIG_ARM64_64K_PAGES
 #define TCR_TG_FLAGS	TCR_TG0_64K | TCR_TG1_64K
 #elif defined(CONFIG_ARM64_16K_PAGES)
Signature · 8 lines
2.5.0



_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#2 lore raw

PATCH 2/19 arm64: kernel: Include _AC definition in page.h

In reply to Geoff Levand

From: James Morse <[email protected]>

From: James Morse <[email protected]>

page.h uses '_AC' in the definition of PAGE_SIZE, but doesn't include linux/const.h where this is defined. This produces build warnings when only asm/page.h is included by asm code.

---
 arch/arm64/include/asm/page.h | 2 ++
 1 file changed, 2 insertions(+)
arch/arm64/include/asm/page.h +2 -0
index 9b2f5a9..fbafd0a 100644
@@ -19,6 +19,8 @@
 #ifndef __ASM_PAGE_H
 #define __ASM_PAGE_H
 
+#include <linux/const.h>
+
 /* PAGE_SHIFT determines the page size */
 /* CONT_SHIFT determines the number of pages which can be tracked together  */
 #ifdef CONFIG_ARM64_64K_PAGES
Signature · 8 lines
2.5.0



_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
reviewer Acked-by on v1 2/19
#3 lore raw

Re: [PATCH 02/19] arm64: kernel: Include _AC definition in page.h

Quoted 3 lines · Geoff Levand

From: James Morse <[email protected]>

From: James Morse <[email protected]>

Not sure why this appears multiple times.

Quoted 7 lines

page.h uses '_AC' in the definition of PAGE_SIZE, but doesn't include linux/const.h where this is defined. This produces build warnings when only asm/page.h is included by asm code.

This is sensible even in isolation, so FWIW:

I note that for the !__ASSEMBLY__ portion we use current, READ_IMPLIES_EXEC, and some VM_* flags, without including the headers those are defined in. It might be worth fixing those up also.

Mark.

Quoted 21 lines
---
 arch/arm64/include/asm/page.h | 2 ++
 1 file changed, 2 insertions(+)
arch/arm64/include/asm/page.h +2 -0
index 9b2f5a9..fbafd0a 100644
@@ -19,6 +19,8 @@
 #ifndef __ASM_PAGE_H
 #define __ASM_PAGE_H
 
+#include <linux/const.h>
+
 /* PAGE_SHIFT determines the page size */
 /* CONT_SHIFT determines the number of pages which can be tracked together  */
 #ifdef CONFIG_ARM64_64K_PAGES
Signature · 1 line
2.5.0

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#4 lore raw

PATCH 3/19 arm64: Add new asm macro copy_page

In reply to Geoff Levand
---
 arch/arm64/include/asm/assembler.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
arch/arm64/include/asm/assembler.h +19 -0
index 21979a4..c47a623 100644
@@ -24,6 +24,7 @@
 #define __ASM_ASSEMBLER_H
 
 #include <asm/asm-offsets.h>
+#include <asm/page.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/ptrace.h>
 #include <asm/thread_info.h>
@@ -240,6 +241,24 @@ lr	.req	x30		// link register
 	.endm
 
 /*
+ * copy_page - copy src to dest using temp registers t1-t8
+ */
+	.macro copy_page dest:req src:req t1:req t2:req t3:req t4:req t5:req t6:req t7:req t8:req
+1:	ldp	\t1, \t2, [\src]
+	ldp	\t3, \t4, [\src, #16]
+	ldp	\t5, \t6, [\src, #32]
+	ldp	\t7, \t8, [\src, #48]
+	add	\src, \src, #64
+	stnp	\t1, \t2, [\dest]
+	stnp	\t3, \t4, [\dest, #16]
+	stnp	\t5, \t6, [\dest, #32]
+	stnp	\t7, \t8, [\dest, #48]
+	add	\dest, \dest, #64
+	tst	\src, #(PAGE_SIZE - 1)
+	b.ne	1b
+	.endm
+
+/*
  * Annotate a function as position independent, i.e., safe to be called before
  * the kernel virtual mapping is activated.
  */
Signature · 8 lines
2.5.0



_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#5 lore raw

Re: [PATCH 03/19] arm64: Add new asm macro copy_page

Hi Geoff,

On 15/01/16 19:18, Geoff Levand wrote:

Can I donate a commit message:

Kexec and hibernate need to copy pages of memory, but may not have all of the kernel mapped, and are unable to call copy_page().

Convert copy_page() to a macro, so that it can be inlined in these situations.

Quoted 18 lines
---
 arch/arm64/include/asm/assembler.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
arch/arm64/include/asm/assembler.h +1 -0
index 21979a4..c47a623 100644
@@ -24,6 +24,7 @@
 #define __ASM_ASSEMBLER_H
 
 #include <asm/asm-offsets.h>
+#include <asm/page.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/ptrace.h>
 #include <asm/thread_info.h>

arch/arm64/include/asm/assembler.h lr .req x30 // link register · line 247

Quoted 7 lines
arch/arm64/include/asm/assembler.h +4 -0
@@ -240,6 +241,24 @@ lr	.req	x30		// link register
 	.endm
 
 /*
+ * copy_page - copy src to dest using temp registers t1-t8
+ */
+	.macro copy_page dest:req src:req t1:req t2:req t3:req t4:req t5:req t6:req t7:req t8:req
+1:	ldp	\t1, \t2, [\src]

Using '1' as a label here means callers can't jump back over it using the same label. The convention with USER() and alternatives is to use unlikely values like '9999'.

arch/arm64/include/asm/assembler.h lr .req x30 // link register · line 259

Quoted 12 lines
arch/arm64/include/asm/assembler.h +12 -0
+	ldp	\t3, \t4, [\src, #16]
+	ldp	\t5, \t6, [\src, #32]
+	ldp	\t7, \t8, [\src, #48]
+	add	\src, \src, #64
+	stnp	\t1, \t2, [\dest]
+	stnp	\t3, \t4, [\dest, #16]
+	stnp	\t5, \t6, [\dest, #32]
+	stnp	\t7, \t8, [\dest, #48]
+	add	\dest, \dest, #64
+	tst	\src, #(PAGE_SIZE - 1)
+	b.ne	1b
+	.endm

It may be worth updating lib/copy_page.S to use this macro.

I will fix the code in hibernate to use this!

Thanks,

James

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#6 lore raw

PATCH 4/19 arm64: Cleanup SCTLR flags

In reply to Geoff Levand

We currently have macros defining flags for the arm64 sctlr registers in both kvm_arm.h and sysreg.h. To clean things up and simplify move the definitions of the SCTLR_EL2 flags from kvm_arm.h to sysreg.h, rename any SCTLR_EL1 or SCTLR_EL2 flags that are common to both registers to be SCTLR_ELx, with 'x' indicating a common flag, and fixup all files to include the proper header or to use the new macro names.

---
 arch/arm64/include/asm/kvm_arm.h | 11 -----------
 arch/arm64/include/asm/sysreg.h  | 19 +++++++++++++++----
 arch/arm64/kvm/hyp-init.S        |  6 +++---
 3 files changed, 18 insertions(+), 18 deletions(-)
arch/arm64/include/asm/kvm_arm.h +0 -11
index 5e6857b..92ef6f6 100644
@@ -83,17 +83,6 @@
 #define HCR_INT_OVERRIDE   (HCR_FMO | HCR_IMO)
 
 
-/* Hyp System Control Register (SCTLR_EL2) bits */
-#define SCTLR_EL2_EE	(1 << 25)
-#define SCTLR_EL2_WXN	(1 << 19)
-#define SCTLR_EL2_I	(1 << 12)
-#define SCTLR_EL2_SA	(1 << 3)
-#define SCTLR_EL2_C	(1 << 2)
-#define SCTLR_EL2_A	(1 << 1)
-#define SCTLR_EL2_M	1
-#define SCTLR_EL2_FLAGS	(SCTLR_EL2_M | SCTLR_EL2_A | SCTLR_EL2_C |	\
-			 SCTLR_EL2_SA | SCTLR_EL2_I)
-
 /* TCR_EL2 Registers bits */
 #define TCR_EL2_RES1	((1 << 31) | (1 << 23))
 #define TCR_EL2_TBI	(1 << 20)
arch/arm64/include/asm/sysreg.h +15 -4
index d48ab5b..109d46e 100644
@@ -80,10 +80,21 @@
 #define SET_PSTATE_PAN(x) __inst_arm(0xd5000000 | REG_PSTATE_PAN_IMM |\
 				     (!!x)<<8 | 0x1f)
 
-/* SCTLR_EL1 */
-#define SCTLR_EL1_CP15BEN	(0x1 << 5)
-#define SCTLR_EL1_SED		(0x1 << 8)
-#define SCTLR_EL1_SPAN		(0x1 << 23)
+/* Common SCTLR_ELx flags. */
+#define SCTLR_ELx_EE    (1 << 25)
+#define SCTLR_ELx_I	(1 << 12)
+#define SCTLR_ELx_SA	(1 << 3)
+#define SCTLR_ELx_C	(1 << 2)
+#define SCTLR_ELx_A	(1 << 1)
+#define SCTLR_ELx_M	1
+
+#define SCTLR_ELx_FLAGS	(SCTLR_ELx_M | SCTLR_ELx_A | SCTLR_ELx_C | \
+			 SCTLR_ELx_SA | SCTLR_ELx_I)
+
+/* SCTLR_EL1 specific flags. */
+#define SCTLR_EL1_SPAN		(1 << 23)
+#define SCTLR_EL1_SED		(1 << 8)
+#define SCTLR_EL1_CP15BEN	(1 << 5)
 
 
 /* id_aa64isar0 */
arch/arm64/kvm/hyp-init.S +3 -3
index 178ba22..1d7e502 100644
@@ -20,7 +20,7 @@
 #include <asm/assembler.h>
 #include <asm/kvm_arm.h>
 #include <asm/kvm_mmu.h>
-#include <asm/pgtable-hwdef.h>
+#include <asm/sysreg.h>
 
 	.text
 	.pushsection	.hyp.idmap.text, "ax"
@@ -105,8 +105,8 @@ __do_hyp_init:
 	dsb	sy
 
 	mrs	x4, sctlr_el2
-	and	x4, x4, #SCTLR_EL2_EE	// preserve endianness of EL2
-	ldr	x5, =SCTLR_EL2_FLAGS
+	and	x4, x4, #SCTLR_ELx_EE	// preserve endianness of EL2
+	ldr	x5, =SCTLR_ELx_FLAGS
 	orr	x4, x4, x5
 	msr	sctlr_el2, x4
 	isb
Signature · 8 lines
2.5.0



_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
reviewer
#7 lore raw

Re: [PATCH 04/19] arm64: Cleanup SCTLR flags

[Adding Marc as this touches KVM code]

Quoted 6 lines · Geoff Levand

We currently have macros defining flags for the arm64 sctlr registers in both kvm_arm.h and sysreg.h. To clean things up and simplify move the definitions of the SCTLR_EL2 flags from kvm_arm.h to sysreg.h, rename any SCTLR_EL1 or SCTLR_EL2 flags that are common to both registers to be SCTLR_ELx, with 'x' indicating a common flag, and fixup all files to include the proper header or to use the new macro names.

I am certainly in favour of having consistently named and located macros for register fields.

Quoted 15 lines
---
 arch/arm64/include/asm/kvm_arm.h | 11 -----------
 arch/arm64/include/asm/sysreg.h  | 19 +++++++++++++++----
 arch/arm64/kvm/hyp-init.S        |  6 +++---
 3 files changed, 18 insertions(+), 18 deletions(-)
arch/arm64/include/asm/kvm_arm.h +0 -0
index 5e6857b..92ef6f6 100644
@@ -83,17 +83,6 @@
 #define HCR_INT_OVERRIDE   (HCR_FMO | HCR_IMO)
 
 

arch/arm64/include/asm/kvm_arm.h line 95

Quoted 10 lines
arch/arm64/include/asm/kvm_arm.h +0 -10
-/* Hyp System Control Register (SCTLR_EL2) bits */
-#define SCTLR_EL2_EE	(1 << 25)
-#define SCTLR_EL2_WXN	(1 << 19)
-#define SCTLR_EL2_I	(1 << 12)
-#define SCTLR_EL2_SA	(1 << 3)
-#define SCTLR_EL2_C	(1 << 2)
-#define SCTLR_EL2_A	(1 << 1)
-#define SCTLR_EL2_M	1
-#define SCTLR_EL2_FLAGS	(SCTLR_EL2_M | SCTLR_EL2_A | SCTLR_EL2_C |	\
-			 SCTLR_EL2_SA | SCTLR_EL2_I)

SCTLR_EL2_FLAGS is a KVM-specific value (i.e. the SCTLR_EL2 flags which KVM wants to set), even if it consists solely of common fields.

I believe it should stay here (with an include for <asm/sysreg.h>), perhaps with a KVM_ prefix to imply it's not as generic as one might assume it is.

Quoted 13 lines
arch/arm64/include/asm/kvm_arm.h +0 -1
-
 /* TCR_EL2 Registers bits */
 #define TCR_EL2_RES1	((1 << 31) | (1 << 23))
 #define TCR_EL2_TBI	(1 << 20)
arch/arm64/include/asm/sysreg.h +0 -1
index d48ab5b..109d46e 100644
@@ -80,10 +80,21 @@
 #define SET_PSTATE_PAN(x) __inst_arm(0xd5000000 | REG_PSTATE_PAN_IMM |\
 				     (!!x)<<8 | 0x1f)
 
-/* SCTLR_EL1 */

arch/arm64/include/asm/sysreg.h line 89

Quoted 10 lines
arch/arm64/include/asm/sysreg.h +7 -3
-#define SCTLR_EL1_CP15BEN	(0x1 << 5)
-#define SCTLR_EL1_SED		(0x1 << 8)
-#define SCTLR_EL1_SPAN		(0x1 << 23)
+/* Common SCTLR_ELx flags. */
+#define SCTLR_ELx_EE    (1 << 25)
+#define SCTLR_ELx_I	(1 << 12)
+#define SCTLR_ELx_SA	(1 << 3)
+#define SCTLR_ELx_C	(1 << 2)
+#define SCTLR_ELx_A	(1 << 1)
+#define SCTLR_ELx_M	1

For consistency, (1 << 0) would be preferable.

Quoted 25 lines
arch/arm64/include/asm/sysreg.h +8 -0
+
+#define SCTLR_ELx_FLAGS	(SCTLR_ELx_M | SCTLR_ELx_A | SCTLR_ELx_C | \
+			 SCTLR_ELx_SA | SCTLR_ELx_I)
+
+/* SCTLR_EL1 specific flags. */
+#define SCTLR_EL1_SPAN		(1 << 23)
+#define SCTLR_EL1_SED		(1 << 8)
+#define SCTLR_EL1_CP15BEN	(1 << 5)
 
 
 /* id_aa64isar0 */
arch/arm64/kvm/hyp-init.S +1 -1
index 178ba22..1d7e502 100644
@@ -20,7 +20,7 @@
 #include <asm/assembler.h>
 #include <asm/kvm_arm.h>
 #include <asm/kvm_mmu.h>
-#include <asm/pgtable-hwdef.h>
+#include <asm/sysreg.h>
 
 	.text
 	.pushsection	.hyp.idmap.text, "ax"

arch/arm64/kvm/hyp-init.S __do_hyp_init: · line 109

Quoted 7 lines
arch/arm64/kvm/hyp-init.S +2 -2
@@ -105,8 +105,8 @@ __do_hyp_init:
 	dsb	sy
 
 	mrs	x4, sctlr_el2
-	and	x4, x4, #SCTLR_EL2_EE	// preserve endianness of EL2
-	ldr	x5, =SCTLR_EL2_FLAGS
+	and	x4, x4, #SCTLR_ELx_EE	// preserve endianness of EL2
+	ldr	x5, =SCTLR_ELx_FLAGS

Marc, Christoffer, I note that in SCTLR_EL2_FLAGS we don't set the RES1 bits of SCTLR_EL2 (not in head.S el2_setup). Should we perhaps be doing so so as to avoid any future surprises?

Thanks,
Mark.

Quoted 7 lines
arch/arm64/kvm/hyp-init.S +0 -0
 	orr	x4, x4, x5
 	msr	sctlr_el2, x4
 	isb
Signature · 1 line
2.5.0

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#8 lore raw

Re: [PATCH 04/19] arm64: Cleanup SCTLR flags

Quoted 99 lines · Mark Rutland

[Adding Marc as this touches KVM code]

Quoted 6 lines · Geoff Levand

We currently have macros defining flags for the arm64 sctlr registers in both kvm_arm.h and sysreg.h. To clean things up and simplify move the definitions of the SCTLR_EL2 flags from kvm_arm.h to sysreg.h, rename any SCTLR_EL1 or SCTLR_EL2 flags that are common to both registers to be SCTLR_ELx, with 'x' indicating a common flag, and fixup all files to include the proper header or to use the new macro names.

I am certainly in favour of having consistently named and located macros for register fields.

Quoted 15 lines
---
 arch/arm64/include/asm/kvm_arm.h | 11 -----------
 arch/arm64/include/asm/sysreg.h  | 19 +++++++++++++++----
 arch/arm64/kvm/hyp-init.S        |  6 +++---
 3 files changed, 18 insertions(+), 18 deletions(-)
arch/arm64/include/asm/kvm_arm.h +0 -0
index 5e6857b..92ef6f6 100644
@@ -83,17 +83,6 @@
 #define HCR_INT_OVERRIDE   (HCR_FMO | HCR_IMO)
 
 

arch/arm64/include/asm/kvm_arm.h line 95

Quoted 10 lines
arch/arm64/include/asm/kvm_arm.h +0 -10
-/* Hyp System Control Register (SCTLR_EL2) bits */
-#define SCTLR_EL2_EE	(1 << 25)
-#define SCTLR_EL2_WXN	(1 << 19)
-#define SCTLR_EL2_I	(1 << 12)
-#define SCTLR_EL2_SA	(1 << 3)
-#define SCTLR_EL2_C	(1 << 2)
-#define SCTLR_EL2_A	(1 << 1)
-#define SCTLR_EL2_M	1
-#define SCTLR_EL2_FLAGS	(SCTLR_EL2_M | SCTLR_EL2_A | SCTLR_EL2_C |	\
-			 SCTLR_EL2_SA | SCTLR_EL2_I)

SCTLR_EL2_FLAGS is a KVM-specific value (i.e. the SCTLR_EL2 flags which KVM wants to set), even if it consists solely of common fields.

I believe it should stay here (with an include for <asm/sysreg.h>), perhaps with a KVM_ prefix to imply it's not as generic as one might assume it is.

Quoted 13 lines
arch/arm64/include/asm/kvm_arm.h +0 -1
-
 /* TCR_EL2 Registers bits */
 #define TCR_EL2_RES1	((1 << 31) | (1 << 23))
 #define TCR_EL2_TBI	(1 << 20)
arch/arm64/include/asm/sysreg.h +0 -1
index d48ab5b..109d46e 100644
@@ -80,10 +80,21 @@
 #define SET_PSTATE_PAN(x) __inst_arm(0xd5000000 | REG_PSTATE_PAN_IMM |\
 				     (!!x)<<8 | 0x1f)
 
-/* SCTLR_EL1 */

arch/arm64/include/asm/sysreg.h line 89

Quoted 10 lines
arch/arm64/include/asm/sysreg.h +7 -3
-#define SCTLR_EL1_CP15BEN	(0x1 << 5)
-#define SCTLR_EL1_SED		(0x1 << 8)
-#define SCTLR_EL1_SPAN		(0x1 << 23)
+/* Common SCTLR_ELx flags. */
+#define SCTLR_ELx_EE    (1 << 25)
+#define SCTLR_ELx_I	(1 << 12)
+#define SCTLR_ELx_SA	(1 << 3)
+#define SCTLR_ELx_C	(1 << 2)
+#define SCTLR_ELx_A	(1 << 1)
+#define SCTLR_ELx_M	1

For consistency, (1 << 0) would be preferable.

Quoted 27 lines
arch/arm64/include/asm/sysreg.h +8 -0
+
+#define SCTLR_ELx_FLAGS	(SCTLR_ELx_M | SCTLR_ELx_A | SCTLR_ELx_C | \
+			 SCTLR_ELx_SA | SCTLR_ELx_I)
+
+/* SCTLR_EL1 specific flags. */
+#define SCTLR_EL1_SPAN		(1 << 23)
+#define SCTLR_EL1_SED		(1 << 8)
+#define SCTLR_EL1_CP15BEN	(1 << 5)
 
 
 /* id_aa64isar0 */
arch/arm64/kvm/hyp-init.S +1 -1
index 178ba22..1d7e502 100644
@@ -20,7 +20,7 @@
 #include <asm/assembler.h>
 #include <asm/kvm_arm.h>
 #include <asm/kvm_mmu.h>
-#include <asm/pgtable-hwdef.h>
+#include <asm/sysreg.h>
 
 	.text
 	.pushsection	.hyp.idmap.text, "ax"
@@ -105,8 +105,8 @@ __do_hyp_init:
 	dsb	sy
 
Quoted 9 lines

arch/arm64/kvm/hyp-init.S __do_hyp_init: · line 109

Quoted 5 lines
arch/arm64/kvm/hyp-init.S +2 -2
 	mrs	x4, sctlr_el2
-	and	x4, x4, #SCTLR_EL2_EE	// preserve endianness of EL2
-	ldr	x5, =SCTLR_EL2_FLAGS
+	and	x4, x4, #SCTLR_ELx_EE	// preserve endianness of EL2
+	ldr	x5, =SCTLR_ELx_FLAGS

Marc, Christoffer, I note that in SCTLR_EL2_FLAGS we don't set the RES1 bits of SCTLR_EL2 (not in head.S el2_setup). Should we perhaps be doing so so as to avoid any future surprises?

Yes, that's one of the numerous instances of the same problem - I think Dave Martin also has some fixes in that area.

I'll definitely take patches!

	M.
Signature · 6 lines
Jazz is not dead. It just smells funny...

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#9 lore raw

Re: [PATCH 04/19] arm64: Cleanup SCTLR flags

Quoted 1 line · Marc Zyngier

On 15/01/16 20:07, Mark Rutland wrote:

[...]

Quoted 8 lines
Quoted 3 lines

Marc, Christoffer, I note that in SCTLR_EL2_FLAGS we don't set the RES1 bits of SCTLR_EL2 (not in head.S el2_setup). Should we perhaps be doing so so as to avoid any future surprises?

Yes, that's one of the numerous instances of the same problem - I think Dave Martin also has some fixes in that area.

I'll definitely take patches!

Yep, we have a similar problem with CPTR_EL2, patch to follow at some point. There are likely other instances...

Cheers
---Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#10 lore raw

Re: [PATCH 04/19] arm64: Cleanup SCTLR flags

In reply to Geoff Levand

Hi Geoff,

Quoted 15 lines · Geoff Levand

We currently have macros defining flags for the arm64 sctlr registers in both kvm_arm.h and sysreg.h. To clean things up and simplify move the definitions of the SCTLR_EL2 flags from kvm_arm.h to sysreg.h, rename any SCTLR_EL1 or SCTLR_EL2 flags that are common to both registers to be SCTLR_ELx, with 'x' indicating a common flag, and fixup all files to include the proper header or to use the new macro names.

---

arch/arm64/kvm/hyp-init.S +0 -0
index 178ba22..1d7e502 100644

arch/arm64/kvm/hyp-init.S line 23

Quoted 4 lines
arch/arm64/kvm/hyp-init.S +0 -1
@@ -20,7 +20,7 @@
 #include <asm/assembler.h>
 #include <asm/kvm_arm.h>
 #include <asm/kvm_mmu.h>
-#include <asm/pgtable-hwdef.h>

I think this one crept in... this header file is needed for the definition of TCR_T0SZ_OFFSET and TCR_TxSZ_WIDTH.

arch/arm64/kvm/hyp-init.S line 26

Quoted 4 lines
arch/arm64/kvm/hyp-init.S +1 -0
+#include <asm/sysreg.h>
 
 	.text
 	.pushsection	.hyp.idmap.text, "ax"

Thanks,

James

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#11 lore raw

PATCH 5/19 arm64: Convert hcalls to use HVC immediate value

In reply to Geoff Levand

The existing arm64 hcall implementations are limited in that they only allow for two distinct hcalls; with the x0 register either zero or not zero. Also, the API of the hyp-stub exception vector routines and the KVM exception vector routines differ; hyp-stub uses a non-zero value in x0 to implement __hyp_set_vectors, whereas KVM uses it to implement kvm_call_hyp.

To allow for additional hcalls to be defined and to make the arm64 hcall API more consistent across exception vector routines, change the hcall implementations to use the 16 bit immediate value of the HVC instruction to specify the hcall type.

Define three new preprocessor macros HVC_CALL_HYP, HVC_GET_VECTORS, and HVC_SET_VECTORS to be used as hcall type specifiers and convert the existing __hyp_get_vectors(), __hyp_set_vectors() and kvm_call_hyp() routines to use these new macros when executing an HVC call. Also, change the corresponding hyp-stub and KVM el1_sync exception vector routines to use these new macros.

---
 arch/arm64/include/asm/virt.h | 27 +++++++++++++++++++++++++++
 arch/arm64/kernel/hyp-stub.S  | 32 +++++++++++++++++++++-----------
 arch/arm64/kvm/hyp.S          | 16 +++++++++-------
 3 files changed, 57 insertions(+), 18 deletions(-)
arch/arm64/include/asm/virt.h +27 -0
index 7a5df52..eb10368 100644
@@ -18,6 +18,33 @@
 #ifndef __ASM__VIRT_H
 #define __ASM__VIRT_H
 
+/*
+ * The arm64 hcall implementation uses the ISS field of the ESR_EL2 register to
+ * specify the hcall type.  The exception handlers are allowed to use registers
+ * x17 and x18 in their implementation.  Any routine issuing an hcall must not
+ * expect these registers to be preserved.
+ */
+
+/*
+ * HVC_CALL_HYP - Execute a hyp routine.
+ */
+
+#define HVC_CALL_HYP 0
+
+/*
+ * HVC_GET_VECTORS - Return the value of the vbar_el2 register.
+ */
+
+#define HVC_GET_VECTORS 1
+
+/*
+ * HVC_SET_VECTORS - Set the value of the vbar_el2 register.
+ *
+ * @x0: Physical address of the new vector table.
+ */
+
+#define HVC_SET_VECTORS 2
+
 #define BOOT_CPU_MODE_EL1	(0xe11)
 #define BOOT_CPU_MODE_EL2	(0xe12)
 
arch/arm64/kernel/hyp-stub.S +21 -11
index a272f33..017ab519 100644
@@ -22,6 +22,7 @@
 #include <linux/irqchip/arm-gic-v3.h>
 
 #include <asm/assembler.h>
+#include <asm/kvm_arm.h>
 #include <asm/ptrace.h>
 #include <asm/virt.h>
 
@@ -53,14 +54,22 @@ ENDPROC(__hyp_stub_vectors)
 	.align 11
 
 el1_sync:
-	mrs	x1, esr_el2
-	lsr	x1, x1, #26
-	cmp	x1, #0x16
+	mrs	x18, esr_el2
+	lsr	x17, x18, #ESR_ELx_EC_SHIFT
+	and	x18, x18, #ESR_ELx_ISS_MASK
+
+	cmp	x17, #ESR_ELx_EC_HVC64
 	b.ne	2f				// Not an HVC trap
-	cbz	x0, 1f
-	msr	vbar_el2, x0			// Set vbar_el2
+
+	cmp	x18, #HVC_GET_VECTORS
+	b.ne	1f
+	mrs	x0, vbar_el2
 	b	2f
-1:	mrs	x0, vbar_el2			// Return vbar_el2
+
+1:	cmp	x18, #HVC_SET_VECTORS
+	b.ne	2f
+	msr	vbar_el2, x0
+
 2:	eret
 ENDPROC(el1_sync)
 
@@ -100,11 +109,12 @@ ENDPROC(\label)
  * initialisation entry point.
  */
 
-ENTRY(__hyp_get_vectors)
-	mov	x0, xzr
-	// fall through
 ENTRY(__hyp_set_vectors)
-	hvc	#0
+	hvc	#HVC_SET_VECTORS
 	ret
-ENDPROC(__hyp_get_vectors)
 ENDPROC(__hyp_set_vectors)
+
+ENTRY(__hyp_get_vectors)
+	hvc	#HVC_GET_VECTORS
+	ret
+ENDPROC(__hyp_get_vectors)
arch/arm64/kvm/hyp.S +9 -7
index 86c2898..15b1ef9 100644
@@ -29,6 +29,7 @@
 #include <asm/kvm_asm.h>
 #include <asm/kvm_mmu.h>
 #include <asm/memory.h>
+#include <asm/virt.h>
 
 #define CPU_GP_REG_OFFSET(x)	(CPU_GP_REGS + x)
 #define CPU_XREG_OFFSET(x)	CPU_GP_REG_OFFSET(CPU_USER_PT_REGS + 8*x)
@@ -936,12 +937,9 @@ __hyp_panic_str:
  * in Hyp mode (see init_hyp_mode in arch/arm/kvm/arm.c).  Return values are
  * passed in r0 and r1.
  *
- * A function pointer with a value of 0 has a special meaning, and is
- * used to implement __hyp_get_vectors in the same way as in
- * arch/arm64/kernel/hyp_stub.S.
  */
 ENTRY(kvm_call_hyp)
-	hvc	#0
+	hvc	#HVC_CALL_HYP
 	ret
 ENDPROC(kvm_call_hyp)
 
@@ -972,6 +970,7 @@ el1_sync:					// Guest trapped into EL2
 
 	mrs	x1, esr_el2
 	lsr	x2, x1, #ESR_ELx_EC_SHIFT
+	and	x0, x1, #ESR_ELx_ISS_MASK
 
 	cmp	x2, #ESR_ELx_EC_HVC64
 	b.ne	el1_trap
@@ -980,15 +979,18 @@ el1_sync:					// Guest trapped into EL2
 	cbnz	x3, el1_trap			// called HVC
 
 	/* Here, we're pretty sure the host called HVC. */
+	mov	x18, x0
 	pop	x2, x3
 	pop	x0, x1
 
-	/* Check for __hyp_get_vectors */
-	cbnz	x0, 1f
+	cmp	x18, #HVC_GET_VECTORS
+	b.ne	1f
 	mrs	x0, vbar_el2
 	b	2f
 
-1:	push	lr, xzr
+1:	/* Default to HVC_CALL_HYP. */
+
+	push	lr, xzr
 
 	/*
 	 * Compute the function address in EL2, and shuffle the parameters.
Signature · 8 lines
2.5.0



_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#12 lore raw

PATCH 6/19 arm64: Add new hcall HVC_CALL_FUNC

In reply to Geoff Levand

Add the new hcall HVC_CALL_FUNC that allows execution of a function at EL2. During CPU reset the CPU must be brought to the exception level it had on entry to the kernel. The HVC_CALL_FUNC hcall will provide the mechanism needed for this exception level switch.

To allow the HVC_CALL_FUNC exception vector to work without a stack, which is needed to support an hcall at CPU reset, this implementation uses register x18 to store the link register across the caller provided function. This dictates that the caller provided function must preserve the contents of register x18.

---
 arch/arm64/include/asm/virt.h | 13 +++++++++++++
 arch/arm64/kernel/hyp-stub.S  | 13 ++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)
arch/arm64/include/asm/virt.h +13 -0
index eb10368..3070096 100644
@@ -45,6 +45,19 @@
 
 #define HVC_SET_VECTORS 2
 
+/*
+ * HVC_CALL_FUNC - Execute a function at EL2.
+ *
+ * @x0: Physical address of the function to be executed.
+ * @x1: Passed as the first argument to the function.
+ * @x2: Passed as the second argument to the function.
+ * @x3: Passed as the third argument to the function.
+ *
+ * The called function must preserve the contents of register x18.
+ */
+
+#define HVC_CALL_FUNC 3
+
 #define BOOT_CPU_MODE_EL1	(0xe11)
 #define BOOT_CPU_MODE_EL2	(0xe12)
 
arch/arm64/kernel/hyp-stub.S +12 -1
index 017ab519..e8febe9 100644
@@ -67,8 +67,19 @@ el1_sync:
 	b	2f
 
 1:	cmp	x18, #HVC_SET_VECTORS
-	b.ne	2f
+	b.ne	1f
 	msr	vbar_el2, x0
+	b	2f
+
+1:	cmp	x18, #HVC_CALL_FUNC
+	b.ne	2f
+	mov	x18, lr
+	mov	lr, x0
+	mov	x0, x1
+	mov	x1, x2
+	mov	x2, x3
+	blr	lr
+	mov	lr, x18
 
 2:	eret
 ENDPROC(el1_sync)
Signature · 8 lines
2.5.0



_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#13 lore raw

PATCH 7/19 arm64: Add back cpu_reset routines

In reply to Geoff Levand

Commit 68234df4ea7939f98431aa81113fbdce10c4a84b (arm64: kill flush_cache_all()) removed the global arm64 routines cpu_reset() and cpu_soft_restart() needed by the arm64 kexec and kdump support. Add simplified versions of those two routines back with some changes needed for kexec in the new files cpu_reset.S, and cpu_reset.h.

When a CPU is reset it needs to be put into the exception level it had when it entered the kernel. Update cpu_reset() to accept an argument which signals if the reset address needs to be entered at EL1 or EL2.

---
 arch/arm64/kernel/cpu-reset.S | 57 +++++++++++++++++++++++++++++++++++++++++++
 arch/arm64/kernel/cpu-reset.h | 29 ++++++++++++++++++++++
 2 files changed, 86 insertions(+)
 create mode 100644 arch/arm64/kernel/cpu-reset.S
 create mode 100644 arch/arm64/kernel/cpu-reset.h
arch/arm64/kernel/cpu-reset.S new file +57 -0
new file mode 100644
index 0000000..f8d00d5
@@ -0,0 +1,57 @@
+/*
+ * CPU reset routines
+ *
+ * Copyright (C) 2001 Deep Blue Solutions Ltd.
+ * Copyright (C) 2012 ARM Ltd.
+ * Copyright (C) 2015 Huawei Futurewei Technologies.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/linkage.h>
+#include <asm/assembler.h>
+#include <asm/sysreg.h>
+#include <asm/virt.h>
+
+.text
+.pushsection    .idmap.text, "ax"
+
+/*
+ * __cpu_soft_restart(el2_switch, entry, arg0, arg1, arg2) - Helper for
+ * cpu_soft_restart.
+ *
+ * @el2_switch: Flag to indicate a swich to EL2 is needed.
+ * @entry: Location to jump to for soft reset.
+ * arg0: First argument passed to @entry.
+ * arg1: Second argument passed to @entry.
+ * arg2: Third argument passed to @entry.
+ *
+ * Put the CPU into the same state as it would be if it had been reset, and
+ * branch to what would be the reset vector. It must be executed with the
+ * flat identity mapping.
+ */
+ENTRY(__cpu_soft_restart)
+	/* Clear sctlr_el1 flags. */
+	mrs	x12, sctlr_el1
+	ldr	x13, =SCTLR_ELx_FLAGS
+	bic	x12, x12, x13
+	msr	sctlr_el1, x12
+	isb
+
+	cbz	x0, 1f				// el2_switch?
+	mov	x0, x1				// entry
+	mov	x1, x2				// arg0
+	mov	x2, x3				// arg1
+	mov	x3, x4				// arg2
+	hvc	#HVC_CALL_FUNC			// no return
+
+1:	mov	x18, x1				// entry
+	mov	x0, x2				// arg0
+	mov	x1, x3				// arg1
+	mov	x2, x4				// arg2
+	ret	x18
+ENDPROC(__cpu_soft_restart)
+
+.popsection
arch/arm64/kernel/cpu-reset.h new file +29 -0
new file mode 100644
index 0000000..5a5ea0a
@@ -0,0 +1,29 @@
+/*
+ * CPU reset routines
+ *
+ * Copyright (C) 2015 Huawei Futurewei Technologies.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ARM64_CPU_RESET_H
+#define _ARM64_CPU_RESET_H
+
+#include <asm/virt.h>
+
+void __cpu_soft_restart(unsigned long el2_switch, unsigned long entry,
+	unsigned long arg0, unsigned long arg1, unsigned long arg2);
+
+static inline void __noreturn cpu_soft_restart(unsigned long el2_switch,
+	unsigned long entry, unsigned long arg0, unsigned long arg1,
+	unsigned long arg2)
+{
+	typeof(__cpu_soft_restart) *restart;
+	restart = (void *)virt_to_phys(__cpu_soft_restart);
+	restart(el2_switch, entry, arg0, arg1, arg2);
+	unreachable();
+}
+
+#endif
Signature · 8 lines
2.5.0



_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#14 lore raw

PATCH 8/19 Revert "arm64: mm: remove unused cpu_set_idmap_tcr_t0sz function"

In reply to Geoff Levand

This reverts commit c51e97d89e526368eb697f87cd4d391b9e19f369.

Add back the cpu_set_idmap_tcr_t0sz function needed by setup_mmu_for_reboot.

---
 arch/arm64/include/asm/mmu_context.h | 35 +++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)
arch/arm64/include/asm/mmu_context.h +23 -12
index 2416578..7567030 100644
@@ -70,23 +70,34 @@ static inline bool __cpu_uses_extended_idmap(void)
 		unlikely(idmap_t0sz != TCR_T0SZ(VA_BITS)));
 }
 
+static inline void __cpu_set_tcr_t0sz(u64 t0sz)
+{
+	unsigned long tcr;
+
+	if (__cpu_uses_extended_idmap())
+		asm volatile (
+		"	mrs	%0, tcr_el1	;"
+		"	bfi	%0, %1, %2, %3	;"
+		"	msr	tcr_el1, %0	;"
+		"	isb"
+		: "=&r" (tcr)
+		: "r"(t0sz), "I"(TCR_T0SZ_OFFSET), "I"(TCR_TxSZ_WIDTH));
+}
+
+/*
+ * Set TCR.T0SZ to the value appropriate for activating the identity map.
+ */
+static inline void cpu_set_idmap_tcr_t0sz(void)
+{
+	__cpu_set_tcr_t0sz(idmap_t0sz);
+}
+
 /*
  * Set TCR.T0SZ to its default value (based on VA_BITS)
  */
 static inline void cpu_set_default_tcr_t0sz(void)
 {
-	unsigned long tcr;
-
-	if (!__cpu_uses_extended_idmap())
-		return;
-
-	asm volatile (
-	"	mrs	%0, tcr_el1	;"
-	"	bfi	%0, %1, %2, %3	;"
-	"	msr	tcr_el1, %0	;"
-	"	isb"
-	: "=&r" (tcr)
-	: "r"(TCR_T0SZ(VA_BITS)), "I"(TCR_T0SZ_OFFSET), "I"(TCR_TxSZ_WIDTH));
+	__cpu_set_tcr_t0sz(TCR_T0SZ(VA_BITS));
 }
 
 /*
Signature · 8 lines
2.5.0



_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#15 lore raw

PATCH 9/19 Revert "arm64: remove dead code"

In reply to Geoff Levand

This reverts commit b08d4640a3dca68670fc5af2fe9205b395a02388.

Add back the setup_mm_for_reboot() needed for kexec.

---
 arch/arm64/include/asm/mmu.h |  1 +
 arch/arm64/mm/mmu.c          | 11 +++++++++++
 2 files changed, 12 insertions(+)
arch/arm64/include/asm/mmu.h +1 -0
index 990124a..6326d11 100644
@@ -29,6 +29,7 @@ typedef struct {
 #define ASID(mm)	((mm)->context.id.counter & 0xffff)
 
 extern void paging_init(void);
+extern void setup_mm_for_reboot(void);
 extern void __iomem *early_io_map(phys_addr_t phys, unsigned long virt);
 extern void init_mem_pgprot(void);
 extern void create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys,
arch/arm64/mm/mmu.c +11 -0
index 873e363..afcf1ee 100644
@@ -466,6 +466,17 @@ void __init paging_init(void)
 }
 
 /*
+ * Enable the identity mapping to allow the MMU disabling.
+ */
+void setup_mm_for_reboot(void)
+{
+	cpu_set_reserved_ttbr0();
+	flush_tlb_all();
+	cpu_set_idmap_tcr_t0sz();
+	cpu_switch_mm(idmap_pg_dir, &init_mm);
+}
+
+/*
  * Check whether a kernel address is valid (derived from arch/x86/).
  */
 int kern_addr_valid(unsigned long addr)
Signature · 8 lines
2.5.0



_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
reviewer
#16 lore raw

Re: [PATCH 09/19] Revert "arm64: remove dead code"

Hi,

Quoted 3 lines · Geoff Levand

This reverts commit b08d4640a3dca68670fc5af2fe9205b395a02388.

Add back the setup_mm_for_reboot() needed for kexec.

My pagetable rework series [1,2] adds cpu_install_idmap() [3], which supersedes setup_mm_for_reboot, and differs only in name.

I intend to rebase once v4.5-rc1 comes out. Unless there are substantial changes or new comments, I expect that to be on a stable branche shortly thereafter. When that happens, it should be possible to drop this patch.

Thanks,
Mark.

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-January/397095.html
[2] https://git.kernel.org/cgit/linux/kernel/git/mark/linux.git/log/?h=arm64/pagetable-rework
[3] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-January/397101.html

Quoted 45 lines
---
 arch/arm64/include/asm/mmu.h |  1 +
 arch/arm64/mm/mmu.c          | 11 +++++++++++
 2 files changed, 12 insertions(+)
arch/arm64/include/asm/mmu.h +1 -0
index 990124a..6326d11 100644
@@ -29,6 +29,7 @@ typedef struct {
 #define ASID(mm)	((mm)->context.id.counter & 0xffff)
 
 extern void paging_init(void);
+extern void setup_mm_for_reboot(void);
 extern void __iomem *early_io_map(phys_addr_t phys, unsigned long virt);
 extern void init_mem_pgprot(void);
 extern void create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys,
arch/arm64/mm/mmu.c +11 -0
index 873e363..afcf1ee 100644
@@ -466,6 +466,17 @@ void __init paging_init(void)
 }
 
 /*
+ * Enable the identity mapping to allow the MMU disabling.
+ */
+void setup_mm_for_reboot(void)
+{
+	cpu_set_reserved_ttbr0();
+	flush_tlb_all();
+	cpu_set_idmap_tcr_t0sz();
+	cpu_switch_mm(idmap_pg_dir, &init_mm);
+}
+
+/*
  * Check whether a kernel address is valid (derived from arch/x86/).
  */
 int kern_addr_valid(unsigned long addr)
Signature · 1 line
2.5.0

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#17 lore raw

Re: [PATCH 09/19] Revert "arm64: remove dead code"

Quoted 7 lines · Mark Rutland
Quoted 3 lines · Geoff Levand

This reverts commit b08d4640a3dca68670fc5af2fe9205b395a02388.

Add back the setup_mm_for_reboot() needed for kexec.

My pagetable rework series [1,2] adds cpu_install_idmap() [3], which supersedes setup_mm_for_reboot, and differs only in name.

OK, I'll switch to cpu_install_idmap.

-Geoff

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#18 lore raw

PATCH 10/19 arm64: kvm: allows kvm cpu hotplug

In reply to Geoff Levand

From: AKASHI Takahiro <[email protected]>

The current kvm implementation on arm64 does cpu-specific initialization at system boot, and has no way to gracefully shutdown a core in terms of kvm. This prevents, especially, kexec from rebooting the system on a boot core in EL2.

This patch adds a cpu tear-down function and also puts an existing cpu-init code into a separate function, kvm_arch_hardware_disable() and kvm_arch_hardware_enable() respectively.
We don't need arm64-specific cpu hotplug hook any more.

Since this patch modifies common part of code between arm and arm64, one stub definition, __cpu_reset_hyp_mode(), is added on arm side to avoid compiling errors.

---
 arch/arm/include/asm/kvm_host.h   | 10 ++++-
 arch/arm/include/asm/kvm_mmu.h    |  1 +
 arch/arm/kvm/arm.c                | 93 +++++++++++++++++++++++----------------
 arch/arm/kvm/mmu.c                |  5 +++
 arch/arm64/include/asm/kvm_host.h | 11 ++++-
 arch/arm64/include/asm/kvm_mmu.h  |  1 +
 arch/arm64/include/asm/virt.h     |  9 ++++
 arch/arm64/kvm/hyp-init.S         | 33 ++++++++++++++
 arch/arm64/kvm/hyp.S              | 32 ++++++++++++--
 9 files changed, 151 insertions(+), 44 deletions(-)
arch/arm/include/asm/kvm_host.h +9 -1
index 6692982..9242765 100644
@@ -214,6 +214,15 @@ static inline void __cpu_init_hyp_mode(phys_addr_t boot_pgd_ptr,
 	kvm_call_hyp((void*)hyp_stack_ptr, vector_ptr, pgd_ptr);
 }
 
+static inline void __cpu_reset_hyp_mode(phys_addr_t boot_pgd_ptr,
+					phys_addr_t phys_idmap_start)
+{
+	/*
+	 * TODO
+	 * kvm_call_reset(boot_pgd_ptr, phys_idmap_start);
+	 */
+}
+
 static inline int kvm_arch_dev_ioctl_check_extension(long ext)
 {
 	return 0;
@@ -226,7 +235,6 @@ void kvm_mmu_wp_memory_region(struct kvm *kvm, int slot);
 
 struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr);
 
-static inline void kvm_arch_hardware_disable(void) {}
 static inline void kvm_arch_hardware_unsetup(void) {}
 static inline void kvm_arch_sync_events(struct kvm *kvm) {}
 static inline void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) {}
arch/arm/include/asm/kvm_mmu.h +1 -0
index 405aa18..dc6fadf 100644
@@ -66,6 +66,7 @@ void kvm_mmu_free_memory_caches(struct kvm_vcpu *vcpu);
 phys_addr_t kvm_mmu_get_httbr(void);
 phys_addr_t kvm_mmu_get_boot_httbr(void);
 phys_addr_t kvm_get_idmap_vector(void);
+phys_addr_t kvm_get_idmap_start(void);
 int kvm_mmu_init(void);
 void kvm_clear_hyp_idmap(void);
 
arch/arm/kvm/arm.c +55 -38

169 lines not on this page · raw message

arch/arm/kvm/mmu.c +5 -0
index 61d96a6..e6651dd 100644
@@ -1643,6 +1643,11 @@ phys_addr_t kvm_get_idmap_vector(void)
 	return hyp_idmap_vector;
 }
 
+phys_addr_t kvm_get_idmap_start(void)
+{
+	return hyp_idmap_start;
+}
+
 int kvm_mmu_init(void)
 {
 	int err;
arch/arm64/include/asm/kvm_host.h +10 -1
index a35ce72..de08e4c 100644
@@ -223,6 +223,7 @@ struct kvm_vcpu *kvm_arm_get_running_vcpu(void);
 struct kvm_vcpu * __percpu *kvm_get_running_vcpus(void);
 
 u64 kvm_call_hyp(void *hypfn, ...);
+void kvm_call_reset(phys_addr_t boot_pgd_ptr, phys_addr_t phys_idmap_start);
 void force_vm_exit(const cpumask_t *mask);
 void kvm_mmu_wp_memory_region(struct kvm *kvm, int slot);
 
@@ -247,7 +248,15 @@ static inline void __cpu_init_hyp_mode(phys_addr_t boot_pgd_ptr,
 		     hyp_stack_ptr, vector_ptr);
 }
 
-static inline void kvm_arch_hardware_disable(void) {}
+static inline void __cpu_reset_hyp_mode(phys_addr_t boot_pgd_ptr,
+					phys_addr_t phys_idmap_start)
+{
+	/*
+	 * Call reset code, and switch back to stub hyp vectors.
+	 */
+	kvm_call_reset(boot_pgd_ptr, phys_idmap_start);
+}
+
 static inline void kvm_arch_hardware_unsetup(void) {}
 static inline void kvm_arch_sync_events(struct kvm *kvm) {}
 static inline void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) {}
arch/arm64/include/asm/kvm_mmu.h +1 -0
index 6150567..ff5a087 100644
@@ -98,6 +98,7 @@ void kvm_mmu_free_memory_caches(struct kvm_vcpu *vcpu);
 phys_addr_t kvm_mmu_get_httbr(void);
 phys_addr_t kvm_mmu_get_boot_httbr(void);
 phys_addr_t kvm_get_idmap_vector(void);
+phys_addr_t kvm_get_idmap_start(void);
 int kvm_mmu_init(void);
 void kvm_clear_hyp_idmap(void);
 
arch/arm64/include/asm/virt.h +9 -0
index 3070096..bca79f9 100644
@@ -58,9 +58,18 @@
 
 #define HVC_CALL_FUNC 3
 
+/*
+ * HVC_RESET_CPU - Reset cpu in EL2 to initial state.
+ *
+ * @x0: entry address in trampoline code in va
+ * @x1: identical mapping page table in pa
+ */
+
 #define BOOT_CPU_MODE_EL1	(0xe11)
 #define BOOT_CPU_MODE_EL2	(0xe12)
 
+#define HVC_RESET_CPU 4
+
 #ifndef __ASSEMBLY__
 
 /*
arch/arm64/kvm/hyp-init.S +33 -0
index 1d7e502..d909ce2 100644
@@ -140,6 +140,39 @@ merged:
 	eret
 ENDPROC(__kvm_hyp_init)
 
+	/*
+	 * x0: HYP boot pgd
+	 * x1: HYP phys_idmap_start
+	 */
+ENTRY(__kvm_hyp_reset)
+	/* We're in trampoline code in VA, switch back to boot page tables */
+	msr	ttbr0_el2, x0
+	isb
+
+	/* Invalidate the old TLBs */
+	tlbi	alle2
+	dsb	sy
+
+	/* Branch into PA space */
+	adr	x0, 1f
+	bfi	x1, x0, #0, #PAGE_SHIFT
+	br	x1
+
+	/* We're now in idmap, disable MMU */
+1:	mrs	x0, sctlr_el2
+	ldr	x1, =SCTLR_ELx_FLAGS
+	bic	x0, x0, x1		// Clear SCTL_M and etc
+	msr	sctlr_el2, x0
+	isb
+
+	/* Install stub vectors */
+	adrp	x0, __hyp_stub_vectors
+	add	x0, x0, #:lo12:__hyp_stub_vectors
+	msr	vbar_el2, x0
+
+	eret
+ENDPROC(__kvm_hyp_reset)
+
 	.ltorg
 
 	.popsection
arch/arm64/kvm/hyp.S +28 -4
index 15b1ef9..ed82dc2 100644
@@ -943,6 +943,11 @@ ENTRY(kvm_call_hyp)
 	ret
 ENDPROC(kvm_call_hyp)
 
+ENTRY(kvm_call_reset)
+	hvc	#HVC_RESET_CPU
+	ret
+ENDPROC(kvm_call_reset)
+
 .macro invalid_vector	label, target
 	.align	2
 \label:
@@ -986,10 +991,27 @@ el1_sync:					// Guest trapped into EL2
 	cmp	x18, #HVC_GET_VECTORS
 	b.ne	1f
 	mrs	x0, vbar_el2
-	b	2f
-
-1:	/* Default to HVC_CALL_HYP. */
+	b	do_eret
 
+	/* jump into trampoline code */
+1:	cmp	x18, #HVC_RESET_CPU
+	b.ne	2f
+	/*
+	 * Entry point is:
+	 *	TRAMPOLINE_VA
+	 *	+ (__kvm_hyp_reset - (__hyp_idmap_text_start & PAGE_MASK))
+	 */
+	adrp	x2, __kvm_hyp_reset
+	add	x2, x2, #:lo12:__kvm_hyp_reset
+	adrp	x3, __hyp_idmap_text_start
+	add	x3, x3, #:lo12:__hyp_idmap_text_start
+	and	x3, x3, PAGE_MASK
+	sub	x2, x2, x3
+	ldr	x3, =TRAMPOLINE_VA
+	add	x2, x2, x3
+	br	x2				// no return
+
+2:	/* Default to HVC_CALL_HYP. */
 	push	lr, xzr
 
 	/*
@@ -1003,7 +1025,9 @@ el1_sync:					// Guest trapped into EL2
 	blr	lr
 
 	pop	lr, xzr
-2:	eret
+
+do_eret:
+	eret
 
 el1_trap:
 	/*
Signature · 8 lines
2.5.0



_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#19 lore raw

Re: [PATCH 10/19] arm64: kvm: allows kvm cpu hotplug

Hi!

Quoted 31 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

The current kvm implementation on arm64 does cpu-specific initialization at system boot, and has no way to gracefully shutdown a core in terms of kvm. This prevents, especially, kexec from rebooting the system on a boot core in EL2.

This patch adds a cpu tear-down function and also puts an existing cpu-init code into a separate function, kvm_arch_hardware_disable() and kvm_arch_hardware_enable() respectively.
We don't need arm64-specific cpu hotplug hook any more.

Since this patch modifies common part of code between arm and arm64, one stub definition, __cpu_reset_hyp_mode(), is added on arm side to avoid compiling errors.

arch/arm/kvm/arm.c +0 -3
index e06fd29..e91f80e 100644
 
 #ifdef CONFIG_CPU_PM
 static int hyp_init_cpu_pm_notifier(struct notifier_block *self,
 				    unsigned long cmd,
 				    void *v)
 {
-	if (cmd == CPU_PM_EXIT &&
-	    __hyp_get_vectors() == hyp_default_vectors) {
-		cpu_init_hyp_mode(NULL);

arch/arm/kvm/arm.c static void cpu_init_hyp_mode(void *dummy) · line 1024

Quoted 10 lines
arch/arm/kvm/arm.c +8 -1
+	switch (cmd) {
+	case CPU_PM_ENTER:
+		if (__this_cpu_read(kvm_arm_hardware_enabled))
+			cpu_reset_hyp_mode();
+
 		return NOTIFY_OK;
-	}
+	case CPU_PM_EXIT:
+		if (__this_cpu_read(kvm_arm_hardware_enabled))
+			cpu_init_hyp_mode();

I read this as:

		if (enabled)
			enable();

What am I missing? Is there a missing '!'?

[/me thinks some more]

I suspect this is trying to be clever: leaving the flag set over a deep-sleep, to indicate that the hardware should be re-enabled when we resume... if so, a comment to that effect would be good.

Quoted 21 lines
arch/arm/kvm/arm.c +5 -1
-	return NOTIFY_DONE;
+		return NOTIFY_OK;
+
+	default:
+		return NOTIFY_DONE;
+	}
 }
 
 static struct notifier_block hyp_init_cpu_pm_nb = {
arch/arm64/include/asm/virt.h +2 -0
index 3070096..bca79f9 100644
@@ -58,9 +58,18 @@
 
 #define HVC_CALL_FUNC 3
 
+/*
+ * HVC_RESET_CPU - Reset cpu in EL2 to initial state.

arch/arm64/include/asm/virt.h line 72

Quoted 10 lines
arch/arm64/include/asm/virt.h +7 -0
+ *
+ * @x0: entry address in trampoline code in va
+ * @x1: identical mapping page table in pa
+ */
+
 #define BOOT_CPU_MODE_EL1	(0xe11)
 #define BOOT_CPU_MODE_EL2	(0xe12)
 
+#define HVC_RESET_CPU 4
+

Patch 5 added a fancy new way to call arbitrary functions at el2, why not use that? (it would save beating up el1_sync again).

I agree the trampoline stuff is complicated - I will try and cook-up a version of this patch for hibernate that does this. (... and comment what I think is happening above while I'm at it)

Quoted 29 lines
arch/arm64/include/asm/virt.h +0 -0
 #ifndef __ASSEMBLY__
 
 /*
arch/arm64/kvm/hyp-init.S +18 -0
index 1d7e502..d909ce2 100644
@@ -140,6 +140,39 @@ merged:
 	eret
 ENDPROC(__kvm_hyp_init)
 
+	/*
+	 * x0: HYP boot pgd
+	 * x1: HYP phys_idmap_start
+	 */
+ENTRY(__kvm_hyp_reset)
+	/* We're in trampoline code in VA, switch back to boot page tables */
+	msr	ttbr0_el2, x0
+	isb
+
+	/* Invalidate the old TLBs */
+	tlbi	alle2
+	dsb	sy
+
+	/* Branch into PA space */
+	adr	x0, 1f
+	bfi	x1, x0, #0, #PAGE_SHIFT
+	br	x1
+

arch/arm64/kvm/hyp-init.S merged: · line 170

Quoted 10 lines
arch/arm64/kvm/hyp-init.S +10 -0
+	/* We're now in idmap, disable MMU */
+1:	mrs	x0, sctlr_el2
+	ldr	x1, =SCTLR_ELx_FLAGS
+	bic	x0, x0, x1		// Clear SCTL_M and etc
+	msr	sctlr_el2, x0
+	isb
+
+	/* Install stub vectors */
+	adrp	x0, __hyp_stub_vectors
+	add	x0, x0, #:lo12:__hyp_stub_vectors

adr_l ?

Quoted 23 lines
arch/arm64/kvm/hyp-init.S +5 -0
+	msr	vbar_el2, x0
+
+	eret
+ENDPROC(__kvm_hyp_reset)
+
 	.ltorg
 
 	.popsection
arch/arm64/kvm/hyp.S +3 -3
index 15b1ef9..ed82dc2 100644
@@ -986,10 +991,27 @@ el1_sync:					// Guest trapped into EL2
 	cmp	x18, #HVC_GET_VECTORS
 	b.ne	1f
 	mrs	x0, vbar_el2
-	b	2f
-
-1:	/* Default to HVC_CALL_HYP. */
+	b	do_eret
 
+	/* jump into trampoline code */
+1:	cmp	x18, #HVC_RESET_CPU

arch/arm64/kvm/hyp.S el1_sync: // Guest trapped into EL2 · line 1007

Quoted 10 lines
arch/arm64/kvm/hyp.S +10 -0
+	b.ne	2f
+	/*
+	 * Entry point is:
+	 *	TRAMPOLINE_VA
+	 *	+ (__kvm_hyp_reset - (__hyp_idmap_text_start & PAGE_MASK))
+	 */
+	adrp	x2, __kvm_hyp_reset
+	add	x2, x2, #:lo12:__kvm_hyp_reset
+	adrp	x3, __hyp_idmap_text_start
+	add	x3, x3, #:lo12:__hyp_idmap_text_start

adr_l ?

arch/arm64/kvm/hyp.S el1_sync: // Guest trapped into EL2 · line 1017

Quoted 10 lines
arch/arm64/kvm/hyp.S +7 -0
+	and	x3, x3, PAGE_MASK
+	sub	x2, x2, x3
+	ldr	x3, =TRAMPOLINE_VA
+	add	x2, x2, x3
+	br	x2				// no return
+
+2:	/* Default to HVC_CALL_HYP. */
 	push	lr, xzr
 
 	/*

Thanks,

James

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#20 lore raw

Re: [PATCH 10/19] arm64: kvm: allows kvm cpu hotplug

Quoted 49 lines · James Morse

Hi!

Quoted 31 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

The current kvm implementation on arm64 does cpu-specific initialization at system boot, and has no way to gracefully shutdown a core in terms of kvm. This prevents, especially, kexec from rebooting the system on a boot core in EL2.

This patch adds a cpu tear-down function and also puts an existing cpu-init code into a separate function, kvm_arch_hardware_disable() and kvm_arch_hardware_enable() respectively.
We don't need arm64-specific cpu hotplug hook any more.

Since this patch modifies common part of code between arm and arm64, one stub definition, __cpu_reset_hyp_mode(), is added on arm side to avoid compiling errors.

arch/arm/kvm/arm.c +0 -3
index e06fd29..e91f80e 100644
 
  #ifdef CONFIG_CPU_PM
  static int hyp_init_cpu_pm_notifier(struct notifier_block *self,
  				    unsigned long cmd,
  				    void *v)
  {
-	if (cmd == CPU_PM_EXIT &&
-	    __hyp_get_vectors() == hyp_default_vectors) {
-		cpu_init_hyp_mode(NULL);

arch/arm/kvm/arm.c static void cpu_init_hyp_mode(void *dummy) · line 1024

Quoted 10 lines
arch/arm/kvm/arm.c +8 -1
+	switch (cmd) {
+	case CPU_PM_ENTER:
+		if (__this_cpu_read(kvm_arm_hardware_enabled))
+			cpu_reset_hyp_mode();
+
  		return NOTIFY_OK;
-	}
+	case CPU_PM_EXIT:
+		if (__this_cpu_read(kvm_arm_hardware_enabled))
+			cpu_init_hyp_mode();

I read this as:

		if (enabled)
			enable();
Quoted 7 lines

What am I missing? Is there a missing '!'?

[/me thinks some more]

I suspect this is trying to be clever: leaving the flag set over a deep-sleep, to indicate that the hardware should be re-enabled when we resume... if so, a comment to that effect would be good.

Yep, I meant so. Will add some comment.

Quoted 30 lines
Quoted 30 lines
arch/arm/kvm/arm.c +5 -1
-	return NOTIFY_DONE;
+		return NOTIFY_OK;
+
+	default:
+		return NOTIFY_DONE;
+	}
  }
 
  static struct notifier_block hyp_init_cpu_pm_nb = {
arch/arm64/include/asm/virt.h +7 -0
index 3070096..bca79f9 100644
@@ -58,9 +58,18 @@
 
  #define HVC_CALL_FUNC 3
 
+/*
+ * HVC_RESET_CPU - Reset cpu in EL2 to initial state.
+ *
+ * @x0: entry address in trampoline code in va
+ * @x1: identical mapping page table in pa
+ */
+
  #define BOOT_CPU_MODE_EL1	(0xe11)
  #define BOOT_CPU_MODE_EL2	(0xe12)
 
Quoted 5 lines

arch/arm64/include/asm/virt.h line 72

Quoted 2 lines
arch/arm64/include/asm/virt.h +2 -0
+#define HVC_RESET_CPU 4
+

Patch 5 added a fancy new way to call arbitrary functions at el2, why not use that? (it would save beating up el1_sync again).

Let me think. I need to detangle some header files.

Quoted 38 lines

I agree the trampoline stuff is complicated - I will try and cook-up a version of this patch for hibernate that does this. (... and comment what I think is happening above while I'm at it)

Quoted 33 lines
arch/arm64/include/asm/virt.h +0 -0
  #ifndef __ASSEMBLY__
 
  /*
arch/arm64/kvm/hyp-init.S +22 -0
index 1d7e502..d909ce2 100644
@@ -140,6 +140,39 @@ merged:
  	eret
  ENDPROC(__kvm_hyp_init)
 
+	/*
+	 * x0: HYP boot pgd
+	 * x1: HYP phys_idmap_start
+	 */
+ENTRY(__kvm_hyp_reset)
+	/* We're in trampoline code in VA, switch back to boot page tables */
+	msr	ttbr0_el2, x0
+	isb
+
+	/* Invalidate the old TLBs */
+	tlbi	alle2
+	dsb	sy
+
+	/* Branch into PA space */
+	adr	x0, 1f
+	bfi	x1, x0, #0, #PAGE_SHIFT
+	br	x1
+
+	/* We're now in idmap, disable MMU */
+1:	mrs	x0, sctlr_el2
+	ldr	x1, =SCTLR_ELx_FLAGS
+	bic	x0, x0, x1		// Clear SCTL_M and etc
Quoted 8 lines

arch/arm64/kvm/hyp-init.S merged: · line 170

Quoted 6 lines
arch/arm64/kvm/hyp-init.S +6 -0
+	msr	sctlr_el2, x0
+	isb
+
+	/* Install stub vectors */
+	adrp	x0, __hyp_stub_vectors
+	add	x0, x0, #:lo12:__hyp_stub_vectors

adr_l ?

OK.

Thanks,
-Takahiro AKASHI

Quoted 52 lines
Quoted 23 lines
arch/arm64/kvm/hyp-init.S +5 -0
+	msr	vbar_el2, x0
+
+	eret
+ENDPROC(__kvm_hyp_reset)
+
  	.ltorg
 
  	.popsection
arch/arm64/kvm/hyp.S +3 -3
index 15b1ef9..ed82dc2 100644
@@ -986,10 +991,27 @@ el1_sync:					// Guest trapped into EL2
  	cmp	x18, #HVC_GET_VECTORS
  	b.ne	1f
  	mrs	x0, vbar_el2
-	b	2f
-
-1:	/* Default to HVC_CALL_HYP. */
+	b	do_eret
 
+	/* jump into trampoline code */
+1:	cmp	x18, #HVC_RESET_CPU

arch/arm64/kvm/hyp.S el1_sync: // Guest trapped into EL2 · line 1007

Quoted 10 lines
arch/arm64/kvm/hyp.S +10 -0
+	b.ne	2f
+	/*
+	 * Entry point is:
+	 *	TRAMPOLINE_VA
+	 *	+ (__kvm_hyp_reset - (__hyp_idmap_text_start & PAGE_MASK))
+	 */
+	adrp	x2, __kvm_hyp_reset
+	add	x2, x2, #:lo12:__kvm_hyp_reset
+	adrp	x3, __hyp_idmap_text_start
+	add	x3, x3, #:lo12:__hyp_idmap_text_start

adr_l ?

arch/arm64/kvm/hyp.S el1_sync: // Guest trapped into EL2 · line 1017

Quoted 10 lines
arch/arm64/kvm/hyp.S +7 -0
+	and	x3, x3, PAGE_MASK
+	sub	x2, x2, x3
+	ldr	x3, =TRAMPOLINE_VA
+	add	x2, x2, x3
+	br	x2				// no return
+
+2:	/* Default to HVC_CALL_HYP. */
  	push	lr, xzr
 
  	/*

Thanks,

James

#21 lore raw

PATCH 11/19 arm64/kexec: Add core kexec support

In reply to Geoff Levand

Add three new files, kexec.h, machine_kexec.c and relocate_kernel.S to the arm64 architecture that add support for the kexec re-boot mechanism (CONFIG_KEXEC) on arm64 platforms.

---
 arch/arm64/Kconfig                  |  10 +++
 arch/arm64/include/asm/kexec.h      |  48 +++++++++++
 arch/arm64/kernel/Makefile          |   2 +
 arch/arm64/kernel/machine_kexec.c   | 158 ++++++++++++++++++++++++++++++++++++
 arch/arm64/kernel/relocate_kernel.S | 131 ++++++++++++++++++++++++++++++
 include/uapi/linux/kexec.h          |   1 +
 6 files changed, 350 insertions(+)
 create mode 100644 arch/arm64/include/asm/kexec.h
 create mode 100644 arch/arm64/kernel/machine_kexec.c
 create mode 100644 arch/arm64/kernel/relocate_kernel.S
arch/arm64/Kconfig +10 -0
index 871f217..b7d0078 100644
@@ -556,6 +556,16 @@ config SECCOMP
 	  and the task is only allowed to execute a few safe syscalls
 	  defined by each seccomp mode.
 
+config KEXEC
+	depends on PM_SLEEP_SMP
+	select KEXEC_CORE
+	bool "kexec system call"
+	---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.
+
 config XEN_DOM0
 	def_bool y
 	depends on XEN
arch/arm64/include/asm/kexec.h new file +48 -0

48 lines not on this page · raw message

arch/arm64/kernel/Makefile +2 -0
index 474691f..f68420d 100644
@@ -41,6 +41,8 @@ arm64-obj-$(CONFIG_EFI)			+= efi.o efi-entry.stub.o
 arm64-obj-$(CONFIG_PCI)			+= pci.o
 arm64-obj-$(CONFIG_ARMV8_DEPRECATED)	+= armv8_deprecated.o
 arm64-obj-$(CONFIG_ACPI)		+= acpi.o
+arm64-obj-$(CONFIG_KEXEC)		+= machine_kexec.o relocate_kernel.o	\
+					   cpu-reset.o
 
 obj-y					+= $(arm64-obj-y) vdso/
 obj-m					+= $(arm64-obj-m)
arch/arm64/kernel/machine_kexec.c new file +158 -0

158 lines not on this page · raw message

arch/arm64/kernel/relocate_kernel.S new file +131 -0

131 lines not on this page · raw message

include/uapi/linux/kexec.h +1 -0
index 99048e5..aae5ebf 100644
@@ -39,6 +39,7 @@
 #define KEXEC_ARCH_SH      (42 << 16)
 #define KEXEC_ARCH_MIPS_LE (10 << 16)
 #define KEXEC_ARCH_MIPS    ( 8 << 16)
+#define KEXEC_ARCH_AARCH64 (183 << 16)
 
 /* The artificial cap on the number of segments passed to kexec_load. */
 #define KEXEC_SEGMENT_MAX 16
Signature · 8 lines
2.5.0



_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#22 lore raw

PATCH 12/19 arm64/kexec: Enable kexec in the arm64 defconfig

In reply to Geoff Levand
---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
index bdd7aa3..0470fdf 100644
@@ -58,6 +58,7 @@ CONFIG_PREEMPT=y
 CONFIG_KSM=y
 CONFIG_TRANSPARENT_HUGEPAGE=y
 CONFIG_CMA=y
+CONFIG_KEXEC=y
 CONFIG_CMDLINE="console=ttyAMA0"
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
 CONFIG_COMPAT=y
Signature · 8 lines
2.5.0



_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#23 lore raw

PATCH 13/19 arm64/kexec: Add pr_debug output

In reply to Geoff Levand

To aid in debugging kexec problems or when adding new functionality to kexec add a new routine kexec_image_info() and several inline pr_debug statements.

---
 arch/arm64/kernel/machine_kexec.c | 70 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 68 insertions(+), 2 deletions(-)
arch/arm64/kernel/machine_kexec.c +68 -2
index 9379d31..a375268 100644
@@ -11,6 +11,7 @@
 
 #include <linux/highmem.h>
 #include <linux/kexec.h>
+#include <linux/libfdt_env.h>
 #include <linux/of_fdt.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
@@ -26,6 +27,50 @@ extern const unsigned long arm64_relocate_new_kernel_size;
 
 static unsigned long kimage_start;
 
+/**
+ * kexec_is_dtb - Helper routine to check the device tree header signature.
+ */
+static bool kexec_is_dtb(const void *dtb)
+{
+	__be32 magic;
+
+	if (get_user(magic, (__be32 *)dtb))
+		return false;
+
+	return fdt32_to_cpu(magic) == OF_DT_HEADER;
+}
+
+/**
+ * kexec_image_info - For debugging output.
+ */
+#define kexec_image_info(_i) _kexec_image_info(__func__, __LINE__, _i)
+static void _kexec_image_info(const char *func, int line,
+	const struct kimage *kimage)
+{
+	unsigned long i;
+
+#ifndef DEBUG
+	return;
+#endif
+	pr_debug("%s:%d:\n", func, line);
+	pr_debug("  kexec kimage info:\n");
+	pr_debug("    type:        %d\n", kimage->type);
+	pr_debug("    start:       %lx\n", kimage->start);
+	pr_debug("    head:        %lx\n", kimage->head);
+	pr_debug("    nr_segments: %lu\n", kimage->nr_segments);
+
+	for (i = 0; i < kimage->nr_segments; i++) {
+		pr_debug("      segment[%lu]: %016lx - %016lx, 0x%lx bytes, %lu pages%s\n",
+			i,
+			kimage->segment[i].mem,
+			kimage->segment[i].mem + kimage->segment[i].memsz,
+			kimage->segment[i].memsz,
+			kimage->segment[i].memsz /  PAGE_SIZE,
+			(kexec_is_dtb(kimage->segment[i].buf) ?
+				", dtb segment" : ""));
+	}
+}
+
 void machine_kexec_cleanup(struct kimage *kimage)
 {
 	/* Empty routine needed to avoid build errors. */
@@ -39,6 +84,8 @@ void machine_kexec_cleanup(struct kimage *kimage)
 int machine_kexec_prepare(struct kimage *kimage)
 {
 	kimage_start = kimage->start;
+	kexec_image_info(kimage);
+
 	return 0;
 }
 
@@ -81,10 +128,10 @@ static void kexec_segment_flush(const struct kimage *kimage)
 {
 	unsigned long i;
 
-	pr_devel("%s:\n", __func__);
+	pr_debug("%s:\n", __func__);
 
 	for (i = 0; i < kimage->nr_segments; i++) {
-		pr_devel("  segment[%lu]: %016lx - %016lx, %lx bytes, %lu pages\n",
+		pr_debug("  segment[%lu]: %016lx - %016lx, 0x%lx bytes, %lu pages\n",
 			i,
 			kimage->segment[i].mem,
 			kimage->segment[i].mem + kimage->segment[i].memsz,
@@ -111,6 +158,25 @@ void machine_kexec(struct kimage *kimage)
 	reboot_code_buffer_phys = page_to_phys(kimage->control_code_page);
 	reboot_code_buffer = kmap(kimage->control_code_page);
 
+	kexec_image_info(kimage);
+
+	pr_debug("%s:%d: control_code_page:        %p\n", __func__, __LINE__,
+		kimage->control_code_page);
+	pr_debug("%s:%d: reboot_code_buffer_phys:  %pa\n", __func__, __LINE__,
+		&reboot_code_buffer_phys);
+	pr_debug("%s:%d: reboot_code_buffer:       %p\n", __func__, __LINE__,
+		reboot_code_buffer);
+	pr_debug("%s:%d: relocate_new_kernel:      %p\n", __func__, __LINE__,
+		arm64_relocate_new_kernel);
+	pr_debug("%s:%d: relocate_new_kernel_size: 0x%lx(%lu) bytes\n",
+		__func__, __LINE__, arm64_relocate_new_kernel_size,
+		arm64_relocate_new_kernel_size);
+
+	pr_debug("%s:%d: kimage_head:              %lx\n", __func__, __LINE__,
+		kimage->head);
+	pr_debug("%s:%d: kimage_start:             %lx\n", __func__, __LINE__,
+		kimage_start);
+
 	/*
 	 * Copy arm64_relocate_new_kernel to the reboot_code_buffer for use
 	 * after the kernel is shut down.
Signature · 8 lines
2.5.0



_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#24 lore raw

PATCH 14/19 arm64: kdump: reserve memory for crash dump kernel

In reply to Geoff Levand

From: AKASHI Takahiro <[email protected]>

On primary kernel, the memory region used by crash dump kernel must be specified by "crashkernel=" boot parameter. reserve_crashkernel() will allocate and reserve the region for later use.

User space tools will be able to find the region marked as "Crash kernel" in /proc/iomem.

---
 arch/arm64/kernel/setup.c |  7 +++++-
 arch/arm64/mm/init.c      | 57 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 1 deletion(-)
arch/arm64/kernel/setup.c +6 -1
index 8119479..293cee2 100644
@@ -31,7 +31,6 @@
 #include <linux/screen_info.h>
 #include <linux/init.h>
 #include <linux/kexec.h>
-#include <linux/crash_dump.h>
 #include <linux/root_dev.h>
 #include <linux/cpu.h>
 #include <linux/interrupt.h>
@@ -221,6 +220,12 @@ static void __init request_standard_resources(void)
 		    kernel_data.end <= res->end)
 			request_resource(res, &kernel_data);
 	}
+
+#ifdef CONFIG_KEXEC_CORE
+	/* User space tools will find "Crash kernel" region in /proc/iomem. */
+	if (crashk_res.end)
+		insert_resource(&iomem_resource, &crashk_res);
+#endif
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
arch/arm64/mm/init.c +57 -0

75 lines not on this page · raw message

Signature · 8 lines
2.5.0



_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#25 lore raw

PATCH 15/19 arm64: kdump: implement machine_crash_shutdown()

In reply to Geoff Levand

From: AKASHI Takahiro <[email protected]>

kdump calls machine_crash_shutdown() to shut down non-boot cpus and save registers' status in per-cpu ELF notes before starting the crash dump kernel. See kernel_kexec().

ipi_cpu_stop() is a bit modified and used to support this behavior.

---
 arch/arm64/include/asm/kexec.h    | 47 +++++++++++++++++++++++++++-
 arch/arm64/kernel/machine_kexec.c | 65 +++++++++++++++++++++++++++++++++++++--
 arch/arm64/kernel/smp.c           | 18 ++++++++---
 3 files changed, 123 insertions(+), 7 deletions(-)
arch/arm64/include/asm/kexec.h +46 -1
index 04744dc..3dffb1d 100644
@@ -30,6 +30,21 @@
 
 #ifndef __ASSEMBLY__
 
+extern bool in_crash_kexec;
+
+static inline bool is_in_crash_kexec(void)
+{
+#ifdef CONFIG_KEXEC_CORE
+	return in_crash_kexec;
+#else
+	return false;
+#endif
+}
+
+#ifndef CONFIG_KEXEC_CORE
+#define crash_save_cpu(regs, cpu)
+#endif
+
 /**
  * crash_setup_regs() - save registers for the panic kernel
  *
@@ -40,7 +55,37 @@
 static inline void crash_setup_regs(struct pt_regs *newregs,
 				    struct pt_regs *oldregs)
 {
-	/* Empty routine needed to avoid build errors. */
+	if (oldregs) {
+		memcpy(newregs, oldregs, sizeof(*newregs));
+	} else {
+		__asm__ __volatile__ (
+			"stp	 x0,   x1, [%3, #16 *  0]\n"
+			"stp	 x2,   x3, [%3, #16 *  1]\n"
+			"stp	 x4,   x5, [%3, #16 *  2]\n"
+			"stp	 x6,   x7, [%3, #16 *  3]\n"
+			"stp	 x8,   x9, [%3, #16 *  4]\n"
+			"stp	x10,  x11, [%3, #16 *  5]\n"
+			"stp	x12,  x13, [%3, #16 *  6]\n"
+			"stp	x14,  x15, [%3, #16 *  7]\n"
+			"stp	x16,  x17, [%3, #16 *  8]\n"
+			"stp	x18,  x19, [%3, #16 *  9]\n"
+			"stp	x20,  x21, [%3, #16 * 10]\n"
+			"stp	x22,  x23, [%3, #16 * 11]\n"
+			"stp	x24,  x25, [%3, #16 * 12]\n"
+			"stp	x26,  x27, [%3, #16 * 13]\n"
+			"stp	x28,  x29, [%3, #16 * 14]\n"
+			"str	x30,	   [%3, #16 * 15]\n"
+			"mov	%0, sp\n"
+			"adr	%1, 1f\n"
+			"mrs	%2, spsr_el1\n"
+		"1:"
+			: "=r" (newregs->sp),
+			  "=r" (newregs->pc),
+			  "=r" (newregs->pstate)
+			: "r"  (&newregs->regs)
+			: "memory"
+		);
+	}
 }
 
 #endif /* __ASSEMBLY__ */
arch/arm64/kernel/machine_kexec.c +63 -2

88 lines not on this page · raw message

arch/arm64/kernel/smp.c +14 -4
index b1adc51..aa45c21 100644
@@ -37,6 +37,7 @@
 #include <linux/completion.h>
 #include <linux/of.h>
 #include <linux/irq_work.h>
+#include <linux/kexec.h>
 
 #include <asm/alternative.h>
 #include <asm/atomic.h>
@@ -44,6 +45,7 @@
 #include <asm/cpu.h>
 #include <asm/cputype.h>
 #include <asm/cpu_ops.h>
+#include <asm/kexec.h>
 #include <asm/mmu_context.h>
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
@@ -54,6 +56,8 @@
 #include <asm/ptrace.h>
 #include <asm/virt.h>
 
+#include "cpu-reset.h"
+
 #define CREATE_TRACE_POINTS
 #include <trace/events/ipi.h>
 
@@ -683,10 +687,16 @@ static DEFINE_RAW_SPINLOCK(stop_lock);
 /*
  * ipi_cpu_stop - handle IPI from smp_send_stop()
  */
-static void ipi_cpu_stop(unsigned int cpu)
+static void ipi_cpu_stop(unsigned int cpu, struct pt_regs *regs)
 {
-	if (system_state == SYSTEM_BOOTING ||
-	    system_state == SYSTEM_RUNNING) {
+	if (is_in_crash_kexec()) {
+		crash_save_cpu(regs, cpu);
+		/*
+		 * printing messages at panic may slow down the shutdown.
+		 * So don't fall through dump_stack().
+		 */
+	} else if (system_state == SYSTEM_BOOTING ||
+			system_state == SYSTEM_RUNNING) {
 		raw_spin_lock(&stop_lock);
 		pr_crit("CPU%u: stopping\n", cpu);
 		dump_stack();
@@ -727,7 +737,7 @@ void handle_IPI(int ipinr, struct pt_regs *regs)
 
 	case IPI_CPU_STOP:
 		irq_enter();
-		ipi_cpu_stop(cpu);
+		ipi_cpu_stop(cpu, regs);
 		irq_exit();
 		break;
 
Signature · 8 lines
2.5.0



_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#26 lore raw

PATCH 16/19 arm64: kdump: add kdump support

In reply to Geoff Levand

From: AKASHI Takahiro <[email protected]>

On crash dump kernel, all the information about primary kernel's core image is available in elf core header specified by "elfcorehdr=" boot parameter. reserve_elfcorehdr() will set aside the region to avoid any corruption by crash dump kernel.

Crash dump kernel will access the system memory of primary kernel via copy_oldmem_page(), which reads one page by ioremap'ing it since it does not reside in linear mapping on crash dump kernel.
Please note that we should add "mem=X[MG]" boot parameter to limit the memory size and avoid the following assertion at ioremap():

	if (WARN_ON(pfn_valid(__phys_to_pfn(phys_addr))))
		return NULL;

when accessing any pages beyond the usable memories of crash dump kernel.

We also need our own elfcorehdr_read() here since the weak definition of elfcorehdr_read() utilizes copy_oldmem_page() and will hit the assertion above on arm64.

---
 arch/arm64/Kconfig             | 11 +++++++
 arch/arm64/kernel/Makefile     |  1 +
 arch/arm64/kernel/crash_dump.c | 71 ++++++++++++++++++++++++++++++++++++++++++
 arch/arm64/mm/init.c           | 32 +++++++++++++++++++
 4 files changed, 115 insertions(+)
 create mode 100644 arch/arm64/kernel/crash_dump.c
arch/arm64/Kconfig +11 -0
index b7d0078..31901d0 100644
@@ -566,6 +566,17 @@ config KEXEC
 	  but it is independent of the system firmware.   And like a reboot
 	  you can start any kernel with it, not just Linux.
 
+config CRASH_DUMP
+	bool "Build kdump crash kernel"
+	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/kdump/kdump.txt
+
 config XEN_DOM0
 	def_bool y
 	depends on XEN
arch/arm64/kernel/Makefile +1 -0
index f68420d..a08b054 100644
@@ -43,6 +43,7 @@ arm64-obj-$(CONFIG_ARMV8_DEPRECATED)	+= armv8_deprecated.o
 arm64-obj-$(CONFIG_ACPI)		+= acpi.o
 arm64-obj-$(CONFIG_KEXEC)		+= machine_kexec.o relocate_kernel.o	\
 					   cpu-reset.o
+arm64-obj-$(CONFIG_CRASH_DUMP)		+= crash_dump.o
 
 obj-y					+= $(arm64-obj-y) vdso/
 obj-m					+= $(arm64-obj-m)
arch/arm64/kernel/crash_dump.c new file +71 -0

71 lines not on this page · raw message

arch/arm64/mm/init.c +32 -0
index a8eae6b..7398a6b 100644
@@ -35,6 +35,7 @@
 #include <linux/efi.h>
 #include <linux/swiotlb.h>
 #include <linux/kexec.h>
+#include <linux/crash_dump.h>
 
 #include <asm/fixmap.h>
 #include <asm/memory.h>
@@ -119,6 +120,36 @@ static void __init reserve_crashkernel(void)
 }
 #endif /* CONFIG_KEXEC_CORE */
 
+#ifdef CONFIG_CRASH_DUMP
+/*
+ * reserve_elfcorehdr() - reserves memory for elf core header
+ *
+ * This function reserves elf core header given in "elfcorehdr=" kernel
+ * command line parameter. This region contains all the information about
+ * primary kernel's core image and is used by a dump capture kernel to
+ * access the system memory on primary kernel.
+ */
+static void __init reserve_elfcorehdr(void)
+{
+	if (!elfcorehdr_size)
+		return;
+
+	if (memblock_is_region_reserved(elfcorehdr_addr, elfcorehdr_size)) {
+		pr_warn("elfcorehdr is overlapped\n");
+		return;
+	}
+
+	memblock_reserve(elfcorehdr_addr, elfcorehdr_size);
+
+	pr_info("Reserving %lldKB of memory at 0x%llx for elfcorehdr\n",
+		elfcorehdr_size >> 10, elfcorehdr_addr);
+}
+#else
+static void __init reserve_elfcorehdr(void)
+{
+	;
+}
+#endif /* CONFIG_CRASH_DUMP */
 /*
  * Return the maximum physical address for ZONE_DMA (DMA_BIT_MASK(32)). It
  * currently assumes that for memory starting above 4G, 32-bit devices will
@@ -227,6 +258,7 @@ void __init arm64_memblock_init(void)
 #ifdef CONFIG_KEXEC_CORE
 	reserve_crashkernel();
 #endif
+	reserve_elfcorehdr();
 
 	early_init_fdt_scan_reserved_mem();
 
Signature · 8 lines
2.5.0



_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#27 lore raw

Re: [PATCH 16/19] arm64: kdump: add kdump support

Hi!

Quoted 12 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

On crash dump kernel, all the information about primary kernel's core image is available in elf core header specified by "elfcorehdr=" boot parameter. reserve_elfcorehdr() will set aside the region to avoid any corruption by crash dump kernel.

Crash dump kernel will access the system memory of primary kernel via copy_oldmem_page(), which reads one page by ioremap'ing it since it does not reside in linear mapping on crash dump kernel.
Please note that we should add "mem=X[MG]" boot parameter to limit the memory size and avoid the following assertion at ioremap():

Quoted 7 lines
	if (WARN_ON(pfn_valid(__phys_to_pfn(phys_addr))))
		return NULL;

when accessing any pages beyond the usable memories of crash dump kernel.

We also need our own elfcorehdr_read() here since the weak definition of elfcorehdr_read() utilizes copy_oldmem_page() and will hit the assertion above on arm64.

How does this work for a different-endian crash kernel?

It looks like fs/proc/vmcore.c:parse_crash_elf64_headers() does some validation on the elf-headers that doesn't look like it will work if elfcorehdr:endian != kernel:endian.

Is it worth preventing this corner case by getting kexec-tools to prevent linux with a different endianness being loaded as a kdump kernel?

Thanks,

James

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#28 lore raw

Re: [PATCH 16/19] arm64: kdump: add kdump support

James,

Quoted 23 lines · James Morse

Hi!

Quoted 12 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

On crash dump kernel, all the information about primary kernel's core image is available in elf core header specified by "elfcorehdr=" boot parameter. reserve_elfcorehdr() will set aside the region to avoid any corruption by crash dump kernel.

Crash dump kernel will access the system memory of primary kernel via copy_oldmem_page(), which reads one page by ioremap'ing it since it does not reside in linear mapping on crash dump kernel.
Please note that we should add "mem=X[MG]" boot parameter to limit the memory size and avoid the following assertion at ioremap():

Quoted 7 lines
	if (WARN_ON(pfn_valid(__phys_to_pfn(phys_addr))))
		return NULL;

when accessing any pages beyond the usable memories of crash dump kernel.

We also need our own elfcorehdr_read() here since the weak definition of elfcorehdr_read() utilizes copy_oldmem_page() and will hit the assertion above on arm64.

Quoted 5 lines

How does this work for a different-endian crash kernel?

It looks like fs/proc/vmcore.c:parse_crash_elf64_headers() does some validation on the elf-headers that doesn't look like it will work if elfcorehdr:endian != kernel:endian.

Good point!

Quoted 2 lines

Is it worth preventing this corner case by getting kexec-tools to prevent linux with a different endianness being loaded as a kdump kernel?

It may be, but I think that people should always check whether or not kdump will work in their environment before puting the system in practical use.

(I know the check costs almost nothing though.)

Thanks,
-Takahiro AKASHI

Quoted 6 lines

Thanks,

James

#29 lore raw

PATCH 17/19 arm64: kdump: enable kdump in the arm64 defconfig

In reply to Geoff Levand

From: AKASHI Takahiro <[email protected]>

---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
index 0470fdf..6dc3d00 100644
@@ -59,6 +59,7 @@ CONFIG_KSM=y
 CONFIG_TRANSPARENT_HUGEPAGE=y
 CONFIG_CMA=y
 CONFIG_KEXEC=y
+CONFIG_CRASH_DUMP=y
 CONFIG_CMDLINE="console=ttyAMA0"
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
 CONFIG_COMPAT=y
Signature · 8 lines
2.5.0



_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#30 lore raw

PATCH 18/19 arm64: kdump: update a kernel doc

In reply to Geoff Levand

From: AKASHI Takahiro <[email protected]>

This patch adds arch specific descriptions about kdump usage on arm64 to kdump.txt.

---
 Documentation/kdump/kdump.txt | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/kdump/kdump.txt +22 -1
index bc4bd5a..36cf978 100644
@@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to
 a remote system.
 
 Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
-s390x and arm architectures.
+s390x, arm and arm64 architectures.
 
 When the system kernel boots, it reserves a small section of memory for
 the dump-capture kernel. This ensures that ongoing Direct Memory Access
@@ -249,6 +249,20 @@ Dump-capture kernel config options (Arch Dependent, arm)
 
     AUTO_ZRELADDR=y
 
+Dump-capture kernel config options (Arch Dependent, arm64)
+----------------------------------------------------------
+
+1) The maximum memory size on the dump-capture kernel must be limited by
+   specifying:
+
+   mem=X[MG]
+
+   where X should be less than or equal to the size in "crashkernel="
+   boot parameter. Kexec-tools will automatically add this.
+
+2) Currently, kvm will not be enabled on the dump-capture kernel even
+   if it is configured.
+
 Extended crashkernel syntax
 ===========================
 
@@ -312,6 +326,8 @@ Boot into System Kernel
    any space below the alignment point may be overwritten by the dump-capture kernel,
    which means it is possible that the vmcore is not that precise as expected.
 
+   On arm64, use "crashkernel=Y[@X]".  Note that the start address of
+   the kernel, X if explicitly specified, must be aligned to 2MiB (0x200000).
 
 Load the Dump-capture Kernel
 ============================
@@ -334,6 +350,8 @@ For s390x:
 	- Use image or bzImage
 For arm:
 	- Use zImage
+For arm64:
+	- Use vmlinux or Image
 
 If you are using a uncompressed vmlinux image then use following command
 to load dump-capture kernel.
@@ -377,6 +395,9 @@ For s390x:
 For arm:
 	"1 maxcpus=1 reset_devices"
 
+For arm64:
+	"1 mem=X[MG] maxcpus=1 reset_devices"
+
 Notes on loading the dump-capture kernel:
 
 * By default, the ELF headers are stored in ELF64 format to support
Signature · 8 lines
2.5.0



_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
reviewer
#31 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 27 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

This patch adds arch specific descriptions about kdump usage on arm64 to kdump.txt.

---
 Documentation/kdump/kdump.txt | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/kdump/kdump.txt +1 -1
index bc4bd5a..36cf978 100644
@@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to
 a remote system.
 
 Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
-s390x and arm architectures.
+s390x, arm and arm64 architectures.
 
 When the system kernel boots, it reserves a small section of memory for
 the dump-capture kernel. This ensures that ongoing Direct Memory Access
@@ -249,6 +249,20 @@ Dump-capture kernel config options (Arch Dependent, arm)
 
     AUTO_ZRELADDR=y
 

Documentation/kdump/kdump.txt Dump-capture kernel config options (Arch Dependent, arm) · line 261

Quoted 10 lines
Documentation/kdump/kdump.txt +10 -0
+Dump-capture kernel config options (Arch Dependent, arm64)
+----------------------------------------------------------
+
+1) The maximum memory size on the dump-capture kernel must be limited by
+   specifying:
+
+   mem=X[MG]
+
+   where X should be less than or equal to the size in "crashkernel="
+   boot parameter. Kexec-tools will automatically add this.

This is extremely fragile, and will trivially fail when the kernel can be loaded anywhere (see [1]).

We must explicitly describe the set of regions the crash kernel may use (i.e. we need base and size). NAK in the absence of that.

Thanks,
Mark.

Quoted 39 lines
Documentation/kdump/kdump.txt +11 -0
+
+2) Currently, kvm will not be enabled on the dump-capture kernel even
+   if it is configured.
+
 Extended crashkernel syntax
 ===========================
 
@@ -312,6 +326,8 @@ Boot into System Kernel
    any space below the alignment point may be overwritten by the dump-capture kernel,
    which means it is possible that the vmcore is not that precise as expected.
 
+   On arm64, use "crashkernel=Y[@X]".  Note that the start address of
+   the kernel, X if explicitly specified, must be aligned to 2MiB (0x200000).
 
 Load the Dump-capture Kernel
 ============================
@@ -334,6 +350,8 @@ For s390x:
 	- Use image or bzImage
 For arm:
 	- Use zImage
+For arm64:
+	- Use vmlinux or Image
 
 If you are using a uncompressed vmlinux image then use following command
 to load dump-capture kernel.
@@ -377,6 +395,9 @@ For s390x:
 For arm:
 	"1 maxcpus=1 reset_devices"
 
+For arm64:
+	"1 mem=X[MG] maxcpus=1 reset_devices"
+
 Notes on loading the dump-capture kernel:
 
 * By default, the ELF headers are stored in ELF64 format to support
Signature · 1 line
2.5.0

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-January/398527.html

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#32 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 28 lines · Mark Rutland
Quoted 27 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

This patch adds arch specific descriptions about kdump usage on arm64 to kdump.txt.

---
  Documentation/kdump/kdump.txt | 23 ++++++++++++++++++++++-
  1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/kdump/kdump.txt +1 -1
index bc4bd5a..36cf978 100644
@@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to
  a remote system.
 
  Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
-s390x and arm architectures.
+s390x, arm and arm64 architectures.
 
  When the system kernel boots, it reserves a small section of memory for
  the dump-capture kernel. This ensures that ongoing Direct Memory Access
@@ -249,6 +249,20 @@ Dump-capture kernel config options (Arch Dependent, arm)
 
      AUTO_ZRELADDR=y
 
Quoted 14 lines

Documentation/kdump/kdump.txt Dump-capture kernel config options (Arch Dependent, arm) · line 261

Quoted 10 lines
Documentation/kdump/kdump.txt +10 -0
+Dump-capture kernel config options (Arch Dependent, arm64)
+----------------------------------------------------------
+
+1) The maximum memory size on the dump-capture kernel must be limited by
+   specifying:
+
+   mem=X[MG]
+
+   where X should be less than or equal to the size in "crashkernel="
+   boot parameter. Kexec-tools will automatically add this.

This is extremely fragile, and will trivially fail when the kernel can be loaded anywhere (see [1]).

As I said before, this restriction also exists on arm, but I understand that recent Ard's patches break it.

Quoted 2 lines

We must explicitly describe the set of regions the crash kernel may use (i.e. we need base and size). NAK in the absence of that.

There seem to exist several approaches:
(a) use a device-tree property, "linux,usable-memory", in addition to "reg" under "memory" node
(b) use a kernel's early parameter, "memmap=nn[@#$]ss"

Power PC takes (a), while this does not work on efi-started kernel because dtb has no "memory" nodes under efi.
X86 takes (b). If we take this, we will need to overwrite a weak early_init_dt_add_memory().
(I thought that this approach was not smart as we have three different ways to specify memory regions, dtb, efi and this kernel parameter.)

Do you have any other ideas?

Thanks,
-Takahiro AKASHI

Quoted 45 lines

Thanks,
Mark.

Quoted 36 lines
Documentation/kdump/kdump.txt +11 -1
+
+2) Currently, kvm will not be enabled on the dump-capture kernel even
+   if it is configured.
+
  Extended crashkernel syntax
  ===========================
 
@@ -312,6 +326,8 @@ Boot into System Kernel
     any space below the alignment point may be overwritten by the dump-capture kernel,
     which means it is possible that the vmcore is not that precise as expected.
 
+   On arm64, use "crashkernel=Y[@X]".  Note that the start address of
+   the kernel, X if explicitly specified, must be aligned to 2MiB (0x200000).
 
  Load the Dump-capture Kernel
  ============================
@@ -334,6 +350,8 @@ For s390x:
  	- Use image or bzImage
  For arm:
  	- Use zImage
+For arm64:
+	- Use vmlinux or Image
 
  If you are using a uncompressed vmlinux image then use following command
  to load dump-capture kernel.
@@ -377,6 +395,9 @@ For s390x:
  For arm:
  	"1 maxcpus=1 reset_devices"
 
+For arm64:
+	"1 mem=X[MG] maxcpus=1 reset_devices"
+
  Notes on loading the dump-capture kernel:
 
  * By default, the ELF headers are stored in ELF64 format to support
--
Quoted 3 lines

2.5.0

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-January/398527.html

reviewer
#33 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 44 lines · AKASHI Takahiro
Quoted 28 lines · Mark Rutland
Quoted 27 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

This patch adds arch specific descriptions about kdump usage on arm64 to kdump.txt.

---
 Documentation/kdump/kdump.txt | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/kdump/kdump.txt +1 -1
index bc4bd5a..36cf978 100644
@@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to
 a remote system.
 
 Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
-s390x and arm architectures.
+s390x, arm and arm64 architectures.
 
 When the system kernel boots, it reserves a small section of memory for
 the dump-capture kernel. This ensures that ongoing Direct Memory Access
@@ -249,6 +249,20 @@ Dump-capture kernel config options (Arch Dependent, arm)
 
     AUTO_ZRELADDR=y
 
Quoted 14 lines

Documentation/kdump/kdump.txt Dump-capture kernel config options (Arch Dependent, arm) · line 261

Quoted 10 lines
Documentation/kdump/kdump.txt +10 -0
+Dump-capture kernel config options (Arch Dependent, arm64)
+----------------------------------------------------------
+
+1) The maximum memory size on the dump-capture kernel must be limited by
+   specifying:
+
+   mem=X[MG]
+
+   where X should be less than or equal to the size in "crashkernel="
+   boot parameter. Kexec-tools will automatically add this.

This is extremely fragile, and will trivially fail when the kernel can be loaded anywhere (see [1]).

Quoted 8 lines

As I said before, this restriction also exists on arm, but I understand that recent Ard's patches break it.

Quoted 2 lines

We must explicitly describe the set of regions the crash kernel may use (i.e. we need base and size). NAK in the absence of that.

There seem to exist several approaches:
(a) use a device-tree property, "linux,usable-memory", in addition to "reg"

I'm not opposed to the idea of a DT property, though I think that should live under /chosen.

I see that "linux,usable-memory" exists already, though I'm confused as to exactly what it is for as there is no documentation (neither in the kernel nor in ePAPR). It's also painful to alter multiple memory nodes to use that, and I can see that going wrong.

Quoted 2 lines

under "memory" node
(b) use a kernel's early parameter, "memmap=nn[@#$]ss"

I'm not too keen on this, as I think it's fragile, and logically somewhat distinct from what mem= is for (a best effort testing tool).

Quoted 2 lines

Power PC takes (a), while this does not work on efi-started kernel because dtb has no "memory" nodes under efi.

A property under /chosen would work for EFI too.

Quoted 4 lines

X86 takes (b). If we take this, we will need to overwrite a weak early_init_dt_add_memory().
(I thought that this approach was not smart as we have three different ways to specify memory regions, dtb, efi and this kernel parameter.)

I'm not sure that's a big problem. We may be able to make this generic, also.

We don't necessarily need a weak add memory function if we can guarantee nothing gets memblock_alloc'd before we carve it out.

Something like the nomap stuff Ard put together might be useful here.

Thanks,
Mark.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#34 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 48 lines · Mark Rutland
Quoted 47 lines · AKASHI Takahiro
Quoted 28 lines · Mark Rutland
Quoted 27 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

This patch adds arch specific descriptions about kdump usage on arm64 to kdump.txt.

---
  Documentation/kdump/kdump.txt | 23 ++++++++++++++++++++++-
  1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/kdump/kdump.txt +1 -1
index bc4bd5a..36cf978 100644
@@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to
  a remote system.
 
  Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
-s390x and arm architectures.
+s390x, arm and arm64 architectures.
 
  When the system kernel boots, it reserves a small section of memory for
  the dump-capture kernel. This ensures that ongoing Direct Memory Access
@@ -249,6 +249,20 @@ Dump-capture kernel config options (Arch Dependent, arm)
 
      AUTO_ZRELADDR=y
 
Quoted 14 lines

Documentation/kdump/kdump.txt Dump-capture kernel config options (Arch Dependent, arm) · line 261

Quoted 10 lines
Documentation/kdump/kdump.txt +10 -0
+Dump-capture kernel config options (Arch Dependent, arm64)
+----------------------------------------------------------
+
+1) The maximum memory size on the dump-capture kernel must be limited by
+   specifying:
+
+   mem=X[MG]
+
+   where X should be less than or equal to the size in "crashkernel="
+   boot parameter. Kexec-tools will automatically add this.

This is extremely fragile, and will trivially fail when the kernel can be loaded anywhere (see [1]).

As I said before, this restriction also exists on arm, but I understand that recent Ard's patches break it.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

We must explicitly describe the set of regions the crash kernel may use (i.e. we need base and size). NAK in the absence of that.

There seem to exist several approaches:
(a) use a device-tree property, "linux,usable-memory", in addition to "reg"

I'm not opposed to the idea of a DT property, though I think that should live under /chosen.

In fact, powerpc uses another property, "linux,crashkernel-base(& size)", under /chosen in order for the *1st kernel* to export info about a memory region for the 2nd(crash dump) kernel to user apps (kexec-tools).

Quoted 3 lines

I see that "linux,usable-memory" exists already, though I'm confused as to exactly what it is for as there is no documentation (neither in the kernel nor in ePAPR).

For example,

   memory at 0x80000000 {
     reg = <0x0 0x80000000 0x0 0x80000000>;
     linux,usable-memory = <0x0 0x8c000000 0x0 0x4000000>;

}
There exists 2GB memory available on the system, but the last 64MB can be used as a system ram. See early_init_dt_scan_memory() in fdt.c.

Quoted 2 lines

It's also painful to alter multiple memory nodes
to use that, and I can see that going wrong.

Yeah, I implemented this feature in my old versions experimentally, but didn't like it as we had to touch all the memory nodes.

Quoted 5 lines
Quoted 2 lines

under "memory" node
(b) use a kernel's early parameter, "memmap=nn[@#$]ss"

I'm not too keen on this, as I think it's fragile, and logically somewhat distinct from what mem= is for (a best effort testing tool).

I'm not sure whether it is fragile, and contrary to x86, as Dave described, I think we will only need a single memmap= on arm64 as efi's mem map table is accessible even on the crash kernel.

Quoted 10 lines
Quoted 2 lines

Power PC takes (a), while this does not work on efi-started kernel because dtb has no "memory" nodes under efi.

A property under /chosen would work for EFI too.

Quoted 4 lines

X86 takes (b). If we take this, we will need to overwrite a weak early_init_dt_add_memory().
(I thought that this approach was not smart as we have three different ways to specify memory regions, dtb, efi and this kernel parameter.)

Quoted 7 lines

I'm not sure that's a big problem. We may be able to make this generic, also.

We don't necessarily need a weak add memory function if we can guarantee nothing gets memblock_alloc'd before we carve it out.

Something like the nomap stuff Ard put together might be useful here.

I'm afraid it doesn't work.
It doesn't matter whether it is linearly mapped or not. We should prevent any part of memory regions used by the 1st kernel from being reclaimed by memblock_alloc() and others.
Or do you mean we can introduce another memblock flag?

-Takahiro AKASHI

Quoted 3 lines

Thanks,
Mark.

reviewer
#35 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 55 lines · AKASHI Takahiro
Quoted 54 lines · Mark Rutland
Quoted 52 lines · AKASHI Takahiro
Quoted 28 lines · Mark Rutland
Quoted 27 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

This patch adds arch specific descriptions about kdump usage on arm64 to kdump.txt.

---
 Documentation/kdump/kdump.txt | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/kdump/kdump.txt +1 -1
index bc4bd5a..36cf978 100644
@@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to
 a remote system.
 
 Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
-s390x and arm architectures.
+s390x, arm and arm64 architectures.
 
 When the system kernel boots, it reserves a small section of memory for
 the dump-capture kernel. This ensures that ongoing Direct Memory Access
@@ -249,6 +249,20 @@ Dump-capture kernel config options (Arch Dependent, arm)
 
     AUTO_ZRELADDR=y
 
Quoted 14 lines

Documentation/kdump/kdump.txt Dump-capture kernel config options (Arch Dependent, arm) · line 261

Quoted 10 lines
Documentation/kdump/kdump.txt +10 -0
+Dump-capture kernel config options (Arch Dependent, arm64)
+----------------------------------------------------------
+
+1) The maximum memory size on the dump-capture kernel must be limited by
+   specifying:
+
+   mem=X[MG]
+
+   where X should be less than or equal to the size in "crashkernel="
+   boot parameter. Kexec-tools will automatically add this.

This is extremely fragile, and will trivially fail when the kernel can be loaded anywhere (see [1]).

As I said before, this restriction also exists on arm, but I understand that recent Ard's patches break it.

Quoted 2 lines

We must explicitly describe the set of regions the crash kernel may use (i.e. we need base and size). NAK in the absence of that.

There seem to exist several approaches:
(a) use a device-tree property, "linux,usable-memory", in addition to "reg"

Quoted 6 lines
Quoted 2 lines

I'm not opposed to the idea of a DT property, though I think that should live under /chosen.

In fact, powerpc uses another property, "linux,crashkernel-base(& size)", under /chosen in order for the *1st kernel* to export info about a memory region for the 2nd(crash dump) kernel to user apps (kexec-tools).

Do you mean that said property is provided _to_ the 1st kernel, or provided _by_ the first kernel?

Quoted 11 lines
Quoted 3 lines

I see that "linux,usable-memory" exists already, though I'm confused as to exactly what it is for as there is no documentation (neither in the kernel nor in ePAPR).

For example,

  memory@0x80000000 {
    reg = <0x0 0x80000000 0x0 0x80000000>;
    linux,usable-memory = <0x0 0x8c000000 0x0 0x4000000>;

}
There exists 2GB memory available on the system, but the last 64MB can be used as a system ram. See early_init_dt_scan_memory() in fdt.c.

Sure, except that's the implementation rather than the intended semantics (which are not defined).

Quoted 9 lines
Quoted 2 lines

It's also painful to alter multiple memory nodes
to use that, and I can see that going wrong.

Yeah, I implemented this feature in my old versions experimentally, but didn't like it as we had to touch all the memory nodes.

Quoted 3 lines
Quoted 2 lines

under "memory" node
(b) use a kernel's early parameter, "memmap=nn[@#$]ss"

Quoted 6 lines
Quoted 2 lines

I'm not too keen on this, as I think it's fragile, and logically somewhat distinct from what mem= is for (a best effort testing tool).

I'm not sure whether it is fragile, and contrary to x86, as Dave described, I think we will only need a single memmap= on arm64 as efi's mem map table is accessible even on the crash kernel.

I just realised I misread this as "mem=", apologies.

It looks like memmap= to force a specific region of memory to be used may work.

I'd still err on the side of preferring an explicit property in the DT.

Quoted 16 lines
Quoted 16 lines
Quoted 2 lines

Power PC takes (a), while this does not work on efi-started kernel because dtb has no "memory" nodes under efi.

A property under /chosen would work for EFI too.

Quoted 4 lines

X86 takes (b). If we take this, we will need to overwrite a weak early_init_dt_add_memory().
(I thought that this approach was not smart as we have three different ways to specify memory regions, dtb, efi and this kernel parameter.)

I'm not sure that's a big problem. We may be able to make this generic, also.

We don't necessarily need a weak add memory function if we can guarantee nothing gets memblock_alloc'd before we carve it out.

Quoted 6 lines
Quoted 1 line

Something like the nomap stuff Ard put together might be useful here.

I'm afraid it doesn't work.
It doesn't matter whether it is linearly mapped or not. We should prevent any part of memory regions used by the 1st kernel from being reclaimed by memblock_alloc() and others.

Are you certain that nomap memory can be allocated? That sounds like a major bug.

Nomap memory should act like reserved memory with the additional property that the kernel must not map it implicitly.

Quoted 1 line

Or do you mean we can introduce another memblock flag?

That wasn't what I meant, but that would be a potential solution.

Thanks,
Mark.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#36 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 59 lines · Mark Rutland
Quoted 58 lines · AKASHI Takahiro
Quoted 56 lines · Mark Rutland
Quoted 44 lines · AKASHI Takahiro
Quoted 28 lines · Mark Rutland
Quoted 27 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

This patch adds arch specific descriptions about kdump usage on arm64 to kdump.txt.

---
  Documentation/kdump/kdump.txt | 23 ++++++++++++++++++++++-
  1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/kdump/kdump.txt +1 -1
index bc4bd5a..36cf978 100644
@@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to
  a remote system.
 
  Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
-s390x and arm architectures.
+s390x, arm and arm64 architectures.
 
  When the system kernel boots, it reserves a small section of memory for
  the dump-capture kernel. This ensures that ongoing Direct Memory Access
@@ -249,6 +249,20 @@ Dump-capture kernel config options (Arch Dependent, arm)
 
      AUTO_ZRELADDR=y
 
Quoted 14 lines

Documentation/kdump/kdump.txt Dump-capture kernel config options (Arch Dependent, arm) · line 261

Quoted 10 lines
Documentation/kdump/kdump.txt +10 -0
+Dump-capture kernel config options (Arch Dependent, arm64)
+----------------------------------------------------------
+
+1) The maximum memory size on the dump-capture kernel must be limited by
+   specifying:
+
+   mem=X[MG]
+
+   where X should be less than or equal to the size in "crashkernel="
+   boot parameter. Kexec-tools will automatically add this.

This is extremely fragile, and will trivially fail when the kernel can be loaded anywhere (see [1]).

Quoted 8 lines

As I said before, this restriction also exists on arm, but I understand that recent Ard's patches break it.

Quoted 2 lines

We must explicitly describe the set of regions the crash kernel may use (i.e. we need base and size). NAK in the absence of that.

There seem to exist several approaches:
(a) use a device-tree property, "linux,usable-memory", in addition to "reg"

I'm not opposed to the idea of a DT property, though I think that should live under /chosen.

Quoted 6 lines
Quoted 3 lines

In fact, powerpc uses another property, "linux,crashkernel-base(& size)", under /chosen in order for the *1st kernel* to export info about a memory region for the 2nd(crash dump) kernel to user apps (kexec-tools).

Do you mean that said property is provided _to_ the 1st kernel, or provided _by_ the first kernel?

_by_ the 1st kernel.

Based on a kernel parameter, "crashkernel=", the 1st kernel reserve some memory region at boot time and export its information through this property. Most architectures other than powerpc, however, use an iomem resource entry, "Crash kernel", in /proc/iomem instead for this purpose.

Quoted 12 lines
Quoted 11 lines
Quoted 3 lines

I see that "linux,usable-memory" exists already, though I'm confused as to exactly what it is for as there is no documentation (neither in the kernel nor in ePAPR).

For example,

   memory at 0x80000000 {
     reg = <0x0 0x80000000 0x0 0x80000000>;
     linux,usable-memory = <0x0 0x8c000000 0x0 0x4000000>;

}
There exists 2GB memory available on the system, but the last 64MB can be used as a system ram. See early_init_dt_scan_memory() in fdt.c.

Quoted 2 lines

Sure, except that's the implementation rather than the intended semantics (which are not defined).

Yeah, but the code itself was ack'ed (actually committed) by Grant:)

Quoted 16 lines
Quoted 9 lines
Quoted 2 lines

It's also painful to alter multiple memory nodes
to use that, and I can see that going wrong.

Yeah, I implemented this feature in my old versions experimentally, but didn't like it as we had to touch all the memory nodes.

Quoted 3 lines
Quoted 2 lines

under "memory" node
(b) use a kernel's early parameter, "memmap=nn[@#$]ss"

Quoted 6 lines
Quoted 2 lines

I'm not too keen on this, as I think it's fragile, and logically somewhat distinct from what mem= is for (a best effort testing tool).

I'm not sure whether it is fragile, and contrary to x86, as Dave described, I think we will only need a single memmap= on arm64 as efi's mem map table is accessible even on the crash kernel.

Quoted 6 lines

I just realised I misread this as "mem=", apologies.

It looks like memmap= to force a specific region of memory to be used may work.

I'd still err on the side of preferring an explicit property in the DT.

Let's discuss in succeeding replies.

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 2 lines

Power PC takes (a), while this does not work on efi-started kernel because dtb has no "memory" nodes under efi.

A property under /chosen would work for EFI too.

Quoted 4 lines

X86 takes (b). If we take this, we will need to overwrite a weak early_init_dt_add_memory().
(I thought that this approach was not smart as we have three different ways to specify memory regions, dtb, efi and this kernel parameter.)

I'm not sure that's a big problem. We may be able to make this generic, also.

We don't necessarily need a weak add memory function if we can guarantee nothing gets memblock_alloc'd before we carve it out.

Something like the nomap stuff Ard put together might be useful here.

Quoted 7 lines
Quoted 4 lines

I'm afraid it doesn't work.
It doesn't matter whether it is linearly mapped or not. We should prevent any part of memory regions used by the 1st kernel from being reclaimed by memblock_alloc() and others.

Are you certain that nomap memory can be allocated? That sounds like a major bug.

I misunderstood. __next_mem_range() called by mem_alloc stuff has some check.

-Takahiro AKASHI

Quoted 10 lines

Nomap memory should act like reserved memory with the additional property that the kernel must not map it implicitly.

Quoted 1 line

Or do you mean we can introduce another memblock flag?

That wasn't what I meant, but that would be a potential solution.

Thanks,
Mark.

#37 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

In reply to AKASHI Takahiro
Quoted 55 lines · AKASHI Takahiro
Quoted 28 lines · Mark Rutland
Quoted 27 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

This patch adds arch specific descriptions about kdump usage on arm64 to kdump.txt.

---
 Documentation/kdump/kdump.txt | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/kdump/kdump.txt +1 -1
index bc4bd5a..36cf978 100644
@@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to
 a remote system.
 
 Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
-s390x and arm architectures.
+s390x, arm and arm64 architectures.
 
 When the system kernel boots, it reserves a small section of memory for
 the dump-capture kernel. This ensures that ongoing Direct Memory Access
@@ -249,6 +249,20 @@ Dump-capture kernel config options (Arch Dependent, arm)
 
     AUTO_ZRELADDR=y
 
Quoted 14 lines

Documentation/kdump/kdump.txt Dump-capture kernel config options (Arch Dependent, arm) · line 261

Quoted 10 lines
Documentation/kdump/kdump.txt +10 -0
+Dump-capture kernel config options (Arch Dependent, arm64)
+----------------------------------------------------------
+
+1) The maximum memory size on the dump-capture kernel must be limited by
+   specifying:
+
+   mem=X[MG]
+
+   where X should be less than or equal to the size in "crashkernel="
+   boot parameter. Kexec-tools will automatically add this.

This is extremely fragile, and will trivially fail when the kernel can be loaded anywhere (see [1]).

As I said before, this restriction also exists on arm, but I understand that recent Ard's patches break it.

Quoted 2 lines

We must explicitly describe the set of regions the crash kernel may use (i.e. we need base and size). NAK in the absence of that.

There seem to exist several approaches:
(a) use a device-tree property, "linux,usable-memory", in addition to "reg" under "memory" node
(b) use a kernel's early parameter, "memmap=nn[@#$]ss"

Quoted 4 lines

Power PC takes (a), while this does not work on efi-started kernel because dtb has no "memory" nodes under efi.
X86 takes (b). If we take this, we will need to overwrite a weak early_init_dt_add_memory().

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

I think it is X86 specific. Personally I think device tree property is better.

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#38 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 61 lines · Dave Young
Quoted 55 lines · AKASHI Takahiro
Quoted 28 lines · Mark Rutland
Quoted 27 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

This patch adds arch specific descriptions about kdump usage on arm64 to kdump.txt.

---
 Documentation/kdump/kdump.txt | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/kdump/kdump.txt +1 -1
index bc4bd5a..36cf978 100644
@@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to
 a remote system.
 
 Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
-s390x and arm architectures.
+s390x, arm and arm64 architectures.
 
 When the system kernel boots, it reserves a small section of memory for
 the dump-capture kernel. This ensures that ongoing Direct Memory Access
@@ -249,6 +249,20 @@ Dump-capture kernel config options (Arch Dependent, arm)
 
     AUTO_ZRELADDR=y
 
Quoted 14 lines

Documentation/kdump/kdump.txt Dump-capture kernel config options (Arch Dependent, arm) · line 261

Quoted 10 lines
Documentation/kdump/kdump.txt +10 -0
+Dump-capture kernel config options (Arch Dependent, arm64)
+----------------------------------------------------------
+
+1) The maximum memory size on the dump-capture kernel must be limited by
+   specifying:
+
+   mem=X[MG]
+
+   where X should be less than or equal to the size in "crashkernel="
+   boot parameter. Kexec-tools will automatically add this.

This is extremely fragile, and will trivially fail when the kernel can be loaded anywhere (see [1]).

As I said before, this restriction also exists on arm, but I understand that recent Ard's patches break it.

Quoted 2 lines

We must explicitly describe the set of regions the crash kernel may use (i.e. we need base and size). NAK in the absence of that.

There seem to exist several approaches:
(a) use a device-tree property, "linux,usable-memory", in addition to "reg" under "memory" node
(b) use a kernel's early parameter, "memmap=nn[@#$]ss"

Quoted 4 lines

Power PC takes (a), while this does not work on efi-started kernel because dtb has no "memory" nodes under efi.
X86 takes (b). If we take this, we will need to overwrite a weak early_init_dt_add_memory().

Quoted 4 lines

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

One reason about the changing is kernel cmdline space is limited. We need to pass not only usable memory ranges, also reserved and other different memory ranges, cmdline array size is not enough sometimes.

Quoted 6 lines

I think it is X86 specific. Personally I think device tree property is better.

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#39 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

In reply to Dave Young
Quoted 61 lines · Dave Young
Quoted 55 lines · AKASHI Takahiro
Quoted 28 lines · Mark Rutland
Quoted 27 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

This patch adds arch specific descriptions about kdump usage on arm64 to kdump.txt.

---
  Documentation/kdump/kdump.txt | 23 ++++++++++++++++++++++-
  1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/kdump/kdump.txt +1 -1
index bc4bd5a..36cf978 100644
@@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to
  a remote system.
 
  Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
-s390x and arm architectures.
+s390x, arm and arm64 architectures.
 
  When the system kernel boots, it reserves a small section of memory for
  the dump-capture kernel. This ensures that ongoing Direct Memory Access
@@ -249,6 +249,20 @@ Dump-capture kernel config options (Arch Dependent, arm)
 
      AUTO_ZRELADDR=y
 
Quoted 14 lines

Documentation/kdump/kdump.txt Dump-capture kernel config options (Arch Dependent, arm) · line 261

Quoted 10 lines
Documentation/kdump/kdump.txt +10 -0
+Dump-capture kernel config options (Arch Dependent, arm64)
+----------------------------------------------------------
+
+1) The maximum memory size on the dump-capture kernel must be limited by
+   specifying:
+
+   mem=X[MG]
+
+   where X should be less than or equal to the size in "crashkernel="
+   boot parameter. Kexec-tools will automatically add this.

This is extremely fragile, and will trivially fail when the kernel can be loaded anywhere (see [1]).

As I said before, this restriction also exists on arm, but I understand that recent Ard's patches break it.

Quoted 2 lines

We must explicitly describe the set of regions the crash kernel may use (i.e. we need base and size). NAK in the absence of that.

There seem to exist several approaches:
(a) use a device-tree property, "linux,usable-memory", in addition to "reg" under "memory" node
(b) use a kernel's early parameter, "memmap=nn[@#$]ss"

Quoted 4 lines

Power PC takes (a), while this does not work on efi-started kernel because dtb has no "memory" nodes under efi.
X86 takes (b). If we take this, we will need to overwrite a weak early_init_dt_add_memory().

Quoted 4 lines

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

Thanks. I will visit x86 code again.

Quoted 2 lines

I think it is X86 specific. Personally I think device tree property is better.

Do you think so?

-Takahiro AKASHI

Quoted 4 lines

Thanks
Dave

#40 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 67 lines · AKASHI Takahiro
Quoted 61 lines · Dave Young
Quoted 55 lines · AKASHI Takahiro
Quoted 28 lines · Mark Rutland
Quoted 27 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

This patch adds arch specific descriptions about kdump usage on arm64 to kdump.txt.

---
 Documentation/kdump/kdump.txt | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/kdump/kdump.txt +1 -1
index bc4bd5a..36cf978 100644
@@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to
 a remote system.
 
 Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
-s390x and arm architectures.
+s390x, arm and arm64 architectures.
 
 When the system kernel boots, it reserves a small section of memory for
 the dump-capture kernel. This ensures that ongoing Direct Memory Access
@@ -249,6 +249,20 @@ Dump-capture kernel config options (Arch Dependent, arm)
 
     AUTO_ZRELADDR=y
 
Quoted 14 lines

Documentation/kdump/kdump.txt Dump-capture kernel config options (Arch Dependent, arm) · line 261

Quoted 10 lines
Documentation/kdump/kdump.txt +10 -0
+Dump-capture kernel config options (Arch Dependent, arm64)
+----------------------------------------------------------
+
+1) The maximum memory size on the dump-capture kernel must be limited by
+   specifying:
+
+   mem=X[MG]
+
+   where X should be less than or equal to the size in "crashkernel="
+   boot parameter. Kexec-tools will automatically add this.

This is extremely fragile, and will trivially fail when the kernel can be loaded anywhere (see [1]).

As I said before, this restriction also exists on arm, but I understand that recent Ard's patches break it.

Quoted 2 lines

We must explicitly describe the set of regions the crash kernel may use (i.e. we need base and size). NAK in the absence of that.

There seem to exist several approaches:
(a) use a device-tree property, "linux,usable-memory", in addition to "reg" under "memory" node
(b) use a kernel's early parameter, "memmap=nn[@#$]ss"

Quoted 4 lines

Power PC takes (a), while this does not work on efi-started kernel because dtb has no "memory" nodes under efi.
X86 takes (b). If we take this, we will need to overwrite a weak early_init_dt_add_memory().

Quoted 4 lines

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

Quoted 6 lines

Thanks. I will visit x86 code again.

Quoted 2 lines

I think it is X86 specific. Personally I think device tree property is better.

Do you think so?

I'm not sure it is the best way. For X86 we run into problem with memmap= design, one example is pci domain X (X>1) need the pci memory ranges being passed to kdump kernel. When we passed reserved ranges in /proc/iomem to 2nd kernel we find that cmdline[] array is not big enough.

Do you think for arm64 only usable memory is necessary to let kdump kernel know? I'm curious about how arm64 kernel get all memory layout from boot loader, via UEFI memmap?

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

reviewer
#41 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 73 lines · Dave Young
Quoted 72 lines · AKASHI Takahiro
Quoted 61 lines · Dave Young
Quoted 55 lines · AKASHI Takahiro
Quoted 28 lines · Mark Rutland
Quoted 27 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

This patch adds arch specific descriptions about kdump usage on arm64 to kdump.txt.

---
 Documentation/kdump/kdump.txt | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/kdump/kdump.txt +1 -1
index bc4bd5a..36cf978 100644
@@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to
 a remote system.
 
 Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
-s390x and arm architectures.
+s390x, arm and arm64 architectures.
 
 When the system kernel boots, it reserves a small section of memory for
 the dump-capture kernel. This ensures that ongoing Direct Memory Access
@@ -249,6 +249,20 @@ Dump-capture kernel config options (Arch Dependent, arm)
 
     AUTO_ZRELADDR=y
 
Quoted 14 lines

Documentation/kdump/kdump.txt Dump-capture kernel config options (Arch Dependent, arm) · line 261

Quoted 10 lines
Documentation/kdump/kdump.txt +10 -0
+Dump-capture kernel config options (Arch Dependent, arm64)
+----------------------------------------------------------
+
+1) The maximum memory size on the dump-capture kernel must be limited by
+   specifying:
+
+   mem=X[MG]
+
+   where X should be less than or equal to the size in "crashkernel="
+   boot parameter. Kexec-tools will automatically add this.

This is extremely fragile, and will trivially fail when the kernel can be loaded anywhere (see [1]).

As I said before, this restriction also exists on arm, but I understand that recent Ard's patches break it.

Quoted 2 lines

We must explicitly describe the set of regions the crash kernel may use (i.e. we need base and size). NAK in the absence of that.

There seem to exist several approaches:
(a) use a device-tree property, "linux,usable-memory", in addition to "reg" under "memory" node
(b) use a kernel's early parameter, "memmap=nn[@#$]ss"

Quoted 4 lines

Power PC takes (a), while this does not work on efi-started kernel because dtb has no "memory" nodes under efi.
X86 takes (b). If we take this, we will need to overwrite a weak early_init_dt_add_memory().

Quoted 4 lines

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

Thanks. I will visit x86 code again.

Quoted 2 lines

I think it is X86 specific. Personally I think device tree property is better.

Quoted 6 lines
Quoted 1 line

Do you think so?

I'm not sure it is the best way. For X86 we run into problem with memmap= design, one example is pci domain X (X>1) need the pci memory ranges being passed to kdump kernel. When we passed reserved ranges in /proc/iomem to 2nd kernel we find that cmdline[] array is not big enough.

I'm not sure how PCI ranges relate to the memory map used for normal memory (i.e. RAM), though I'm probably missing some caveat with the way ACPI and UEFI describe PCI. Why does memmap= affect PCI memory?

If the kernel got the rest of its system topology from DT, the PCI regions would be described there.

Quoted 3 lines

Do you think for arm64 only usable memory is necessary to let kdump kernel know? I'm curious about how arm64 kernel get all memory layout from boot loader, via UEFI memmap?

When booted via EFI, we use the EFI memory map. The EFI stub handles acquring the relevant information and passing that to the first kernel in the DTB (see Documentation/arm/uefi.txt).

A kexec'd kernel should simply inherit that. So long as the DTB and/or UEFI tables in memory are the same, it would be the same as a cold boot.

In the !EFI case, we use the memory nodes in the DTB. Only in this case could usable-memory properties in memory nodes make sense. I'd prefer a uniform property under /chosen for both cases.

Thanks,
Mark.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#42 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 76 lines · Mark Rutland
Quoted 75 lines · Dave Young
Quoted 73 lines · AKASHI Takahiro
Quoted 61 lines · Dave Young
Quoted 55 lines · AKASHI Takahiro
Quoted 28 lines · Mark Rutland
Quoted 27 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

This patch adds arch specific descriptions about kdump usage on arm64 to kdump.txt.

---
 Documentation/kdump/kdump.txt | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/kdump/kdump.txt +1 -1
index bc4bd5a..36cf978 100644
@@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to
 a remote system.
 
 Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
-s390x and arm architectures.
+s390x, arm and arm64 architectures.
 
 When the system kernel boots, it reserves a small section of memory for
 the dump-capture kernel. This ensures that ongoing Direct Memory Access
@@ -249,6 +249,20 @@ Dump-capture kernel config options (Arch Dependent, arm)
 
     AUTO_ZRELADDR=y
 
Quoted 14 lines

Documentation/kdump/kdump.txt Dump-capture kernel config options (Arch Dependent, arm) · line 261

Quoted 10 lines
Documentation/kdump/kdump.txt +10 -0
+Dump-capture kernel config options (Arch Dependent, arm64)
+----------------------------------------------------------
+
+1) The maximum memory size on the dump-capture kernel must be limited by
+   specifying:
+
+   mem=X[MG]
+
+   where X should be less than or equal to the size in "crashkernel="
+   boot parameter. Kexec-tools will automatically add this.

This is extremely fragile, and will trivially fail when the kernel can be loaded anywhere (see [1]).

As I said before, this restriction also exists on arm, but I understand that recent Ard's patches break it.

Quoted 2 lines

We must explicitly describe the set of regions the crash kernel may use (i.e. we need base and size). NAK in the absence of that.

There seem to exist several approaches:
(a) use a device-tree property, "linux,usable-memory", in addition to "reg" under "memory" node
(b) use a kernel's early parameter, "memmap=nn[@#$]ss"

Quoted 4 lines

Power PC takes (a), while this does not work on efi-started kernel because dtb has no "memory" nodes under efi.
X86 takes (b). If we take this, we will need to overwrite a weak early_init_dt_add_memory().

Quoted 4 lines

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

Thanks. I will visit x86 code again.

Quoted 2 lines

I think it is X86 specific. Personally I think device tree property is better.

Do you think so?

Quoted 8 lines
Quoted 4 lines

I'm not sure it is the best way. For X86 we run into problem with memmap= design, one example is pci domain X (X>1) need the pci memory ranges being passed to kdump kernel. When we passed reserved ranges in /proc/iomem to 2nd kernel we find that cmdline[] array is not big enough.

I'm not sure how PCI ranges relate to the memory map used for normal memory (i.e. RAM), though I'm probably missing some caveat with the way ACPI and UEFI describe PCI. Why does memmap= affect PCI memory?

Here is the old patch which was rejected in kexec-tools:
http://lists.infradead.org/pipermail/kexec/2013-February/007924.html

Quoted 3 lines

If the kernel got the rest of its system topology from DT, the PCI regions would be described there.

Yes, if kdump kernel use same DT as 1st kernel.

Quoted 8 lines
Quoted 4 lines

Do you think for arm64 only usable memory is necessary to let kdump kernel know? I'm curious about how arm64 kernel get all memory layout from boot loader, via UEFI memmap?

When booted via EFI, we use the EFI memory map. The EFI stub handles acquring the relevant information and passing that to the first kernel in the DTB (see Documentation/arm/uefi.txt).

Ok, thanks for the pointer. So in dt we are just have uefi memmap infomation instead of memory nodes details..

Quoted 3 lines

A kexec'd kernel should simply inherit that. So long as the DTB and/or UEFI tables in memory are the same, it would be the same as a cold boot.

For kexec all memory ranges are same, for kdump we need use original reserved range with crashkernel= as usable memory and all other orignal usable ranges are not usable anymore.

Is it possible to modify uefi memmap for kdump case?

Quoted 4 lines

In the !EFI case, we use the memory nodes in the DTB. Only in this case could usable-memory properties in memory nodes make sense. I'd prefer a uniform property under /chosen for both cases.

We stil use same DTB, need to modify the DT and update the usable and unusable nodes for kdump?

Quoted 2 lines

Thanks,
Mark.

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

reviewer
#43 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 25 lines · Dave Young
Quoted 15 lines · Mark Rutland
Quoted 14 lines · Dave Young
Quoted 12 lines · AKASHI Takahiro
Quoted 4 lines · Dave Young

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

Thanks. I will visit x86 code again.

Quoted 2 lines

I think it is X86 specific. Personally I think device tree property is better.

Do you think so?

Quoted 8 lines
Quoted 4 lines

I'm not sure it is the best way. For X86 we run into problem with memmap= design, one example is pci domain X (X>1) need the pci memory ranges being passed to kdump kernel. When we passed reserved ranges in /proc/iomem to 2nd kernel we find that cmdline[] array is not big enough.

I'm not sure how PCI ranges relate to the memory map used for normal memory (i.e. RAM), though I'm probably missing some caveat with the way ACPI and UEFI describe PCI. Why does memmap= affect PCI memory?

Quoted 8 lines

Here is the old patch which was rejected in kexec-tools:
http://lists.infradead.org/pipermail/kexec/2013-February/007924.html

Quoted 3 lines

If the kernel got the rest of its system topology from DT, the PCI regions would be described there.

Yes, if kdump kernel use same DT as 1st kernel.

Other than for testing purposes, I don't see why you'd pass the kdump kernel a DTB inconsistent with that the 1st kernel was passsed (other than some proerties under /chosen).

We added /sys/firmware/fdt specifically to allow the kexec tools to get the exact DTB the first kernel used. There's no reason for tools to have to make something up.

Quoted 10 lines
Quoted 7 lines
Quoted 3 lines

Do you think for arm64 only usable memory is necessary to let kdump kernel know? I'm curious about how arm64 kernel get all memory layout from boot loader, via UEFI memmap?

When booted via EFI, we use the EFI memory map. The EFI stub handles acquring the relevant information and passing that to the first kernel in the DTB (see Documentation/arm/uefi.txt).

Ok, thanks for the pointer. So in dt we are just have uefi memmap infomation instead of memory nodes details..

When booted via EFI, yes.

For NUMA topology in !ACPI kernels, we might need to also retain and parse memory nodes, but only for toplogy information. The kernel would still only use memory as described by the EFI memory map.

There's a horrible edge case I've spotted if performing a chain of cross-endian kexecs: LE -> BE -> LE, as the BE kernel would have to respect the EFI memory map so as to avoid corrupting it for the subsequent LE kernel. Other than this I believe everything should just work.

Quoted 6 lines
Quoted 2 lines

A kexec'd kernel should simply inherit that. So long as the DTB and/or UEFI tables in memory are the same, it would be the same as a cold boot.

For kexec all memory ranges are same, for kdump we need use original reserved range with crashkernel= as usable memory and all other orignal usable ranges are not usable anymore.

Sure. This is what I believe we should expose with an additional property under /chosen, while keeping everything else pristine.

The crash kernel can then limit itself to that region, while it would have the information of the full memory map (which it could log and/or use to drive other dumping).

Quoted 1 line

Is it possible to modify uefi memmap for kdump case?

Technically it would be possible, however I don't think it's necessary, and I think it would be disadvantageous to do so.

Describing the range(s) the crash kernel can use in separate properties under /chosen has a number of advantages.

Quoted 6 lines
Quoted 3 lines

In the !EFI case, we use the memory nodes in the DTB. Only in this case could usable-memory properties in memory nodes make sense. I'd prefer a uniform property under /chosen for both cases.

We stil use same DTB, need to modify the DT and update the usable and unusable nodes for kdump?

We'd have a (slightly) modified DTB that contained additional properties describing the range(s) reserved for use by the crash kernel.

Other than those properties under /chosen (e.g. the command line, initrd pointers if any), it would be the original DTB.

Thanks,
Mark.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#44 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 35 lines · Mark Rutland
Quoted 25 lines · Dave Young
Quoted 15 lines · Mark Rutland
Quoted 14 lines · Dave Young
Quoted 12 lines · AKASHI Takahiro
Quoted 4 lines · Dave Young

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

Thanks. I will visit x86 code again.

Quoted 2 lines

I think it is X86 specific. Personally I think device tree property is better.

Do you think so?

Quoted 8 lines
Quoted 4 lines

I'm not sure it is the best way. For X86 we run into problem with memmap= design, one example is pci domain X (X>1) need the pci memory ranges being passed to kdump kernel. When we passed reserved ranges in /proc/iomem to 2nd kernel we find that cmdline[] array is not big enough.

I'm not sure how PCI ranges relate to the memory map used for normal memory (i.e. RAM), though I'm probably missing some caveat with the way ACPI and UEFI describe PCI. Why does memmap= affect PCI memory?

Quoted 8 lines

Here is the old patch which was rejected in kexec-tools:
http://lists.infradead.org/pipermail/kexec/2013-February/007924.html

Quoted 3 lines

If the kernel got the rest of its system topology from DT, the PCI regions would be described there.

Yes, if kdump kernel use same DT as 1st kernel.

Quoted 7 lines

Other than for testing purposes, I don't see why you'd pass the kdump kernel a DTB inconsistent with that the 1st kernel was passsed (other than some proerties under /chosen).

We added /sys/firmware/fdt specifically to allow the kexec tools to get the exact DTB the first kernel used. There's no reason for tools to have to make something up.

Agreed, but kexec-tools has an option to pass in any dtb files. Who knows how one will use it unless dropping the option and use /sys/firmware/fdt unconditionally.

If we choose to implement kexec_file_load only in kernel, the interfaces provided are kernel, initrd and cmdline. We can always use same dtb.

Quoted 18 lines
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines

Do you think for arm64 only usable memory is necessary to let kdump kernel know? I'm curious about how arm64 kernel get all memory layout from boot loader, via UEFI memmap?

When booted via EFI, we use the EFI memory map. The EFI stub handles acquring the relevant information and passing that to the first kernel in the DTB (see Documentation/arm/uefi.txt).

Ok, thanks for the pointer. So in dt we are just have uefi memmap infomation instead of memory nodes details..

When booted via EFI, yes.

For NUMA topology in !ACPI kernels, we might need to also retain and parse memory nodes, but only for toplogy information. The kernel would still only use memory as described by the EFI memory map.

Quoted 5 lines

There's a horrible edge case I've spotted if performing a chain of cross-endian kexecs: LE -> BE -> LE, as the BE kernel would have to respect the EFI memory map so as to avoid corrupting it for the subsequent LE kernel. Other than this I believe everything should just work.

Firmware do not know kernel endianniess, kernel should respect firmware maps and adapt to it, it sounds like a generic issue not specfic to kexec.

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

A kexec'd kernel should simply inherit that. So long as the DTB and/or UEFI tables in memory are the same, it would be the same as a cold boot.

For kexec all memory ranges are same, for kdump we need use original reserved range with crashkernel= as usable memory and all other orignal usable ranges are not usable anymore.

Quoted 6 lines

Sure. This is what I believe we should expose with an additional property under /chosen, while keeping everything else pristine.

The crash kernel can then limit itself to that region, while it would have the information of the full memory map (which it could log and/or use to drive other dumping).

In this way kernel should be aware it is a kdump booting, it is doable though I feel it is better for kdump kernel in a black box with infomations it can use just like the 1st kernel. Things here is where we choose to cook the memory infomation in boot loader or in kernel itself.

Quoted 8 lines
Quoted 2 lines

Is it possible to modify uefi memmap for kdump case?

Technically it would be possible, however I don't think it's necessary, and I think it would be disadvantageous to do so.

Describing the range(s) the crash kernel can use in separate properties under /chosen has a number of advantages.

Ok, I got the points. We have a is_kdump_kernel() by checking if there is elfcorehdr_addr kernel cmdline. This is mainly for some drivers which do not work well in kdump kernel some uncertain reasons. But ideally I think kernel should handle things just like in 1st kernel and avoid to use it.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

In the !EFI case, we use the memory nodes in the DTB. Only in this case could usable-memory properties in memory nodes make sense. I'd prefer a uniform property under /chosen for both cases.

We stil use same DTB, need to modify the DT and update the usable and unusable nodes for kdump?

Quoted 8 lines

We'd have a (slightly) modified DTB that contained additional properties describing the range(s) reserved for use by the crash kernel.

Other than those properties under /chosen (e.g. the command line, initrd pointers if any), it would be the original DTB.

Thanks,
Mark.

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#45 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 40 lines · Dave Young
Quoted 39 lines · Mark Rutland
Quoted 25 lines · Dave Young
Quoted 15 lines · Mark Rutland
Quoted 14 lines · Dave Young
Quoted 12 lines · AKASHI Takahiro
Quoted 4 lines · Dave Young

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

Thanks. I will visit x86 code again.

Quoted 2 lines

I think it is X86 specific. Personally I think device tree property is better.

Do you think so?

Quoted 8 lines
Quoted 4 lines

I'm not sure it is the best way. For X86 we run into problem with memmap= design, one example is pci domain X (X>1) need the pci memory ranges being passed to kdump kernel. When we passed reserved ranges in /proc/iomem to 2nd kernel we find that cmdline[] array is not big enough.

I'm not sure how PCI ranges relate to the memory map used for normal memory (i.e. RAM), though I'm probably missing some caveat with the way ACPI and UEFI describe PCI. Why does memmap= affect PCI memory?

Quoted 8 lines

Here is the old patch which was rejected in kexec-tools:
http://lists.infradead.org/pipermail/kexec/2013-February/007924.html

Quoted 3 lines

If the kernel got the rest of its system topology from DT, the PCI regions would be described there.

Yes, if kdump kernel use same DT as 1st kernel.

Other than for testing purposes, I don't see why you'd pass the kdump kernel a DTB inconsistent with that the 1st kernel was passsed (other than some proerties under /chosen).

Quoted 7 lines
Quoted 3 lines

We added /sys/firmware/fdt specifically to allow the kexec tools to get the exact DTB the first kernel used. There's no reason for tools to have to make something up.

Agreed, but kexec-tools has an option to pass in any dtb files. Who knows how one will use it unless dropping the option and use /sys/firmware/fdt unconditionally.

As a matter of fact, specifying proper command line parameters as well as dtb is partly users' responsibility for kdump to work correctly. (especially for BE kernel)

Quoted 2 lines

If we choose to implement kexec_file_load only in kernel, the interfaces provided are kernel, initrd and cmdline. We can always use same dtb.

I would say that we can always use the same dtb even with kexec_load from user's perspective. Right?
(The difference is whether changes are made by kernel itself or kexec-tools.)

Quoted 18 lines
Quoted 18 lines
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines

Do you think for arm64 only usable memory is necessary to let kdump kernel know? I'm curious about how arm64 kernel get all memory layout from boot loader, via UEFI memmap?

When booted via EFI, we use the EFI memory map. The EFI stub handles acquring the relevant information and passing that to the first kernel in the DTB (see Documentation/arm/uefi.txt).

Ok, thanks for the pointer. So in dt we are just have uefi memmap infomation instead of memory nodes details..

When booted via EFI, yes.

For NUMA topology in !ACPI kernels, we might need to also retain and parse memory nodes, but only for toplogy information. The kernel would still only use memory as described by the EFI memory map.

Quoted 8 lines
Quoted 5 lines

There's a horrible edge case I've spotted if performing a chain of cross-endian kexecs: LE -> BE -> LE, as the BE kernel would have to respect the EFI memory map so as to avoid corrupting it for the subsequent LE kernel. Other than this I believe everything should just work.

Firmware do not know kernel endianniess, kernel should respect firmware maps and adapt to it, it sounds like a generic issue not specfic to kexec.

On arm64, a kernel image header has a bit field to specify the image's endianness. Anyway, our current implementation replies on a user-supplied dtb to start BE kernel.

Quoted 26 lines
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

A kexec'd kernel should simply inherit that. So long as the DTB and/or UEFI tables in memory are the same, it would be the same as a cold boot.

For kexec all memory ranges are same, for kdump we need use original reserved range with crashkernel= as usable memory and all other orignal usable ranges are not usable anymore.

Quoted 6 lines

Sure. This is what I believe we should expose with an additional property under /chosen, while keeping everything else pristine.

The crash kernel can then limit itself to that region, while it would have the information of the full memory map (which it could log and/or use to drive other dumping).

In this way kernel should be aware it is a kdump booting, it is doable though I feel it is better for kdump kernel in a black box with infomations it can use just like the 1st kernel. Things here is where we choose to cook the memory infomation in boot loader or in kernel itself.

Quoted 6 lines
Quoted 2 lines

Is it possible to modify uefi memmap for kdump case?

Technically it would be possible, however I don't think it's necessary, and I think it would be disadvantageous to do so.

Quoted 8 lines
Quoted 2 lines

Describing the range(s) the crash kernel can use in separate properties under /chosen has a number of advantages.

Ok, I got the points. We have a is_kdump_kernel() by checking if there is elfcorehdr_addr kernel cmdline. This is mainly for some drivers which do not work well in kdump kernel some uncertain reasons. But ideally I think kernel should handle things just like in 1st kernel and avoid to use it.

So I'm not still sure about what are advantages of a property under /chosen over "memmap=" kernel parameter.
Both are simple and can have the same effect with minimizing changes to dtb. (But if, in the latter case, we have to provide *all* the memory-related information through "memmap=" parameters, it would be much complicated.)

-Takahiro AKASHI

Quoted 20 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

In the !EFI case, we use the memory nodes in the DTB. Only in this case could usable-memory properties in memory nodes make sense. I'd prefer a uniform property under /chosen for both cases.

We stil use same DTB, need to modify the DT and update the usable and unusable nodes for kdump?

Quoted 8 lines

We'd have a (slightly) modified DTB that contained additional properties describing the range(s) reserved for use by the crash kernel.

Other than those properties under /chosen (e.g. the command line, initrd pointers if any), it would be the original DTB.

Thanks,
Mark.

Thanks
Dave

#46 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 45 lines · AKASHI Takahiro
Quoted 44 lines · Dave Young
Quoted 42 lines · Mark Rutland
Quoted 25 lines · Dave Young
Quoted 15 lines · Mark Rutland
Quoted 14 lines · Dave Young
Quoted 12 lines · AKASHI Takahiro
Quoted 4 lines · Dave Young

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

Thanks. I will visit x86 code again.

Quoted 2 lines

I think it is X86 specific. Personally I think device tree property is better.

Do you think so?

Quoted 8 lines
Quoted 4 lines

I'm not sure it is the best way. For X86 we run into problem with memmap= design, one example is pci domain X (X>1) need the pci memory ranges being passed to kdump kernel. When we passed reserved ranges in /proc/iomem to 2nd kernel we find that cmdline[] array is not big enough.

I'm not sure how PCI ranges relate to the memory map used for normal memory (i.e. RAM), though I'm probably missing some caveat with the way ACPI and UEFI describe PCI. Why does memmap= affect PCI memory?

Quoted 8 lines

Here is the old patch which was rejected in kexec-tools:
http://lists.infradead.org/pipermail/kexec/2013-February/007924.html

Quoted 3 lines

If the kernel got the rest of its system topology from DT, the PCI regions would be described there.

Yes, if kdump kernel use same DT as 1st kernel.

Other than for testing purposes, I don't see why you'd pass the kdump kernel a DTB inconsistent with that the 1st kernel was passsed (other than some proerties under /chosen).

We added /sys/firmware/fdt specifically to allow the kexec tools to get the exact DTB the first kernel used. There's no reason for tools to have to make something up.

Quoted 7 lines
Quoted 3 lines

Agreed, but kexec-tools has an option to pass in any dtb files. Who knows how one will use it unless dropping the option and use /sys/firmware/fdt unconditionally.

As a matter of fact, specifying proper command line parameters as well as dtb is partly users' responsibility for kdump to work correctly. (especially for BE kernel)

Right.

Quoted 7 lines
Quoted 3 lines

If we choose to implement kexec_file_load only in kernel, the interfaces provided are kernel, initrd and cmdline. We can always use same dtb.

I would say that we can always use the same dtb even with kexec_load from user's perspective. Right?
(The difference is whether changes are made by kernel itself or kexec-tools.)

Right.

Quoted 25 lines
Quoted 25 lines
Quoted 24 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

Do you think for arm64 only usable memory is necessary to let kdump kernel know? I'm curious about how arm64 kernel get all memory layout from boot loader, via UEFI memmap?

Quoted 6 lines
Quoted 3 lines

When booted via EFI, we use the EFI memory map. The EFI stub handles acquring the relevant information and passing that to the first kernel in the DTB (see Documentation/arm/uefi.txt).

Ok, thanks for the pointer. So in dt we are just have uefi memmap infomation instead of memory nodes details..

When booted via EFI, yes.

For NUMA topology in !ACPI kernels, we might need to also retain and parse memory nodes, but only for toplogy information. The kernel would still only use memory as described by the EFI memory map.

There's a horrible edge case I've spotted if performing a chain of cross-endian kexecs: LE -> BE -> LE, as the BE kernel would have to respect the EFI memory map so as to avoid corrupting it for the subsequent LE kernel. Other than this I believe everything should just work.

Quoted 5 lines
Quoted 2 lines

Firmware do not know kernel endianniess, kernel should respect firmware maps and adapt to it, it sounds like a generic issue not specfic to kexec.

On arm64, a kernel image header has a bit field to specify the image's endianness. Anyway, our current implementation replies on a user-supplied dtb to start BE kernel.

Ok, I means uefi memmap are same, not specific to LE or BE.

Quoted 36 lines
Quoted 27 lines
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

A kexec'd kernel should simply inherit that. So long as the DTB and/or UEFI tables in memory are the same, it would be the same as a cold boot.

For kexec all memory ranges are same, for kdump we need use original reserved range with crashkernel= as usable memory and all other orignal usable ranges are not usable anymore.

Quoted 6 lines

Sure. This is what I believe we should expose with an additional property under /chosen, while keeping everything else pristine.

The crash kernel can then limit itself to that region, while it would have the information of the full memory map (which it could log and/or use to drive other dumping).

In this way kernel should be aware it is a kdump booting, it is doable though I feel it is better for kdump kernel in a black box with infomations it can use just like the 1st kernel. Things here is where we choose to cook the memory infomation in boot loader or in kernel itself.

Quoted 6 lines
Quoted 2 lines

Is it possible to modify uefi memmap for kdump case?

Technically it would be possible, however I don't think it's necessary, and I think it would be disadvantageous to do so.

Quoted 8 lines
Quoted 2 lines

Describing the range(s) the crash kernel can use in separate properties under /chosen has a number of advantages.

Ok, I got the points. We have a is_kdump_kernel() by checking if there is elfcorehdr_addr kernel cmdline. This is mainly for some drivers which do not work well in kdump kernel some uncertain reasons. But ideally I think kernel should handle things just like in 1st kernel and avoid to use it.

Quoted 5 lines

So I'm not still sure about what are advantages of a property under /chosen over "memmap=" kernel parameter.
Both are simple and can have the same effect with minimizing changes to dtb. (But if, in the latter case, we have to provide *all* the memory-related information through "memmap=" parameters, it would be much complicated.)

Maybe I did not say it clearly, I prefer kexec syscall/tool to modifiy dtb or uefi-memmap so that we do not need any extra kernel cmdline.

For x86 we would like to drop the memmap= usage in kexec-tools but we can not do that for a compatibility problem about calgary iommu. So that currently kexec-tools supports both recreating E820 maps and passing memmap=.

We should think it carefully because it will be hard to remove once we support it. IMO handling it in code is better than using an external interface.

Quoted 23 lines

-Takahiro AKASHI

Quoted 20 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

In the !EFI case, we use the memory nodes in the DTB. Only in this case could usable-memory properties in memory nodes make sense. I'd prefer a uniform property under /chosen for both cases.

We stil use same DTB, need to modify the DT and update the usable and unusable nodes for kdump?

Quoted 8 lines

We'd have a (slightly) modified DTB that contained additional properties describing the range(s) reserved for use by the crash kernel.

Other than those properties under /chosen (e.g. the command line, initrd pointers if any), it would be the original DTB.

Thanks,
Mark.

Thanks
Dave

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#47 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 9 lines
Quoted 5 lines

So I'm not still sure about what are advantages of a property under /chosen over "memmap=" kernel parameter.
Both are simple and can have the same effect with minimizing changes to dtb. (But if, in the latter case, we have to provide *all* the memory-related information through "memmap=" parameters, it would be much complicated.)

Maybe I did not say it clearly, I prefer kexec syscall/tool to modifiy dtb or uefi-memmap so that we do not need any extra kernel cmdline.

Quoted 7 lines

For x86 we would like to drop the memmap= usage in kexec-tools but we can not do that for a compatibility problem about calgary iommu. So that currently kexec-tools supports both recreating E820 maps and passing memmap=.

We should think it carefully because it will be hard to remove once we support it. IMO handling it in code is better than using an external interface.

Also seems semantic of memmap=exactmap is different than current use in the implementation exactmap means we need pass each range seperately including reserved, acpi and other types We can not reuse ranges in uefi memmap for other than usable memory.

It will also have the cmdline array size issue.

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#48 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 8 lines · Dave Young
Quoted 8 lines
Quoted 5 lines

So I'm not still sure about what are advantages of a property under /chosen over "memmap=" kernel parameter.
Both are simple and can have the same effect with minimizing changes to dtb. (But if, in the latter case, we have to provide *all* the memory-related information through "memmap=" parameters, it would be much complicated.)

Maybe I did not say it clearly, I prefer kexec syscall/tool to modifiy dtb or uefi-memmap so that we do not need any extra kernel cmdline.

Yes, I understand.
But on arm64, kexec-tools can generate a "memmap=" parameter for crash kernel's memory region without any user's interaction.
(please note that this parameter eventually goes into dtb's cmdline property in /chosen.)

In this sense, it is no different from an extra property under /chosen as kexec-tools can also add it to dtb passed to the crash dump kernel.

(See what I mean?)

Quoted 1 line
Quoted 1 line

For x86 we would like to drop the memmap= usage in kexec-tools

I didn't know that :)

Quoted 5 lines
Quoted 5 lines

but we can not
do that for a compatibility problem about calgary iommu. So that currently kexec-tools supports both recreating E820 maps and passing memmap=.

We should think it carefully because it will be hard to remove once we support it.

Absolutely.

Quoted 5 lines
Quoted 1 line

IMO handling it in code is better than using an external interface.

Also seems semantic of memmap=exactmap is different than current use in the implementation exactmap means we need pass each range seperately including reserved, acpi and other types We can not reuse ranges in uefi memmap for other than usable memory.

If necessary, we may use a different name, say, "usablememmap=" for arm64 or just extend "mem=" semantics (allowing XX at YY format) to avoid any confusion.

Thanks,
-Takahiro AKASHI

Quoted 5 lines

It will also have the cmdline array size issue.k

Thanks
Dave

#49 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 16 lines · AKASHI Takahiro
Quoted 8 lines · Dave Young
Quoted 8 lines
Quoted 5 lines

So I'm not still sure about what are advantages of a property under /chosen over "memmap=" kernel parameter.
Both are simple and can have the same effect with minimizing changes to dtb. (But if, in the latter case, we have to provide *all* the memory-related information through "memmap=" parameters, it would be much complicated.)

Maybe I did not say it clearly, I prefer kexec syscall/tool to modifiy dtb or uefi-memmap so that we do not need any extra kernel cmdline.

Yes, I understand.
But on arm64, kexec-tools can generate a "memmap=" parameter for crash kernel's memory region without any user's interaction.
(please note that this parameter eventually goes into dtb's cmdline property in /chosen.)

Quoted 4 lines

In this sense, it is no different from an extra property under /chosen as kexec-tools can also add it to dtb passed to the crash dump kernel.

(See what I mean?)

I think I understand your points, what I would prefer is not an extra property but modifying uefi memmap or recreating memory nodes for !EFI to be used in kdump kernel.

Quoted 15 lines
Quoted 2 lines
Quoted 2 lines

For x86 we would like to drop the memmap= usage in kexec-tools

I didn't know that :)

Quoted 5 lines
Quoted 5 lines

but we can not
do that for a compatibility problem about calgary iommu. So that currently kexec-tools supports both recreating E820 maps and passing memmap=.

We should think it carefully because it will be hard to remove once we support it.

Absolutely.

Quoted 2 lines
Quoted 1 line

IMO handling it in code is better than using an external interface.

Quoted 7 lines
Quoted 3 lines

Also seems semantic of memmap=exactmap is different than current use in the implementation exactmap means we need pass each range seperately including reserved, acpi and other types We can not reuse ranges in uefi memmap for other than usable memory.

If necessary, we may use a different name, say, "usablememmap=" for arm64 or just extend "mem=" semantics (allowing XX@YY format) to avoid any confusion.

For either of above what is the 1st kernel behavior with these params?

Quoted 9 lines

Thanks,
-Takahiro AKASHI

Quoted 5 lines

It will also have the cmdline array size issue.k

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

reviewer
#50 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

In reply to Dave Young
Quoted 2 lines · Dave Young

Maybe I did not say it clearly, I prefer kexec syscall/tool to modifiy dtb or uefi-memmap so that we do not need any extra kernel cmdline.

I am strongly opposed to modifying the FW-provided memroy map information, for the reasons I expressed in other replies.

What are your concerns with a property under /chosen?

Quoted 5 lines

For x86 we would like to drop the memmap= usage in kexec-tools but we can not do that for a compatibility problem about calgary iommu. So that currently kexec-tools supports both recreating E820 maps and passing memmap=.

We should think it carefully because it will be hard to remove once we support it.

I agree that we don't want a plethora of solutions that we have to support forever.

Quoted 1 line

IMO handling it in code is better than using an external interface.

I'm not sure what you mean by this. What is the "external interface", and which code do you beleive it is better to handle this in?

Thanks,
Mark.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#51 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Hi, Mark

Quoted 15 lines · Mark Rutland
Quoted 2 lines · Dave Young

Maybe I did not say it clearly, I prefer kexec syscall/tool to modifiy dtb or uefi-memmap so that we do not need any extra kernel cmdline.

I am strongly opposed to modifying the FW-provided memroy map information, for the reasons I expressed in other replies.

What are your concerns with a property under /chosen?

Quoted 5 lines

For x86 we would like to drop the memmap= usage in kexec-tools but we can not do that for a compatibility problem about calgary iommu. So that currently kexec-tools supports both recreating E820 maps and passing memmap=.

We should think it carefully because it will be hard to remove once we support it.

Quoted 7 lines

I agree that we don't want a plethora of solutions that we have to support forever.

Quoted 1 line

IMO handling it in code is better than using an external interface.

I'm not sure what you mean by this. What is the "external interface", and which code do you beleive it is better to handle this in?

I think we have covered all these in another reply. Let's continue the discussion if needed in that thread.

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#52 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

In reply to Mark Rutland
Quoted 4 lines

I am strongly opposed to modifying the FW-provided memroy map information, for the reasons I expressed in other replies.

What are your concerns with a property under /chosen?

If we choose a simpler way between memmap= and /chosen property then I think a property in /chosen looks better to me.

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

reviewer
#53 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

In reply to AKASHI Takahiro
Quoted 53 lines · AKASHI Takahiro
Quoted 40 lines · Dave Young
Quoted 39 lines · Mark Rutland
Quoted 25 lines · Dave Young
Quoted 15 lines · Mark Rutland
Quoted 14 lines · Dave Young
Quoted 12 lines · AKASHI Takahiro
Quoted 4 lines · Dave Young

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

Thanks. I will visit x86 code again.

Quoted 2 lines

I think it is X86 specific. Personally I think device tree property is better.

Do you think so?

Quoted 8 lines
Quoted 4 lines

I'm not sure it is the best way. For X86 we run into problem with memmap= design, one example is pci domain X (X>1) need the pci memory ranges being passed to kdump kernel. When we passed reserved ranges in /proc/iomem to 2nd kernel we find that cmdline[] array is not big enough.

I'm not sure how PCI ranges relate to the memory map used for normal memory (i.e. RAM), though I'm probably missing some caveat with the way ACPI and UEFI describe PCI. Why does memmap= affect PCI memory?

Quoted 8 lines

Here is the old patch which was rejected in kexec-tools:
http://lists.infradead.org/pipermail/kexec/2013-February/007924.html

Quoted 3 lines

If the kernel got the rest of its system topology from DT, the PCI regions would be described there.

Yes, if kdump kernel use same DT as 1st kernel.

Other than for testing purposes, I don't see why you'd pass the kdump kernel a DTB inconsistent with that the 1st kernel was passsed (other than some proerties under /chosen).

Quoted 7 lines
Quoted 3 lines

We added /sys/firmware/fdt specifically to allow the kexec tools to get the exact DTB the first kernel used. There's no reason for tools to have to make something up.

Agreed, but kexec-tools has an option to pass in any dtb files. Who knows how one will use it unless dropping the option and use /sys/firmware/fdt unconditionally.

As a matter of fact, specifying proper command line parameters as well as dtb is partly users' responsibility for kdump to work correctly. (especially for BE kernel)

Quoted 5 lines
Quoted 2 lines

If we choose to implement kexec_file_load only in kernel, the interfaces provided are kernel, initrd and cmdline. We can always use same dtb.

I would say that we can always use the same dtb even with kexec_load from user's perspective. Right?

No.

This breaks using kexec for boot-loader purposes, and imposes a policy.

For better or worse kexec_file_load has always imposed a constrained Linux-only policy, so that's a different story.

Quoted 11 lines
Quoted 8 lines
Quoted 5 lines

There's a horrible edge case I've spotted if performing a chain of cross-endian kexecs: LE -> BE -> LE, as the BE kernel would have to respect the EFI memory map so as to avoid corrupting it for the subsequent LE kernel. Other than this I believe everything should just work.

Firmware do not know kernel endianniess, kernel should respect firmware maps and adapt to it, it sounds like a generic issue not specfic to kexec.

On arm64, a kernel image header has a bit field to specify the image's endianness. Anyway, our current implementation replies on a user-supplied dtb to start BE kernel.

The firmware should _never_ care about the kernel's endianness. The bootlaoder or first kernel shouldn't care about the next kernel's endianness apart from in exceptional circumstances. The DTB for a LE kernel should look identical to that passed to a BE kernel.

In my mind, the only valid reason to look at that bit is so that bootloaders can provide a warning if the CPU does not implement that endianness.

The issue I mention above should be solved by changes to the BE kernel.

Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

Is it possible to modify uefi memmap for kdump case?

Technically it would be possible, however I don't think it's necessary, and I think it would be disadvantageous to do so.

Quoted 8 lines
Quoted 2 lines

Describing the range(s) the crash kernel can use in separate properties under /chosen has a number of advantages.

Ok, I got the points. We have a is_kdump_kernel() by checking if there is elfcorehdr_addr kernel cmdline. This is mainly for some drivers which do not work well in kdump kernel some uncertain reasons. But ideally I think kernel should handle things just like in 1st kernel and avoid to use it.

Quoted 5 lines

So I'm not still sure about what are advantages of a property under /chosen over "memmap=" kernel parameter.
Both are simple and can have the same effect with minimizing changes to dtb. (But if, in the latter case, we have to provide *all* the memory-related information through "memmap=" parameters, it would be much complicated.)

The reason I prefer a property over command line additions include:

* It keeps the command line simple (as you mention the opposite is "complicated").

* It is logically separate from options the user may pass to the kernel in that the restricted region(s) of memory avaialble are effectively properties of the system (in that the crashed OS is part of the system state).

* The semantics of the command line parsing can change subtly over time (for example, see 51e158c12aca3c9a, which terminates command line parseing at "--"). Maknig sure that a command line option will actually be parsed by the next kernel is not trivial.

Keeping this information isolated from the command line is more robust.

* Addition of a property is a self-contained operation, that doesn't require any knowledge about the command line.

Thanks,
Mark.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#54 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 57 lines · Mark Rutland
Quoted 56 lines · AKASHI Takahiro
Quoted 40 lines · Dave Young
Quoted 39 lines · Mark Rutland
Quoted 25 lines · Dave Young
Quoted 15 lines · Mark Rutland
Quoted 14 lines · Dave Young
Quoted 12 lines · AKASHI Takahiro
Quoted 4 lines · Dave Young

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

Thanks. I will visit x86 code again.

Quoted 2 lines

I think it is X86 specific. Personally I think device tree property is better.

Do you think so?

Quoted 8 lines
Quoted 4 lines

I'm not sure it is the best way. For X86 we run into problem with memmap= design, one example is pci domain X (X>1) need the pci memory ranges being passed to kdump kernel. When we passed reserved ranges in /proc/iomem to 2nd kernel we find that cmdline[] array is not big enough.

I'm not sure how PCI ranges relate to the memory map used for normal memory (i.e. RAM), though I'm probably missing some caveat with the way ACPI and UEFI describe PCI. Why does memmap= affect PCI memory?

Quoted 8 lines

Here is the old patch which was rejected in kexec-tools:
http://lists.infradead.org/pipermail/kexec/2013-February/007924.html

Quoted 3 lines

If the kernel got the rest of its system topology from DT, the PCI regions would be described there.

Yes, if kdump kernel use same DT as 1st kernel.

Other than for testing purposes, I don't see why you'd pass the kdump kernel a DTB inconsistent with that the 1st kernel was passsed (other than some proerties under /chosen).

Quoted 7 lines
Quoted 3 lines

We added /sys/firmware/fdt specifically to allow the kexec tools to get the exact DTB the first kernel used. There's no reason for tools to have to make something up.

Agreed, but kexec-tools has an option to pass in any dtb files. Who knows how one will use it unless dropping the option and use /sys/firmware/fdt unconditionally.

As a matter of fact, specifying proper command line parameters as well as dtb is partly users' responsibility for kdump to work correctly. (especially for BE kernel)

Quoted 2 lines

If we choose to implement kexec_file_load only in kernel, the interfaces provided are kernel, initrd and cmdline. We can always use same dtb.

Quoted 6 lines
Quoted 2 lines

I would say that we can always use the same dtb even with kexec_load from user's perspective. Right?

No.

This breaks using kexec for boot-loader purposes, and imposes a policy.

What kind of policy?
I said "can", but if we want to use other setting/configuration, we can still have a full control.

Quoted 12 lines

For better or worse kexec_file_load has always imposed a constrained Linux-only policy, so that's a different story.

Quoted 9 lines
Quoted 8 lines
Quoted 5 lines

There's a horrible edge case I've spotted if performing a chain of cross-endian kexecs: LE -> BE -> LE, as the BE kernel would have to respect the EFI memory map so as to avoid corrupting it for the subsequent LE kernel. Other than this I believe everything should just work.

Firmware do not know kernel endianniess, kernel should respect firmware maps and adapt to it, it sounds like a generic issue not specfic to kexec.

Quoted 7 lines
Quoted 2 lines

On arm64, a kernel image header has a bit field to specify the image's endianness. Anyway, our current implementation replies on a user-supplied dtb to start BE kernel.

The firmware should _never_ care about the kernel's endianness. The bootlaoder or first kernel shouldn't care about the next kernel's endianness apart from in exceptional circumstances. The DTB for a LE kernel should look identical to that passed to a BE kernel.

Please note that I didn't say anything different from your last two statements. The current arm64 kexec implementation doesn't do anything specific to BE, but as far as BE kernel doesn't support UEFI, users are responsible for providing a proper dtb.

Quoted 20 lines

In my mind, the only valid reason to look at that bit is so that bootloaders can provide a warning if the CPU does not implement that endianness.

The issue I mention above should be solved by changes to the BE kernel.

Quoted 14 lines
Quoted 13 lines
Quoted 7 lines
Quoted 1 line

Is it possible to modify uefi memmap for kdump case?

Technically it would be possible, however I don't think it's necessary, and I think it would be disadvantageous to do so.

Describing the range(s) the crash kernel can use in separate properties under /chosen has a number of advantages.

Ok, I got the points. We have a is_kdump_kernel() by checking if there is elfcorehdr_addr kernel cmdline. This is mainly for some drivers which do not work well in kdump kernel some uncertain reasons. But ideally I think kernel should handle things just like in 1st kernel and avoid to use it.

Quoted 7 lines
Quoted 5 lines

So I'm not still sure about what are advantages of a property under /chosen over "memmap=" kernel parameter.
Both are simple and can have the same effect with minimizing changes to dtb. (But if, in the latter case, we have to provide *all* the memory-related information through "memmap=" parameters, it would be much complicated.)

The reason I prefer a property over command line additions include:

Take some examples:
(a) a property under /chosen

   {
     chosen = {
       cmdline = "elfcorehdr=AA at BB maxcpus=1 ...";
     }
     usable-memory = <XX YY>;
     memory {
       ...
     }

}

(b) a kernel command line parameter
(I use the same name, "usable-memory", to show the similarity. may use another name though.)

   {
     chosen = {
       cmdline = "elfcorehdr=AA at BB maxcpus=1 usable-memory=YY at XX ...";
     }
     memory {
       ...
     }

}

Quoted 2 lines

* It keeps the command line simple (as you mention the opposite is "complicated").

I think both are simple.

Quoted 4 lines

* It is logically separate from options the user may pass to the kernel in that the restricted region(s) of memory avaialble are effectively properties of the system (in that the crashed OS is part of the system state).

"elfcorehdr=" parameter already breaks your point.
"elfcorehdr=" looks to be, what you say, a system property, and is actually added by kexec-tools on all architectures, and "usable-memory", whether it is a DT property or a kernel parameter, will also be added by kexec-tools. (Users don't have to care.)

Quoted 7 lines

* The semantics of the command line parsing can change subtly over time (for example, see 51e158c12aca3c9a, which terminates command line parseing at "--"). Maknig sure that a command line option will actually be parsed by the next kernel is not trivial.

Keeping this information isolated from the command line is more robust.

Even so, who wants to use kdump without testing?
and this is not a kdump specific issue.

Quoted 2 lines

* Addition of a property is a self-contained operation, that doesn't require any knowledge about the command line.

I don't get your point here.
For a kernel parameter, early_param() can encapsulate all the stuffs necessary. Once the kernel recognizes a usable memory region, limiting available memory should be done in the exact same way.

Thanks,
-Takahiro AKASHI

Quoted 3 lines

Thanks,
Mark.

reviewer
#55 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 61 lines · AKASHI Takahiro
Quoted 60 lines · Mark Rutland
Quoted 58 lines · AKASHI Takahiro
Quoted 40 lines · Dave Young
Quoted 39 lines · Mark Rutland
Quoted 25 lines · Dave Young
Quoted 15 lines · Mark Rutland
Quoted 14 lines · Dave Young
Quoted 12 lines · AKASHI Takahiro
Quoted 4 lines · Dave Young

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

Thanks. I will visit x86 code again.

Quoted 2 lines

I think it is X86 specific. Personally I think device tree property is better.

Do you think so?

Quoted 8 lines
Quoted 4 lines

I'm not sure it is the best way. For X86 we run into problem with memmap= design, one example is pci domain X (X>1) need the pci memory ranges being passed to kdump kernel. When we passed reserved ranges in /proc/iomem to 2nd kernel we find that cmdline[] array is not big enough.

I'm not sure how PCI ranges relate to the memory map used for normal memory (i.e. RAM), though I'm probably missing some caveat with the way ACPI and UEFI describe PCI. Why does memmap= affect PCI memory?

Quoted 8 lines

Here is the old patch which was rejected in kexec-tools:
http://lists.infradead.org/pipermail/kexec/2013-February/007924.html

Quoted 3 lines

If the kernel got the rest of its system topology from DT, the PCI regions would be described there.

Yes, if kdump kernel use same DT as 1st kernel.

Other than for testing purposes, I don't see why you'd pass the kdump kernel a DTB inconsistent with that the 1st kernel was passsed (other than some proerties under /chosen).

Quoted 7 lines
Quoted 3 lines

We added /sys/firmware/fdt specifically to allow the kexec tools to get the exact DTB the first kernel used. There's no reason for tools to have to make something up.

Agreed, but kexec-tools has an option to pass in any dtb files. Who knows how one will use it unless dropping the option and use /sys/firmware/fdt unconditionally.

As a matter of fact, specifying proper command line parameters as well as dtb is partly users' responsibility for kdump to work correctly. (especially for BE kernel)

Quoted 2 lines

If we choose to implement kexec_file_load only in kernel, the interfaces provided are kernel, initrd and cmdline. We can always use same dtb.

I would say that we can always use the same dtb even with kexec_load from user's perspective. Right?

Quoted 7 lines
Quoted 3 lines

No.

This breaks using kexec for boot-loader purposes, and imposes a policy.

What kind of policy?
I said "can", but if we want to use other setting/configuration, we can still have a full control.

Apologies, I misunderstood.

In most cases, using the existing DTB (with minor modifications to /chosen for bootargs and such) is fine. If the user just wants to boot another Linux kernel, that's generally what they should do.

I think we're agreed on that.

However, there are cases when the user may want to use a different DTB, or use a different purgatory. So we cannot mandate that the existing DTB is reused, nor that an in-kernel purgatory must be used, as that imposes a policy.

Quoted 20 lines
Quoted 12 lines

For better or worse kexec_file_load has always imposed a constrained Linux-only policy, so that's a different story.

Quoted 9 lines
Quoted 8 lines
Quoted 5 lines

There's a horrible edge case I've spotted if performing a chain of cross-endian kexecs: LE -> BE -> LE, as the BE kernel would have to respect the EFI memory map so as to avoid corrupting it for the subsequent LE kernel. Other than this I believe everything should just work.

Firmware do not know kernel endianniess, kernel should respect firmware maps and adapt to it, it sounds like a generic issue not specfic to kexec.

Quoted 7 lines
Quoted 2 lines

On arm64, a kernel image header has a bit field to specify the image's endianness. Anyway, our current implementation replies on a user-supplied dtb to start BE kernel.

The firmware should _never_ care about the kernel's endianness. The bootlaoder or first kernel shouldn't care about the next kernel's endianness apart from in exceptional circumstances. The DTB for a LE kernel should look identical to that passed to a BE kernel.

Quoted 4 lines

Please note that I didn't say anything different from your last two statements. The current arm64 kexec implementation doesn't do anything specific to BE, but as far as BE kernel doesn't support UEFI, users are responsible for providing a proper dtb.

I'm just confused as to what you mean by a "proper dtb" in that case.

If you just mean one with memory nodes hacked in, then that would currently be a way to make that work, yes.

It seems like the better option is to fix the BE kernel to support a UEFI memory map, as that solves other issues.

Quoted 62 lines
Quoted 21 lines

In my mind, the only valid reason to look at that bit is so that bootloaders can provide a warning if the CPU does not implement that endianness.

The issue I mention above should be solved by changes to the BE kernel.

Quoted 14 lines
Quoted 13 lines
Quoted 7 lines
Quoted 1 line

Is it possible to modify uefi memmap for kdump case?

Technically it would be possible, however I don't think it's necessary, and I think it would be disadvantageous to do so.

Describing the range(s) the crash kernel can use in separate properties under /chosen has a number of advantages.

Ok, I got the points. We have a is_kdump_kernel() by checking if there is elfcorehdr_addr kernel cmdline. This is mainly for some drivers which do not work well in kdump kernel some uncertain reasons. But ideally I think kernel should handle things just like in 1st kernel and avoid to use it.

Quoted 7 lines
Quoted 5 lines

So I'm not still sure about what are advantages of a property under /chosen over "memmap=" kernel parameter.
Both are simple and can have the same effect with minimizing changes to dtb. (But if, in the latter case, we have to provide *all* the memory-related information through "memmap=" parameters, it would be much complicated.)

The reason I prefer a property over command line additions include:

Take some examples:
(a) a property under /chosen

  {
    chosen = {
      cmdline = "elfcorehdr=AA@BB maxcpus=1 ...";
    }
    usable-memory = <XX YY>;
    memory {
      ...
    }

}

(b) a kernel command line parameter
(I use the same name, "usable-memory", to show the similarity. may use another name though.)

  {
    chosen = {
      cmdline = "elfcorehdr=AA@BB maxcpus=1 usable-memory=YY@XX ...";
    }
    memory {
      ...
    }

}

Quoted 2 lines

* It keeps the command line simple (as you mention the opposite is "complicated").

I think both are simple.

Quoted 4 lines

* It is logically separate from options the user may pass to the kernel in that the restricted region(s) of memory avaialble are effectively properties of the system (in that the crashed OS is part of the system state).

Quoted 5 lines

"elfcorehdr=" parameter already breaks your point.
"elfcorehdr=" looks to be, what you say, a system property, and is actually added by kexec-tools on all architectures, and "usable-memory", whether it is a DT property or a kernel parameter, will also be added by kexec-tools. (Users don't have to care.)

Just because architectures do one thing today does not mean that we have to follow it.

I don't think that breaks my point so much as shows that a different approach is taken by others today.

There's also no reason this cannot be a property under /chosen.

Quoted 11 lines
Quoted 7 lines

* The semantics of the command line parsing can change subtly over time (for example, see 51e158c12aca3c9a, which terminates command line parseing at "--"). Maknig sure that a command line option will actually be parsed by the next kernel is not trivial.

Keeping this information isolated from the command line is more robust.

Even so, who wants to use kdump without testing?
and this is not a kdump specific issue.

Quoted 7 lines
Quoted 2 lines

* Addition of a property is a self-contained operation, that doesn't require any knowledge about the command line.

I don't get your point here.
For a kernel parameter, early_param() can encapsulate all the stuffs necessary. Once the kernel recognizes a usable memory region, limiting available memory should be done in the exact same way.

I mean when modifying the command line.

To place "elfcorehdr=" or "memmap="/"usable-memory=" into the command line, one needs to know where it is valid to place it. Appending doesn't always work, as per the example above with 51e158c12aca3c9a.

For both of these my point was that generally there is some fragility in this area. While it's easy to say that breaking this would be someone else's fault, we can easily avoid the possibility of that happening, and avoid a set of problems trying to maintain backwards compatibility if there were a sensible change that happened to break things.

Thanks,
Mark.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#56 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 70 lines · Mark Rutland
Quoted 61 lines · AKASHI Takahiro
Quoted 60 lines · Mark Rutland
Quoted 58 lines · AKASHI Takahiro
Quoted 40 lines · Dave Young
Quoted 39 lines · Mark Rutland
Quoted 25 lines · Dave Young
Quoted 15 lines · Mark Rutland
Quoted 14 lines · Dave Young
Quoted 12 lines · AKASHI Takahiro
Quoted 4 lines · Dave Young

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

Thanks. I will visit x86 code again.

Quoted 2 lines

I think it is X86 specific. Personally I think device tree property is better.

Do you think so?

Quoted 8 lines
Quoted 4 lines

I'm not sure it is the best way. For X86 we run into problem with memmap= design, one example is pci domain X (X>1) need the pci memory ranges being passed to kdump kernel. When we passed reserved ranges in /proc/iomem to 2nd kernel we find that cmdline[] array is not big enough.

I'm not sure how PCI ranges relate to the memory map used for normal memory (i.e. RAM), though I'm probably missing some caveat with the way ACPI and UEFI describe PCI. Why does memmap= affect PCI memory?

Quoted 8 lines

Here is the old patch which was rejected in kexec-tools:
http://lists.infradead.org/pipermail/kexec/2013-February/007924.html

Quoted 3 lines

If the kernel got the rest of its system topology from DT, the PCI regions would be described there.

Yes, if kdump kernel use same DT as 1st kernel.

Other than for testing purposes, I don't see why you'd pass the kdump kernel a DTB inconsistent with that the 1st kernel was passsed (other than some proerties under /chosen).

Quoted 7 lines
Quoted 3 lines

We added /sys/firmware/fdt specifically to allow the kexec tools to get the exact DTB the first kernel used. There's no reason for tools to have to make something up.

Agreed, but kexec-tools has an option to pass in any dtb files. Who knows how one will use it unless dropping the option and use /sys/firmware/fdt unconditionally.

As a matter of fact, specifying proper command line parameters as well as dtb is partly users' responsibility for kdump to work correctly. (especially for BE kernel)

Quoted 2 lines

If we choose to implement kexec_file_load only in kernel, the interfaces provided are kernel, initrd and cmdline. We can always use same dtb.

I would say that we can always use the same dtb even with kexec_load from user's perspective. Right?

Quoted 7 lines
Quoted 3 lines

No.

This breaks using kexec for boot-loader purposes, and imposes a policy.

What kind of policy?
I said "can", but if we want to use other setting/configuration, we can still have a full control.

Quoted 7 lines

Apologies, I misunderstood.

In most cases, using the existing DTB (with minor modifications to /chosen for bootargs and such) is fine. If the user just wants to boot another Linux kernel, that's generally what they should do.

I think we're agreed on that.

Yes.

Quoted 4 lines

However, there are cases when the user may want to use a different DTB, or use a different purgatory. So we cannot mandate that the existing DTB is reused, nor that an in-kernel purgatory must be used, as that imposes a policy.

Agree!

Quoted 25 lines
Quoted 20 lines
Quoted 12 lines

For better or worse kexec_file_load has always imposed a constrained Linux-only policy, so that's a different story.

Quoted 9 lines
Quoted 8 lines
Quoted 5 lines

There's a horrible edge case I've spotted if performing a chain of cross-endian kexecs: LE -> BE -> LE, as the BE kernel would have to respect the EFI memory map so as to avoid corrupting it for the subsequent LE kernel. Other than this I believe everything should just work.

Firmware do not know kernel endianniess, kernel should respect firmware maps and adapt to it, it sounds like a generic issue not specfic to kexec.

Quoted 7 lines
Quoted 2 lines

On arm64, a kernel image header has a bit field to specify the image's endianness. Anyway, our current implementation replies on a user-supplied dtb to start BE kernel.

The firmware should _never_ care about the kernel's endianness. The bootlaoder or first kernel shouldn't care about the next kernel's endianness apart from in exceptional circumstances. The DTB for a LE kernel should look identical to that passed to a BE kernel.

Quoted 4 lines

Please note that I didn't say anything different from your last two statements. The current arm64 kexec implementation doesn't do anything specific to BE, but as far as BE kernel doesn't support UEFI, users are responsible for providing a proper dtb.

Quoted 4 lines

I'm just confused as to what you mean by a "proper dtb" in that case.

If you just mean one with memory nodes hacked in, then that would currently be a way to make that work, yes.

One of useful cases that I have in my mind is kdump.
We may want to use a small sub-set of dtb, especially devices, to make the reboot more reliable. Device drivers are likely to be vulnerable at crash.

Quoted 2 lines

It seems like the better option is to fix the BE kernel to support a UEFI memory map, as that solves other issues.

Why did Ard throw away his patch?

Quoted 68 lines
Quoted 62 lines
Quoted 21 lines

In my mind, the only valid reason to look at that bit is so that bootloaders can provide a warning if the CPU does not implement that endianness.

The issue I mention above should be solved by changes to the BE kernel.

Quoted 14 lines
Quoted 13 lines
Quoted 7 lines
Quoted 1 line

Is it possible to modify uefi memmap for kdump case?

Technically it would be possible, however I don't think it's necessary, and I think it would be disadvantageous to do so.

Describing the range(s) the crash kernel can use in separate properties under /chosen has a number of advantages.

Ok, I got the points. We have a is_kdump_kernel() by checking if there is elfcorehdr_addr kernel cmdline. This is mainly for some drivers which do not work well in kdump kernel some uncertain reasons. But ideally I think kernel should handle things just like in 1st kernel and avoid to use it.

Quoted 7 lines
Quoted 5 lines

So I'm not still sure about what are advantages of a property under /chosen over "memmap=" kernel parameter.
Both are simple and can have the same effect with minimizing changes to dtb. (But if, in the latter case, we have to provide *all* the memory-related information through "memmap=" parameters, it would be much complicated.)

The reason I prefer a property over command line additions include:

Take some examples:
(a) a property under /chosen

   {
     chosen = {
       cmdline = "elfcorehdr=AA at BB maxcpus=1 ...";
     }
     usable-memory = <XX YY>;
     memory {
       ...
     }

}

(b) a kernel command line parameter
(I use the same name, "usable-memory", to show the similarity. may use another name though.)

   {
     chosen = {
       cmdline = "elfcorehdr=AA at BB maxcpus=1 usable-memory=YY at XX ...";
     }
     memory {
       ...
     }

}

Quoted 2 lines

* It keeps the command line simple (as you mention the opposite is "complicated").

I think both are simple.

Quoted 4 lines

* It is logically separate from options the user may pass to the kernel in that the restricted region(s) of memory avaialble are effectively properties of the system (in that the crashed OS is part of the system state).

Quoted 5 lines

"elfcorehdr=" parameter already breaks your point.
"elfcorehdr=" looks to be, what you say, a system property, and is actually added by kexec-tools on all architectures, and "usable-memory", whether it is a DT property or a kernel parameter, will also be added by kexec-tools. (Users don't have to care.)

Quoted 7 lines

Just because architectures do one thing today does not mean that we have to follow it.

I don't think that breaks my point so much as shows that a different approach is taken by others today.

There's also no reason this cannot be a property under /chosen.

No, but no strong reason to be so IMO.

Quoted 14 lines
Quoted 14 lines
Quoted 7 lines

* The semantics of the command line parsing can change subtly over time (for example, see 51e158c12aca3c9a, which terminates command line parseing at "--"). Maknig sure that a command line option will actually be parsed by the next kernel is not trivial.

Keeping this information isolated from the command line is more robust.

Even so, who wants to use kdump without testing?
and this is not a kdump specific issue.

Quoted 2 lines

* Addition of a property is a self-contained operation, that doesn't require any knowledge about the command line.

Quoted 6 lines
Quoted 4 lines

I don't get your point here.
For a kernel parameter, early_param() can encapsulate all the stuffs necessary. Once the kernel recognizes a usable memory region, limiting available memory should be done in the exact same way.

I mean when modifying the command line.

OK, I understand what you mean.

Quoted 3 lines

To place "elfcorehdr=" or "memmap="/"usable-memory=" into the command line, one needs to know where it is valid to place it. Appending doesn't always work, as per the example above with 51e158c12aca3c9a.

So, are you now suggesting that we put both "elfcorehdr=" and "usable-memory=" under /chosen in dtb? That's fair enough. (as far as nobody cares about incompatibility with other archs.)

-Takahiro AKASHI

Quoted 9 lines

For both of these my point was that generally there is some fragility in this area. While it's easy to say that breaking this would be someone else's fault, we can easily avoid the possibility of that happening, and avoid a set of problems trying to maintain backwards compatibility if there were a sensible change that happened to break things.

Thanks,
Mark.

reviewer
#57 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 23 lines · AKASHI Takahiro
Quoted 22 lines · Mark Rutland
Quoted 14 lines · AKASHI Takahiro
Quoted 5 lines · Mark Rutland
Quoted 4 lines · AKASHI Takahiro
Quoted 2 lines · Dave Young

Firmware do not know kernel endianniess, kernel should respect firmware maps and adapt to it, it sounds like a generic issue not specfic to kexec.

Quoted 7 lines
Quoted 2 lines

On arm64, a kernel image header has a bit field to specify the image's endianness. Anyway, our current implementation replies on a user-supplied dtb to start BE kernel.

The firmware should _never_ care about the kernel's endianness. The bootlaoder or first kernel shouldn't care about the next kernel's endianness apart from in exceptional circumstances. The DTB for a LE kernel should look identical to that passed to a BE kernel.

Quoted 4 lines

Please note that I didn't say anything different from your last two statements. The current arm64 kexec implementation doesn't do anything specific to BE, but as far as BE kernel doesn't support UEFI, users are responsible for providing a proper dtb.

I'm just confused as to what you mean by a "proper dtb" in that case.

Quoted 7 lines
Quoted 2 lines

If you just mean one with memory nodes hacked in, then that would currently be a way to make that work, yes.

One of useful cases that I have in my mind is kdump.
We may want to use a small sub-set of dtb, especially devices, to make the reboot more reliable. Device drivers are likely to be vulnerable at crash.

I don't think that we can reliably have userspace carve out devices from the DTB or from ACPI tables in order to achieve that. That's going to end up complex and/or incomplete. We also can't do this in the kexec_load_file / Secure Boot case.

That's not to say we cannot try, as it's possible when using kexec_load. However, it's only going to be possible on a subset of systems, and it would probably make sense to reserve this approach to those cases we cannot work around by other means (e.g. whitelisting "safe" devices in the kdump kernel, forcing explicit resets, etc).

Quoted 4 lines
Quoted 2 lines

It seems like the better option is to fix the BE kernel to support a UEFI memory map, as that solves other issues.

Why did Ard throw away his patch?

In the absence of kexec it wasn't necessary, it only supported a subset of the runtime services (and no other features like DMI IIRC), and it looked like it would be painful to debug (if something went wrong while a CPU was in LE mode, we couldn't even panic()).

Given BE kernels on UEFI were never supported until that point, there wasn't a compelling reason to support that case.

Even if we support the UEFI memory map, I don't think it's worth the effort to support runtime services, ACPI, and related code that's only ever been tested on LE. So realistically this would only work on systems using UEFI && DT rather than UEFI && ACPI.

Quoted 2 lines

So, are you now suggesting that we put both "elfcorehdr=" and "usable-memory=" under /chosen in dtb?

Yes.

Quoted 2 lines

That's fair enough. (as far as nobody cares about incompatibility with other archs.)

Glad to hear! :)

Thanks,
Mark.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#58 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Mark,

Quoted 64 lines · Mark Rutland
Quoted 23 lines · AKASHI Takahiro
Quoted 22 lines · Mark Rutland
Quoted 14 lines · AKASHI Takahiro
Quoted 5 lines · Mark Rutland
Quoted 4 lines · AKASHI Takahiro
Quoted 2 lines · Dave Young

Firmware do not know kernel endianniess, kernel should respect firmware maps and adapt to it, it sounds like a generic issue not specfic to kexec.

Quoted 7 lines
Quoted 2 lines

On arm64, a kernel image header has a bit field to specify the image's endianness. Anyway, our current implementation replies on a user-supplied dtb to start BE kernel.

The firmware should _never_ care about the kernel's endianness. The bootlaoder or first kernel shouldn't care about the next kernel's endianness apart from in exceptional circumstances. The DTB for a LE kernel should look identical to that passed to a BE kernel.

Quoted 4 lines

Please note that I didn't say anything different from your last two statements. The current arm64 kexec implementation doesn't do anything specific to BE, but as far as BE kernel doesn't support UEFI, users are responsible for providing a proper dtb.

I'm just confused as to what you mean by a "proper dtb" in that case.

Quoted 7 lines
Quoted 2 lines

If you just mean one with memory nodes hacked in, then that would currently be a way to make that work, yes.

One of useful cases that I have in my mind is kdump.
We may want to use a small sub-set of dtb, especially devices, to make the reboot more reliable. Device drivers are likely to be vulnerable at crash.

I don't think that we can reliably have userspace carve out devices from the DTB or from ACPI tables in order to achieve that. That's going to end up complex and/or incomplete. We also can't do this in the kexec_load_file / Secure Boot case.

That's not to say we cannot try, as it's possible when using kexec_load. However, it's only going to be possible on a subset of systems, and it would probably make sense to reserve this approach to those cases we cannot work around by other means (e.g. whitelisting "safe" devices in the kdump kernel, forcing explicit resets, etc).

Quoted 4 lines
Quoted 2 lines

It seems like the better option is to fix the BE kernel to support a UEFI memory map, as that solves other issues.

Why did Ard throw away his patch?

In the absence of kexec it wasn't necessary, it only supported a subset of the runtime services (and no other features like DMI IIRC), and it looked like it would be painful to debug (if something went wrong while a CPU was in LE mode, we couldn't even panic()).

Given BE kernels on UEFI were never supported until that point, there wasn't a compelling reason to support that case.

Even if we support the UEFI memory map, I don't think it's worth the effort to support runtime services, ACPI, and related code that's only ever been tested on LE. So realistically this would only work on systems using UEFI && DT rather than UEFI && ACPI.

Quoted 2 lines

So, are you now suggesting that we put both "elfcorehdr=" and "usable-memory=" under /chosen in dtb?

Quoted 6 lines

Yes.

Quoted 2 lines

That's fair enough. (as far as nobody cares about incompatibility with other archs.)

Glad to hear! :)

I'm preparing for a new version based on our discussions.
Do you think that UEFI memory map support on BE kernel is a prerequisite for accepting my kdump?

-Takahiro AKASHI

Quoted 3 lines

Thanks,
Mark.

#59 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

In reply to AKASHI Takahiro

Hi, AKASHI

Quoted 7 lines
Quoted 3 lines

To place "elfcorehdr=" or "memmap="/"usable-memory=" into the command line, one needs to know where it is valid to place it. Appending doesn't always work, as per the example above with 51e158c12aca3c9a.

So, are you now suggesting that we put both "elfcorehdr=" and "usable-memory=" under /chosen in dtb? That's fair enough. (as far as nobody cares about incompatibility with other archs.)

You may need move is_kdump_kernel as a weak function so that in arm64 you can still use it in kdump kernel.

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#60 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 6 lines · Dave Young

Hi, AKASHI

Quoted 4 lines
Quoted 3 lines

To place "elfcorehdr=" or "memmap="/"usable-memory=" into the command line, one needs to know where it is valid to place it. Appending doesn't always work, as per the example above with 51e158c12aca3c9a.

Quoted 6 lines
Quoted 3 lines

So, are you now suggesting that we put both "elfcorehdr=" and "usable-memory=" under /chosen in dtb? That's fair enough. (as far as nobody cares about incompatibility with other archs.)

You may need move is_kdump_kernel as a weak function so that in arm64 you can still use it in kdump kernel.

Ignore the comment please, you just use a different way to set the variable is_kdump_kernel will still work..

It is pretty fine to use dtb along with usable memories then.

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

reviewer
#61 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

In reply to Dave Young
Quoted 40 lines · Dave Young
Quoted 39 lines · Mark Rutland
Quoted 25 lines · Dave Young
Quoted 15 lines · Mark Rutland
Quoted 14 lines · Dave Young
Quoted 12 lines · AKASHI Takahiro
Quoted 4 lines · Dave Young

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

Thanks. I will visit x86 code again.

Quoted 2 lines

I think it is X86 specific. Personally I think device tree property is better.

Do you think so?

Quoted 8 lines
Quoted 4 lines

I'm not sure it is the best way. For X86 we run into problem with memmap= design, one example is pci domain X (X>1) need the pci memory ranges being passed to kdump kernel. When we passed reserved ranges in /proc/iomem to 2nd kernel we find that cmdline[] array is not big enough.

I'm not sure how PCI ranges relate to the memory map used for normal memory (i.e. RAM), though I'm probably missing some caveat with the way ACPI and UEFI describe PCI. Why does memmap= affect PCI memory?

Quoted 8 lines

Here is the old patch which was rejected in kexec-tools:
http://lists.infradead.org/pipermail/kexec/2013-February/007924.html

Quoted 3 lines

If the kernel got the rest of its system topology from DT, the PCI regions would be described there.

Yes, if kdump kernel use same DT as 1st kernel.

Other than for testing purposes, I don't see why you'd pass the kdump kernel a DTB inconsistent with that the 1st kernel was passsed (other than some proerties under /chosen).

Quoted 7 lines
Quoted 3 lines

We added /sys/firmware/fdt specifically to allow the kexec tools to get the exact DTB the first kernel used. There's no reason for tools to have to make something up.

Agreed, but kexec-tools has an option to pass in any dtb files. Who knows how one will use it unless dropping the option and use /sys/firmware/fdt unconditionally.

I think this is a tangential discussion. I think it's fine to say that for kdump we do not expect this -- a user would be shooting themselves in the foot if they did. Regardless, I was under the impression that kdump was usually set up by distribution-provided init code.

or kdump, which typically is set up automatically by the OS,

Quoted 2 lines

If we choose to implement kexec_file_load only in kernel, the interfaces provided are kernel, initrd and cmdline. We can always use same dtb.

There are use-cases where being in complete control of the purgatory code is necessary. For example, the next OS might not be Linux (and might not accept a DTB, or have different requirements on the initial register state).

Regardless of the need for something like kexec_file_load for kdump in Secure Boot environments, there is also a need for kexec_load with the user having complete control.

Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines

Do you think for arm64 only usable memory is necessary to let kdump kernel know? I'm curious about how arm64 kernel get all memory layout from boot loader, via UEFI memmap?

When booted via EFI, we use the EFI memory map. The EFI stub handles acquring the relevant information and passing that to the first kernel in the DTB (see Documentation/arm/uefi.txt).

Ok, thanks for the pointer. So in dt we are just have uefi memmap infomation instead of memory nodes details..

When booted via EFI, yes.

For NUMA topology in !ACPI kernels, we might need to also retain and parse memory nodes, but only for toplogy information. The kernel would still only use memory as described by the EFI memory map.

Quoted 8 lines
Quoted 5 lines

There's a horrible edge case I've spotted if performing a chain of cross-endian kexecs: LE -> BE -> LE, as the BE kernel would have to respect the EFI memory map so as to avoid corrupting it for the subsequent LE kernel. Other than this I believe everything should just work.

Firmware do not know kernel endianniess, kernel should respect firmware maps and adapt to it, it sounds like a generic issue not specfic to kexec.

I agree that this isn't kexec's fault as such, but in the absence of kexec, the above issue does not exist, so one can't consider it in isolation.

Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
Quoted 2 lines

A kexec'd kernel should simply inherit that. So long as the DTB and/or UEFI tables in memory are the same, it would be the same as a cold boot.

For kexec all memory ranges are same, for kdump we need use original reserved range with crashkernel= as usable memory and all other orignal usable ranges are not usable anymore.

Sure. This is what I believe we should expose with an additional property under /chosen, while keeping everything else pristine.

Quoted 8 lines
Quoted 3 lines

The crash kernel can then limit itself to that region, while it would have the information of the full memory map (which it could log and/or use to drive other dumping).

In this way kernel should be aware it is a kdump booting, it is doable though I feel it is better for kdump kernel in a black box with infomations it can use just like the 1st kernel. Things here is where we choose to cook the memory infomation in boot loader or in kernel itself.

Sorry, I can't follow what you are trying to say here. Could you elaborate?

Quoted 5 lines
Quoted 5 lines
Quoted 1 line

Is it possible to modify uefi memmap for kdump case?

Technically it would be possible, however I don't think it's necessary, and I think it would be disadvantageous to do so.

Quoted 8 lines
Quoted 2 lines

Describing the range(s) the crash kernel can use in separate properties under /chosen has a number of advantages.

Ok, I got the points. We have a is_kdump_kernel() by checking if there is elfcorehdr_addr kernel cmdline. This is mainly for some drivers which do not work well in kdump kernel some uncertain reasons. But ideally I think kernel should handle things just like in 1st kernel and avoid to use it.

I agree that we should not have kexec/kdump knowledge spread throughout the kernel, and that the boot protocol should be uniform with a cold boot as far as possible.

However, requiring userspace or the first kernel to modify firmware-provided information has a number of risks and reduces the amount of information available to the kdump kernel. To that end I am opposed to modifying the memory nodes in the DTB, or to modifying the EFI memory map.

Having a property in the DTB describing the range(s) of memory reserved for use by the kdump kernel is vastly simpler, and avoids those risks:

* It requires a tiny amount of self-contained code in the kdump kernel to parse the property and apply the constraints imposed (i.e. carve up memblock).

This is easy to contain in a single function (or at least within a single file), and need not affect drivers or other code.

* It is uniform regardless of whether the EFI memory map, DT memory nodes, or some other mechanism is used to discover memory in the systems.

This makes it easy to impose the restrictions consistently, and is somewhat future-proof.

* Userspace or the first kernel to not need to parse and modify an arbitrary amount of data (which might be in an extended format it doesn't fully understand). There is less risk for this to go wrong.

It is far easier to add a property than it is to correctly modify the EFI memory map, memory nodes, or some other data structure. There is less risk, and it is somewhat future-proof.

* The original memory map information is preserved, even though unused. This may be useful for debugging, and it may turn out that the kdump kernel needs to know about certain portions of the original memory map, even if we are not currently aware of why we would need this.

Thanks,
Mark.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#62 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 49 lines · Mark Rutland
Quoted 40 lines · Dave Young
Quoted 39 lines · Mark Rutland
Quoted 25 lines · Dave Young
Quoted 15 lines · Mark Rutland
Quoted 14 lines · Dave Young
Quoted 12 lines · AKASHI Takahiro
Quoted 4 lines · Dave Young

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

Thanks. I will visit x86 code again.

Quoted 2 lines

I think it is X86 specific. Personally I think device tree property is better.

Do you think so?

Quoted 8 lines
Quoted 4 lines

I'm not sure it is the best way. For X86 we run into problem with memmap= design, one example is pci domain X (X>1) need the pci memory ranges being passed to kdump kernel. When we passed reserved ranges in /proc/iomem to 2nd kernel we find that cmdline[] array is not big enough.

I'm not sure how PCI ranges relate to the memory map used for normal memory (i.e. RAM), though I'm probably missing some caveat with the way ACPI and UEFI describe PCI. Why does memmap= affect PCI memory?

Quoted 8 lines

Here is the old patch which was rejected in kexec-tools:
http://lists.infradead.org/pipermail/kexec/2013-February/007924.html

Quoted 3 lines

If the kernel got the rest of its system topology from DT, the PCI regions would be described there.

Yes, if kdump kernel use same DT as 1st kernel.

Other than for testing purposes, I don't see why you'd pass the kdump kernel a DTB inconsistent with that the 1st kernel was passsed (other than some proerties under /chosen).

Quoted 7 lines
Quoted 3 lines

We added /sys/firmware/fdt specifically to allow the kexec tools to get the exact DTB the first kernel used. There's no reason for tools to have to make something up.

Agreed, but kexec-tools has an option to pass in any dtb files. Who knows how one will use it unless dropping the option and use /sys/firmware/fdt unconditionally.

Quoted 6 lines

I think this is a tangential discussion. I think it's fine to say that for kdump we do not expect this -- a user would be shooting themselves in the foot if they did. Regardless, I was under the impression that kdump was usually set up by distribution-provided init code.

or kdump, which typically is set up automatically by the OS,

Yes, usually os setup kdump but with some config file user can tune the kexec arguments. Anyway I agree that one should do right but if we are sure exact fdt in 1st kernel is needed we can drop kexec-tools --dtb option.

Quoted 4 lines
Quoted 3 lines

If we choose to implement kexec_file_load only in kernel, the interfaces provided are kernel, initrd and cmdline. We can always use same dtb.

Quoted 8 lines

There are use-cases where being in complete control of the purgatory code is necessary. For example, the next OS might not be Linux (and might not accept a DTB, or have different requirements on the initial register state).

Regardless of the need for something like kexec_file_load for kdump in Secure Boot environments, there is also a need for kexec_load with the user having complete control.

I'm not sure if there are such use cases in arm64 in real life.
But indeed it is a reason kexec_load can exist if there really are such requests.

Quoted 45 lines
Quoted 18 lines
Quoted 18 lines
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines

Do you think for arm64 only usable memory is necessary to let kdump kernel know? I'm curious about how arm64 kernel get all memory layout from boot loader, via UEFI memmap?

When booted via EFI, we use the EFI memory map. The EFI stub handles acquring the relevant information and passing that to the first kernel in the DTB (see Documentation/arm/uefi.txt).

Ok, thanks for the pointer. So in dt we are just have uefi memmap infomation instead of memory nodes details..

When booted via EFI, yes.

For NUMA topology in !ACPI kernels, we might need to also retain and parse memory nodes, but only for toplogy information. The kernel would still only use memory as described by the EFI memory map.

Quoted 8 lines
Quoted 5 lines

There's a horrible edge case I've spotted if performing a chain of cross-endian kexecs: LE -> BE -> LE, as the BE kernel would have to respect the EFI memory map so as to avoid corrupting it for the subsequent LE kernel. Other than this I believe everything should just work.

Firmware do not know kernel endianniess, kernel should respect firmware maps and adapt to it, it sounds like a generic issue not specfic to kexec.

I agree that this isn't kexec's fault as such, but in the absence of kexec, the above issue does not exist, so one can't consider it in isolation.

Quoted 14 lines
Quoted 13 lines
Quoted 6 lines
Quoted 2 lines

A kexec'd kernel should simply inherit that. So long as the DTB and/or UEFI tables in memory are the same, it would be the same as a cold boot.

For kexec all memory ranges are same, for kdump we need use original reserved range with crashkernel= as usable memory and all other orignal usable ranges are not usable anymore.

Sure. This is what I believe we should expose with an additional property under /chosen, while keeping everything else pristine.

The crash kernel can then limit itself to that region, while it would have the information of the full memory map (which it could log and/or use to drive other dumping).

Quoted 7 lines
Quoted 4 lines

In this way kernel should be aware it is a kdump booting, it is doable though I feel it is better for kdump kernel in a black box with infomations it can use just like the 1st kernel. Things here is where we choose to cook the memory infomation in boot loader or in kernel itself.

Sorry, I can't follow what you are trying to say here. Could you elaborate?

Hmm, I menas if we prepare a kdump usable uefi memmap then we do not need introduce the extra dtb property and kdump kernel just works like a normal boot. I think we have understand each other upon latter part of this mail :)

One additianl issue with the simple way is if it can be used only in kdump kernel Or it applys to both normal boot and kdump kernel boot so that it becomes a general interface instead of only for kdump.

That means in 1st kernel we need override all system ram sections from uefi if the usable chosen property is provided in 1st kernel.

Quoted 35 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

Is it possible to modify uefi memmap for kdump case?

Technically it would be possible, however I don't think it's necessary, and I think it would be disadvantageous to do so.

Quoted 8 lines
Quoted 2 lines

Describing the range(s) the crash kernel can use in separate properties under /chosen has a number of advantages.

Ok, I got the points. We have a is_kdump_kernel() by checking if there is elfcorehdr_addr kernel cmdline. This is mainly for some drivers which do not work well in kdump kernel some uncertain reasons. But ideally I think kernel should handle things just like in 1st kernel and avoid to use it.

I agree that we should not have kexec/kdump knowledge spread throughout the kernel, and that the boot protocol should be uniform with a cold boot as far as possible.

However, requiring userspace or the first kernel to modify firmware-provided information has a number of risks and reduces the amount of information available to the kdump kernel. To that end I am opposed to modifying the memory nodes in the DTB, or to modifying the EFI memory map.

Having a property in the DTB describing the range(s) of memory reserved for use by the kdump kernel is vastly simpler, and avoids those risks:

* It requires a tiny amount of self-contained code in the kdump kernel to parse the property and apply the constraints imposed (i.e. carve up memblock).

This is easy to contain in a single function (or at least within a single file), and need not affect drivers or other code.

Quoted 6 lines

* It is uniform regardless of whether the EFI memory map, DT memory nodes, or some other mechanism is used to discover memory in the systems.

This makes it easy to impose the restrictions consistently, and is somewhat future-proof.

Ok, considering arm64 specific complexity of the several combind cases especially this one I would say choosing a simple solution may be the best choice.

Quoted 5 lines

* Userspace or the first kernel to not need to parse and modify an arbitrary amount of data (which might be in an extended format it doesn't fully understand). There is less risk for this to go wrong.

Quoted 8 lines

It is far easier to add a property than it is to correctly modify the EFI memory map, memory nodes, or some other data structure. There is less risk, and it is somewhat future-proof.

* The original memory map information is preserved, even though unused. This may be useful for debugging, and it may turn out that the kdump kernel needs to know about certain portions of the original memory map, even if we are not currently aware of why we would need this.

Thanks
Dave

Quoted 3 lines

Thanks,
Mark.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#63 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

In reply to Mark Rutland
Quoted 35 lines · Mark Rutland
Quoted 25 lines · Dave Young
Quoted 15 lines · Mark Rutland
Quoted 14 lines · Dave Young
Quoted 12 lines · AKASHI Takahiro
Quoted 4 lines · Dave Young

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

Thanks. I will visit x86 code again.

Quoted 2 lines

I think it is X86 specific. Personally I think device tree property is better.

Do you think so?

Quoted 8 lines
Quoted 4 lines

I'm not sure it is the best way. For X86 we run into problem with memmap= design, one example is pci domain X (X>1) need the pci memory ranges being passed to kdump kernel. When we passed reserved ranges in /proc/iomem to 2nd kernel we find that cmdline[] array is not big enough.

I'm not sure how PCI ranges relate to the memory map used for normal memory (i.e. RAM), though I'm probably missing some caveat with the way ACPI and UEFI describe PCI. Why does memmap= affect PCI memory?

Quoted 8 lines

Here is the old patch which was rejected in kexec-tools:
http://lists.infradead.org/pipermail/kexec/2013-February/007924.html

Quoted 3 lines

If the kernel got the rest of its system topology from DT, the PCI regions would be described there.

Yes, if kdump kernel use same DT as 1st kernel.

Quoted 7 lines

Other than for testing purposes, I don't see why you'd pass the kdump kernel a DTB inconsistent with that the 1st kernel was passsed (other than some proerties under /chosen).

We added /sys/firmware/fdt specifically to allow the kexec tools to get the exact DTB the first kernel used. There's no reason for tools to have to make something up.

Currently, arm64 kexec-tools modifies only a cmdline property in dtb to pass a "elfcorehdr=" parameter as well as other restrictions (like maxcpus=1).

Quoted 17 lines
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines

Do you think for arm64 only usable memory is necessary to let kdump kernel know? I'm curious about how arm64 kernel get all memory layout from boot loader, via UEFI memmap?

When booted via EFI, we use the EFI memory map. The EFI stub handles acquring the relevant information and passing that to the first kernel in the DTB (see Documentation/arm/uefi.txt).

Ok, thanks for the pointer. So in dt we are just have uefi memmap infomation instead of memory nodes details..

When booted via EFI, yes.

For NUMA topology in !ACPI kernels, we might need to also retain and parse memory nodes, but only for toplogy information. The kernel would still only use memory as described by the EFI memory map.

Quoted 5 lines

There's a horrible edge case I've spotted if performing a chain of cross-endian kexecs: LE -> BE -> LE, as the BE kernel would have to respect the EFI memory map so as to avoid corrupting it for the subsequent LE kernel. Other than this I believe everything should just work.

BE kernel doesn't support UEFI yet and cannot access UEFI memmap table. So, for LE -> BE, we don't use a dtb generated from /sys/firmware/fdt (or /proc/device-tree) (as in the case of LE -> LE) and require users to provide a dtb file explicitly.

For BE -> LE, BE kernel doesn't know wther UEFI memmap table is available or not and so use the same (explicitly-provided) dtb (as LE -> LE in !UEFI)

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

A kexec'd kernel should simply inherit that. So long as the DTB and/or UEFI tables in memory are the same, it would be the same as a cold boot.

For kexec all memory ranges are same, for kdump we need use original reserved range with crashkernel= as usable memory and all other orignal usable ranges are not usable anymore.

Quoted 6 lines

Sure. This is what I believe we should expose with an additional property under /chosen, while keeping everything else pristine.

The crash kernel can then limit itself to that region, while it would have the information of the full memory map (which it could log and/or use to drive other dumping).

FYI,
all the original usable memory regions used by the 1st kernel are also described in an ELF core header specified by "elfcorehdr=" parameter to the crash dump kernel.

-Takahiro AKASHI

Quoted 24 lines
Quoted 1 line

Is it possible to modify uefi memmap for kdump case?

Technically it would be possible, however I don't think it's necessary, and I think it would be disadvantageous to do so.

Describing the range(s) the crash kernel can use in separate properties under /chosen has a number of advantages.

Quoted 6 lines
Quoted 3 lines

In the !EFI case, we use the memory nodes in the DTB. Only in this case could usable-memory properties in memory nodes make sense. I'd prefer a uniform property under /chosen for both cases.

We stil use same DTB, need to modify the DT and update the usable and unusable nodes for kdump?

We'd have a (slightly) modified DTB that contained additional properties describing the range(s) reserved for use by the crash kernel.

Other than those properties under /chosen (e.g. the command line, initrd pointers if any), it would be the original DTB.

Thanks,
Mark.

reviewer
#64 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 11 lines · AKASHI Takahiro
Quoted 9 lines · Mark Rutland

For NUMA topology in !ACPI kernels, we might need to also retain and parse memory nodes, but only for toplogy information. The kernel would still only use memory as described by the EFI memory map.

There's a horrible edge case I've spotted if performing a chain of cross-endian kexecs: LE -> BE -> LE, as the BE kernel would have to respect the EFI memory map so as to avoid corrupting it for the subsequent LE kernel. Other than this I believe everything should just work.

Quoted 3 lines

BE kernel doesn't support UEFI yet and cannot access UEFI memmap table. So, for LE -> BE, we don't use a dtb generated from /sys/firmware/fdt (or /proc/device-tree) (as in the case of LE -> LE) and require users to provide a dtb file explicitly.

As I mentioned above, the problem exists when memory nodes also exist (for describing NUMA topology). In that case the BE kernel would try to use the information from the memory nodes.

Quoted 2 lines

For BE -> LE, BE kernel doesn't know wther UEFI memmap table is available or not and so use the same (explicitly-provided) dtb (as LE -> LE in !UEFI)

See above. The problem I imagine is:

LE kernel - uses EFI mmap, takes NUMA information from DT memory nodes

v kexec

BE kernel - uses DT memory nodes
- clobbers EFI runtime regions as it sees them as available

v kexec

LE kernel - uses EFI mmap, takes NUMA information from DT memory nodes
- tries to call EFI runtime services, and explodes.

Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
Quoted 2 lines

A kexec'd kernel should simply inherit that. So long as the DTB and/or UEFI tables in memory are the same, it would be the same as a cold boot.

For kexec all memory ranges are same, for kdump we need use original reserved range with crashkernel= as usable memory and all other orignal usable ranges are not usable anymore.

Sure. This is what I believe we should expose with an additional property under /chosen, while keeping everything else pristine.

Quoted 8 lines
Quoted 3 lines

The crash kernel can then limit itself to that region, while it would have the information of the full memory map (which it could log and/or use to drive other dumping).

FYI,
all the original usable memory regions used by the 1st kernel are also described in an ELF core header specified by "elfcorehdr=" parameter to the crash dump kernel.

That only describes what the first kernel parsed and thus believed, not exactly what the firmware described.

Thanks,
Mark.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

reviewer
#65 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Ard, Ganapatrao, the below is something we need to consider for the combination of the NUMA & kexec approaches. It only becomes a problem if/when we preserve DT memory nodes in the presence of EFI, though it would be nice to not box ourselves into a corner.

Quoted 29 lines · Mark Rutland
Quoted 11 lines · AKASHI Takahiro
Quoted 9 lines · Mark Rutland

For NUMA topology in !ACPI kernels, we might need to also retain and parse memory nodes, but only for toplogy information. The kernel would still only use memory as described by the EFI memory map.

There's a horrible edge case I've spotted if performing a chain of cross-endian kexecs: LE -> BE -> LE, as the BE kernel would have to respect the EFI memory map so as to avoid corrupting it for the subsequent LE kernel. Other than this I believe everything should just work.

Quoted 3 lines

BE kernel doesn't support UEFI yet and cannot access UEFI memmap table. So, for LE -> BE, we don't use a dtb generated from /sys/firmware/fdt (or /proc/device-tree) (as in the case of LE -> LE) and require users to provide a dtb file explicitly.

As I mentioned above, the problem exists when memory nodes also exist (for describing NUMA topology). In that case the BE kernel would try to use the information from the memory nodes.

Quoted 2 lines

For BE -> LE, BE kernel doesn't know wther UEFI memmap table is available or not and so use the same (explicitly-provided) dtb (as LE -> LE in !UEFI)

See above. The problem I imagine is:

LE kernel - uses EFI mmap, takes NUMA information from DT memory nodes

v kexec

Quoted 7 lines

BE kernel - uses DT memory nodes
- clobbers EFI runtime regions as it sees them as available

v kexec

LE kernel - uses EFI mmap, takes NUMA information from DT memory nodes
- tries to call EFI runtime services, and explodes.

I'm not really sure what the best approach is here, but I thought that it would be good to raise awareness of the edge-case.

Mark.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#66 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 38 lines · Mark Rutland

Ard, Ganapatrao, the below is something we need to consider for the combination of the NUMA & kexec approaches. It only becomes a problem if/when we preserve DT memory nodes in the presence of EFI, though it would be nice to not box ourselves into a corner.

Quoted 32 lines · Mark Rutland
Quoted 11 lines · AKASHI Takahiro
Quoted 9 lines · Mark Rutland

For NUMA topology in !ACPI kernels, we might need to also retain and parse memory nodes, but only for toplogy information. The kernel would still only use memory as described by the EFI memory map.

There's a horrible edge case I've spotted if performing a chain of cross-endian kexecs: LE -> BE -> LE, as the BE kernel would have to respect the EFI memory map so as to avoid corrupting it for the subsequent LE kernel. Other than this I believe everything should just work.

Quoted 3 lines

BE kernel doesn't support UEFI yet and cannot access UEFI memmap table. So, for LE -> BE, we don't use a dtb generated from /sys/firmware/fdt (or /proc/device-tree) (as in the case of LE -> LE) and require users to provide a dtb file explicitly.

As I mentioned above, the problem exists when memory nodes also exist (for describing NUMA topology). In that case the BE kernel would try to use the information from the memory nodes.

Quoted 2 lines

For BE -> LE, BE kernel doesn't know wther UEFI memmap table is available or not and so use the same (explicitly-provided) dtb (as LE -> LE in !UEFI)

See above. The problem I imagine is:

LE kernel - uses EFI mmap, takes NUMA information from DT memory nodes

v kexec

BE kernel - uses DT memory nodes
- clobbers EFI runtime regions as it sees them as available

Quoted 8 lines
Quoted 4 lines

v kexec

LE kernel - uses EFI mmap, takes NUMA information from DT memory nodes
- tries to call EFI runtime services, and explodes.

I'm not really sure what the best approach is here, but I thought that it would be good to raise awareness of the edge-case.

I think we should simply allow the BE kernel to deal with a UEFI memory map. It only involves a bit of byte swapping (which I already implemented at some point)

It would require some minor refactoring to make the UEFI init code separate from all the other bits, but I don't see any major issues here

reviewer
#67 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 48 lines · Ard Biesheuvel
Quoted 38 lines · Mark Rutland

Ard, Ganapatrao, the below is something we need to consider for the combination of the NUMA & kexec approaches. It only becomes a problem if/when we preserve DT memory nodes in the presence of EFI, though it would be nice to not box ourselves into a corner.

Quoted 32 lines · Mark Rutland
Quoted 11 lines · AKASHI Takahiro
Quoted 9 lines · Mark Rutland

For NUMA topology in !ACPI kernels, we might need to also retain and parse memory nodes, but only for toplogy information. The kernel would still only use memory as described by the EFI memory map.

There's a horrible edge case I've spotted if performing a chain of cross-endian kexecs: LE -> BE -> LE, as the BE kernel would have to respect the EFI memory map so as to avoid corrupting it for the subsequent LE kernel. Other than this I believe everything should just work.

Quoted 3 lines

BE kernel doesn't support UEFI yet and cannot access UEFI memmap table. So, for LE -> BE, we don't use a dtb generated from /sys/firmware/fdt (or /proc/device-tree) (as in the case of LE -> LE) and require users to provide a dtb file explicitly.

As I mentioned above, the problem exists when memory nodes also exist (for describing NUMA topology). In that case the BE kernel would try to use the information from the memory nodes.

Quoted 2 lines

For BE -> LE, BE kernel doesn't know wther UEFI memmap table is available or not and so use the same (explicitly-provided) dtb (as LE -> LE in !UEFI)

See above. The problem I imagine is:

LE kernel - uses EFI mmap, takes NUMA information from DT memory nodes

v kexec

BE kernel - uses DT memory nodes
- clobbers EFI runtime regions as it sees them as available

Quoted 8 lines
Quoted 4 lines

v kexec

LE kernel - uses EFI mmap, takes NUMA information from DT memory nodes
- tries to call EFI runtime services, and explodes.

I'm not really sure what the best approach is here, but I thought that it would be good to raise awareness of the edge-case.

Quoted 7 lines

I think we should simply allow the BE kernel to deal with a UEFI memory map. It only involves a bit of byte swapping (which I already implemented at some point)

It would require some minor refactoring to make the UEFI init code separate from all the other bits, but I don't see any major issues here

Ok. I had assumed that getting the BE kernel to deal with the UEFI memory map would be a bit more involved.

I'm happy to be proven wrong. :)

Thanks,
Mark.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#68 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

In reply to Ard Biesheuvel
Quoted 44 lines · Ard Biesheuvel
Quoted 43 lines · Mark Rutland

Ard, Ganapatrao, the below is something we need to consider for the combination of the NUMA & kexec approaches. It only becomes a problem if/when we preserve DT memory nodes in the presence of EFI, though it would be nice to not box ourselves into a corner.

Quoted 36 lines · Mark Rutland
Quoted 11 lines · AKASHI Takahiro
Quoted 9 lines · Mark Rutland

For NUMA topology in !ACPI kernels, we might need to also retain and parse memory nodes, but only for toplogy information. The kernel would still only use memory as described by the EFI memory map.

There's a horrible edge case I've spotted if performing a chain of cross-endian kexecs: LE -> BE -> LE, as the BE kernel would have to respect the EFI memory map so as to avoid corrupting it for the subsequent LE kernel. Other than this I believe everything should just work.

Quoted 3 lines

BE kernel doesn't support UEFI yet and cannot access UEFI memmap table. So, for LE -> BE, we don't use a dtb generated from /sys/firmware/fdt (or /proc/device-tree) (as in the case of LE -> LE) and require users to provide a dtb file explicitly.

As I mentioned above, the problem exists when memory nodes also exist (for describing NUMA topology). In that case the BE kernel would try to use the information from the memory nodes.

Quoted 2 lines

For BE -> LE, BE kernel doesn't know wther UEFI memmap table is available or not and so use the same (explicitly-provided) dtb (as LE -> LE in !UEFI)

See above. The problem I imagine is:

LE kernel - uses EFI mmap, takes NUMA information from DT memory nodes

v kexec

BE kernel - uses DT memory nodes
- clobbers EFI runtime regions as it sees them as available

v kexec

LE kernel - uses EFI mmap, takes NUMA information from DT memory nodes
- tries to call EFI runtime services, and explodes.

Quoted 7 lines
Quoted 3 lines

I'm not really sure what the best approach is here, but I thought that it would be good to raise awareness of the edge-case.

I think we should simply allow the BE kernel to deal with a UEFI memory map. It only involves a bit of byte swapping (which I already implemented at some point)

Just from my curiosity,
will runtime services be also available on BE kernel with LE uefi?

-Takahiro AKASHI

Quoted 4 lines

It would require some minor refactoring to make the UEFI init code separate from all the other bits, but I don't see any major issues here

reviewer
#69 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 49 lines · AKASHI Takahiro
Quoted 48 lines · Ard Biesheuvel
Quoted 46 lines · Mark Rutland

Ard, Ganapatrao, the below is something we need to consider for the combination of the NUMA & kexec approaches. It only becomes a problem if/when we preserve DT memory nodes in the presence of EFI, though it would be nice to not box ourselves into a corner.

Quoted 29 lines · Mark Rutland
Quoted 11 lines · AKASHI Takahiro
Quoted 9 lines · Mark Rutland

For NUMA topology in !ACPI kernels, we might need to also retain and parse memory nodes, but only for toplogy information. The kernel would still only use memory as described by the EFI memory map.

There's a horrible edge case I've spotted if performing a chain of cross-endian kexecs: LE -> BE -> LE, as the BE kernel would have to respect the EFI memory map so as to avoid corrupting it for the subsequent LE kernel. Other than this I believe everything should just work.

Quoted 3 lines

BE kernel doesn't support UEFI yet and cannot access UEFI memmap table. So, for LE -> BE, we don't use a dtb generated from /sys/firmware/fdt (or /proc/device-tree) (as in the case of LE -> LE) and require users to provide a dtb file explicitly.

As I mentioned above, the problem exists when memory nodes also exist (for describing NUMA topology). In that case the BE kernel would try to use the information from the memory nodes.

Quoted 2 lines

For BE -> LE, BE kernel doesn't know wther UEFI memmap table is available or not and so use the same (explicitly-provided) dtb (as LE -> LE in !UEFI)

See above. The problem I imagine is:

LE kernel - uses EFI mmap, takes NUMA information from DT memory nodes

v kexec

Quoted 7 lines

BE kernel - uses DT memory nodes
- clobbers EFI runtime regions as it sees them as available

v kexec

LE kernel - uses EFI mmap, takes NUMA information from DT memory nodes
- tries to call EFI runtime services, and explodes.

I'm not really sure what the best approach is here, but I thought that it would be good to raise awareness of the edge-case.

Quoted 6 lines
Quoted 3 lines

I think we should simply allow the BE kernel to deal with a UEFI memory map. It only involves a bit of byte swapping (which I already implemented at some point)

Just from my curiosity,
will runtime services be also available on BE kernel with LE uefi?

It may be possible to implement that (I recall that Ard had a go), but that's far more complicated than simply supporting the EFI memory map, as you need separate (endian-swapped) page tables and other data structures, lose the ability to handle exceptions, etc.

All that's suggested above is supporting the memory map.

Thanks,
Mark.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

reviewer
#70 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

In reply to Dave Young
Quoted 61 lines · Dave Young
Quoted 55 lines · AKASHI Takahiro
Quoted 28 lines · Mark Rutland
Quoted 27 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

This patch adds arch specific descriptions about kdump usage on arm64 to kdump.txt.

---
 Documentation/kdump/kdump.txt | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/kdump/kdump.txt +1 -1
index bc4bd5a..36cf978 100644
@@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to
 a remote system.
 
 Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
-s390x and arm architectures.
+s390x, arm and arm64 architectures.
 
 When the system kernel boots, it reserves a small section of memory for
 the dump-capture kernel. This ensures that ongoing Direct Memory Access
@@ -249,6 +249,20 @@ Dump-capture kernel config options (Arch Dependent, arm)
 
     AUTO_ZRELADDR=y
 
Quoted 14 lines

Documentation/kdump/kdump.txt Dump-capture kernel config options (Arch Dependent, arm) · line 261

Quoted 10 lines
Documentation/kdump/kdump.txt +10 -0
+Dump-capture kernel config options (Arch Dependent, arm64)
+----------------------------------------------------------
+
+1) The maximum memory size on the dump-capture kernel must be limited by
+   specifying:
+
+   mem=X[MG]
+
+   where X should be less than or equal to the size in "crashkernel="
+   boot parameter. Kexec-tools will automatically add this.

This is extremely fragile, and will trivially fail when the kernel can be loaded anywhere (see [1]).

As I said before, this restriction also exists on arm, but I understand that recent Ard's patches break it.

Quoted 2 lines

We must explicitly describe the set of regions the crash kernel may use (i.e. we need base and size). NAK in the absence of that.

There seem to exist several approaches:
(a) use a device-tree property, "linux,usable-memory", in addition to "reg" under "memory" node
(b) use a kernel's early parameter, "memmap=nn[@#$]ss"

Quoted 4 lines

Power PC takes (a), while this does not work on efi-started kernel because dtb has no "memory" nodes under efi.
X86 takes (b). If we take this, we will need to overwrite a weak early_init_dt_add_memory().

Quoted 4 lines

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

This would imply modifying the EFI memory map or the memory nodes, which I'm not keen on.

I would prefer that they are left _pristine_, and we describe the restriction on the kdump kernel with additional properties under /chosen.

That leaves us with more useful information about the environment of the first kernel, is simpler for userspace (it's resilient to updates to the UEFI memory map spec, for example), and is simple for the crash kernel.

Quoted 2 lines

I think it is X86 specific. Personally I think device tree property is better.

As above, agreed.

Thanks,
Mark.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#71 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 70 lines · Mark Rutland
Quoted 61 lines · Dave Young
Quoted 55 lines · AKASHI Takahiro
Quoted 28 lines · Mark Rutland
Quoted 27 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

This patch adds arch specific descriptions about kdump usage on arm64 to kdump.txt.

---
 Documentation/kdump/kdump.txt | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/kdump/kdump.txt +1 -1
index bc4bd5a..36cf978 100644
@@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to
 a remote system.
 
 Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
-s390x and arm architectures.
+s390x, arm and arm64 architectures.
 
 When the system kernel boots, it reserves a small section of memory for
 the dump-capture kernel. This ensures that ongoing Direct Memory Access
@@ -249,6 +249,20 @@ Dump-capture kernel config options (Arch Dependent, arm)
 
     AUTO_ZRELADDR=y
 
Quoted 14 lines

Documentation/kdump/kdump.txt Dump-capture kernel config options (Arch Dependent, arm) · line 261

Quoted 10 lines
Documentation/kdump/kdump.txt +10 -0
+Dump-capture kernel config options (Arch Dependent, arm64)
+----------------------------------------------------------
+
+1) The maximum memory size on the dump-capture kernel must be limited by
+   specifying:
+
+   mem=X[MG]
+
+   where X should be less than or equal to the size in "crashkernel="
+   boot parameter. Kexec-tools will automatically add this.

This is extremely fragile, and will trivially fail when the kernel can be loaded anywhere (see [1]).

As I said before, this restriction also exists on arm, but I understand that recent Ard's patches break it.

Quoted 2 lines

We must explicitly describe the set of regions the crash kernel may use (i.e. we need base and size). NAK in the absence of that.

There seem to exist several approaches:
(a) use a device-tree property, "linux,usable-memory", in addition to "reg" under "memory" node
(b) use a kernel's early parameter, "memmap=nn[@#$]ss"

Quoted 4 lines

Power PC takes (a), while this does not work on efi-started kernel because dtb has no "memory" nodes under efi.
X86 takes (b). If we take this, we will need to overwrite a weak early_init_dt_add_memory().

Quoted 4 lines

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

This would imply modifying the EFI memory map or the memory nodes, which I'm not keen on.

Quoted 7 lines

I would prefer that they are left _pristine_, and we describe the restriction on the kdump kernel with additional properties under /chosen.

That leaves us with more useful information about the environment of the first kernel, is simpler for userspace (it's resilient to updates to the UEFI memory map spec, for example), and is simple for the crash kernel.

In theory kexec as boot loader should prepare correct efi memmap and pass to kernel, but as you said yes it will increase complexity. We need banlance them.

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

reviewer
#72 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 75 lines · Dave Young
Quoted 74 lines · Mark Rutland
Quoted 61 lines · Dave Young
Quoted 55 lines · AKASHI Takahiro
Quoted 28 lines · Mark Rutland
Quoted 27 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

This patch adds arch specific descriptions about kdump usage on arm64 to kdump.txt.

---
 Documentation/kdump/kdump.txt | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/kdump/kdump.txt +1 -1
index bc4bd5a..36cf978 100644
@@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to
 a remote system.
 
 Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
-s390x and arm architectures.
+s390x, arm and arm64 architectures.
 
 When the system kernel boots, it reserves a small section of memory for
 the dump-capture kernel. This ensures that ongoing Direct Memory Access
@@ -249,6 +249,20 @@ Dump-capture kernel config options (Arch Dependent, arm)
 
     AUTO_ZRELADDR=y
 
Quoted 14 lines

Documentation/kdump/kdump.txt Dump-capture kernel config options (Arch Dependent, arm) · line 261

Quoted 10 lines
Documentation/kdump/kdump.txt +10 -0
+Dump-capture kernel config options (Arch Dependent, arm64)
+----------------------------------------------------------
+
+1) The maximum memory size on the dump-capture kernel must be limited by
+   specifying:
+
+   mem=X[MG]
+
+   where X should be less than or equal to the size in "crashkernel="
+   boot parameter. Kexec-tools will automatically add this.

This is extremely fragile, and will trivially fail when the kernel can be loaded anywhere (see [1]).

As I said before, this restriction also exists on arm, but I understand that recent Ard's patches break it.

Quoted 2 lines

We must explicitly describe the set of regions the crash kernel may use (i.e. we need base and size). NAK in the absence of that.

There seem to exist several approaches:
(a) use a device-tree property, "linux,usable-memory", in addition to "reg" under "memory" node
(b) use a kernel's early parameter, "memmap=nn[@#$]ss"

Quoted 4 lines

Power PC takes (a), while this does not work on efi-started kernel because dtb has no "memory" nodes under efi.
X86 takes (b). If we take this, we will need to overwrite a weak early_init_dt_add_memory().

Quoted 4 lines

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

This would imply modifying the EFI memory map or the memory nodes, which I'm not keen on.

I would prefer that they are left _pristine_, and we describe the restriction on the kdump kernel with additional properties under /chosen.

Quoted 7 lines
Quoted 3 lines

That leaves us with more useful information about the environment of the first kernel, is simpler for userspace (it's resilient to updates to the UEFI memory map spec, for example), and is simple for the crash kernel.

In theory kexec as boot loader should prepare correct efi memmap and pass to kernel, but as you said yes it will increase complexity. We need banlance them.

I'd argue that the "correct efi memmap" is what we were given by the firmware initially -- none of that information is any less true.

For kdump all we need to ensure is that the kdump kernel only uses the memory that was specially reserved for it by the first kernel. The simplest way of doing that is to tell the kdump kernel which specific region(s) of memory were reserved for it, leaving the EFI memory map alone.

Thanks,
Mark.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#73 lore raw

Re: [PATCH 18/19] arm64: kdump: update a kernel doc

Quoted 80 lines · Mark Rutland
Quoted 79 lines · Dave Young
Quoted 77 lines · Mark Rutland
Quoted 61 lines · Dave Young
Quoted 55 lines · AKASHI Takahiro
Quoted 28 lines · Mark Rutland
Quoted 27 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

This patch adds arch specific descriptions about kdump usage on arm64 to kdump.txt.

---
 Documentation/kdump/kdump.txt | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/kdump/kdump.txt +1 -1
index bc4bd5a..36cf978 100644
@@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to
 a remote system.
 
 Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
-s390x and arm architectures.
+s390x, arm and arm64 architectures.
 
 When the system kernel boots, it reserves a small section of memory for
 the dump-capture kernel. This ensures that ongoing Direct Memory Access
@@ -249,6 +249,20 @@ Dump-capture kernel config options (Arch Dependent, arm)
 
     AUTO_ZRELADDR=y
 
Quoted 14 lines

Documentation/kdump/kdump.txt Dump-capture kernel config options (Arch Dependent, arm) · line 261

Quoted 10 lines
Documentation/kdump/kdump.txt +10 -0
+Dump-capture kernel config options (Arch Dependent, arm64)
+----------------------------------------------------------
+
+1) The maximum memory size on the dump-capture kernel must be limited by
+   specifying:
+
+   mem=X[MG]
+
+   where X should be less than or equal to the size in "crashkernel="
+   boot parameter. Kexec-tools will automatically add this.

This is extremely fragile, and will trivially fail when the kernel can be loaded anywhere (see [1]).

As I said before, this restriction also exists on arm, but I understand that recent Ard's patches break it.

Quoted 2 lines

We must explicitly describe the set of regions the crash kernel may use (i.e. we need base and size). NAK in the absence of that.

There seem to exist several approaches:
(a) use a device-tree property, "linux,usable-memory", in addition to "reg" under "memory" node
(b) use a kernel's early parameter, "memmap=nn[@#$]ss"

Quoted 4 lines

Power PC takes (a), while this does not work on efi-started kernel because dtb has no "memory" nodes under efi.
X86 takes (b). If we take this, we will need to overwrite a weak early_init_dt_add_memory().

Quoted 4 lines

X86 takes another way in latest kexec-tools and kexec_file_load, that is recreating E820 table and pass it to kexec/kdump kernel, if the entries are over E820 limitation then turn to use setup_data list for remain entries.

This would imply modifying the EFI memory map or the memory nodes, which I'm not keen on.

I would prefer that they are left _pristine_, and we describe the restriction on the kdump kernel with additional properties under /chosen.

That leaves us with more useful information about the environment of the first kernel, is simpler for userspace (it's resilient to updates to the UEFI memory map spec, for example), and is simple for the crash kernel.

Quoted 6 lines
Quoted 3 lines

In theory kexec as boot loader should prepare correct efi memmap and pass to kernel, but as you said yes it will increase complexity. We need banlance them.

I'd argue that the "correct efi memmap" is what we were given by the firmware initially -- none of that information is any less true.

In X86 boot loader will cook a E820 map for kernel use, there's no such needs in arm so maybe it is acceptable to use same memmap to avoid modifying it only for kdump.

I think I will not insist though I like more about doing something in bootloader instead of in kernel.

Quoted 6 lines

For kdump all we need to ensure is that the kdump kernel only uses the memory that was specially reserved for it by the first kernel. The simplest way of doing that is to tell the kdump kernel which specific region(s) of memory were reserved for it, leaving the EFI memory map alone.

Yes, agreed that it is simpler.

Quoted 3 lines

Thanks,
Mark.

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#74 lore raw

PATCH 19/19 arm64: kdump: relax BUG_ON() if more than one cpus are still active

In reply to Geoff Levand

From: AKASHI Takahiro <[email protected]>

We should try best in case of kdump.
So even if not all secondary cpus have shut down, we do kdump anyway.

---
 arch/arm64/kernel/machine_kexec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/machine_kexec.c +1 -1
index 0ba2ae4..3230551 100644
@@ -157,7 +157,7 @@ void machine_kexec(struct kimage *kimage)
 	phys_addr_t reboot_code_buffer_phys;
 	void *reboot_code_buffer;
 
-	BUG_ON(num_online_cpus() > 1);
+	BUG_ON((num_online_cpus() > 1) && !WARN_ON(in_crash_kexec));
 
 	reboot_code_buffer_phys = page_to_phys(kimage->control_code_page);
 	reboot_code_buffer = kmap(kimage->control_code_page);
Signature · 7 lines
2.5.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#75 lore raw
In reply to Geoff Levand
Quoted 11 lines · Geoff Levand

This series adds the core support for kexec re-boot and kdump on ARM64. This version of the series combines Takahiro's kdump patches with my kexec patches. Please consider all patches for inclusion.

I just tested all the endian combinations of kexec LE->LE, LE->BE, BE->BE, BE->LE, and both LE an BE kdump, and all work as expected.

To load a second stage kernel and execute a kexec re-boot or to work with kdump on ARM64 systems a series of patches to kexec-tools [2], which have not yet been merged upstream, are needed.

Quoted 7 lines

To examine vmcore (/proc/vmcore), you should use
- gdb v7.7 or later
- crash v7.1.1 or later

[1] https://git.kernel.org/cgit/linux/kernel/git/geoff/linux-kexec.git
[2] https://git.kernel.org/cgit/linux/kernel/git/geoff/kexec-tools.git

Geoff, another question about kexec-tools part is, can the kexec-tools code been written in kernel? We have the infrastructure for kexec_file_load.

In the future if we have to support loading a signed kernel then we still need to do that, but we may have to support both the kexec-tools and the in kernel loader for compatibility purpose. It will be hard to maintain.

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#76 lore raw
Quoted 3 lines · Dave Young

Geoff, another question about kexec-tools part is, can the kexec -tools code
been written in kernel? We have the infrastructure for kexec_file_load.

I see no technical reason why the arm64 kernel cannot support kexec_file_load.

-Geoff

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#77 lore raw
Quoted 7 lines · Geoff Levand
Quoted 3 lines · Dave Young

Geoff, another question about kexec-tools part is, can the kexec -tools code
been written in kernel? We have the infrastructure for kexec_file_load.

I see no technical reason why the arm64 kernel cannot support kexec_file_load.

Cool, care to port it to kernel so that we have kexec_file_load only in arm64 we do not need to support both kexec_load and kexec_file_load?

Quoted 3 lines

-Geoff

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#78 lore raw
Quoted 7 lines · Dave Young
Quoted 6 lines · Geoff Levand
Quoted 4 lines · Dave Young

Geoff, another question about kexec-tools part is, can the kexec -tools code
been written in kernel? We have the infrastructure for kexec_file_load.

Quoted 7 lines
Quoted 2 lines

I see no technical reason why the arm64 kernel cannot support kexec_file_load.

Cool, care to port it to kernel so that we have kexec_file_load only in arm64
we do not need to support both kexec_load and kexec_file_load?

I have no plans to do so. Feel free to submit a patch.

-Geoff

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

reviewer
#79 lore raw
In reply to Dave Young
Quoted 11 lines · Dave Young
Quoted 7 lines · Geoff Levand
Quoted 3 lines · Dave Young

Geoff, another question about kexec-tools part is, can the kexec -tools code
been written in kernel? We have the infrastructure for kexec_file_load.

I see no technical reason why the arm64 kernel cannot support kexec_file_load.

Cool, care to port it to kernel so that we have kexec_file_load only in arm64 we do not need to support both kexec_load and kexec_file_load?

I have reasons for wanting kexec_load, even if we have kexec_file_load. For example, being able to test modified DTBs during development, and being able to kexec to non-Linux OSs.

I don't think we should drop kexec_load, as kexec_file_load is designed such that it cannot be used for these purposes, while kexec_load is more general.

I appreciate that we will need kexec_file_load for Secure Boot, and it would be perfectly fine for your kdump userspace to require and always use kexec_file_load.

Thanks,
Mark.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

A message that is not in the archive (sent off-list or not yet received): [email protected]

#81 lore raw

Hi Geoff,

Quoted 11 lines · Geoff Levand

This series adds the core support for kexec re-boot and kdump on ARM64.This version of the series combines Takahiro's kdump patches with my kexec patches. Please consider all patches for inclusion.

I just tested all the endian combinations of kexec LE->LE, LE->BE, BE->BE, BE->LE, and both LE an BE kdump, and all work as expected.

To load a second stage kernel and execute a kexec re-boot or to work with kdump on ARM64 systems a series of patches to kexec-tools [2], which have not yet been merged upstream, are needed.

Quoted 8 lines

To examine vmcore (/proc/vmcore), you should use - gdb v7.7 or later
- crash v7.1.1 or later

[1]
https://git.kernel.org/cgit/linux/kernel/git/geoff/linux-kexec.git
[2]
https://git.kernel.org/cgit/linux/kernel/git/geoff/kexec-tools.git

We have been using the kexec/kdump patches on ARM64 and would like to use them from upstream.

Assuming these are not going to be in Linux-4.5, a rebased set on Linux-4.5 would be very useful.

Thank you for your work.

Signature · 10 lines
Thanks,
Azriel Samson
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#82 lore raw

Hi,

Quoted 5 lines · Azriel Samson

We have been using the kexec/kdump patches on ARM64 and would like to use them from upstream.

Assuming these are not going to be in Linux-4.5, a rebased set on Linux-4.5 would be very useful.

I'm waiting for one of two things to happen, either Marc Zyngier gives an ack for the patch 'arm64: kvm: allows kvm cpu hotplug', or the arm64 maintainers decide they will accept my proposal to merge kexec with a conditional in the Kconfig that only allows one of KVM or kexec to be selected.

The kexec patches have been in review for 20 months now, with only minor changes in the past 15. I don't expect much would be gained in posting the kexec series again unless there is a chance they would be merged.

-Geoff

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#83 lore raw
Quoted 5 lines · Geoff Levand
Quoted 3 lines · Azriel Samson

We have been using the kexec/kdump patches on ARM64 and would like to use them from upstream.

Quoted 8 lines
Quoted 2 lines

Assuming these are not going to be in Linux-4.5, a rebased set on Linux-4.5 would be very useful.

I'm waiting for one of two things to happen, either Marc Zyngier gives an ack for the patch 'arm64: kvm: allows kvm cpu hotplug', or the arm64 maintainers decide they will accept my proposal to merge kexec with a conditional in the Kconfig that only allows one of KVM or kexec to be selected.

Depending on !KVM isn't even an option as far as I'm concerned. It basically makes this all dead code.

As for awaiting an ack on the kvm hotplug patch, afaict, Akashi was going to address James's comments on the last posting [1].

Quoted 4 lines

The kexec patches have been in review for 20 months now, with only minor changes in the past 15. I don't expect much would be gained in posting the kexec series again unless there is a chance they would be merged.

Why do you say that? v13 attracted lots of comments from a variety of reviewers, so the onus is on you to address that feedback and post a new version. Alternatively, declare that you no longer to intend to work on the series, and perhaps then somebody else can pick it up and finish the job.

Will

[1] http://lkml.kernel.org/r/[email protected]

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#84 lore raw
Quoted 15 lines · Will Deacon
Quoted 5 lines · Geoff Levand
Quoted 3 lines · Azriel Samson

We have been using the kexec/kdump patches on ARM64 and would like to use them from upstream.

Quoted 8 lines
Quoted 2 lines

Assuming these are not going to be in Linux-4.5, a rebased set on Linux-4.5 would be very useful.

I'm waiting for one of two things to happen, either Marc Zyngier gives an ack for the patch 'arm64: kvm: allows kvm cpu hotplug', or the arm64 maintainers decide they will accept my proposal to merge kexec with a conditional in the Kconfig that only allows one of KVM or kexec to be selected.

Quoted 5 lines

Depending on !KVM isn't even an option as far as I'm concerned. It basically makes this all dead code.

As for awaiting an ack on the kvm hotplug patch, afaict, Akashi was going to address James's comments on the last posting [1].

Come on!
I have already fixed this issue, but still waiting for Geoff rebasing his patch as he is now a submitter of the whole patch series including kexec/kdump. (Please note, as James suggested, some (minor) modification need be made for rebasing onto v4.5)

Quoted 10 lines
Quoted 4 lines

The kexec patches have been in review for 20 months now, with only minor changes in the past 15. I don't expect much would be gained in posting the kexec series again unless there is a chance they would be merged.

Why do you say that? v13 attracted lots of comments from a variety of reviewers, so the onus is on you to address that feedback and post a new version. Alternatively, declare that you no longer to intend to work on the series, and perhaps then somebody else can pick it up and finish the job.

*If* Geoff is no longer willing to work on upstreaming kexec stuff, I will probably take over his task.

-Takahiro AKASHI

Quoted 4 lines

Will

[1] http://lkml.kernel.org/r/56A873C0.6090406 at linaro.org

#85 lore raw
In reply to Geoff Levand

On Tue, 1 Mar 2016 17:17:55 -0800
Geoff Levand <[email protected]> wrote:

Geoff,

Quoted 7 lines

Hi,

Quoted 3 lines · Azriel Samson

We have been using the kexec/kdump patches on ARM64 and would like to use them from upstream.

Quoted 8 lines
Quoted 2 lines

Assuming these are not going to be in Linux-4.5, a rebased set on Linux-4.5 would be very useful.

I'm waiting for one of two things to happen, either Marc Zyngier gives an ack for the patch 'arm64: kvm: allows kvm cpu hotplug', or the arm64 maintainers decide they will accept my proposal to merge kexec with a conditional in the Kconfig that only allows one of KVM or kexec to be selected.

Do you expect me to give my Ack on a series that I cannot even apply (let alone test) with mainline?

Quoted 2 lines

The kexec patches have been in review for 20 months now, with only minor changes in the past 15.

Given the amount of comment each posting of this series has attracted, I think we have a different appreciation of what a minor change is.

Quoted 2 lines

I don't expect much would be gained in posting the kexec series again unless there is a chance they would be merged.

I think that's perfectly fine. Akashi Takahiro and James Morse have been working together for a while now, reusing part of the kexec series for the hibernate support (and not breaking KVM, oddly enough). My vote is that they both take over the maintenance of this series on top the the hibernate support, and finish the job.

Thanks,

	M.
Signature · 6 lines
Jazz is not dead. It just smells funny.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#86 lore raw
In reply to Azriel Samson
Quoted 5 lines · Azriel Samson

We have been using the kexec/kdump patches on ARM64 and would like to use them from upstream.

Assuming these are not going to be in Linux-4.5, a rebased set on Linux-4.5 would be very useful.

If you just want rebased set then you may take it from my branch, until next version is released.

https://github.com/pratyushanand/linux.git : kexec/upstream_arm64_devel

~Pratyush

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#87 lore raw
Quoted 5 lines · Pratyush Anand

If you just want rebased set then you may take it from my branch, until next version is released.

https://github.com/pratyushanand/linux.git : kexec/upstream_arm64_devel

Thanks Pratyush,
This should help for now.

Signature · 10 lines
Thanks,
Azriel Samson
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec