<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/tty/hvc, branch v4.19.112</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v4.19.112</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v4.19.112'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2020-01-09T09:19:08+00:00</updated>
<entry>
<title>powerpc/pseries/hvconsole: Fix stack overread via udbg</title>
<updated>2020-01-09T09:19:08+00:00</updated>
<author>
<name>Daniel Axtens</name>
<email>dja@axtens.net</email>
</author>
<published>2019-06-03T06:56:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=3d14b83e71b233b32166ebf55fce7821135742c4'/>
<id>urn:sha1:3d14b83e71b233b32166ebf55fce7821135742c4</id>
<content type='text'>
[ Upstream commit 934bda59f286d0221f1a3ebab7f5156a996cc37d ]

While developing KASAN for 64-bit book3s, I hit the following stack
over-read.

It occurs because the hypercall to put characters onto the terminal
takes 2 longs (128 bits/16 bytes) of characters at a time, and so
hvc_put_chars() would unconditionally copy 16 bytes from the argument
buffer, regardless of supplied length. However, udbg_hvc_putc() can
call hvc_put_chars() with a single-byte buffer, leading to the error.

  ==================================================================
  BUG: KASAN: stack-out-of-bounds in hvc_put_chars+0xdc/0x110
  Read of size 8 at addr c0000000023e7a90 by task swapper/0

  CPU: 0 PID: 0 Comm: swapper Not tainted 5.2.0-rc2-next-20190528-02824-g048a6ab4835b #113
  Call Trace:
    dump_stack+0x104/0x154 (unreliable)
    print_address_description+0xa0/0x30c
    __kasan_report+0x20c/0x224
    kasan_report+0x18/0x30
    __asan_report_load8_noabort+0x24/0x40
    hvc_put_chars+0xdc/0x110
    hvterm_raw_put_chars+0x9c/0x110
    udbg_hvc_putc+0x154/0x200
    udbg_write+0xf0/0x240
    console_unlock+0x868/0xd30
    register_console+0x970/0xe90
    register_early_udbg_console+0xf8/0x114
    setup_arch+0x108/0x790
    start_kernel+0x104/0x784
    start_here_common+0x1c/0x534

  Memory state around the buggy address:
   c0000000023e7980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   c0000000023e7a00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1
  &gt;c0000000023e7a80: f1 f1 01 f2 f2 f2 00 00 00 00 00 00 00 00 00 00
                           ^
   c0000000023e7b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   c0000000023e7b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  ==================================================================

Document that a 16-byte buffer is requred, and provide it in udbg.

Signed-off-by: Daniel Axtens &lt;dja@axtens.net&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>tty: Don't force RISCV SBI console as preferred console</title>
<updated>2019-05-22T05:37:43+00:00</updated>
<author>
<name>Anup Patel</name>
<email>Anup.Patel@wdc.com</email>
</author>
<published>2019-04-25T13:35:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=c907ce3fd5528cf0483bcac7db55a3d82d35e000'/>
<id>urn:sha1:c907ce3fd5528cf0483bcac7db55a3d82d35e000</id>
<content type='text'>
commit f91253a3d005796404ae0e578b3394459b5f9b71 upstream.

The Linux kernel will auto-disables all boot consoles whenever it
gets a preferred real console.

Currently on RISC-V systems, if we have a real console which is not
RISCV SBI console then boot consoles (such as earlycon=sbi) are not
auto-disabled when a real console (ttyS0 or ttySIF0) is available.
This results in duplicate prints at boot-time after kernel starts
using real console (i.e. ttyS0 or ttySIF0) if "earlycon=" kernel
parameter was passed by bootloader.

The reason for above issue is that RISCV SBI console always adds
itself as preferred console which is causing other real consoles
to be not used as preferred console.

Ideally "console=" kernel parameter passed by bootloaders should
be the one selecting a preferred real console.

This patch fixes above issue by not forcing RISCV SBI console as
preferred console.

