Skip to contentSkip to conversation

arm64 kexec kernel patches v15

PATCH Superseded Geoff Levand 7 participants 45 messages Mar 14, 2016 – May 18, 2016

Subsystems (7)

v15 of 20 Superseded Latest is v20 →

lore
Share & tools
lore
#0 lore raw

v15 cover arm64 kexec kernel patches v15

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.

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. Please update to the latest if you have been using an older version.

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 v15 (Mar 14, 2016, 22m):

o Rebase to Linux-4.5.
o Remove DEBUG conditional in 'Add pr_debug output'.

Changes for v14 (Mar 4, 2016, 22m):

o Rebase to Linux-4.5-rc6.
o Rename setup_mm_for_reboot to cpu_install_idmap.
o kdump: leave non-boot cpus online at crash dump
As we don't have to make non-boot (crashed) cpus offline at crash dump, this patch adds a variant of smp_send_stop().
o kdump: use a new device-tree property, "linux,elfcorehdr", instead of traditional "elfcorehdr=" kernel parameter
o limit memory regions based on DT property, "usable-memory", instead of "mem=" kernel parameter
o kdump: fix a build error when !CONFIG_KEXEC_CORE
o kvm: use generic kvm_call_hyp() interface instead of kvm_cpu_reset()
o kvm: initialize only a primary cpu at init_hyp_mode()

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 b562e44f507e863c6792946e4e1b1449fbbac85d:

Linux 4.5 (2016-03-13 21:28:54 -0700)

are available in the git repository at:

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

for you to fetch changes up to 906d185a6451d3349669bcf4b080129dfaa7359f:

arm64: kdump: update a kernel doc (2016-03-14 10:29:13 -0700)

----------------------------------------------------------------
AKASHI Takahiro (7):
arm64: kvm: allows kvm cpu hotplug
arm64: kdump: reserve memory for crash dump kernel
arm64: limit memory regions based on DT property, usable-memory
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

Geoff Levand (11):
arm64: Fold proc-macros.S into assembler.h
arm64: Cleanup SCTLR flags
arm64: Convert hcalls to use HVC immediate value
arm64: Add new hcall HVC_CALL_FUNC
arm64: Add new asm macro copy_page
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 (2):
arm64: kernel: Include _AC definition in page.h
arm64: Promote KERNEL_START/KERNEL_END definitions to a header file

 Documentation/kdump/kdump.txt        |  15 +-
 arch/arm/include/asm/kvm_host.h      |  10 +-
 arch/arm/include/asm/kvm_mmu.h       |   1 +
 arch/arm/kvm/arm.c                   | 104 +++++++++-----
 arch/arm/kvm/mmu.c                   |   5 +
 arch/arm64/Kconfig                   |  21 +++
 arch/arm64/configs/defconfig         |   2 +
 arch/arm64/include/asm/assembler.h   | 101 ++++++++++++-
 arch/arm64/include/asm/hardirq.h     |   2 +-
 arch/arm64/include/asm/kexec.h       |  82 +++++++++++
 arch/arm64/include/asm/kvm_arm.h     |  11 --
 arch/arm64/include/asm/kvm_asm.h     |   1 +
 arch/arm64/include/asm/kvm_host.h    |  12 +-
 arch/arm64/include/asm/kvm_mmu.h     |   1 +
 arch/arm64/include/asm/memory.h      |   3 +
 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/smp.h         |   5 +
 arch/arm64/include/asm/sysreg.h      |  19 ++-
 arch/arm64/include/asm/virt.h        |  40 ++++++
 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/head.S             |   3 -
 arch/arm64/kernel/hyp-stub.S         |  49 +++++--
 arch/arm64/kernel/machine_kexec.c    | 270 +++++++++++++++++++++++++++++++++++
 arch/arm64/kernel/relocate_kernel.S  | 131 +++++++++++++++++
 arch/arm64/kernel/setup.c            |   7 +-
 arch/arm64/kernel/smp.c              |  56 ++++++++
 arch/arm64/kvm/hyp-init.S            |  47 +++++-
 arch/arm64/kvm/hyp.S                 |   3 +-
 arch/arm64/kvm/hyp/hyp-entry.S       |   9 +-
 arch/arm64/kvm/reset.c               |  14 ++
 arch/arm64/mm/cache.S                |   2 -
 arch/arm64/mm/init.c                 | 151 ++++++++++++++++++++
 arch/arm64/mm/mmu.c                  |  11 ++
 arch/arm64/mm/proc-macros.S          |  98 -------------
 arch/arm64/mm/proc.S                 |   3 -
 include/uapi/linux/kexec.h           |   1 +
 41 files changed, 1291 insertions(+), 197 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 v15 1/20 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.

[rebased, included dcache_by_line_op]
---
 arch/arm64/include/asm/assembler.h | 82 ++++++++++++++++++++++++++++++-
 arch/arm64/mm/cache.S              |  2 -
 arch/arm64/mm/proc-macros.S        | 98 --------------------------------------
 arch/arm64/mm/proc.S               |  3 --
 4 files changed, 81 insertions(+), 104 deletions(-)
 delete mode 100644 arch/arm64/mm/proc-macros.S
arch/arm64/include/asm/assembler.h +81 -1
index bb7b727..ec4e37c 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>
 
@@ -205,6 +207,84 @@ 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
+
+/*
+ * Macro to perform a data cache maintenance for the interval
+ * [kaddr, kaddr + size)
+ *
+ * 	op:		operation passed to dc instruction
+ * 	domain:		domain used in dsb instruciton
+ * 	kaddr:		starting virtual address of the region
+ * 	size:		size of the region
+ * 	Corrupts:	kaddr, size, tmp1, tmp2
+ */
+	.macro dcache_by_line_op op, domain, kaddr, size, tmp1, tmp2
+	dcache_line_size \tmp1, \tmp2
+	add	\size, \kaddr, \size
+	sub	\tmp2, \tmp1, #1
+	bic	\kaddr, \kaddr, \tmp2
+9998:	dc	\op, \kaddr
+	add	\kaddr, \kaddr, \tmp1
+	cmp	\kaddr, \size
+	b.lo	9998b
+	dsb	\domain
+	.endm
+
+/*
+ * reset_pmuserenr_el0 - reset PMUSERENR_EL0 if PMUv3 present
+ */
+	.macro	reset_pmuserenr_el0, tmpreg
+	mrs	\tmpreg, id_aa64dfr0_el1	// Check ID_AA64DFR0_EL1 PMUVer
+	sbfx	\tmpreg, \tmpreg, #8, #4
+	cmp	\tmpreg, #1			// Skip if no PMU present
+	b.lt	9000f
+	msr	pmuserenr_el0, xzr		// Disable PMU access from EL0
+9000:
+	.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 6df0706..50ff9ba 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 -98

98 lines not on this page · raw message

arch/arm64/mm/proc.S +0 -3
index c164d2c..5e01309 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 v15 2/20 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.

[Restored pgtable-hwdef.h include]
---
 arch/arm64/include/asm/kvm_arm.h | 11 -----------
 arch/arm64/include/asm/sysreg.h  | 19 +++++++++++++++----
 arch/arm64/kvm/hyp-init.S        |  5 +++--
 3 files changed, 18 insertions(+), 17 deletions(-)
arch/arm64/include/asm/kvm_arm.h +0 -11
index d201d4b..fbd5dbd 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 4aeebec..99dac2f 100644
@@ -82,10 +82,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 -2
index d073b5a..034d152c 100644
@@ -21,6 +21,7 @@
 #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"
@@ -116,8 +117,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
#3 lore raw

PATCH v15 3/20 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           |  3 ++-
 arch/arm64/kvm/hyp/hyp-entry.S |  9 ++++++---
 4 files changed, 56 insertions(+), 15 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 +2 -1
index 0ccdcbb..a598f9e 100644
@@ -18,6 +18,7 @@
 #include <linux/linkage.h>
 
 #include <asm/assembler.h>
+#include <asm/virt.h>
 
 /*
  * u64 kvm_call_hyp(void *hypfn, ...);
@@ -38,6 +39,6 @@
  * arch/arm64/kernel/hyp_stub.S.
  */
 ENTRY(kvm_call_hyp)
-	hvc	#0
+	hvc	#HVC_CALL_HYP
 	ret
 ENDPROC(kvm_call_hyp)
arch/arm64/kvm/hyp/hyp-entry.S +6 -3
index 93e8d983..a1edf77 100644
@@ -43,6 +43,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
@@ -51,14 +52,16 @@ el1_sync:				// Guest trapped into EL2
 	cbnz	x3, el1_trap		// called HVC
 
 	/* Here, we're pretty sure the host called HVC. */
+	mov	x18, x0
 	restore_x0_to_x3
 
-	/* Check for __hyp_get_vectors */
-	cbnz	x0, 1f
+	cmp	x18, #HVC_GET_VECTORS
+	b.ne	1f
 	mrs	x0, vbar_el2
 	b	2f
 
