RE: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump over Hyper-V during panic
> -Original Message- > From: KY Srinivasan > Sent: Monday, June 11, 2018 11:39 AM > To: Sunil Muthuswamy ; Haiyang Zhang > > Cc: de...@linuxdriverproject.org; Stephen Hemminger > > Subject: RE: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump > over Hyper-V during panic > > > > > -Original Message- > > From: Sunil Muthuswamy > > Sent: Monday, June 11, 2018 10:44 AM > > To: KY Srinivasan ; Haiyang Zhang > > > > Cc: de...@linuxdriverproject.org; Stephen Hemminger > > > > Subject: RE: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump > > over Hyper-V during panic > > > > > > > > > -Original Message- > > > From: KY Srinivasan > > > Sent: Sunday, June 10, 2018 2:54 PM > > > To: Sunil Muthuswamy ; Haiyang Zhang > > > > > > Cc: de...@linuxdriverproject.org; Stephen Hemminger > > > > > > Subject: RE: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump > > > over Hyper-V during panic > > > > > > > > > > > > > -Original Message- > > > > From: Sunil Muthuswamy > > > > Sent: Friday, June 8, 2018 11:39 AM > > > > To: Haiyang Zhang > > > > Cc: de...@linuxdriverproject.org; Sunil Muthuswamy > > > > ; KY Srinivasan ; > > Stephen > > > > Hemminger > > > > Subject: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump > > over > > > > Hyper-V during panic > > > > > > > > In the VM mode on Hyper-V, currently, when the kernel panics, an > error > > > > code and few register values are populated in an MSR and the > Hypervisor > > > > notified. This information is collected on the host. The amount of > > > > information currently collected is found to be limited and not very > > > > actionable. To gather more actionable data, such as stack trace, the > > > > proposal is to write one page worth of kmsg data on an allocated page > > > > and the Hypervisor notified of the page address through the MSR. > > > > > > Snip. > > > > > /* > > > > * vmbus_bus_init -Main vmbus driver initialization routine. > > > > @@ -1065,6 +1136,38 @@ static int vmbus_bus_init(void) > > > > * Only register if the crash MSRs are available > > > > */ > > > > if (ms_hyperv.misc_features & > > > > HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) { > > > > + u64 hyperv_crash_ctl; > > > > + if (!hv_ctl_table_hdr) { > > > When vmus_bus_init is invoked, would hv_ctl_table_hdr ever be > > > Non-NULL? > Ping. Missed this somehow. It should not be. Will fix this as well in the next version. > > Snip. > > Regards, > > K. Y ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump over Hyper-V during panic
> -Original Message- > From: Sunil Muthuswamy > Sent: Monday, June 11, 2018 10:44 AM > To: KY Srinivasan ; Haiyang Zhang > > Cc: de...@linuxdriverproject.org; Stephen Hemminger > > Subject: RE: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump > over Hyper-V during panic > > > > > -Original Message- > > From: KY Srinivasan > > Sent: Sunday, June 10, 2018 2:54 PM > > To: Sunil Muthuswamy ; Haiyang Zhang > > > > Cc: de...@linuxdriverproject.org; Stephen Hemminger > > > > Subject: RE: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump > > over Hyper-V during panic > > > > > > > > > -Original Message- > > > From: Sunil Muthuswamy > > > Sent: Friday, June 8, 2018 11:39 AM > > > To: Haiyang Zhang > > > Cc: de...@linuxdriverproject.org; Sunil Muthuswamy > > > ; KY Srinivasan ; > Stephen > > > Hemminger > > > Subject: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump > over > > > Hyper-V during panic > > > > > > In the VM mode on Hyper-V, currently, when the kernel panics, an error > > > code and few register values are populated in an MSR and the Hypervisor > > > notified. This information is collected on the host. The amount of > > > information currently collected is found to be limited and not very > > > actionable. To gather more actionable data, such as stack trace, the > > > proposal is to write one page worth of kmsg data on an allocated page > > > and the Hypervisor notified of the page address through the MSR. > > > Snip. > > > /* > > > * vmbus_bus_init -Main vmbus driver initialization routine. > > > @@ -1065,6 +1136,38 @@ static int vmbus_bus_init(void) > > >* Only register if the crash MSRs are available > > >*/ > > > if (ms_hyperv.misc_features & > > > HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) { > > > + u64 hyperv_crash_ctl; > > > + if (!hv_ctl_table_hdr) { > > When vmus_bus_init is invoked, would hv_ctl_table_hdr ever be > > Non-NULL? Ping. Snip. Regards, K. Y ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump over Hyper-V during panic
> -Original Message- > From: KY Srinivasan > Sent: Sunday, June 10, 2018 2:54 PM > To: Sunil Muthuswamy ; Haiyang Zhang > > Cc: de...@linuxdriverproject.org; Stephen Hemminger > > Subject: RE: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump > over Hyper-V during panic > > > > > -Original Message- > > From: Sunil Muthuswamy > > Sent: Friday, June 8, 2018 11:39 AM > > To: Haiyang Zhang > > Cc: de...@linuxdriverproject.org; Sunil Muthuswamy > > ; KY Srinivasan ; Stephen > > Hemminger > > Subject: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump over > > Hyper-V during panic > > > > In the VM mode on Hyper-V, currently, when the kernel panics, an error > > code and few register values are populated in an MSR and the Hypervisor > > notified. This information is collected on the host. The amount of > > information currently collected is found to be limited and not very > > actionable. To gather more actionable data, such as stack trace, the > > proposal is to write one page worth of kmsg data on an allocated page > > and the Hypervisor notified of the page address through the MSR. > > > > - Sysctl option to control the behavior, with ON by default. > > > > Cc: K. Y. Srinivasan > > Cc: Stephen Hemminger > > Signed-off-by: Sunil Muthuswamy > > --- > > Changes since v1: > > - Added a sysctl config option to allow the user to control if panic message > > should be reported to Hyper-V. > > > > Changes since v2: > > - Addressed comments from Greg KH. > > - Moved the sysctl config option from 'kernel.hyperv' to 'kernel.' since the > > likelihood of having many Hyper-V specific sysctl config options seemed > less > > and so having a specific dir for Hyper-V seemed unnecessary overhead. > > > > Changes since v3: > > - The feature is only enabled if the capability is supported by the > hypervisor. > > This is done by reading the crash control MSR, in addition to the pre- > existing > > check for the hypervisor feature using the CPUID. > > > > Changes since v4: > > - Addressed comments from Dexuan Cui: moved the global variable to > static. > > --- > > Documentation/sysctl/kernel.txt| 11 > > arch/x86/hyperv/hv_init.c | 27 + > > arch/x86/include/asm/hyperv-tlfs.h | 5 +- > > arch/x86/include/asm/mshyperv.h| 1 + > > drivers/hv/vmbus_drv.c | 116 > > + > > 5 files changed, 158 insertions(+), 2 deletions(-) > > > > diff --git a/Documentation/sysctl/kernel.txt > > b/Documentation/sysctl/kernel.txt > > index eded671d..5958503 100644 > > --- a/Documentation/sysctl/kernel.txt > > +++ b/Documentation/sysctl/kernel.txt > > @@ -39,6 +39,7 @@ show up in /proc/sys/kernel: > > - hung_task_check_count > > - hung_task_timeout_secs > > - hung_task_warnings > > +- hyperv_record_panic_msg > > - kexec_load_disabled > > - kptr_restrict > > - l2cr[ PPC only ] > > @@ -374,6 +375,16 @@ This file shows up if CONFIG_DETECT_HUNG_TASK > is > > enabled. > > > > > > > == > > > > > > +hyperv_record_panic_msg: > > + > > +Controls whether the panic kmsg data should be reported to Hyper-V. > > + > > +0: do not report panic kmsg data. > > + > > +1: report the panic kmsg data. This is the default behavior. > > + > > > += > > = > > + > > kexec_load_disabled: > > > > A toggle indicating if the kexec_load syscall has been disabled. This > > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c > > index cfecc22..af57162 100644 > > --- a/arch/x86/hyperv/hv_init.c > > +++ b/arch/x86/hyperv/hv_init.c > > @@ -395,6 +395,33 @@ void hyperv_report_panic(struct pt_regs *regs, > long > > err) > > } > > EXPORT_SYMBOL_GPL(hyperv_report_panic); > > > > +/** > > + * hyperv_report_panic_msg - report panic message to Hyper-V > > + * @pa: physical address of the panic page containing the message > > + * @size: size of the message in the page > > + */ > > +void hyperv_report_panic_msg(phys_addr_t pa, size_t size) > > +{ > > + /* > > +* P3 to contain the physical address of the panic page & P4 to > > +* contain the size of the panic data in that page. Rest of the > >
RE: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump over Hyper-V during panic
> -Original Message- > From: Sunil Muthuswamy > Sent: Friday, June 8, 2018 11:39 AM > To: Haiyang Zhang > Cc: de...@linuxdriverproject.org; Sunil Muthuswamy > ; KY Srinivasan ; Stephen > Hemminger > Subject: [PATCH v5] Drivers: HV: Send one page worth of kmsg dump over > Hyper-V during panic > > In the VM mode on Hyper-V, currently, when the kernel panics, an error > code and few register values are populated in an MSR and the Hypervisor > notified. This information is collected on the host. The amount of > information currently collected is found to be limited and not very > actionable. To gather more actionable data, such as stack trace, the > proposal is to write one page worth of kmsg data on an allocated page > and the Hypervisor notified of the page address through the MSR. > > - Sysctl option to control the behavior, with ON by default. > > Cc: K. Y. Srinivasan > Cc: Stephen Hemminger > Signed-off-by: Sunil Muthuswamy > --- > Changes since v1: > - Added a sysctl config option to allow the user to control if panic message > should be reported to Hyper-V. > > Changes since v2: > - Addressed comments from Greg KH. > - Moved the sysctl config option from 'kernel.hyperv' to 'kernel.' since the > likelihood of having many Hyper-V specific sysctl config options seemed less > and so having a specific dir for Hyper-V seemed unnecessary overhead. > > Changes since v3: > - The feature is only enabled if the capability is supported by the > hypervisor. > This is done by reading the crash control MSR, in addition to the > pre-existing > check for the hypervisor feature using the CPUID. > > Changes since v4: > - Addressed comments from Dexuan Cui: moved the global variable to static. > --- > Documentation/sysctl/kernel.txt| 11 > arch/x86/hyperv/hv_init.c | 27 + > arch/x86/include/asm/hyperv-tlfs.h | 5 +- > arch/x86/include/asm/mshyperv.h| 1 + > drivers/hv/vmbus_drv.c | 116 > + > 5 files changed, 158 insertions(+), 2 deletions(-) > > diff --git a/Documentation/sysctl/kernel.txt > b/Documentation/sysctl/kernel.txt > index eded671d..5958503 100644 > --- a/Documentation/sysctl/kernel.txt > +++ b/Documentation/sysctl/kernel.txt > @@ -39,6 +39,7 @@ show up in /proc/sys/kernel: > - hung_task_check_count > - hung_task_timeout_secs > - hung_task_warnings > +- hyperv_record_panic_msg > - kexec_load_disabled > - kptr_restrict > - l2cr[ PPC only ] > @@ -374,6 +375,16 @@ This file shows up if CONFIG_DETECT_HUNG_TASK is > enabled. > > > == > > > +hyperv_record_panic_msg: > + > +Controls whether the panic kmsg data should be reported to Hyper-V. > + > +0: do not report panic kmsg data. > + > +1: report the panic kmsg data. This is the default behavior. > + > += > = > + > kexec_load_disabled: > > A toggle indicating if the kexec_load syscall has been disabled. This > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c > index cfecc22..af57162 100644 > --- a/arch/x86/hyperv/hv_init.c > +++ b/arch/x86/hyperv/hv_init.c > @@ -395,6 +395,33 @@ void hyperv_report_panic(struct pt_regs *regs, long > err) > } > EXPORT_SYMBOL_GPL(hyperv_report_panic); > > +/** > + * hyperv_report_panic_msg - report panic message to Hyper-V > + * @pa: physical address of the panic page containing the message > + * @size: size of the message in the page > + */ > +void hyperv_report_panic_msg(phys_addr_t pa, size_t size) > +{ > + /* > + * P3 to contain the physical address of the panic page & P4 to > + * contain the size of the panic data in that page. Rest of the > + * registers are no-op when the NOTIFY_MSG flag is set. > + */ > + wrmsrl(HV_X64_MSR_CRASH_P0, 0); > + wrmsrl(HV_X64_MSR_CRASH_P1, 0); > + wrmsrl(HV_X64_MSR_CRASH_P2, 0); > + wrmsrl(HV_X64_MSR_CRASH_P3, pa); > + wrmsrl(HV_X64_MSR_CRASH_P4, size); > + > + /* > + * Let Hyper-V know there is crash data available along with > + * the panic message. > + */ > + wrmsrl(HV_X64_MSR_CRASH_CTL, > +(HV_CRASH_CTL_CRASH_NOTIFY | > HV_CRASH_CTL_CRASH_NOTIFY_MSG)); > +} > +EXPORT_SYMBOL_GPL(hyperv_report_panic_msg); > + > bool hv_is_hyperv_initialized(void) > { > union hv_x64_msr_hypercall_contents hypercall_msr; > diff --git a/arch/x86/include/asm/hyperv-tlfs.h > b/arch/x86/include/asm/hyperv-tlfs.h > index 416cb0e..76c58af 100644 > --- a/arch/x86/include/asm/hyperv-tlfs.h > +++ b/arch/x86/include/asm/hyperv-tlfs.h > @@ -171,9 +171,10 @@ > #define HV_X64_ENLIGHTENED_VMCS_RECOMMENDED(1 << 14) > > /* > - * Crash notification flag. > + * Crash notification flags. > */ > -#define HV_CRASH_CTL_CRASH_NOTIFY (1ULL << 63) > +#define HV_CRASH_CTL_CRASH_NOTIFY_MSGBIT_ULL(62) > +#define HV_CRASH_CTL_CRASH_NOTIFYBIT_ULL(6