Fixes: afa6b1ccfad5 ("tty: New RISC-V SBI console driver")
Cc: stable@vger.kernel.org
Signed-off-by: Anup Patel &lt;anup.patel@wdc.com&gt;
Reviewed-by: Atish Patra &lt;atish.patra@wdc.com&gt;
Signed-off-by: Palmer Dabbelt &lt;palmer@sifive.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>tty: hvc: hvc_write() fix break condition</title>
<updated>2018-09-10T16:04:31+00:00</updated>
<author>
<name>Nicholas Piggin</name>
<email>npiggin@gmail.com</email>
</author>
<published>2018-09-09T05:39:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=7f2bf7840b74a160f908db83bc8829f8de10629b'/>
<id>urn:sha1:7f2bf7840b74a160f908db83bc8829f8de10629b</id>
<content type='text'>
Commit 550ddadcc758 ("tty: hvc: hvc_write() may sleep") broke the
termination condition in case the driver stops accepting characters.
This can result in unnecessary polling of the busy driver.

Restore it by testing the hvc_push return code.

Tested-by: Matteo Croce &lt;mcroce@redhat.com&gt;
Tested-by: Jason Gunthorpe &lt;jgg@mellanox.com&gt;
Tested-by: Leon Romanovsky &lt;leonro@mellanox.com&gt;
Signed-off-by: Nicholas Piggin &lt;npiggin@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>tty: hvc: hvc_poll() fix read loop batching</title>
<updated>2018-09-10T16:04:31+00:00</updated>
<author>
<name>Nicholas Piggin</name>
<email>npiggin@gmail.com</email>
</author>
<published>2018-09-09T05:39:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=68b2fc714fb1e08385f9c810d84f06affd007350'/>
<id>urn:sha1:68b2fc714fb1e08385f9c810d84f06affd007350</id>
<content type='text'>
Commit ec97eaad1383 ("tty: hvc: hvc_poll() break hv read loop")
removes get_chars batching entirely, which slows down large console
operations like paste -- virtio console "feels worse than a 9600 baud
serial line," reports Matteo.

This adds back batching in a more latency friendly way. If the caller
can sleep then we try to fill the entire flip buffer, releasing the
lock and scheduling between each iteration. If it can not sleep, then
batches are limited to 128 bytes. Matteo confirms this fixes the
performance problem.

