[linux-yocto] [PATCH 47/52] arm: kvm: Fix crash when hotplugging CPU

Daniel Dragomir daniel.dragomir at windriver.com
Wed Jan 28 09:19:01 PST 2015


From: Anders Berg <anders.berg at intel.com>

CPU4: Booted secondary processor
Kernel panic - not syncing: unexpected prefetch abort in Hyp mode at: 0x921680
unexpected data abort in Hyp mode at: 0xc0916c2c
unexpected HVC/SVC trap in Hyp mode at: 0xc0b2d4a0
CPU: 4 PID: 0 Comm: swapper/4 Not tainted 3.10.38-ltsi-00013-g59f309e-dirty #96
[<c0421658>] (unwind_backtrace+0x0/0xf8) from [<c041df54>] (show_stack+0x10/0x14)
[<c041df54>] (show_stack+0x10/0x14) from [<c0916cbc>] (panic+0x90/0x1e4)
[<c0916cbc>] (panic+0x90/0x1e4) from [<c0413048>] (cpu_init_hyp_mode+0x10/0x6c)
[<c0413048>] (cpu_init_hyp_mode+0x10/0x6c) from [<c04130c8>] (hyp_init_cpu_notify+0x24/0x2c)
[<c04130c8>] (hyp_init_cpu_notify+0x24/0x2c) from [<c091f744>] (notifier_call_chain+0x44/0x84)
[<c091f744>] (notifier_call_chain+0x44/0x84) from [<c04343e8>] (__cpu_notify+0x28/0x44)
[<c04343e8>] (__cpu_notify+0x28/0x44) from [<c09148a0>] (secondary_start_kernel+0xd4/0x120)
[<c09148a0>] (secondary_start_kernel+0xd4/0x120) from [<c042d4c0>] (axxia_platform_cpu_die+0x54/0xa0)

The fix for this crash was obtained from from upstream kernel.org (relevant
parts of):

   commit 37a34ac1 "arm: kvm: fix CPU hotplug"
   commit b20c9f29 "arm/arm64: KVM: detect CPU reset on CPU_PM_EXIT"

Signed-off-by: Anders Berg <anders.berg at intel.com>
---
 arch/arm/kvm/arm.c        |  3 ++-
 arch/arm/kvm/interrupts.S | 11 ++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index ef1703b..34dff05 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -824,7 +824,8 @@ static int hyp_init_cpu_notify(struct notifier_block *self,
 	switch (action) {
 	case CPU_STARTING:
 	case CPU_STARTING_FROZEN:
-		cpu_init_hyp_mode(NULL);
+		if (__hyp_get_vectors() == hyp_default_vectors)
+			cpu_init_hyp_mode(NULL);
 		break;
 	}
 
diff --git a/arch/arm/kvm/interrupts.S b/arch/arm/kvm/interrupts.S
index 16cd4ba..723bcef 100644
--- a/arch/arm/kvm/interrupts.S
+++ b/arch/arm/kvm/interrupts.S
@@ -220,6 +220,10 @@ after_vfp_restore:
  * in Hyp mode (see init_hyp_mode in arch/arm/kvm/arm.c).  Return values are
  * passed in r0 and r1.
  *
+ * A function pointer with a value of 0xffffffff has a special meaning,
+ * and is used to implement __hyp_get_vectors in the same way as in
+ * arch/arm/kernel/hyp_stub.S.
+ *
  * The calling convention follows the standard AAPCS:
  *   r0 - r3: caller save
  *   r12:     caller save
@@ -363,6 +367,11 @@ hyp_hvc:
 host_switch_to_hyp:
 	pop	{r0, r1, r2}
 
+	/* Check for __hyp_get_vectors */
+	cmp	r0, #-1
+	mrceq	p15, 4, r0, c12, c0, 0	@ get HVBAR
+	beq	1f
+
 	push	{lr}
 	mrs	lr, SPSR
 	push	{lr}
@@ -378,7 +387,7 @@ THUMB(	orr	lr, #1)
 	pop	{lr}
 	msr	SPSR_csxf, lr
 	pop	{lr}
-	eret
+1:	eret
 
 guest_trap:
 	load_vcpu			@ Load VCPU pointer to r0
-- 
1.8.1.4



More information about the linux-yocto mailing list