Skip to content

Commit 49f49d4

Browse files
mhklinuxliuw
authored andcommitted
Drivers: hv: Always do Hyper-V panic notification in hv_kmsg_dump()
hv_kmsg_dump() currently skips the panic notification entirely if it doesn't get any message bytes to pass to Hyper-V due to an error from kmsg_dump_get_buffer(). Skipping the notification is undesirable because it leaves the Hyper-V host uncertain about the state of a panic'ed guest. Fix this by always doing the panic notification, even if bytes_written is zero. Also ensure that bytes_written is initialized, which fixes a kernel test robot warning. The warning is actually bogus because kmsg_dump_get_buffer() happens to set bytes_written even if it fails, and in the kernel test robot's CONFIG_PRINTK not set case, hv_kmsg_dump() is never called. But do the initialization for robustness and to quiet the static checker. Fixes: 9c318a1 ("Drivers: hv: move panic report code from vmbus to hv early init code") Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/all/202512172103.OcUspn1Z-lkp@intel.com/ Signed-off-by: Michael Kelley <mhklinux@outlook.com> Reviewed-by: Roman Kisel <vdso@mailbox.org> Signed-off-by: Wei Liu <wei.liu@kernel.org>
1 parent fc55818 commit 49f49d4

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

drivers/hv/hv_common.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,15 @@ static void hv_kmsg_dump(struct kmsg_dumper *dumper,
195195

196196
/*
197197
* Write dump contents to the page. No need to synchronize; panic should
198-
* be single-threaded.
198+
* be single-threaded. Ignore failures from kmsg_dump_get_buffer() since
199+
* panic notification should be done even if there is no message data.
200+
* Don't assume bytes_written is set in case of failure, so initialize it.
199201
*/
200202
kmsg_dump_rewind(&iter);
201-
kmsg_dump_get_buffer(&iter, false, hv_panic_page, HV_HYP_PAGE_SIZE,
203+
bytes_written = 0;
204+
(void)kmsg_dump_get_buffer(&iter, false, hv_panic_page, HV_HYP_PAGE_SIZE,
202205
&bytes_written);
203-
if (!bytes_written)
204-
return;
206+
205207
/*
206208
* P3 to contain the physical address of the panic page & P4 to
207209
* contain the size of the panic data in that page. Rest of the
@@ -210,7 +212,7 @@ static void hv_kmsg_dump(struct kmsg_dumper *dumper,
210212
hv_set_msr(HV_MSR_CRASH_P0, 0);
211213
hv_set_msr(HV_MSR_CRASH_P1, 0);
212214
hv_set_msr(HV_MSR_CRASH_P2, 0);
213-
hv_set_msr(HV_MSR_CRASH_P3, virt_to_phys(hv_panic_page));
215+
hv_set_msr(HV_MSR_CRASH_P3, bytes_written ? virt_to_phys(hv_panic_page) : 0);
214216
hv_set_msr(HV_MSR_CRASH_P4, bytes_written);
215217

216218
/*

0 commit comments

Comments
 (0)