Skip to contentSkip to conversation

Add support for VMBus panic notifier handler

PATCH Superseded Joseph Salisbury 2 participants 3 messages Jun 17, 2015

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

v2 cover Add support for VMBus panic notifier handler

Hello,

Please consider including upstream commits 96c1d0581d00f7abe033350edb021a9d947d8d81 and 5ef5b6927f14f29cacd78fa1fb861661a5367f13 in the next v3.13.y-ckt release. They were included mainline as of v4.1-rc1. They have been tested and confirmed to resolve
http://bugs.launchpad.net/bugs/1463584 .

commit 96c1d0581d00f7abe033350edb021a9d947d8d81

Author: Nick Meier <[email protected]>
Date:   Sat Feb 28 11:39:01 2015 -0800

Drivers: hv: vmbus: Add support for VMBus panic notifier handler

commit 5ef5b6927f14f29cacd78fa1fb861661a5367f13

Author: Nick Meier <[email protected]>
Date:   Wed Mar 18 12:29:24 2015 -0700

Drivers: hv: vmbus: Correcting truncation error for constant HV_CRASH_CTL_CRASH_NOTIFY

Commit 96c1d05 does not apply cleanly to v3.13.y-ckt, so I performed a backport, which is in email 1/1.

Sincerely,

Joseph Salisbury

Nick Meier (1):
Drivers: hv: vmbus: Add support for VMBus panic notifier handler

 drivers/hv/hyperv_vmbus.h | 11 +++++++++++
 drivers/hv/vmbus_drv.c    | 40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)
Signature · 1 line
2.1.0
#1 lore raw

PATCH v2 1/1 Drivers: hv: vmbus: Add support for VMBus panic notifier handler

From: Nick Meier <[email protected]>

Hyper-V allows a guest to notify the Hyper-V host that a panic condition occured. This notification can include up to five 64 bit values. These 64 bit values are written into crash MSRs. Once the data has been written into the crash MSRs, the host is then notified by writing into a Crash Control MSR. On the Hyper-V host, the panic notification data is captured in the Windows Event log as a 18590 event.

Crash MSRs are defined in appendix H of the Hypervisor Top Level Functional Specification. At the time of this patch, v4.0 is the current functional spec. The URL for the v4.0 document is:

http://download.microsoft.com/download/A/B/4/AB43A34E-BDD0-4FA6-BDEF-79EEF16E880B/Hypervisor Top Level Functional Specification v4.0.docx

(backported from commit 96c1d0581d00f7abe033350edb021a9d947d8d81)
---
 drivers/hv/hyperv_vmbus.h | 11 +++++++++++
 drivers/hv/vmbus_drv.c    | 40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)
drivers/hv/hyperv_vmbus.h +11 -0
index 9fa0cab..7a68d28a 100644
@@ -49,6 +49,17 @@ enum hv_cpuid_function {
 	HVCPUID_IMPLEMENTATION_LIMITS		= 0x40000005,
 };
 
+#define  HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE   0x400
+
+#define HV_X64_MSR_CRASH_P0   0x40000100
+#define HV_X64_MSR_CRASH_P1   0x40000101
+#define HV_X64_MSR_CRASH_P2   0x40000102
+#define HV_X64_MSR_CRASH_P3   0x40000103
+#define HV_X64_MSR_CRASH_P4   0x40000104
+#define HV_X64_MSR_CRASH_CTL  0x40000105
+
+#define HV_CRASH_CTL_CRASH_NOTIFY 0x8000000000000000
+
 /* Define version of the synthetic interrupt controller. */
 #define HV_SYNIC_VERSION		(1)
 
drivers/hv/vmbus_drv.c +40 -0
index 48aad4f..4b3d72a 100644
@@ -37,6 +37,8 @@
 #include <asm/hyperv.h>
 #include <asm/hypervisor.h>
 #include <asm/mshyperv.h>
+#include <linux/notifier.h>
+#include <linux/ptrace.h>
 #include "hyperv_vmbus.h"
 
 
@@ -46,6 +48,36 @@ static struct tasklet_struct msg_dpc;
 static struct completion probe_event;
 static int irq;
 
+int hyperv_panic_event(struct notifier_block *nb,
+			unsigned long event, void *ptr)
+{
+	struct pt_regs *regs;
+
+	regs = current_pt_regs();
+
+	wrmsrl(HV_X64_MSR_CRASH_P0, regs->ip);
+	wrmsrl(HV_X64_MSR_CRASH_P1, regs->ax);
+	wrmsrl(HV_X64_MSR_CRASH_P2, regs->bx);
+	wrmsrl(HV_X64_MSR_CRASH_P3, regs->cx);
+	wrmsrl(HV_X64_MSR_CRASH_P4, regs->dx);
+
+	/*
+	 * Let Hyper-V know there is crash data available
+	 */
+	wrmsrl(HV_X64_MSR_CRASH_CTL, HV_CRASH_CTL_CRASH_NOTIFY);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block hyperv_panic_block = {
+	.notifier_call = hyperv_panic_event,
+};
+
+struct resource hyperv_mmio = {
+	.name  = "hyperv mmio",
+	.flags = IORESOURCE_MEM,
+};
+EXPORT_SYMBOL_GPL(hyperv_mmio);
+
 static int vmbus_exists(void)
 {
 	if (hv_acpi_dev == NULL)
@@ -749,6 +781,14 @@ static int vmbus_bus_init(int irq)
 	if (ret)
 		goto err_alloc;
 
+	/*
+	 * Only register if the crash MSRs are available
+	 */
+	if (ms_hyperv.features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) {
+		atomic_notifier_chain_register(&panic_notifier_list,
+					       &hyperv_panic_block);
+	}
+
 	vmbus_request_offers();
 
 	return 0;
Signature · 1 line
2.1.0
#2 lore raw
In reply to Joseph Salisbury
Quoted 15 lines · Joseph Salisbury

Hello,

Please consider including upstream commits 96c1d0581d00f7abe033350edb021a9d947d8d81 and 5ef5b6927f14f29cacd78fa1fb861661a5367f13 in the next v3.13.y-ckt release. They were included mainline as of v4.1-rc1. They have been tested and confirmed to resolve
http://bugs.launchpad.net/bugs/1463584 .

commit 96c1d0581d00f7abe033350edb021a9d947d8d81

Author: Nick Meier <[email protected]>
Date:   Sat Feb 28 11:39:01 2015 -0800

Drivers: hv: vmbus: Add support for VMBus panic notifier handler

commit 5ef5b6927f14f29cacd78fa1fb861661a5367f13

Quoted 8 lines
Author: Nick Meier <[email protected]>
Date:   Wed Mar 18 12:29:24 2015 -0700

Drivers: hv: vmbus: Correcting truncation error for constant HV_CRASH_CTL_CRASH_NOTIFY

Commit 96c1d05 does not apply cleanly to v3.13.y-ckt, so I performed a backport, which is in email 1/1.

Thanks Joseph! Queued up for 3.13-stable: your [V2] backport of 96c1d05, and the cherry-pick of 5ef5b69.

-Kamal