Latency testing the powerpc OPAL console with OpenBMC UART with a
large paste shows about 0.25ms latency, which seems reasonable. 10ms
latencies were typical for this case before the latency breaking work,
so we still see most of the benefit.

  kopald-1204    0d.h.    5us : hvc_poll &lt;-hvc_handle_interrupt
  kopald-1204    0d.h.    5us : __hvc_poll &lt;-hvc_handle_interrupt
  kopald-1204    0d.h.    5us : _raw_spin_lock_irqsave &lt;-__hvc_poll
  kopald-1204    0d.h.    5us : tty_port_tty_get &lt;-__hvc_poll
  kopald-1204    0d.h.    6us : _raw_spin_lock_irqsave &lt;-tty_port_tty_get
  kopald-1204    0d.h.    6us : _raw_spin_unlock_irqrestore &lt;-tty_port_tty_get
  kopald-1204    0d.h.    6us : tty_buffer_request_room &lt;-__hvc_poll
  kopald-1204    0d.h.    7us : __tty_buffer_request_room &lt;-__hvc_poll
  kopald-1204    0d.h.    7us+: opal_get_chars &lt;-__hvc_poll
  kopald-1204    0d.h.   36us : tty_buffer_request_room &lt;-__hvc_poll
  kopald-1204    0d.h.   36us : __tty_buffer_request_room &lt;-__hvc_poll
  kopald-1204    0d.h.   36us+: opal_get_chars &lt;-__hvc_poll
  kopald-1204    0d.h.   65us : tty_buffer_request_room &lt;-__hvc_poll
  kopald-1204    0d.h.   65us : __tty_buffer_request_room &lt;-__hvc_poll
  kopald-1204    0d.h.   66us+: opal_get_chars &lt;-__hvc_poll
  kopald-1204    0d.h.   94us : tty_buffer_request_room &lt;-__hvc_poll
  kopald-1204    0d.h.   95us : __tty_buffer_request_room &lt;-__hvc_poll
  kopald-1204    0d.h.   95us+: opal_get_chars &lt;-__hvc_poll
  kopald-1204    0d.h.  124us : tty_buffer_request_room &lt;-__hvc_poll
  kopald-1204    0d.h.  124us : __tty_buffer_request_room &lt;-__hvc_poll
  kopald-1204    0d.h.  125us+: opal_get_chars &lt;-__hvc_poll
  kopald-1204    0d.h.  154us : tty_buffer_request_room &lt;-__hvc_poll
  kopald-1204    0d.h.  154us : __tty_buffer_request_room &lt;-__hvc_poll
  kopald-1204    0d.h.  154us+: opal_get_chars &lt;-__hvc_poll
  kopald-1204    0d.h.  183us : tty_buffer_request_room &lt;-__hvc_poll
  kopald-1204    0d.h.  184us : __tty_buffer_request_room &lt;-__hvc_poll
  kopald-1204    0d.h.  184us+: opal_get_chars &lt;-__hvc_poll
  kopald-1204    0d.h.  213us : tty_buffer_request_room &lt;-__hvc_poll
  kopald-1204    0d.h.  213us : __tty_buffer_request_room &lt;-__hvc_poll
  kopald-1204    0d.h.  213us+: opal_get_chars &lt;-__hvc_poll
  kopald-1204    0d.h.  242us : _raw_spin_unlock_irqrestore &lt;-__hvc_poll
  kopald-1204    0d.h.  242us : tty_flip_buffer_push &lt;-__hvc_poll
  kopald-1204    0d.h.  243us : queue_work_on &lt;-tty_flip_buffer_push
  kopald-1204    0d.h.  243us : tty_kref_put &lt;-__hvc_poll
  kopald-1204    0d.h.  243us : hvc_kick &lt;-hvc_handle_interrupt
  kopald-1204    0d.h.  243us : wake_up_process &lt;-hvc_kick
  kopald-1204    0d.h.  244us : try_to_wake_up &lt;-hvc_kick
  kopald-1204    0d.h.  244us : _raw_spin_lock_irqsave &lt;-try_to_wake_up
  kopald-1204    0d.h.  244us : _raw_spin_unlock_irqrestore &lt;-try_to_wake_up

