mirror-linux/drivers/tty/hvc
Roger Pau Monne 82268b2da2 hvc/xen: prevent concurrent accesses to the shared ring
[ Upstream commit 6214894f49 ]

The hvc machinery registers both a console and a tty device based on
the hv ops provided by the specific implementation.  Those two
interfaces however have different locks, and there's no single locks
that's shared between the tty and the console implementations, hence
the driver needs to protect itself against concurrent accesses.
Otherwise concurrent calls using the split interfaces are likely to
corrupt the ring indexes, leaving the console unusable.

Introduce a lock to xencons_info to serialize accesses to the shared
ring.  This is only required when using the shared memory console,
concurrent accesses to the hypercall based console implementation are
not an issue.

Note the conditional logic in domU_read_console() is slightly modified
so the notify_daemon() call can be done outside of the locked region:
it's an hypercall and there's no need for it to be done with the lock
held.

Fixes: b536b4b962 ('xen: use the hvc console infrastructure for Xen console')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/20221130150919.13935-1-roger.pau@citrix.com
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-03-30 12:49:09 +02:00
..
Kconfig tty: hvc: dcc: Bind driver to CPU core0 for reads and writes 2022-05-05 22:45:57 +02:00
Makefile
hvc_console.c
hvc_console.h
hvc_dcc.c tty: hvc: dcc: Bind driver to CPU core0 for reads and writes 2022-05-05 22:45:57 +02:00
hvc_irq.c
hvc_iucv.c tty: hvc: remove HVC_IUCV_MAGIC 2022-09-22 16:12:34 +02:00
hvc_opal.c tty/hvc_opal: simplify if-if to if-else 2022-04-26 13:24:17 +02:00
hvc_riscv_sbi.c
hvc_rtas.c
hvc_udbg.c
hvc_vio.c tty: hvc: Prepare cleanup of powerpc's asm/prom.h 2022-04-15 08:42:26 +02:00
hvc_xen.c hvc/xen: prevent concurrent accesses to the shared ring 2023-03-30 12:49:09 +02:00
hvcs.c termios: start unifying non-UAPI parts of asm/termios.h 2022-09-09 10:44:34 +02:00
hvsi.c tty: hvc: Prepare cleanup of powerpc's asm/prom.h 2022-04-15 08:42:26 +02:00
hvsi_lib.c