-1:	stp	lr, xzr, [sp, #-16]!
+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
#9 lore raw

PATCH v15 4/20 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.

[Renumbered labels in el1_sync()]
---
 arch/arm64/include/asm/virt.h | 13 +++++++++++++
 arch/arm64/kernel/hyp-stub.S  | 19 +++++++++++++++----
 2 files changed, 28 insertions(+), 4 deletions(-)
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 +15 -4
index 017ab519..cfacfe5 100644
@@ -59,18 +59,29 @@ el1_sync:
 	and	x18, x18, #ESR_ELx_ISS_MASK
 
 	cmp	x17, #ESR_ELx_EC_HVC64
-	b.ne	2f				// Not an HVC trap
+	b.ne	9f				// Not an HVC trap
 
 	cmp	x18, #HVC_GET_VECTORS
 	b.ne	1f
 	mrs	x0, vbar_el2
-	b	2f
+	b	9f
 
 1:	cmp	x18, #HVC_SET_VECTORS
 	b.ne	2f
 	msr	vbar_el2, x0
-
-2:	eret
+	b	9f
+
+2:	cmp	x18, #HVC_CALL_FUNC
+	b.ne	9f
+	mov	x18, lr
+	mov	lr, x0
+	mov	x0, x1
+	mov	x1, x2
+	mov	x2, x3
+	blr	lr
+	mov	lr, x18
+
+9:	eret
 ENDPROC(el1_sync)
 
 .macro invalid_vector	label
Signature · 8 lines
2.5.0



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

PATCH v15 5/20 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 kexec from rebooting the system at 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 the arm64 specific cpu hotplug hook any more.

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

[Moved __kvm_hyp_reset() to use kvm_call_hyp(), instead of having its own
dedicated entry point in el1_sync. Added some comments and a tlbi.]

---
 arch/arm/include/asm/kvm_host.h   |  10 +++-
 arch/arm/include/asm/kvm_mmu.h    |   1 +
 arch/arm/kvm/arm.c                | 104 ++++++++++++++++++++++++--------------
 arch/arm/kvm/mmu.c                |   5 ++
 arch/arm64/include/asm/kvm_asm.h  |   1 +
 arch/arm64/include/asm/kvm_host.h |  12 ++++-
 arch/arm64/include/asm/kvm_mmu.h  |   1 +
 arch/arm64/kvm/hyp-init.S         |  42 +++++++++++++++
 arch/arm64/kvm/reset.c            |  14 +++++
 9 files changed, 150 insertions(+), 40 deletions(-)
arch/arm/include/asm/kvm_host.h +9 -1
index f9f2779..8af531d 100644
@@ -220,6 +220,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;
@@ -232,7 +241,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 a520b79..4fd9ddb 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 +66 -38

180 lines not on this page · raw message

arch/arm/kvm/mmu.c +5 -0
index aba61fd..7a3aed6 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_asm.h +1 -0
index 52b777b..4191d12 100644
@@ -32,6 +32,7 @@ struct kvm_vcpu;
 
 extern char __kvm_hyp_init[];
 extern char __kvm_hyp_init_end[];
+extern char __kvm_hyp_reset[];
 
 extern char __kvm_hyp_vector[];
 
arch/arm64/include/asm/kvm_host.h +11 -1
index 689d4c9..b218211 100644
@@ -44,6 +44,7 @@
 int __attribute_const__ kvm_target_cpu(void);
 int kvm_reset_vcpu(struct kvm_vcpu *vcpu);
 int kvm_arch_dev_ioctl_check_extension(long ext);
+phys_addr_t kvm_hyp_reset_entry(void);
 
 struct kvm_arch {
 	/* The VMID generation used for the virt. memory system */
@@ -332,7 +333,16 @@ 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_hyp((void *)kvm_hyp_reset_entry(),
+		     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 7364339..7ee6824 100644
@@ -99,6 +99,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/kvm/hyp-init.S +42 -0

48 lines not on this page · raw message

arch/arm64/kvm/reset.c +14 -0
index f34745c..d6e155a 100644
@@ -29,7 +29,9 @@
 #include <asm/cputype.h>
 #include <asm/ptrace.h>
 #include <asm/kvm_arm.h>
+#include <asm/kvm_asm.h>
 #include <asm/kvm_coproc.h>
+#include <asm/kvm_mmu.h>
 
 /*
  * ARMv8 Reset Values
@@ -123,3 +125,15 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
 	/* Reset timer */
 	return kvm_timer_vcpu_reset(vcpu, cpu_vtimer_irq);
 }
+
+extern char __hyp_idmap_text_start[];
+
+phys_addr_t kvm_hyp_reset_entry(void)
+{
+	unsigned long offset;
+
+	offset = (unsigned long)__kvm_hyp_reset
+		 - ((unsigned long)__hyp_idmap_text_start & PAGE_MASK);
+
+	return TRAMPOLINE_VA + offset;
+}
Signature · 8 lines
2.5.0



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

PATCH v15 6/20 arm64: kernel: Include _AC definition in page.h

In reply to Geoff Levand

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 ae615b9..17b45f7 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
#12 lore raw

PATCH v15 7/20 arm64: Promote KERNEL_START/KERNEL_END definitions to a header file

In reply to Geoff Levand

From: James Morse <[email protected]>

KERNEL_START and KERNEL_END are useful outside head.S, move them to a header file.

---
 arch/arm64/include/asm/memory.h | 3 +++
 arch/arm64/kernel/head.S        | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/arm64/include/asm/memory.h +3 -0
index 853953c..5773a66 100644
@@ -70,6 +70,9 @@
 
 #define TASK_UNMAPPED_BASE	(PAGE_ALIGN(TASK_SIZE / 4))
 
+#define KERNEL_START      _text
+#define KERNEL_END        _end
+
 /*
  * Physical vs virtual RAM address space conversion.  These are
  * private definitions which should NOT be used outside memory.h
arch/arm64/kernel/head.S +0 -3
index 917d981..21bfb5d 100644
@@ -48,9 +48,6 @@
 #error TEXT_OFFSET must be less than 2MB
 #endif
 
-#define KERNEL_START	_text
-#define KERNEL_END	_end
-
 /*
  * Kernel startup entry point.
  * ---------------------------
Signature · 8 lines
2.5.0



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

PATCH v15 8/20 arm64: Add new asm macro copy_page

In reply to Geoff Levand

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().

Add a simplistic copy_page() macro, that can be inlined in these situations. lib/copy_page.S provides a bigger better version, but uses more registers.

[Changed asm label to 9998, added commit message]
---
 arch/arm64/include/asm/assembler.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
arch/arm64/include/asm/assembler.h +19 -0
index ec4e37c..f3854d9 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>
@@ -285,6 +286,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
+9998:	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	9998b
+	.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
#14 lore raw

PATCH v15 9/20 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
#15 lore raw

PATCH v15 10/20 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
#16 lore raw

PATCH v15 11/20 Revert "arm64: remove dead code"

In reply to Geoff Levand

This reverts commit b08d4640a3dca68670fc5af2fe9205b395a02388.

Add back the setup_mm_for_reboot() needed for kexec. Rename setup_mm_for_reboot() to cpu_install_idmap() in preparation for the pagetable rework series.

---
 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..ce63a20 100644
@@ -29,6 +29,7 @@ typedef struct {
 #define ASID(mm)	((mm)->context.id.counter & 0xffff)
 
 extern void paging_init(void);
+extern void cpu_install_idmap(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 58faeaa..e43d060 100644
@@ -479,6 +479,17 @@ void __init paging_init(void)
 }
 
 /*
+ * Enable the identity mapping to allow the MMU disabling.
+ */
+void cpu_install_idmap(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
#17 lore raw

PATCH v15 12/20 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 8cc6228..3001c51 100644
@@ -603,6 +603,16 @@ config PARAVIRT_TIME_ACCOUNTING
 
 	  If in doubt, say N here.
 
+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 83cd7e6..c0aa90d 100644
@@ -42,6 +42,8 @@ arm64-obj-$(CONFIG_PCI)			+= pci.o
 arm64-obj-$(CONFIG_ARMV8_DEPRECATED)	+= armv8_deprecated.o
 arm64-obj-$(CONFIG_ACPI)		+= acpi.o
 arm64-obj-$(CONFIG_PARAVIRT)		+= paravirt.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
#18 lore raw

PATCH v15 13/20 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 86581f7..288cbd6 100644
@@ -64,6 +64,7 @@ CONFIG_KSM=y
 CONFIG_TRANSPARENT_HUGEPAGE=y
 CONFIG_CMA=y
 CONFIG_XEN=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
#19 lore raw

PATCH v15 14/20 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 | 67 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 65 insertions(+), 2 deletions(-)
arch/arm64/kernel/machine_kexec.c +65 -2
index 6fd0f0c..75f6696 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,47 @@ 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;
+
+	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 +81,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 +125,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 +155,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
#20 lore raw

PATCH v15 15/20 arm64: kdump: reserve memory for crash dump kernel

In reply to Geoff Levand

From: AKASHI Takahiro <[email protected]>

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

User space tools, like kexec-tools, will be able to find that region marked as "Crash kernel" in /proc/iomem.

---
 arch/arm64/kernel/setup.c |  7 +++++-
 arch/arm64/mm/init.c      | 60 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 66 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 +60 -0

78 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
#24 lore raw

PATCH v15 16/20 arm64: limit memory regions based on DT property, usable-memory

In reply to Geoff Levand

From: AKASHI Takahiro <[email protected]>

Crash dump kernel will be run with a limited range of memory as System RAM.

On arm64, we will use a device-tree property under /chosen,
linux,usable-memory = <BASE SIZE>
in order for primary kernel either on uefi or non-uefi (device tree only) system to hand over the information about usable memory region to crash dump kernel. This property will supercede entries in uefi memory map table and "memory" nodes in a device tree.

---
 arch/arm64/mm/init.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
arch/arm64/mm/init.c +37 -0
index 4edf181..82527da 100644
@@ -215,8 +215,45 @@ static int __init early_mem(char *p)
 }
 early_param("mem", early_mem);
 
+static int __init early_init_dt_scan_usablemem(unsigned long node,
+		const char *uname, int depth, void *data)
+{
+	struct memblock_region *usablemem = (struct memblock_region *)data;
+	const __be32 *reg;
+	int len;
+
+	usablemem->size = 0;
+
+	if (depth != 1 || strcmp(uname, "chosen") != 0)
+		return 0;
+
+	reg = of_get_flat_dt_prop(node, "linux,usable-memory", &len);
+	if (!reg || (len < (dt_root_addr_cells + dt_root_size_cells)))
+		return 1;
+
+	usablemem->base = dt_mem_next_cell(dt_root_addr_cells, &reg);
+	usablemem->size = dt_mem_next_cell(dt_root_size_cells, &reg);
+
+	return 1;
+}
+
+static void __init fdt_enforce_memory_region(void)
+{
+	struct memblock_region reg;
+
+	of_scan_flat_dt(early_init_dt_scan_usablemem, &reg);
+
+	if (reg.size) {
+		memblock_remove(0, PAGE_ALIGN(reg.base));
+		memblock_remove(round_down(reg.base + reg.size, PAGE_SIZE),
+				ULLONG_MAX);
+	}
+}
+
 void __init arm64_memblock_init(void)
 {
+	fdt_enforce_memory_region();
+
 	memblock_enforce_memory_limit(memory_limit);
 
 	/*
Signature · 8 lines
2.5.0



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

PATCH v15 17/20 arm64: kdump: implement machine_crash_shutdown()

In reply to Geoff Levand

From: AKASHI Takahiro <[email protected]>

Primary kernel calls machine_crash_shutdown() to shut down non-boot cpus and save registers' status in per-cpu ELF notes before starting crash dump kernel. See kernel_kexec().
Even if not all secondary cpus have shut down, we do kdump anyway.

As we don't have to make non-boot(crashed) cpus offline (to preserve correct status of cpus at crash dump) before shutting down, this patch also adds a variant of smp_send_stop().

---
 arch/arm64/include/asm/hardirq.h  |  2 +-
 arch/arm64/include/asm/kexec.h    | 36 ++++++++++++++++++++++++-
 arch/arm64/include/asm/smp.h      |  5 ++++
 arch/arm64/kernel/machine_kexec.c | 55 +++++++++++++++++++++++++++++++++++---
 arch/arm64/kernel/smp.c           | 56 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 149 insertions(+), 5 deletions(-)
arch/arm64/include/asm/hardirq.h +1 -1
index a57601f..8740297 100644
@@ -20,7 +20,7 @@
 #include <linux/threads.h>
 #include <asm/irq.h>
 
-#define NR_IPI	5
+#define NR_IPI	6
 
 typedef struct {
 	unsigned int __softirq_pending;
arch/arm64/include/asm/kexec.h +35 -1
index 04744dc..2f089b3 100644
@@ -30,6 +30,10 @@
 
 #ifndef __ASSEMBLY__
 
+#ifndef CONFIG_KEXEC_CORE
+#define crash_save_cpu(regs, cpu)
+#endif
+
 /**
  * crash_setup_regs() - save registers for the panic kernel
  *
@@ -40,7 +44,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/include/asm/smp.h +5 -0
index d9c3d6a..0e42ece 100644
@@ -69,4 +69,9 @@ extern int __cpu_disable(void);
 extern void __cpu_die(unsigned int cpu);
 extern void cpu_die(void);
 
+/*
+ * for crash dump
+ */
+extern void smp_send_crash_stop(void);
+
 #endif /* ifndef __ASM_SMP_H */
arch/arm64/kernel/machine_kexec.c +52 -3

84 lines not on this page · raw message

arch/arm64/kernel/smp.c +56 -0

98 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
#36 lore raw

PATCH v15 18/20 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 system memory (core image) is available in elf core header.
The primary kernel will set aside this header with reserve_elfcorehdr() at boot time and inform crash dump kernel of its location via a new device-tree property, "linux,elfcorehdr".

Please note that all other architectures use traditional "elfcorehdr=" kernel parameter for this purpose.

Then crash dump kernel will access the primary kernel's memory with copy_oldmem_page(), which reads one page by ioremap'ing it since it does not reside in linear mapping on crash dump kernel.

We also need our own elfcorehdr_read() here since the header is placed within crash dump kernel's usable memory.

---
 arch/arm64/Kconfig             | 11 +++++++
 arch/arm64/kernel/Makefile     |  1 +
 arch/arm64/kernel/crash_dump.c | 71 ++++++++++++++++++++++++++++++++++++++++++
 arch/arm64/mm/init.c           | 54 ++++++++++++++++++++++++++++++++
 4 files changed, 137 insertions(+)
 create mode 100644 arch/arm64/kernel/crash_dump.c
arch/arm64/Kconfig +11 -0
index 3001c51..0780e4c 100644
@@ -613,6 +613,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 c0aa90d..804ecd4 100644
@@ -44,6 +44,7 @@ arm64-obj-$(CONFIG_ACPI)		+= acpi.o
 arm64-obj-$(CONFIG_PARAVIRT)		+= paravirt.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 +54 -0

72 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
#37 lore raw

PATCH v15 19/20 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 288cbd6..16bf6dc 100644
@@ -65,6 +65,7 @@ CONFIG_TRANSPARENT_HUGEPAGE=y
 CONFIG_CMA=y
 CONFIG_XEN=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
#38 lore raw

PATCH v15 20/20 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 | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
Documentation/kdump/kdump.txt +14 -1
index bc4bd5a..acc4d98 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,12 @@ Dump-capture kernel config options (Arch Dependent, arm)
 
     AUTO_ZRELADDR=y
 
+Dump-capture kernel config options (Arch Dependent, arm64)
+----------------------------------------------------------
+
+1) Currently, kvm will not be enabled on the dump-capture kernel even
+   if it is configured.
+
 Extended crashkernel syntax
 ===========================
 
@@ -312,6 +318,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 +342,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 +387,9 @@ For s390x:
 For arm:
 	"1 maxcpus=1 reset_devices"
 
+For arm64:
+	"1 maxcpus=1 reset_devices"
+
 Notes on loading the dump-capture kernel:
 
 * By default, the ELF headers are stored in ELF64 format to support
Signature · 7 lines
2.5.0


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

Re: [PATCH v15 03/20] arm64: Convert hcalls to use HVC immediate value

In reply to Geoff Levand

Hi

Quoted 11 lines · 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.

I'm a bit concerned about namespace pollution on the HVC immediate here. Existing users tend allocate a single "random" number to identify the API -- Xen and Jailhouse do this for example.

If we start using the HVC immediate to select functions, not just APIs, the space is going to fill up a lot faster, if we have a multiplex multiple APIs through it.

(We don't currently seem to multiplex APIs much here, except that we do use HVC for PSCI calls from the guest, and it could be used for additional paravirtualised services in the future).

Quoted 6 lines

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.

It would also be preferable to keep the 32-bit and 64-bit APIs the same; we should avoid having them different unless there's a clinching technical reason...

There may be some historical context for this that I'm missing...

Cheers
---Dave

Quoted 10 lines
---
 arch/arm64/include/asm/virt.h  | 27 +++++++++++++++++++++++++++
 arch/arm64/kernel/hyp-stub.S   | 32 +++++++++++++++++++++-----------
 arch/arm64/kvm/hyp.S           |  3 ++-
 arch/arm64/kvm/hyp/hyp-entry.S |  9 ++++++---
 4 files changed, 56 insertions(+), 15 deletions(-)

[...]

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

#5 lore raw

Re: [PATCH v15 03/20] arm64: Convert hcalls to use HVC immediate value

Hi,

Quoted 13 lines · Dave Martin
Quoted 11 lines · 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.

Quoted 7 lines

I'm a bit concerned about namespace pollution on the HVC immediate here. Existing users tend allocate a single "random" number to identify the API -- Xen and Jailhouse do this for example.

If we start using the HVC immediate to select functions, not just APIs, the space is going to fill up a lot faster, if we have a multiplex multiple APIs through it.

This was discussed and concluded that we have 16 bits to fill up, and that is enough. Functions can still be multiplexed through a single HVC immediate if the user chooses to do so.

Quoted 12 lines

(We don't currently seem to multiplex APIs much here, except that we do use HVC for PSCI calls from the guest, and it could be used for additional paravirtualised services in the future).

Quoted 6 lines

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.

Quoted 3 lines

It would also be preferable to keep the 32-bit and 64-bit APIs the same; we should avoid having them different unless there's a clinching technical reason...

Please expand on why you see it as preferable. What problems do you see?

-Geoff

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

#6 lore raw

Re: [PATCH v15 03/20] arm64: Convert hcalls to use HVC immediate value

Quoted 20 lines · Geoff Levand

Hi,

Quoted 17 lines · Dave Martin
Quoted 11 lines · 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.

I'm a bit concerned about namespace pollution on the HVC immediate here. Existing users tend allocate a single "random" number to identify the API -- Xen and Jailhouse do this for example.

Quoted 6 lines
Quoted 3 lines

If we start using the HVC immediate to select functions, not just APIs, the space is going to fill up a lot faster, if we have a multiplex multiple APIs through it.

This was discussed and concluded that we have 16 bits to fill up, and that is enough. Functions can still be multiplexed through a

Enough for what?

Quoted 1 line

single HVC immediate if the user chooses to do so.

But KVM can't?

The HVC #imm space doesn't seem to be managed, which implies that discovery and/or renumbering mechanisms would be needed if we end up wanting to mux multiple ABIs through there. The tighter limitation on immediate size, and the need for code patching if translation of HVC numbers is needed, mean that this can be harder when using the HVC immediate for demux rather than an ordinary register.

Currently, the only other ABI muxed through HVC is PSCI, but it already looks like there is a potential collision -- HVC #0 from EL1 is already KVM_CALL_HYP or a PSCI call, and we rely on knowing whether the call came from the host or guest to demux it properly.

This kind of problem is likely to proliferate over time.

Quoted 11 lines
Quoted 11 lines

(We don't currently seem to multiplex APIs much here, except that we do use HVC for PSCI calls from the guest, and it could be used for additional paravirtualised services in the future).

Quoted 6 lines

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.

Quoted 6 lines
Quoted 3 lines

It would also be preferable to keep the 32-bit and 64-bit APIs the same; we should avoid having them different unless there's a clinching technical reason...

Please expand on why you see it as preferable. What problems do you see?

Fragmentation avoidance is the main argument I see. The architectural constraints and the problem to be solved are basically the same between 32- and 64-bit, AFAICT.

Cheers
---Dave

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

#7 lore raw

Re: [PATCH v15 03/20] arm64: Convert hcalls to use HVC immediate value

Quoted 63 lines · Dave Martin
Quoted 20 lines · Geoff Levand

Hi,

Quoted 17 lines · Dave Martin
Quoted 11 lines · 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.

I'm a bit concerned about namespace pollution on the HVC immediate here. Existing users tend allocate a single "random" number to identify the API -- Xen and Jailhouse do this for example.

Quoted 6 lines
Quoted 3 lines

If we start using the HVC immediate to select functions, not just APIs, the space is going to fill up a lot faster, if we have a multiplex multiple APIs through it.

This was discussed and concluded that we have 16 bits to fill up, and that is enough. Functions can still be multiplexed through a

Enough for what?

Quoted 1 line

single HVC immediate if the user chooses to do so.

But KVM can't?

The HVC #imm space doesn't seem to be managed, which implies that discovery and/or renumbering mechanisms would be needed if we end up wanting to mux multiple ABIs through there. The tighter limitation on immediate size, and the need for code patching if translation of HVC numbers is needed, mean that this can be harder when using the HVC immediate for demux rather than an ordinary register.

Currently, the only other ABI muxed through HVC is PSCI, but it already looks like there is a potential collision -- HVC #0 from EL1 is already KVM_CALL_HYP or a PSCI call, and we rely on knowing whether the call came from the host or guest to demux it properly.

This kind of problem is likely to proliferate over time.

Quoted 15 lines
Quoted 14 lines

(We don't currently seem to multiplex APIs much here, except that we do use HVC for PSCI calls from the guest, and it could be used for additional paravirtualised services in the future).

Quoted 6 lines

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.

It would also be preferable to keep the 32-bit and 64-bit APIs the same; we should avoid having them different unless there's a clinching technical reason...

Quoted 6 lines
Quoted 2 lines

Please expand on why you see it as preferable. What problems do you see?

Fragmentation avoidance is the main argument I see. The architectural constraints and the problem to be solved are basically the same between 32- and 64-bit, AFAICT.

+1. I never quite understood why we went from a single HVC immediate + a register indicating the operation to a proliferation of immediate values (and still the need for a register to indicate the operation in most cases).

This seems to go in a direction that is diametrically opposite the the "normal" ARM way. That doesn't make it an invalid approach, but uniformity with other APIs (PSCI for example) and the 32bit KVM code seems a highly desirable feature (given that I'll end up maintaining that code).

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
#8 lore raw

Re: [PATCH v15 03/20] arm64: Convert hcalls to use HVC immediate value

Hi Marc,

Quoted 6 lines · Marc Zyngier

This seems to go in a direction that is diametrically opposite the the
"normal" ARM way. That doesn't make it an invalid approach, but uniformity with other APIs (PSCI for example) and the 32bit KVM code seems a highly desirable feature (given that I'll end up maintaining that code).

We need a way to get the CPU back to the exception level it had on entry to the kernel, and this hcall change is part of my proposed solution. If you could outline something you think would be a better fit, I'll take that and work on an implementation of it.

-Geoff

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

#26 lore raw

Re: [PATCH v15 17/20] arm64: kdump: implement machine_crash_shutdown()

In reply to Geoff Levand

Hi!

Quoted 24 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

Primary kernel calls machine_crash_shutdown() to shut down non-boot cpus and save registers' status in per-cpu ELF notes before starting crash dump kernel. See kernel_kexec().
Even if not all secondary cpus have shut down, we do kdump anyway.

As we don't have to make non-boot(crashed) cpus offline (to preserve correct status of cpus at crash dump) before shutting down, this patch also adds a variant of smp_send_stop().

arch/arm64/kernel/smp.c +3 -0
index b1adc51..76402c6cd 100644
@@ -701,6 +705,28 @@ static void ipi_cpu_stop(unsigned int cpu)
 		cpu_relax();
 }
 
+static atomic_t waiting_for_crash_ipi;
+
+static void ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs)

arch/arm64/kernel/smp.c static void ipi_cpu_stop(unsigned int cpu) · line 720

Quoted 10 lines
arch/arm64/kernel/smp.c +10 -0
+{
+	crash_save_cpu(regs, cpu);
+
+	raw_spin_lock(&stop_lock);
+	pr_debug("CPU%u: stopping\n", cpu);
+	raw_spin_unlock(&stop_lock);
+
+	atomic_dec(&waiting_for_crash_ipi);
+
+	local_irq_disable();

Aren't irqs already disabled here? - or is this a 'just make sure'....

Quoted 13 lines
arch/arm64/kernel/smp.c +9 -0
+
+	if (cpu_ops[cpu]->cpu_die)
+		cpu_ops[cpu]->cpu_die(cpu);
+
+	/* just in case */
+	while (1)
+		wfi();
+}
+
 /*
  * Main handler for inter-processor interrupts
  */

arch/arm64/kernel/smp.c void handle_IPI(int ipinr, struct pt_regs *regs) · line 763

Quoted 7 lines
arch/arm64/kernel/smp.c +4 -0
@@ -731,6 +757,12 @@ void handle_IPI(int ipinr, struct pt_regs *regs)
 		irq_exit();
 		break;
 
+	case IPI_CPU_CRASH_STOP:
+		irq_enter();
+		ipi_cpu_crash_stop(cpu, regs);
+		irq_exit();

This made me jump: irq_exit() may end up in the __do_softirq() (with irqs turned back on!) ... but these lines are impossible to reach. Maybe get the compiler to enforce this with an unreachable() instead?

Quoted 27 lines
arch/arm64/kernel/smp.c +19 -0
+		break;
+
 #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
 	case IPI_TIMER:
 		irq_enter();
@@ -791,6 +823,30 @@ void smp_send_stop(void)
 		pr_warning("SMP: failed to stop secondary CPUs\n");
 }
 
+void smp_send_crash_stop(void)
+{
+	cpumask_t mask;
+	unsigned long timeout;
+
+	if (num_online_cpus() == 1)
+		return;
+
+	cpumask_copy(&mask, cpu_online_mask);
+	cpumask_clear_cpu(smp_processor_id(), &mask);
+
+	atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1);
+
+	smp_cross_call(&mask, IPI_CPU_CRASH_STOP);
+
+	/* Wait up to one second for other CPUs to stop */
+	timeout = USEC_PER_SEC;

arch/arm64/kernel/smp.c void smp_send_stop(void) · line 852

Quoted 10 lines
arch/arm64/kernel/smp.c +7 -0
+	while ((atomic_read(&waiting_for_crash_ipi) > 0) && timeout--)
+		udelay(1);
+
+	if (atomic_read(&waiting_for_crash_ipi) > 0)
+		pr_warn("SMP: failed to stop secondary CPUs\n");
+}
+
 /*
  * not supported here
  */

