mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] Drivers: hv: fix kexec/kdump after the recent changes
@ 2017-01-25 13:17 Vitaly Kuznetsov
  2017-01-25 13:17 ` [PATCH 1/2] Drivers: hv: restore hypervcall page cleanup before kexec Vitaly Kuznetsov
  2017-01-25 13:17 ` [PATCH 2/2] Drivers: hv: restore TSC " Vitaly Kuznetsov
  0 siblings, 2 replies; 3+ messages in thread
From: Vitaly Kuznetsov @ 2017-01-25 13:17 UTC (permalink / raw)
  To: devel
  Cc: linux-kernel, x86, K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger

'Restructure architecture specific code' series (now merged in char-misc)
introduced a regression wrt kexec/kdump. Hypercall and TSC pages setup was
moved out to the architecture specific code and the cleanup was dropped. We,
however, still need this cleanup: in kexec case the new kernel may try
using these pages as normal memory and will certainly crash. Restore the
minimal cleanup moving it to the architecture specific code.

Commit ids I mention in 'Fixes:' tags are from char-misc-next.

Vitaly Kuznetsov (2):
  Drivers: hv: restore hypervcall page cleanup before kexec
  Drivers: hv: restore TSC page cleanup before kexec

 arch/x86/hyperv/hv_init.c       | 20 ++++++++++++++++++++
 arch/x86/include/asm/mshyperv.h |  1 +
 drivers/hv/hv.c                 | 10 ----------
 drivers/hv/hyperv_vmbus.h       |  2 --
 drivers/hv/vmbus_drv.c          | 10 +++-------
 5 files changed, 24 insertions(+), 19 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] Drivers: hv: restore hypervcall page cleanup before kexec
  2017-01-25 13:17 [PATCH 0/2] Drivers: hv: fix kexec/kdump after the recent changes Vitaly Kuznetsov
@ 2017-01-25 13:17 ` Vitaly Kuznetsov
  2017-01-25 13:17 ` [PATCH 2/2] Drivers: hv: restore TSC " Vitaly Kuznetsov
  1 sibling, 0 replies; 3+ messages in thread
From: Vitaly Kuznetsov @ 2017-01-25 13:17 UTC (permalink / raw)
  To: devel
  Cc: linux-kernel, x86, K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger

We need to cleanup the hypercall page before doing kexec/kdump or the new
kernel may crash if it tries to use it. Reuse the now-empty hv_cleanup
function renaming it to hyperv_cleanup and moving to the arch specific
code.

Fixes: 8730046c1498 ("Drivers: hv vmbus: Move Hypercall page setup out of common code")
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 arch/x86/hyperv/hv_init.c       | 16 ++++++++++++++++
 arch/x86/include/asm/mshyperv.h |  1 +
 drivers/hv/hv.c                 | 10 ----------
 drivers/hv/hyperv_vmbus.h       |  2 --
 drivers/hv/vmbus_drv.c          | 10 +++-------
 5 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index d289bc2..d6b018b 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -166,6 +166,22 @@ void hyperv_init(void)
 }
 
 /*
+ * This routine is called before kexec/kdump, it does the required cleanup.
+ */
+void hyperv_cleanup(void)
+{
+	union hv_x64_msr_hypercall_contents hypercall_msr;
+
+	/* Reset our OS id */
+	wrmsrl(HV_X64_MSR_GUEST_OS_ID, 0);
+
+	/* Reset the hypercall page */
+	hypercall_msr.as_uint64 = 0;
+	wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
+}
+EXPORT_SYMBOL_GPL(hyperv_cleanup);
+
+/*
  * hv_do_hypercall- Invoke the specified hypercall
  */
 u64 hv_do_hypercall(u64 control, void *input, void *output)
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 42505d1..f8dc370 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -171,5 +171,6 @@ void hv_remove_crash_handler(void);
 void hyperv_init(void);
 void hyperv_report_panic(struct pt_regs *regs);
 bool hv_is_hypercall_page_setup(void);
