VirtIO console hangs

From: Matteo Croce
Date: Tue Aug 28 2018 - 08:55:17 EST


With kernel 4.19.0-rc1 virtio_console hangs very often.
I can always trigger the bug by pasting some characters in the
terminal window, the console will stop receiving keypresses, but I can
still see output from the console.
Stangely, logging in the VM via SSH and sending lot of data to hvc0,
like 'dmesg >/dev/hvc0' will fix the issue until the next paste.

I did a git bisect and I've found that this is the offending commit,
reverting it fixes it.

Cheers,

commit ec97eaad1383ab2500fcf9a07ade6044fbcc67f5
Author: Nicholas Piggin <npiggin@xxxxxxxxx>
Date: Tue May 1 00:55:54 2018 +1000

tty: hvc: hvc_poll() break hv read loop

Avoid looping with the spinlock held while there is read data
being returned from the hv driver. Instead note if the entire
size returned by tty_buffer_request_room was read, and request
another read poll.

This limits the critical section lengths, and provides more
even service to other consoles in case there is a pathological
condition.

Signed-off-by: Nicholas Piggin <npiggin@xxxxxxxxx>
Signed-off-by: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
--
Matteo Croce
per aspera ad upstream