Thanks,

James

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

#21 lore raw

Re: [PATCH v15 15/20] arm64: kdump: reserve memory for crash dump kernel

In reply to Geoff Levand

Hi!

Quoted 8 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

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

User space tools, like kexec-tools, will be able to find that region marked as "Crash kernel" in /proc/iomem.

[NB: Re-ordered diff hunks ]

Quoted 6 lines
arch/arm64/mm/init.c +0 -0
index 7802f21..4edf181 100644

arch/arm64/mm/init.c void __init arm64_memblock_init(void) · line 236

Quoted 8 lines
arch/arm64/mm/init.c +2 -0
@@ -171,6 +229,8 @@ void __init arm64_memblock_init(void)
 		memblock_reserve(__virt_to_phys(initrd_start), initrd_end - initrd_start);
 #endif
 
+	reserve_crashkernel();
+
 	early_init_fdt_scan_reserved_mem();
 
 	/* 4GB maximum for 32-bit only capable devices */

This is 'nit' territory, but if you were to make this:

Quoted 2 lines
	if (IS_ENABLED(CONFIG_KEXEC_CORE))
		reserve_crashkernel();

then the #ifdefs around reserve_crashkernel() can go, and the compiler will work out that this static function can be optimised out. It also means the compiler performs its checks, even if CONFIG_KEXEC_CORE isn't selected. The same trick can be applied in patch 18 (around reserve_elfcorehdr()).