+void hyperv_cleanup(void);
 #endif
 #endif
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 60594fa..0f73237 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -71,16 +71,6 @@ int hv_init(void)
 }
 
 /*
- * hv_cleanup - Cleanup routine.
- *
- * This routine is called normally during driver unloading or exiting.
- */
-void hv_cleanup(bool crash)
-{
-
-}
-
-/*
  * hv_post_message - Post a message using the hypervisor message IPC.
  *
  * This involves a hypercall.
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 2463ef9..86b56b6 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -255,8 +255,6 @@ struct hv_ring_buffer_debug_info {
 
 extern int hv_init(void);
 
-extern void hv_cleanup(bool crash);
-
 extern int hv_post_message(union hv_connection_id connection_id,
 			 enum hv_message_type message_type,
 			 void *payload, size_t payload_size);
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 8e81346..f8ebe13 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -962,7 +962,7 @@ static int vmbus_bus_init(void)
 
 	ret = bus_register(&hv_bus);
 	if (ret)
-		goto err_cleanup;
+		return ret;
 
 	hv_setup_vmbus_irq(vmbus_isr);
 
@@ -1004,9 +1004,6 @@ static int vmbus_bus_init(void)
 
 	bus_unregister(&hv_bus);
 
-err_cleanup:
-	hv_cleanup(false);
-
 	return ret;
 }
 
@@ -1462,7 +1459,7 @@ static void hv_kexec_handler(void)
 	/* Make sure conn_state is set as hv_synic_cleanup checks for it */
 	mb();
 	cpuhp_remove_state(hyperv_cpuhp_online);
-	hv_cleanup(false);
+	hyperv_cleanup();
 };
 
 static void hv_crash_handler(struct pt_regs *regs)
@@ -1475,7 +1472,7 @@ static void hv_crash_handler(struct pt_regs *regs)
 	 */
 	vmbus_connection.conn_state = DISCONNECTED;
 	hv_synic_cleanup(smp_processor_id());
-	hv_cleanup(true);
+	hyperv_cleanup();
 };
 
 static int __init hv_acpi_init(void)
@@ -1535,7 +1532,6 @@ static void __exit vmbus_exit(void)
 						 &hyperv_panic_block);
 	}
 	bus_unregister(&hv_bus);
-	hv_cleanup(false);
 	for_each_online_cpu(cpu) {
 		tasklet_kill(hv_context.event_dpc[cpu]);
 	}
-- 
2.9.3

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] Drivers: hv: restore TSC page cleanup before kexec
  2017-01-25 13:17 [PATCH 0/2] Drivers: hv: fix kexec/kdump after the recent changes Vitaly Kuznetsov
  2017-01-25 13:17 ` [PATCH 1/2] Drivers: hv: restore hypervcall page cleanup before kexec Vitaly Kuznetsov
@ 2017-01-25 13:17 ` Vitaly Kuznetsov
  1 sibling, 0 replies; 3+ messages in thread
From: Vitaly Kuznetsov @ 2017-01-25 13:17 UTC (permalink / raw)
  To: devel
  Cc: linux-kernel, x86, K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger

We need to cleanup the TSC page before doing kexec/kdump or the new kernel
may crash if it tries to use it.

Fixes: 63ed4e0c67df ("Drivers: hv: vmbus: Consolidate all Hyper-V specific clocksource code")
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 arch/x86/hyperv/hv_init.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index d6b018b..b371d0e 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -178,6 +178,10 @@ void hyperv_cleanup(void)
 	/* Reset the hypercall page */
 	hypercall_msr.as_uint64 = 0;
 	wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
+
+	/* Reset the TSC page */
+	hypercall_msr.as_uint64 = 0;
+	wrmsrl(HV_X64_MSR_REFERENCE_TSC, hypercall_msr.as_uint64);
 }
 EXPORT_SYMBOL_GPL(hyperv_cleanup);
 
-- 
2.9.3

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-01-25 13:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-25 13:17 [PATCH 0/2] Drivers: hv: fix kexec/kdump after the recent changes Vitaly Kuznetsov
2017-01-25 13:17 ` [PATCH 1/2] Drivers: hv: restore hypervcall page cleanup before kexec Vitaly Kuznetsov
2017-01-25 13:17 ` [PATCH 2/2] Drivers: hv: restore TSC " Vitaly Kuznetsov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®