Skip to content

Commit f3a99e7

Browse files
Tianyu Lanliuw
authored andcommitted
x86/Hyper-V: Report crash data in die() when panic_on_oops is set
When oops happens with panic_on_oops unset, the oops thread is killed by die() and system continues to run. In such case, guest should not report crash register data to host since system still runs. Check panic_on_oops and return directly in hyperv_report_panic() when the function is called in the die() and panic_on_oops is unset. Fix it. Fixes: 7ed4325 ("Drivers: hv: vmbus: Make panic reporting to be more useful") Signed-off-by: Tianyu Lan <[email protected]> Reviewed-by: Michael Kelley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Wei Liu <[email protected]>
1 parent 040026d commit f3a99e7

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

arch/x86/hyperv/hv_init.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/mm.h>
2121
#include <linux/hyperv.h>
2222
#include <linux/slab.h>
23+
#include <linux/kernel.h>
2324
#include <linux/cpuhotplug.h>
2425
#include <linux/syscore_ops.h>
2526
#include <clocksource/hyperv_timer.h>
@@ -419,11 +420,14 @@ void hyperv_cleanup(void)
419420
}
420421
EXPORT_SYMBOL_GPL(hyperv_cleanup);
421422

422-
void hyperv_report_panic(struct pt_regs *regs, long err)
423+
void hyperv_report_panic(struct pt_regs *regs, long err, bool in_die)
423424
{
424425
static bool panic_reported;
425426
u64 guest_id;
426427

428+
if (in_die && !panic_on_oops)
429+
return;
430+
427431
/*
428432
* We prefer to report panic on 'die' chain as we have proper
429433
* registers to report, but if we miss it (e.g. on BUG()) we need

drivers/hv/vmbus_drv.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/kdebug.h>
3232
#include <linux/efi.h>
3333
#include <linux/random.h>
34+
#include <linux/kernel.h>
3435
#include <linux/syscore_ops.h>
3536
#include <clocksource/hyperv_timer.h>
3637
#include "hyperv_vmbus.h"
@@ -75,7 +76,7 @@ static int hyperv_panic_event(struct notifier_block *nb, unsigned long val,
7576
if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE
7677
&& hyperv_report_reg()) {
7778
regs = current_pt_regs();
78-
hyperv_report_panic(regs, val);
79+
hyperv_report_panic(regs, val, false);
7980
}
8081
return NOTIFY_DONE;
8182
}
@@ -92,7 +93,7 @@ static int hyperv_die_event(struct notifier_block *nb, unsigned long val,
9293
* the notification here.
9394
*/
9495
if (hyperv_report_reg())
95-
hyperv_report_panic(regs, val);
96+
hyperv_report_panic(regs, val, true);
9697
return NOTIFY_DONE;
9798
}
9899

include/asm-generic/mshyperv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static inline int cpumask_to_vpset(struct hv_vpset *vpset,
163163
return nr_bank;
164164
}
165165

166-
void hyperv_report_panic(struct pt_regs *regs, long err);
166+
void hyperv_report_panic(struct pt_regs *regs, long err, bool in_die);
167167
void hyperv_report_panic_msg(phys_addr_t pa, size_t size);
168168
bool hv_is_hyperv_initialized(void);
169169
bool hv_is_hibernation_supported(void);

0 commit comments

Comments
 (0)