Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xen/hvc: make sure console output is always emitted, with explicit polling

We never want to rely on the hvc workqueue to emit output, because the
most interesting output is when the kernel is broken. This will
improve oops/crash/console message for better debugging.

Instead, we force-poll until all output is emitted.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Stable Kernel <stable@kernel.org>

+24 -1
+24 -1
drivers/char/hvc_xen.c
··· 55 55 notify_remote_via_evtchn(xen_start_info->console.domU.evtchn); 56 56 } 57 57 58 - static int write_console(uint32_t vtermno, const char *data, int len) 58 + static int __write_console(const char *data, int len) 59 59 { 60 60 struct xencons_interface *intf = xencons_interface(); 61 61 XENCONS_RING_IDX cons, prod; ··· 74 74 75 75 notify_daemon(); 76 76 return sent; 77 + } 78 + 79 + static int write_console(uint32_t vtermno, const char *data, int len) 80 + { 81 + int ret = len; 82 + 83 + /* 84 + * Make sure the whole buffer is emitted, polling if 85 + * necessary. We don't ever want to rely on the hvc daemon 86 + * because the most interesting console output is when the 87 + * kernel is crippled. 88 + */ 89 + while (len) { 90 + int sent = __write_console(data, len); 91 + 92 + data += sent; 93 + len -= sent; 94 + 95 + if (unlikely(len)) 96 + HYPERVISOR_sched_op(SCHEDOP_yield, NULL); 97 + } 98 + 99 + return ret; 77 100 } 78 101 79 102 static int read_console(uint32_t vtermno, char *buf, int len)