qemu-e2k/hw/char
Paul Mackerras fd38b1629c spapr: Implement better workaround in spapr-vty device
Linux guest kernels have code which scans the string of characters
returned from the H_GET_TERM_CHAR hypercall and removes any \0
character which comes immediately after a \r character.  This is to
work around a bug which was present in some ancient versions of
PowerVM.  In order to avoid the corruption of the console byte stream
that this introduced, commit 6c3bc244d3 ("spapr: Implement bug in
spapr-vty device to be compatible with PowerVM") added a workaround
which adds a \0 character after every \r character.  Unfortunately,
this corrupts the console byte stream for those operating systems,
such as AIX, which don't remove the null bytes.

We can avoid triggering the Linux kernel workaround if we avoid
returning a buffer which contains a \0 after a \r.  We can do that by
breaking out of the loop in vty_getchars() if we are about to insert a
\0 and the previous character in the buffer is a \r.  That means we
return the characters up to the \r for the current H_GET_TERM_CHAR,
and the characters starting with the \0 for the next one.

With this workaround, we don't insert any spurious characters and we
avoid triggering the Linux kernel workaround, so the guest will
receive an uncorrupted stream whether or not they have the workaround.

Fixes: 6c3bc244d3 ("spapr: Implement bug in spapr-vty device to be compatible with PowerVM")
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Message-Id: <20190731043653.shdi5sizjp4t65op@oak.ozlabs.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-08-21 17:17:39 +10:00
..
Kconfig hw/char: Move multi-serial devices into separate file 2019-05-17 15:19:39 +02:00
Makefile.objs hw/char: Move multi-serial devices into separate file 2019-05-17 15:19:39 +02:00
bcm2835_aux.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
cadence_uart.c Include migration/vmstate.h less 2019-08-16 13:31:52 +02:00
cmsdk-apb-uart.c Include migration/vmstate.h less 2019-08-16 13:31:52 +02:00
debugcon.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
digic-uart.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
escc.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
etraxfs_ser.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
exynos4210_uart.c Clean up inclusion of sysemu/sysemu.h 2019-08-16 13:31:53 +02:00
grlib_apbuart.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
imx_serial.c Clean up inclusion of sysemu/sysemu.h 2019-08-16 13:31:53 +02:00
ipoctal232.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
lm32_juart.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
lm32_uart.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
mcf_uart.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
milkymist-uart.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
nrf51_uart.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
omap_uart.c Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
parallel-isa.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
parallel.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
pl011.c Include migration/vmstate.h less 2019-08-16 13:31:52 +02:00
sclpconsole-lm.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
sclpconsole.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
serial-isa.c Include sysemu/sysemu.h a lot less 2019-08-16 13:31:53 +02:00
serial-pci-multi.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
serial-pci.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
serial.c sysemu: Split sysemu/runstate.h off sysemu/sysemu.h 2019-08-16 13:37:36 +02:00
sh_serial.c Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
spapr_vty.c spapr: Implement better workaround in spapr-vty device 2019-08-21 17:17:39 +10:00
stm32f2xx_usart.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
terminal3270.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
trace-events trace-events: Fix attribution of trace points to source 2019-03-22 16:18:07 +00:00
virtio-console.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
virtio-serial-bus.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
xen_console.c Include sysemu/sysemu.h a lot less 2019-08-16 13:31:53 +02:00
xilinx_uartlite.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00