Quoted 54 lines
arch/arm64/mm/init.c +50 -0
@@ -66,6 +67,63 @@ static int __init early_initrd(char *p)
 early_param("initrd", early_initrd);
 #endif
 
+#ifdef CONFIG_KEXEC_CORE
+/*
+ * reserve_crashkernel() - reserves memory for crash kernel
+ *
+ * This function reserves memory area given in "crashkernel=" kernel command
+ * line parameter. The memory reserved is used by dump capture kernel when
+ * primary kernel is crashing.
+ */
+static void __init reserve_crashkernel(void)
+{
+	unsigned long long crash_size = 0, crash_base = 0;
+	int ret;
+
+	ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(),
+				&crash_size, &crash_base);
+	if (ret)
+		return;
+
+	if (crash_base == 0) {
+		crash_base = memblock_find_in_range(0,
+				MEMBLOCK_ALLOC_ACCESSIBLE, crash_size, 1 << 21);
+		if (crash_base == 0) {
+			pr_warn("Unable to allocate crashkernel (size:%llx)\n",
+				crash_size);
+			return;
+		}
+		memblock_reserve(crash_base, crash_size);
+
+	} else {
+		/* User specifies base address explicitly. */
+		if (!memblock_is_region_memory(crash_base, crash_size) ||
+			memblock_is_region_reserved(crash_base, crash_size)) {
+			pr_warn("crashkernel has wrong address or size\n");
+			return;
+		}
+
+		if (crash_base & ((1 << 21) - 1)) {
+			pr_warn("crashkernel base address is not 2MB aligned\n");
+			return;
+		}
+
+		memblock_reserve(crash_base, crash_size);
+	}
+
+	pr_info("Reserving %lldMB of memory at %lldMB for crashkernel\n",
+		crash_size >> 20, crash_base >> 20);
+
+	crashk_res.start = crash_base;
+	crashk_res.end = crash_base + crash_size - 1;
+}

