Skip to content

Commit

Permalink
Drivers: hv: avoid vfree() on crash
Browse files Browse the repository at this point in the history
commit a9f61ca upstream.

When we crash from NMI context (e.g. after NMI injection from host when
'sysctl -w kernel.unknown_nmi_panic=1' is set) we hit

    kernel BUG at mm/vmalloc.c:1530!

as vfree() is denied. While the issue could be solved with in_nmi() check
instead I opted for skipping vfree on all sorts of crashes to reduce the
amount of work which can cause consequent crashes. We don't really need to
free anything on crash.

[js] no tsc and kexec in 3.12 yet

Signed-off-by: Vitaly Kuznetsov <[email protected]>
Signed-off-by: K. Y. Srinivasan <[email protected]>
Cc: Sumit Semwal <[email protected]>
Signed-off-by: Jiri Slaby <[email protected]>
Signed-off-by: Willy Tarreau <[email protected]>
  • Loading branch information
vittyvk authored and wtarreau committed Jun 7, 2017
1 parent 801c8a0 commit 9391c80
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions drivers/hv/hv.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ int hv_init(void)
*
* This routine is called normally during driver unloading or exiting.
*/
void hv_cleanup(void)
void hv_cleanup(bool crash)
{
union hv_x64_msr_hypercall_contents hypercall_msr;

Expand All @@ -203,7 +203,8 @@ void hv_cleanup(void)
if (hv_context.hypercall_page) {
hypercall_msr.as_uint64 = 0;
wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
vfree(hv_context.hypercall_page);
if (!crash)
vfree(hv_context.hypercall_page);
hv_context.hypercall_page = NULL;
}
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/hv/hyperv_vmbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ extern struct hv_context hv_context;

extern int hv_init(void);

extern void hv_cleanup(void);
extern void hv_cleanup(bool crash);

extern int hv_post_message(union hv_connection_id connection_id,
enum hv_message_type message_type,
Expand Down
4 changes: 2 additions & 2 deletions drivers/hv/vmbus_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ static int vmbus_bus_init(int irq)
bus_unregister(&hv_bus);

err_cleanup:
hv_cleanup();
hv_cleanup(false);

return ret;
}
Expand Down Expand Up @@ -841,7 +841,7 @@ static void __exit vmbus_exit(void)
free_irq(irq, hv_acpi_dev);
vmbus_free_channels();
bus_unregister(&hv_bus);
hv_cleanup();
hv_cleanup(false);
acpi_bus_unregister_driver(&vmbus_acpi_driver);
hv_cpu_hotplug_quirk(false);
}
Expand Down

0 comments on commit 9391c80

Please sign in to comment.