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 14/26] emul/vuart: add global UART emulator configuration knob
Date: Fri, 20 Nov 2026 10:37:29 +0100 [thread overview]
Message-ID: <4259e4ce-c21d-404d-be89-41eef1232819@gmail.com> (raw)
In-Reply-To: <20261111194800.1070016-15-dmukhin@ford.com>
On 11/11/26 8:47 PM, dmukhin@ford.com wrote:
> From: Denis Mukhin <dmukhin@ford.com>
>
> Introduce new command line setting `vuart=domid[:compatible,name]` for
> configuring UART emulator per given domain.
A new command line option needs an entry in
docs/misc/xen-command-line.pandoc; I don't see one in the series.
>
> Only one domain is supported for now.
>
> Format:
> domid - vUART owner domain ID
> compatible - vUART compatible string, must match with one of the
> registered emulators
> name - vUART user-friendly name used for searching for one of
> the pre-defined guest I/O resources
>
> compatible string and name are optional, if skipped, platform default
Is `name` really optional? Look my reply below ([A]).
> values will be chosen.
>
> Note, documentation update is not covered in this patch.
>
> Signed-off-by: Denis Mukhin <dmukhin@ford.com>
> ---
> xen/common/emul/vuart/vuart.c | 85 +++++++++++++++++++++++++++++++++++
> 1 file changed, 85 insertions(+)
>
> diff --git a/xen/common/emul/vuart/vuart.c b/xen/common/emul/vuart/vuart.c
> index bd3b756fb4d6..0df29540b1b6 100644
> --- a/xen/common/emul/vuart/vuart.c
> +++ b/xen/common/emul/vuart/vuart.c
> @@ -6,8 +6,10 @@
>
> #include <asm/types.h>
>
> +#include <xen/ctype.h>
> #include <xen/err.h>
> #include <xen/resource.h>
> +#include <xen/param.h>
Inclusion of headers should be sorted in alphabetical order so please
put xen/param.h before xen/resouce.h.
> #include <xen/sched.h>
> #include <xen/vuart.h>
> #include <xen/xvmalloc.h>
> @@ -18,6 +20,89 @@
> extern const struct vuart_emulator vuart_array_start[];
> extern const struct vuart_emulator vuart_array_end[];
>
> +static domid_t __read_mostly opt_vuart_domid = DOMID_INVALID;
> +static const struct vuart_info * __read_mostly opt_vuart_info;
Only a single domain can be given a vUART, and a later vuart= silently
replaces an earlier one. If that's the intended scope, the
documentation should say so.
> +
> +static const struct vuart_info vuart_supported[] = {
> +#define VUART(c,n,t,a,s,i) { \
> + .compatible = c, \
> + .name = n, \
> + .flags = VUART_CONSOLE_INPUT, \
> + .base_type = t, \
> + .base_addr = a, \
> + .size = s, \
> + .irq = i, \
> +}
> +#ifdef CONFIG_VUART_NS16X50
> + VUART("ns16550", "com1", IORESOURCE_IO, 0x3f8u, 8u, 4u),
> + VUART("ns16550", "com2", IORESOURCE_IO, 0x2f8u, 8u, 3u),
> + VUART("ns16550", "com3", IORESOURCE_IO, 0x3feu, 8u, 4u),
> + VUART("ns16550", "com4", IORESOURCE_IO, 0x2feu, 8u, 3u),
> +#endif /* CONFIG_VUART_NS16X50 */
COM3 and COM4 are at 0x3e8 and 0x2e8 (e.g. Linux's
arch/x86/include/asm/serial.h). 0x3fe and 0x2fe fall inside the COM1 and
COM2 ranges (0x3fe is COM1's MSR), so a guest wouldn't find com3/com4
where it looks for them, and the emulated range would overlap the
neighbouring ports.
Also, this table describes legacy PC COM ports, i.e. it's x86-specific,
but it lives in the arch-independent framework. For the RISC-V port I
had to limit it to CONFIG_X86. Could it move to x86 code, or into
ns16x50.c, with the framework only parsing the option?
> +#undef VUART
> +};
> +
> +static int __init cf_check vuart_parse_cmdline(const char *s)
> +{
> + const char *compat = "ns16550";
> + size_t compat_len = strlen(compat);
> + const char *name = "com1";
> + size_t name_len = strlen(name);
> + const char *end;
> + domid_t domid;
> + unsigned int i;
> +
> + /* vuart=domid:compatible,name */
> + if ( !isdigit(*s) )
> + return -EINVAL;
> +
> + domid = simple_strtoul(s, &end, 0);
> + if ( domid >= DOMID_FIRST_RESERVED )
> + return -EINVAL;
The value is truncated to domid_t before the range check, so e.g.
vuart=65537 is accepted as domain 1. Also, base 0 makes vuart=010 mean
domain 8. I'd parse into an unsigned long with base 10 and check that
before assigning:
unsigned long val = simple_strtoul(s, &end, 10);
if ( end == s || val >= DOMID_FIRST_RESERVED )
return -EINVAL;
domid = val;
> +
> + if ( *end == '\0' )
> + goto match_defaults;
> +
> + if ( *end != ':' )
> + return -EINVAL;
> +
> + compat = end + 1;
> +
> + while ( *end && *end != ',' )
> + end++;
> + if ( *end != ',' )
> + return -EINVAL;
[A] So once ":compatible" is given, ",name" is mandatory:
vuart=1:ns16550 is rejected. The Kconfig help in 16/26 documents
'vuart=<domid>:<compatible>[,com[1-4]]', i.e. the name as optional;
one of the two needs adjusting.
Also, the comment then should be adjusted too.
> +
> + compat_len = end - compat;
> + if ( !compat_len )
> + return -EINVAL;
> +
> + name = end + 1;
> + name_len = strlen(name);
> + if ( !name_len )
> + return -EINVAL;
> +
> + match_defaults:
> + for ( i = 0; i < ARRAY_SIZE(vuart_supported); i++ )
> + {
> + if ( compat_len != strlen(vuart_supported[i].compatible) ||
> + strncmp(compat, vuart_supported[i].compatible, compat_len) )
Nit: this matches the compatible exactly, while
vuart_match_by_compatible() (01/26) matches a prefix; it would be good
to use one rule for both.
~ Oleksii
next prev parent reply other threads:[~2026-11-20 9:37 UTC|newest]
Thread overview: 54+ 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
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-18 16:28 ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 11/26] emul/ns16x50: implement THR register dmukhin
2026-11-19 10:22 ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 12/26] emul/ns16x50: implement FCR register (write-only) dmukhin
2026-11-19 11:14 ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 13/26] emul/ns16550: implement dump_state() hook dmukhin
2026-11-19 19:43 ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 14/26] emul/vuart: add global UART emulator configuration knob dmukhin
2026-11-20 9:37 ` Oleksii Kurochko [this message]
2026-11-11 19:47 ` [PATCH v8 15/26] emul/ns16x50: enable emulator dmukhin
2026-11-20 9:45 ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 16/26] emul/ns16x50: add Kconfig options dmukhin
2026-11-20 9:53 ` Oleksii Kurochko
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-20 10:17 ` Oleksii Kurochko
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-20 10:23 ` Oleksii Kurochko
2026-11-11 19:47 ` [PATCH v8 23/26] docs/fusa: add NS16x50 UART requirements for x86 dmukhin
2026-11-19 17:10 ` Halder, Ayan Kumar
2026-11-19 22:22 ` Stefano Stabellini
2026-11-20 11:17 ` Halder, Ayan Kumar
2026-11-20 10:26 ` Oleksii Kurochko
2026-11-20 11:16 ` Halder, Ayan Kumar
2026-11-11 19:47 ` [PATCH v8 24/26] ci: add initial NS16550-compatible XTF test dmukhin
2026-11-20 10:34 ` Oleksii Kurochko
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=4259e4ce-c21d-404d-be89-41eef1232819@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.