arch/arm64/mm/init.c static int __init early_initrd(char *p) · line 129

Quoted 10 lines
arch/arm64/mm/init.c +7 -0
+#else
+static void __init reserve_crashkernel(void)
+{
+	;
+}
+#endif /* CONFIG_KEXEC_CORE */
+
 /*
  * 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

Thanks,

James

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

#27 lore raw

Re: [PATCH v15 17/20] arm64: kdump: implement machine_crash_shutdown()

In reply to James Morse

Hi!

Quoted 32 lines · James Morse
Quoted 31 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

Primary kernel calls machine_crash_shutdown() to shut down non-boot cpus and save registers' status in per-cpu ELF notes before starting crash dump kernel. See kernel_kexec().
Even if not all secondary cpus have shut down, we do kdump anyway.

As we don't have to make non-boot(crashed) cpus offline (to preserve correct status of cpus at crash dump) before shutting down, this patch also adds a variant of smp_send_stop().

arch/arm64/kernel/smp.c +12 -0
index b1adc51..76402c6cd 100644
@@ -701,6 +705,28 @@ static void ipi_cpu_stop(unsigned int cpu)
 		cpu_relax();
 }
 
+static atomic_t waiting_for_crash_ipi;
+
+static void ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs)
+{
+	crash_save_cpu(regs, cpu);
+
+	raw_spin_lock(&stop_lock);
+	pr_debug("CPU%u: stopping\n", cpu);
+	raw_spin_unlock(&stop_lock);
+
+	atomic_dec(&waiting_for_crash_ipi);
+
Quoted 8 lines

arch/arm64/kernel/smp.c static void ipi_cpu_stop(unsigned int cpu) · line 727

Quoted 8 lines
arch/arm64/kernel/smp.c +8 -0
+	local_irq_disable();
+
+	if (cpu_ops[cpu]->cpu_die)
+		cpu_ops[cpu]->cpu_die(cpu);
+
+	/* just in case */
+	while (1)
+		wfi();

Having thought about this some more: I don't think spinning like this is safe. We need to spin with the MMU turned off, otherwise this core will pollute the kdump kernel with TLB entries from the old page tables. Suzuki added code to catch this happening with cpu hotplug (grep CPU_STUCK_IN_KERNEL in arm64/for-next/core), but that won't help here. If 'CPU_STUCK_IN_KERNEL' was set by a core, I don't think we can kexec/kdump for this reason.

Something like cpu_die() for spin-table is needed, naively I think it should turn the MMU off, and jump back into the secondary_holding_pen, but the core would still be stuck in the kernel, and the memory addresses associated with secondary_holding_pen can't be re-used. (which is fine for kdump, but not kexec)

Thanks,

James

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

#22 lore raw

Re: [PATCH v15 15/20] arm64: kdump: reserve memory for crash dump kernel

In reply to James Morse
Quoted 31 lines · James Morse

Hi!

Quoted 8 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

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

User space tools, like kexec-tools, will be able to find that region marked as "Crash kernel" in /proc/iomem.

[NB: Re-ordered diff hunks ]

Quoted 6 lines
arch/arm64/mm/init.c +0 -0
index 7802f21..4edf181 100644

arch/arm64/mm/init.c void __init arm64_memblock_init(void) · line 236

Quoted 8 lines
arch/arm64/mm/init.c +2 -0
@@ -171,6 +229,8 @@ void __init arm64_memblock_init(void)
 		memblock_reserve(__virt_to_phys(initrd_start), initrd_end - initrd_start);
 #endif
 
+	reserve_crashkernel();
+
 	early_init_fdt_scan_reserved_mem();
 
 	/* 4GB maximum for 32-bit only capable devices */

This is 'nit' territory, but if you were to make this:

Quoted 7 lines
Quoted 2 lines
	if (IS_ENABLED(CONFIG_KEXEC_CORE))
		reserve_crashkernel();

then the #ifdefs around reserve_crashkernel() can go, and the compiler will work out that this static function can be optimised out. It also means the compiler performs its checks, even if CONFIG_KEXEC_CORE isn't selected. The same trick can be applied in patch 18 (around reserve_elfcorehdr()).

It will also make the code more understandable.

Thanks,
-Takahiro AKASHI

Quoted 68 lines
Quoted 54 lines
arch/arm64/mm/init.c +50 -0
@@ -66,6 +67,63 @@ static int __init early_initrd(char *p)
 early_param("initrd", early_initrd);
 #endif
 
