From: Oleksii Kurochko <oleksii.kurochko@gmail.com>
To: dmukhin@ford.com, xen-devel@lists.xenproject.org
Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech,
jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com,
roger@xenproject.org, sstabellini@kernel.org,
xakep.amatop@gmail.com, dmukhin@xen.org
Subject: Re: [PATCH v8 08/26] emul/ns16x50: implement LCR/LSR registers
Date: Tue, 17 Nov 2026 17:33:57 +0100 [thread overview]
Message-ID: <2c4f0ced-7bae-423c-9265-fe0fcbb3dbfb@gmail.com> (raw)
In-Reply-To: <20261111194800.1070016-9-dmukhin@ford.com>
On 11/11/26 8:47 PM, dmukhin@ford.com wrote:
> From: Denis Mukhin <dmukhin@ford.com>
>
> Add LCR/LSR registers implementation to the I/O port handler.
>
> Add implementation of ns16x50_dlab_get() and ns16x50_iir_check_lsi().
There's no ns16x50_dlab_get() in this patch, or anywhere in the series;
DLAB is tested open-coded as regs[UART_LCR] & UART_LCR_DLAB. Either the
sentence is stale or the helper got lost (a helper would indeed be nice,
as that expression appears four times by now).
>
> Signed-off-by: Denis Mukhin <dmukhin@ford.com>
> ---
> xen/common/emul/vuart/ns16x50.c | 23 ++++++++++++++++++++++-
> 1 file changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/xen/common/emul/vuart/ns16x50.c b/xen/common/emul/vuart/ns16x50.c
> index 7c5cdc99cfa7..e80815ccf6e2 100644
> --- a/xen/common/emul/vuart/ns16x50.c
> +++ b/xen/common/emul/vuart/ns16x50.c
> @@ -64,6 +64,11 @@ do { \
> #define ns16x50_debug(vdev, fmt, args...) \
> ns16x50_log(3, XENLOG_DEBUG, vdev, fmt, ## args)
>
> +/*
> + * Helper register definitions.
> + */
Nit: Single line comment should be enough here so please use /* ... */
> +#define UART_LSR_MASK (UART_LSR_OE | UART_LSR_BI)
Nit: this is local to the emulator, but uses the UART_ prefix of
xen/8250-uart.h, so it looks like a register definition from there. Also
"MASK" doesn't say what it is: these are the LSR bits that raise the LSI
and are cleared by reading LSR. On a 16550 that's all four error bits
(OE, PE, FE, BI); the emulator never sets PE and FE (nor BI, as far as I
can see), but including them would match the datasheet and cost
nothing. Maybe NS16X50_LSR_ERRORS?
> +
> /*
> * Number of supported registers in the UART.
> */
Nit: Single line comment should be enough here so please use /* ... */
> @@ -116,7 +121,7 @@ static inline void ns16x50_unlock(struct vuart_ns16x50 *vdev,
>
> static bool cf_check ns16x50_iir_check_lsi(const struct vuart_ns16x50 *vdev)
> {
> - return false;
> + return vdev->regs[UART_LSR] & UART_LSR_MASK;
> }
>
> static bool cf_check ns16x50_iir_check_rda(const struct vuart_ns16x50 *vdev)
> @@ -245,11 +250,16 @@ static int ns16x50_io_write8(
> }
> break;
>
> + case UART_LCR:
> + regs[UART_LCR] = val;
> + break;
> +
> /* NB: Firmware (e.g. OVMF) may rely on SCR presence. */
> case UART_SCR:
> regs[UART_SCR] = val;
> break;
>
> + case UART_LSR: /* RO */
> default:
A write to LSR (or later MSR) ends up in ns16x50_err(), i.e. a
guest-triggerable error message per access. Real 16550s ignore such
writes (the TL16C550C datasheet only says writing LSR isn't
recommended), so silently ignoring them, or at most a debug message,
seems more appropriate. The same applies to the other "unsupported
access" paths in ns16x50_access().
> rc = -EINVAL;
> break;
> @@ -346,6 +356,15 @@ static int ns16x50_io_read8(
> val = ns16x50_iir_get(vdev);
> break;
>
> + case UART_LCR:
> + val = regs[UART_LCR];
> + break;
> +
> + case UART_LSR:
> + val = regs[UART_LSR];
> + regs[UART_LSR] = val & ~UART_LSR_MASK;
> + break;
> +
> case UART_SCR:
> val = regs[UART_SCR];
> break;
> @@ -509,6 +528,8 @@ static void ns16x50_reset(struct vuart_ns16x50 *vdev)
> memset(vdev->regs, 0, sizeof(vdev->regs));
> vdev->irq_asserted = false;
>
> + vdev->regs[UART_LSR] = UART_LSR_THRE | UART_LSR_TEMT;
> +
Matches the 16550 reset value of LSR (0x60).
> /* NB: report 115200 baud rate. */
> vdev->regs[NS16X50_REGS_NUM + UART_DLL] = divisor & UINT8_MAX;
> vdev->regs[NS16X50_REGS_NUM + UART_DLM] = (divisor >> 8) & UINT8_MAX;
~ Oleksii
next prev parent reply other threads:[~2026-11-17 16:34 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 19:47 [PATCH v8 00/26] x86: introduce NS16550-compatible UART emulator dmukhin
2026-11-11 19:47 ` [PATCH v8 01/26] emul/vuart: introduce framework for UART emulators dmukhin
2026-11-12 15:35 ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 02/26] xen/8250-uart: update definitions dmukhin
2026-11-12 14:49 ` Jan Beulich
2026-11-12 16:34 ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 03/26] x86: fixup dependencies for asm/x86_emulate.h dmukhin
2026-11-12 20:25 ` Oleksii Kurochko
2026-11-13 7:20 ` Jan Beulich
2026-11-11 19:47 ` [PATCH v8 04/26] emul/ns16x50: implement emulator stub dmukhin
2026-11-13 11:48 ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 05/26] emul/ns16x50: implement DLL/DLM registers dmukhin
2026-11-16 10:36 ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 06/26] emul/ns16x50: implement SCR register dmukhin
2026-11-16 10:42 ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 07/26] emul/ns16x50: implement IER/IIR registers dmukhin
2026-11-16 16:59 ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 08/26] emul/ns16x50: implement LCR/LSR registers dmukhin
2026-11-17 16:33 ` Oleksii Kurochko [this message]
2026-11-11 19:47 ` [PATCH v8 09/26] emul/ns16x50: implement MCR/MSR registers dmukhin
2026-11-17 18:32 ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 10/26] emul/ns16x50: implement RBR register dmukhin
2026-11-11 19:47 ` [PATCH v8 11/26] emul/ns16x50: implement THR register dmukhin
2026-11-11 19:47 ` [PATCH v8 12/26] emul/ns16x50: implement FCR register (write-only) dmukhin
2026-11-11 19:47 ` [PATCH v8 13/26] emul/ns16550: implement dump_state() hook dmukhin
2026-11-11 19:47 ` [PATCH v8 14/26] emul/vuart: add global UART emulator configuration knob dmukhin
2026-11-11 19:47 ` [PATCH v8 15/26] emul/ns16x50: enable emulator dmukhin
2026-11-11 19:47 ` [PATCH v8 16/26] emul/ns16x50: add Kconfig options dmukhin
2026-11-11 19:47 ` [PATCH v8 17/26] x86/domain: enable per-domain I/O port bitmaps dmukhin
2026-11-11 19:47 ` [PATCH v8 18/26] emul/ns16x50: resolve physical I/O port sharing dmukhin
2026-11-11 19:47 ` [PATCH v8 19/26] xen/domain: allocate d->irq_caps before arch-specific initialization dmukhin
2026-11-11 19:47 ` [PATCH v8 20/26] emul/ns16x50: resolve physical IRQ sharing dmukhin
2026-11-11 19:47 ` [PATCH v8 21/26] emul/ns16x50: implement IRQ emulation via vIOAPIC dmukhin
2026-11-11 19:47 ` [PATCH v8 22/26] MAINTAINERS: add myself as vUART framework maintainer dmukhin
2026-11-11 19:47 ` [PATCH v8 23/26] docs/fusa: add NS16x50 UART requirements for x86 dmukhin
2026-11-11 19:47 ` [PATCH v8 24/26] ci: add initial NS16550-compatible XTF test dmukhin
2026-11-11 19:47 ` [PATCH v8 25/26] ci: add smoke NS16550-compatible PVH Linux test dmukhin
2026-11-11 19:48 ` [PATCH v8 26/26] ci: do not merge: test dmukhin
2026-11-12 14:53 ` [PATCH v8 00/26] x86: introduce NS16550-compatible UART emulator Oleksii Kurochko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2c4f0ced-7bae-423c-9265-fe0fcbb3dbfb@gmail.com \
--to=oleksii.kurochko@gmail.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=dmukhin@ford.com \
--cc=dmukhin@xen.org \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=roger@xenproject.org \
--cc=sstabellini@kernel.org \
--cc=xakep.amatop@gmail.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.