Reported-by: Matteo Croce &lt;mcroce@redhat.com&gt;
Tested-by: Matteo Croce &lt;mcroce@redhat.com&gt;
Tested-by: Jason Gunthorpe &lt;jgg@mellanox.com&gt;
Tested-by: Leon Romanovsky &lt;leonro@mellanox.com&gt;
Signed-off-by: Nicholas Piggin &lt;npiggin@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>tty: hvc: hvc_poll() fix read loop hang</title>
<updated>2018-09-10T16:04:31+00:00</updated>
<author>
<name>Nicholas Piggin</name>
<email>npiggin@gmail.com</email>
</author>
<published>2018-09-09T05:39:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=6e7f6b82c60afb46ff71c2127421c66207966d6d'/>
<id>urn:sha1:6e7f6b82c60afb46ff71c2127421c66207966d6d</id>
<content type='text'>
Commit ec97eaad1383 ("tty: hvc: hvc_poll() break hv read loop") causes
the virtio console to hang at times (e.g., if you paste a bunch of
characters to it.

The reason is that get_chars must return 0 before we can be sure the
driver will kick or poll input again, but this change only scheduled a
poll if get_chars had returned a full count. Change this to poll on
any &gt; 0 count.

Reported-by: Matteo Croce &lt;mcroce@redhat.com&gt;
Reported-by: Jason Gunthorpe &lt;jgg@mellanox.com&gt;
Tested-by: Matteo Croce &lt;mcroce@redhat.com&gt;
Tested-by: Jason Gunthorpe &lt;jgg@mellanox.com&gt;
Tested-by: Leon Romanovsky &lt;leonro@mellanox.com&gt;
Signed-off-by: Nicholas Piggin &lt;npiggin@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>powerpc/powernv: provide a console flush operation for opal hvc driver</title>
<updated>2018-08-20T10:19:54+00:00</updated>
<author>
<name>Nicholas Piggin</name>
<email>npiggin@gmail.com</email>
</author>
<published>2018-04-30T14:55:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=95b861a76c1ded3e89d33a3d9f4552dce22e9875'/>
<id>urn:sha1:95b861a76c1ded3e89d33a3d9f4552dce22e9875</id>
<content type='text'>
Provide the flush hv_op for the opal hvc driver. This will flush the
firmware console buffers without spinning with interrupts disabled.

Cc: Benjamin Herrenschmidt &lt;benh@kernel.crashing.org&gt;
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Nicholas Piggin &lt;npiggin@gmail.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
</content>
</entry>
<entry>
<title>Merge branch 'topic/hvc' into next</title>
<updated>2018-08-13T06:04:10+00:00</updated>
<author>
<name>Michael Ellerman</name>
<email>mpe@ellerman.id.au</email>
</author>
<published>2018-08-13T06:04:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=70b5c4ee8e3bf7ce107d6926d9c7d8ebb68578c2'/>
<id>urn:sha1:70b5c4ee8e3bf7ce107d6926d9c7d8ebb68578c2</id>
<content type='text'>
This branch held some hvc related commits (Hypervisor Virtual Console)
so that they could get some wider testing in linux-next before merging.
</content>
</entry>
<entry>
<title>tty: hvc: remove unexplained "just in case" spin delay</title>
<updated>2018-07-24T12:09:58+00:00</updated>
<author>
<name>Nicholas Piggin</name>
<email>npiggin@gmail.com</email>
</author>
<published>2018-04-30T14:55:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=cca3d5290ede73b01144aa522910c88b1e02fcef'/>
<id>urn:sha1:cca3d5290ede73b01144aa522910c88b1e02fcef</id>
<content type='text'>
This delay was in the very first OPAL console commit 6.5 years ago,
and came from the vio hvc driver. The firmware console has hardened
sufficiently to remove it.

Reviewed-by: Benjamin Herrenschmidt &lt;benh@kernel.crashing.org&gt;
Signed-off-by: Nicholas Piggin &lt;npiggin@gmail.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
</content>
</entry>
<entry>
<title>powerpc/powernv: implement opal_put_chars_atomic</title>
<updated>2018-07-24T12:09:57+00:00</updated>
<author>
<name>Nicholas Piggin</name>
<email>npiggin@gmail.com</email>
</author>
<published>2018-04-30T14:55:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=17cc1dd4924391b54fb179d0868b89dc96f2ee80'/>
<id>urn:sha1:17cc1dd4924391b54fb179d0868b89dc96f2ee80</id>
<content type='text'>
The RAW console does not need writes to be atomic, so relax
opal_put_chars to be able to do partial writes, and implement an
_atomic variant which does not take a spinlock. This API is used
in xmon, so the less locking that is used, the better chance there
is that a crash can be debugged.

Cc: Benjamin Herrenschmidt &lt;benh@kernel.crashing.org&gt;
Signed-off-by: Nicholas Piggin &lt;npiggin@gmail.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
</content>
</entry>
<entry>
<title>powerpc/powernv: move opal console flushing to udbg</title>
<updated>2018-07-24T12:09:57+00:00</updated>
<author>
<name>Nicholas Piggin</name>
<email>npiggin@gmail.com</email>
</author>
<published>2018-04-30T14:55:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=ac4ac788fdadc6b703ff3322de07dee442e08e1c'/>
<id>urn:sha1:ac4ac788fdadc6b703ff3322de07dee442e08e1c</id>
<content type='text'>
OPAL console writes do not have to synchronously flush firmware /
hardware buffers unless they are going through the udbg path.

Remove the unconditional flushing from opal_put_chars. Flush if
there was no space in the buffer as an optimisation (callers loop
waiting for success in that case). udbg flushing is moved to
udbg_opal_putc.

Signed-off-by: Nicholas Piggin &lt;npiggin@gmail.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
</content>
</entry>
</feed>