+#ifdef CONFIG_KEXEC_CORE
+/*
+ * reserve_crashkernel() - reserves memory for crash kernel
+ *
+ * This function reserves memory area given in "crashkernel=" kernel command
+ * line parameter. The memory reserved is used by dump capture kernel when
+ * primary kernel is crashing.
+ */
+static void __init reserve_crashkernel(void)
+{
+	unsigned long long crash_size = 0, crash_base = 0;
+	int ret;
+
+	ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(),
+				&crash_size, &crash_base);
+	if (ret)
+		return;
+
+	if (crash_base == 0) {
+		crash_base = memblock_find_in_range(0,
+				MEMBLOCK_ALLOC_ACCESSIBLE, crash_size, 1 << 21);
+		if (crash_base == 0) {
+			pr_warn("Unable to allocate crashkernel (size:%llx)\n",
+				crash_size);
+			return;
+		}
+		memblock_reserve(crash_base, crash_size);
+
+	} else {
+		/* User specifies base address explicitly. */
+		if (!memblock_is_region_memory(crash_base, crash_size) ||
+			memblock_is_region_reserved(crash_base, crash_size)) {
+			pr_warn("crashkernel has wrong address or size\n");
+			return;
+		}
+
+		if (crash_base & ((1 << 21) - 1)) {
+			pr_warn("crashkernel base address is not 2MB aligned\n");
+			return;
+		}
+
+		memblock_reserve(crash_base, crash_size);
+	}
+
+	pr_info("Reserving %lldMB of memory at %lldMB for crashkernel\n",
+		crash_size >> 20, crash_base >> 20);
+
+	crashk_res.start = crash_base;
+	crashk_res.end = crash_base + crash_size - 1;
+}

arch/arm64/mm/init.c static int __init early_initrd(char *p) · line 129

Quoted 10 lines
arch/arm64/mm/init.c +7 -0
+#else
+static void __init reserve_crashkernel(void)
+{
+	;
+}
+#endif /* CONFIG_KEXEC_CORE */
+
 /*
  * 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

Thanks,

Quoted 2 lines

James

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

#34 lore raw

Re: [PATCH v15 17/20] arm64: kdump: implement machine_crash_shutdown()

In reply to James Morse
Quoted 24 lines · James Morse

Hi!

Quoted 21 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

Primary kernel calls machine_crash_shutdown() to shut down non-boot cpus and save registers' status in per-cpu ELF notes before starting crash dump kernel. See kernel_kexec().
Even if not all secondary cpus have shut down, we do kdump anyway.

As we don't have to make non-boot(crashed) cpus offline (to preserve correct status of cpus at crash dump) before shutting down, this patch also adds a variant of smp_send_stop().

arch/arm64/kernel/smp.c +0 -0
index b1adc51..76402c6cd 100644
@@ -701,6 +705,28 @@ static void ipi_cpu_stop(unsigned int cpu)
 		cpu_relax();
 }
 
Quoted 15 lines

arch/arm64/kernel/smp.c static void ipi_cpu_stop(unsigned int cpu) · line 720

Quoted 13 lines
arch/arm64/kernel/smp.c +13 -0
+static atomic_t waiting_for_crash_ipi;
+
+static void ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs)
+{
+	crash_save_cpu(regs, cpu);
+
+	raw_spin_lock(&stop_lock);
+	pr_debug("CPU%u: stopping\n", cpu);
+	raw_spin_unlock(&stop_lock);
+
+	atomic_dec(&waiting_for_crash_ipi);
+
+	local_irq_disable();

Aren't irqs already disabled here? - or is this a 'just make sure'....

Well, it also exists in ipi_cpu_stop() ...

Quoted 16 lines
Quoted 16 lines
arch/arm64/kernel/smp.c +9 -0
+
+	if (cpu_ops[cpu]->cpu_die)
+		cpu_ops[cpu]->cpu_die(cpu);
+
+	/* just in case */
+	while (1)
+		wfi();
+}
+
 /*
  * Main handler for inter-processor interrupts
  */
@@ -731,6 +757,12 @@ void handle_IPI(int ipinr, struct pt_regs *regs)
 		irq_exit();
 		break;
 
Quoted 8 lines

arch/arm64/kernel/smp.c void handle_IPI(int ipinr, struct pt_regs *regs) · line 763

Quoted 4 lines
arch/arm64/kernel/smp.c +4 -0
+	case IPI_CPU_CRASH_STOP:
+		irq_enter();
+		ipi_cpu_crash_stop(cpu, regs);
+		irq_exit();

This made me jump: irq_exit() may end up in the __do_softirq() (with irqs turned back on!) ... but these lines are impossible to reach. Maybe get the compiler to enforce this with an unreachable() instead?

I'm not sure how effective unreachable() is here, but OK I will add it.

Thanks,
-Takahiro AKASHI

Quoted 41 lines
Quoted 27 lines
arch/arm64/kernel/smp.c +19 -0
+		break;
+
 #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
 	case IPI_TIMER:
 		irq_enter();
@@ -791,6 +823,30 @@ void smp_send_stop(void)
 		pr_warning("SMP: failed to stop secondary CPUs\n");
 }
 
+void smp_send_crash_stop(void)
+{
+	cpumask_t mask;
+	unsigned long timeout;
+
+	if (num_online_cpus() == 1)
+		return;
+
+	cpumask_copy(&mask, cpu_online_mask);
+	cpumask_clear_cpu(smp_processor_id(), &mask);
+
+	atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1);
+
+	smp_cross_call(&mask, IPI_CPU_CRASH_STOP);
+
+	/* Wait up to one second for other CPUs to stop */
+	timeout = USEC_PER_SEC;

arch/arm64/kernel/smp.c void smp_send_stop(void) · line 852

Quoted 10 lines
arch/arm64/kernel/smp.c +7 -0
+	while ((atomic_read(&waiting_for_crash_ipi) > 0) && timeout--)
+		udelay(1);
+
+	if (atomic_read(&waiting_for_crash_ipi) > 0)
+		pr_warn("SMP: failed to stop secondary CPUs\n");
+}
+
 /*
  * not supported here
  */

Thanks,

Quoted 3 lines

James

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

#28 lore raw

Re: [PATCH v15 17/20] arm64: kdump: implement machine_crash_shutdown()

In reply to James Morse
Quoted 39 lines · James Morse

Hi!

Quoted 36 lines · James Morse
Quoted 35 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

Primary kernel calls machine_crash_shutdown() to shut down non-boot cpus and save registers' status in per-cpu ELF notes before starting crash dump kernel. See kernel_kexec().
Even if not all secondary cpus have shut down, we do kdump anyway.

As we don't have to make non-boot(crashed) cpus offline (to preserve correct status of cpus at crash dump) before shutting down, this patch also adds a variant of smp_send_stop().

arch/arm64/kernel/smp.c +16 -0
index b1adc51..76402c6cd 100644
@@ -701,6 +705,28 @@ static void ipi_cpu_stop(unsigned int cpu)
 		cpu_relax();
 }
 
+static atomic_t waiting_for_crash_ipi;
+
+static void ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs)
+{
+	crash_save_cpu(regs, cpu);
+
+	raw_spin_lock(&stop_lock);
+	pr_debug("CPU%u: stopping\n", cpu);
+	raw_spin_unlock(&stop_lock);
+
+	atomic_dec(&waiting_for_crash_ipi);
+
+	local_irq_disable();
+
+	if (cpu_ops[cpu]->cpu_die)
+		cpu_ops[cpu]->cpu_die(cpu);
Quoted 8 lines
Quoted 4 lines

arch/arm64/kernel/smp.c static void ipi_cpu_stop(unsigned int cpu) · line 727

Quoted 4 lines
arch/arm64/kernel/smp.c +4 -0
+
+	/* just in case */
+	while (1)
+		wfi();

Having thought about this some more: I don't think spinning like this is safe. We need to spin with the MMU turned off, otherwise this core will pollute the kdump kernel with TLB entries from the old page tables.

I think that wfi() will never wake up since local interrupts are disabled here. So how can it pollute the kdump kernel?

Quoted 4 lines

Suzuki added code to
catch this happening with cpu hotplug (grep CPU_STUCK_IN_KERNEL in arm64/for-next/core), but that won't help here. If 'CPU_STUCK_IN_KERNEL' was set by a core, I don't think we can kexec/kdump for this reason.

I will need to look into Suzuki's code.

Quoted 4 lines

Something like cpu_die() for spin-table is needed, naively I think it should turn the MMU off, and jump back into the secondary_holding_pen, but the core would still be stuck in the kernel, and the memory addresses associated with secondary_holding_pen can't be re-used. (which is fine for kdump, but not kexec)

Please note that the code is exercised only in kdump case through machine_crash_shutdown().

Thanks,
-Takahiro AKASHI

Quoted 5 lines

Thanks,

James

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

#29 lore raw

Re: [PATCH v15 17/20] arm64: kdump: implement machine_crash_shutdown()

Quoted 49 lines · AKASHI Takahiro
Quoted 39 lines · James Morse

Hi!

Quoted 36 lines · James Morse
Quoted 35 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

Primary kernel calls machine_crash_shutdown() to shut down non-boot cpus and save registers' status in per-cpu ELF notes before starting crash dump kernel. See kernel_kexec().
Even if not all secondary cpus have shut down, we do kdump anyway.

As we don't have to make non-boot(crashed) cpus offline (to preserve correct status of cpus at crash dump) before shutting down, this patch also adds a variant of smp_send_stop().

arch/arm64/kernel/smp.c +16 -0
index b1adc51..76402c6cd 100644
@@ -701,6 +705,28 @@ static void ipi_cpu_stop(unsigned int cpu)
 		cpu_relax();
 }
 
+static atomic_t waiting_for_crash_ipi;
+
+static void ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs)
+{
+	crash_save_cpu(regs, cpu);
+
+	raw_spin_lock(&stop_lock);
+	pr_debug("CPU%u: stopping\n", cpu);
+	raw_spin_unlock(&stop_lock);
+
+	atomic_dec(&waiting_for_crash_ipi);
+
+	local_irq_disable();
+
+	if (cpu_ops[cpu]->cpu_die)
+		cpu_ops[cpu]->cpu_die(cpu);
Quoted 8 lines
Quoted 4 lines

arch/arm64/kernel/smp.c static void ipi_cpu_stop(unsigned int cpu) · line 727

Quoted 4 lines
arch/arm64/kernel/smp.c +4 -0
+
+	/* just in case */
+	while (1)
+		wfi();

Having thought about this some more: I don't think spinning like this is safe. We need to spin with the MMU turned off, otherwise this core will pollute the kdump kernel with TLB entries from the old page tables.

Quoted 2 lines

I think that wfi() will never wake up since local interrupts are disabled here. So how can it pollute the kdump kernel?

Having interrupts disabled doesn't prevent an exit from WFI. Quite the opposite, actually. It is designed to wake-up the core when something happens on the external interface.

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
reviewer
#30 lore raw

Re: [PATCH v15 17/20] arm64: kdump: implement machine_crash_shutdown()

Quoted 12 lines · Marc Zyngier
Quoted 11 lines · AKASHI Takahiro
Quoted 9 lines · James Morse
Quoted 4 lines · James Morse

arch/arm64/kernel/smp.c static void ipi_cpu_stop(unsigned int cpu) · line 727

Quoted 3 lines · Geoff Levand
arch/arm64/kernel/smp.c +3 -0
+	/* just in case */
+	while (1)
+		wfi();

Having thought about this some more: I don't think spinning like this is safe. We need to spin with the MMU turned off, otherwise this core will pollute the kdump kernel with TLB entries from the old page tables.

Quoted 6 lines
Quoted 2 lines

I think that wfi() will never wake up since local interrupts are disabled here. So how can it pollute the kdump kernel?

Having interrupts disabled doesn't prevent an exit from WFI. Quite the opposite, actually. It is designed to wake-up the core when something happens on the external interface.

Further, WFI is a hint, and may simply act as a NOP.

The ARM ARM calls this out (see "D1.17.2" Wait For Interrupt in ARM DDI 0487A.i):

Because the architecture permits a PE to leave the low-power state for any reason, it is permissible for a PE to treat WFI as a NOP , but this is not recommended for lowest power operation.

Thanks,
Mark.

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

#35 lore raw

Re: [PATCH v15 17/20] arm64: kdump: implement machine_crash_shutdown()

In reply to AKASHI Takahiro
Quoted 6 lines · AKASHI Takahiro
Quoted 3 lines · James Morse

This made me jump: irq_exit() may end up in the __do_softirq() (with irqs turned back on!) ... but these lines are impossible to reach. Maybe get the compiler to enforce this with an unreachable() instead?

I'm not sure how effective unreachable() is here, but OK I will add it.

I thought '__builtin_unreachable()' would generate a warning if it was reachable, but from [0] it looks like it just suppresses warnings.

You're right, it won't help.

Thanks,

James

[0] https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html

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

#39 lore raw
In reply to Geoff Levand
Quoted 9 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.

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. Please update to the latest if you have been using an older version.

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, for easier to review maybe you can send kexec patches first then AKASHI Takahiro can send the kdump patches as a standalone patchset?

Thanks
Dave

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

#23 lore raw

Re: [PATCH v15 15/20] arm64: kdump: reserve memory for crash dump kernel

In reply to AKASHI Takahiro
Quoted 35 lines · AKASHI Takahiro
Quoted 34 lines · James Morse

Hi!

Quoted 8 lines · Geoff Levand

From: AKASHI Takahiro <[email protected]>

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

User space tools, like kexec-tools, will be able to find that region marked as "Crash kernel" in /proc/iomem.

[NB: Re-ordered diff hunks ]

Quoted 6 lines
arch/arm64/mm/init.c +0 -0
index 7802f21..4edf181 100644

arch/arm64/mm/init.c void __init arm64_memblock_init(void) · line 236

Quoted 8 lines
arch/arm64/mm/init.c +2 -0
@@ -171,6 +229,8 @@ void __init arm64_memblock_init(void)
  		memblock_reserve(__virt_to_phys(initrd_start), initrd_end - initrd_start);
  #endif
 
+	reserve_crashkernel();
+
  	early_init_fdt_scan_reserved_mem();
 
  	/* 4GB maximum for 32-bit only capable devices */

This is 'nit' territory, but if you were to make this:

Quoted 2 lines
	if (IS_ENABLED(CONFIG_KEXEC_CORE))
		reserve_crashkernel();
Quoted 6 lines
Quoted 4 lines

then the #ifdefs around reserve_crashkernel() can go, and the compiler will work out that this static function can be optimised out. It also means the compiler performs its checks, even if CONFIG_KEXEC_CORE isn't selected. The same trick can be applied in patch 18 (around reserve_elfcorehdr()).

It will also make the code more understandable.

I tried this change, but
unfortunately, preserve_crashkernel() calls an external function, parse_crashkernel(), which is defined only if CONFIG_KEXEC_CORE. So we will see a compiler error in !CONFIG_KEXEC_CORE if we take #ifdef out around perserve_crashkernel().

-Takahiro AKASHI

Quoted 73 lines

Thanks,
-Takahiro AKASHI

Quoted 70 lines
Quoted 54 lines
arch/arm64/mm/init.c +50 -0
@@ -66,6 +67,63 @@ static int __init early_initrd(char *p)
  early_param("initrd", early_initrd);
  #endif
 
+#ifdef CONFIG_KEXEC_CORE
+/*
+ * reserve_crashkernel() - reserves memory for crash kernel
+ *
+ * This function reserves memory area given in "crashkernel=" kernel command
+ * line parameter. The memory reserved is used by dump capture kernel when
+ * primary kernel is crashing.
+ */
+static void __init reserve_crashkernel(void)
+{
+	unsigned long long crash_size = 0, crash_base = 0;
+	int ret;
+
+	ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(),
+				&crash_size, &crash_base);
+	if (ret)
+		return;
+
+	if (crash_base == 0) {
+		crash_base = memblock_find_in_range(0,
+				MEMBLOCK_ALLOC_ACCESSIBLE, crash_size, 1 << 21);
+		if (crash_base == 0) {
+			pr_warn("Unable to allocate crashkernel (size:%llx)\n",
+				crash_size);
+			return;
+		}
+		memblock_reserve(crash_base, crash_size);
+
+	} else {
+		/* User specifies base address explicitly. */
+		if (!memblock_is_region_memory(crash_base, crash_size) ||
+			memblock_is_region_reserved(crash_base, crash_size)) {
+			pr_warn("crashkernel has wrong address or size\n");
+			return;
+		}
+
+		if (crash_base & ((1 << 21) - 1)) {
+			pr_warn("crashkernel base address is not 2MB aligned\n");
+			return;
+		}
+
+		memblock_reserve(crash_base, crash_size);
+	}
+
+	pr_info("Reserving %lldMB of memory at %lldMB for crashkernel\n",
+		crash_size >> 20, crash_base >> 20);
+
+	crashk_res.start = crash_base;
+	crashk_res.end = crash_base + crash_size - 1;
+}

arch/arm64/mm/init.c static int __init early_initrd(char *p) · line 129

Quoted 10 lines
arch/arm64/mm/init.c +7 -0
+#else
+static void __init reserve_crashkernel(void)
+{
+	;
+}
+#endif /* CONFIG_KEXEC_CORE */
+
  /*
   * 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

Thanks,

James

#31 lore raw

Re: [PATCH v15 17/20] arm64: kdump: implement machine_crash_shutdown()

In reply to Mark Rutland
Quoted 13 lines · Mark Rutland
Quoted 12 lines · Marc Zyngier
Quoted 11 lines · AKASHI Takahiro
Quoted 9 lines · James Morse
Quoted 4 lines · James Morse

arch/arm64/kernel/smp.c static void ipi_cpu_stop(unsigned int cpu) · line 727

Quoted 3 lines · Geoff Levand
arch/arm64/kernel/smp.c +3 -0
+	/* just in case */
+	while (1)
+		wfi();

Having thought about this some more: I don't think spinning like this is safe. We need to spin with the MMU turned off, otherwise this core will pollute the kdump kernel with TLB entries from the old page tables.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I think that wfi() will never wake up since local interrupts are disabled here. So how can it pollute the kdump kernel?

Having interrupts disabled doesn't prevent an exit from WFI. Quite the opposite, actually. It is designed to wake-up the core when something happens on the external interface.

Further, WFI is a hint, and may simply act as a NOP.

Ah, OK. But even so, none of interrupt handlers (nor other code) will be executed after cpu wakes up, and the memory won't be polluted. Or do I still miss something?

-Takahiro AKASHI

Quoted 9 lines

The ARM ARM calls this out (see "D1.17.2" Wait For Interrupt in ARM DDI 0487A.i):

Because the architecture permits a PE to leave the low-power state for any reason, it is permissible for a PE to treat WFI as a NOP , but this is not recommended for lowest power operation.

Thanks,
Mark.

Signature · 7 lines
Thanks,
-Takahiro AKASHI

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

Re: [PATCH v15 17/20] arm64: kdump: implement machine_crash_shutdown()

Quoted 17 lines · AKASHI Takahiro
Quoted 16 lines · Mark Rutland
Quoted 15 lines · Marc Zyngier
Quoted 13 lines · AKASHI Takahiro
Quoted 9 lines · James Morse
Quoted 4 lines · James Morse

Review

Quoted 3 lines · Geoff Levand
(quoted diff) +3 -0
+	/* just in case */
+	while (1)
+		wfi();

Having thought about this some more: I don't think spinning like this is safe. We need to spin with the MMU turned off, otherwise this core will pollute the kdump kernel with TLB entries from the old page tables.

I think that wfi() will never wake up since local interrupts are disabled here. So how can it pollute the kdump kernel?

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Having interrupts disabled doesn't prevent an exit from WFI. Quite the opposite, actually. It is designed to wake-up the core when something happens on the external interface.

Further, WFI is a hint, and may simply act as a NOP.

Ah, OK. But even so, none of interrupt handlers (nor other code) will be executed after cpu wakes up, and the memory won't be polluted.

The code comprising the while(1) loop will be executed, and TLB walks, speculative fetches, etc may occur regardless.

We don't share TLB entries between cores (we don't have support for ARMv8.2s CnP), and the kdump kernel should be running in a carveout from main memory (which IIUC is not mapped by the original kernel). So normally, this would not be a problem.

However, if there is a problem with the page tables (e.g. entries erroneously point into a PA range the kdump kernel is using), then unavoidable background memory traffic from the CPU may cause problems for the kdump kernel.

Thanks,
Mark.

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

#40 lore raw
In reply to Dave Young

Hi,

Quoted 3 lines · Dave Young

Geoff, for easier to review maybe you can send kexec patches first then AKASHI Takahiro
can send the kdump patches as a standalone patchset?

Marc Zyngier specifically asked for an integrated set of patches for easier review. I will keep it that way for now.

-Geoff

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

#33 lore raw

Re: [PATCH v15 17/20] arm64: kdump: implement machine_crash_shutdown()

In reply to Mark Rutland

Mark,

Quoted 27 lines · Mark Rutland
Quoted 17 lines · AKASHI Takahiro
Quoted 16 lines · Mark Rutland
Quoted 15 lines · Marc Zyngier
Quoted 13 lines · AKASHI Takahiro
Quoted 9 lines · James Morse
Quoted 4 lines · James Morse

Review

Quoted 3 lines · Geoff Levand
(quoted diff) +3 -0
+	/* just in case */
+	while (1)
+		wfi();

Having thought about this some more: I don't think spinning like this is safe. We need to spin with the MMU turned off, otherwise this core will pollute the kdump kernel with TLB entries from the old page tables.

I think that wfi() will never wake up since local interrupts are disabled here. So how can it pollute the kdump kernel?

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Having interrupts disabled doesn't prevent an exit from WFI. Quite the opposite, actually. It is designed to wake-up the core when something happens on the external interface.

Further, WFI is a hint, and may simply act as a NOP.

Ah, OK. But even so, none of interrupt handlers (nor other code) will be executed after cpu wakes up, and the memory won't be polluted.

Quoted 7 lines

The code comprising the while(1) loop will be executed, and TLB walks, speculative fetches, etc may occur regardless.

We don't share TLB entries between cores (we don't have support for ARMv8.2s CnP), and the kdump kernel should be running in a carveout from main memory (which IIUC is not mapped by the original kernel). So normally, this would not be a problem.

In fact, the memory region for crash kernel will be just memblock_reserve()'d. We can't do memblock_remove() here because that region is expected to exist as part of system memory.
(For details, see kimage_load_crash_segment() in kexec_core.c.) Should we remove it from kernel mapping?

Quoted 4 lines

However, if there is a problem with the page tables (e.g. entries erroneously point into a PA range the kdump kernel is using), then unavoidable background memory traffic from the CPU may cause problems for the kdump kernel.

But the traffic generated by the cpu will concentrate on the area around the while loop, ipi_cpu_crash_stop(), in the *crashed* kernel's memory. (I'm not sure about speculative behaviors.)

So I don't think it will hurt kdump kernel.

Thanks,
-Takahiro AKASHI

Quoted 2 lines

Thanks,
Mark.

Signature · 7 lines
Thanks,
-Takahiro AKASHI

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#41 lore raw
In reply to Geoff Levand

Marc, it has been discussed for long time, I think kdump code can be logically splitted from this series so that we can get the kexec done first?

Quoted 7 lines · Geoff Levand

Hi,

Quoted 3 lines · Dave Young

Geoff, for easier to review maybe you can send kexec patches first then AKASHI Takahiro
can send the kdump patches as a standalone patchset?

Quoted 5 lines

Marc Zyngier specifically asked for an integrated set of patches for easier review. I will keep it that way for now.

-Geoff

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

#42 lore raw

Hi Dave,

Quoted 3 lines · Dave Young

Marc, it has been discussed for long time, I think kdump code can be logically splitted from this series so that we can get the kexec done first?

The basis for kexec are already on their way to mainline, as part of the hibernate series that James has put together.

I'd expect someone to:

1) rebase the remaining kexec/kdump patches based on the current arm64/for-next/core,
2) post these patches when -rc1 gets cut in two weeks from now,
3) address the review comments in a timely manner,
4) update the series once a week so that we see some actual progress

If this happens, I can't see any reason why this code wouldn't get merged. But keeping kexec and kdump together is not what has prevented the code from getting merged until now.

Thanks,

	M.
Quoted 15 lines · Geoff Levand
Quoted 12 lines

Hi,

Quoted 3 lines · Dave Young

Geoff, for easier to review maybe you can send kexec patches first then AKASHI Takahiro
can send the kdump patches as a standalone patchset?

Marc Zyngier specifically asked for an integrated set of patches for easier review. I will keep it that way for now.

-Geoff

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

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

Marc, Dave

Quoted 7 lines · Marc Zyngier

Hi Dave,

Quoted 3 lines · Dave Young

Marc, it has been discussed for long time, I think kdump code can be logically splitted from this series so that we can get the kexec done first?

Quoted 7 lines

The basis for kexec are already on their way to mainline, as part of the hibernate series that James has put together.

I'd expect someone to:

1) rebase the remaining kexec/kdump patches based on the current arm64/for-next/core,

Done. At the time of last week.
The only issue that I have now is a support for KASLR, but this is not a kernel issue, but tool's. I'm now talking with Dave Anderson (RedHat) about how we should fix it.

Quoted 1 line

2) post these patches when -rc1 gets cut in two weeks from now,

Yes, we are planning to do so.

Quoted 1 line

3) address the review comments in a timely manner,

I'd like to expect the code to be reviewed in a timely manner, too. In v4.6, we have not got any comments (nor ack's) on kexec/kdump-specific part of patches. If this happens again, it will make the turnaround of our re-spinning even longer.

Quoted 1 line

4) update the series once a week so that we see some actual progress

Yes if we have updates.

Quoted 3 lines

If this happens, I can't see any reason why this code wouldn't get merged. But keeping kexec and kdump together is not what has prevented the code from getting merged until now.

Yeah, agree.

Thanks,
-Takahiro AKASHI

Quoted 13 lines

Thanks,

	M.
Quoted 9 lines · Geoff Levand
Quoted 7 lines

Hi,

Quoted 3 lines · Dave Young

Geoff, for easier to review maybe you can send kexec patches first then AKASHI Takahiro
can send the kdump patches as a standalone patchset?

Quoted 10 lines
Quoted 6 lines
Quoted 5 lines

Marc Zyngier specifically asked for an integrated set of patches for easier review. I will keep it that way for now.

-Geoff

Signature · 1 line
Jazz is not dead. It just smells funny...

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

#44 lore raw
In reply to Marc Zyngier

Hi Marc

Quoted 18 lines · Marc Zyngier

Hi Dave,

Quoted 3 lines · Dave Young

Marc, it has been discussed for long time, I think kdump code can be logically splitted from this series so that we can get the kexec done first?

The basis for kexec are already on their way to mainline, as part of the hibernate series that James has put together.

I'd expect someone to:

1) rebase the remaining kexec/kdump patches based on the current arm64/for-next/core,
2) post these patches when -rc1 gets cut in two weeks from now,
3) address the review comments in a timely manner,
4) update the series once a week so that we see some actual progress

Quoted 3 lines

If this happens, I can't see any reason why this code wouldn't get merged. But keeping kexec and kdump together is not what has prevented the code from getting merged until now.

Cool, thanks a lot for the clarification about the situation.

Dave

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