[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v8 00/26] x86: introduce NS16550-compatible UART emulator



Hello Denis,

On 11/11/26 8:47 PM, dmukhin@xxxxxxxx wrote:
x86 port of Xen lacks vUART facility similar to Arm's vpl011 to support x86
guest OS bring up in the embedded setups.

This patch series introduces initial in-hypervisor emulator for
NS8250/NS16x50-compatible UARTs under CONFIG_VUART_NS16X50.

In parallel domain creation scenario (hyperlaunch), NS16550 emulator helps
early guest firmware and OS bringup debugging, because it eliminates
dependency on the external emulator (qemu) being operational by the time
domains are created.

The emulator also allows to forward the physical console input to the x86
domain which is useful when a system has only one physical UART for early
debugging and this UART is owned by Xen.

By default, CONFIG_VUART_NS16X50 enables emulation of NS16550 at I/O port
0x3f8, IRQ#4 in guest OS (legacy COM1). Legacy COM resources can be selected
at run-time via temporary and undocumented switch 'vuart='.

CONFIG_VUART_NS16X50_DEBUG enables some extra debugging facilities useful
for NS16550 emulator development/debugging (disabled by default).

The NS16550 emulator is disabled in default x86 configuration and goes under
CONFIG_EXPERT in Kconfig.

Note, there's a follow on work for RISC-V which is based on that series:
   
https://gitlab.com/xen-project/people/olkur/xen/-/tree/riscv-vuart-support-wip?ref_type=heads

Limitations
===========
- Only x86;
- Only legacy COM resources, custom I/O ports/IRQs are not supported;
- Only Xen console as a backend, no inter-domain communication (similar to
   vpl011 on Arm);
- Only 8n1 emulation (8-bit data, no parity, 1 stop bit);
- No toolstack integration;
- No baud rate emulation (reports 115200 baud to the guest OS);
- No FIFO-less mode emulation;
- No RX FIFO interrupt moderation (FCR) emulation;
- No integration w/ VM snapshotting (HVM_REGISTER_SAVE_RESTORE() and
   friends);
- No MMIO-based UART emulation.

Series
======

   Patch 1 introduces the new vUART framework, that is the code originally
   posted here:
     
https://lore.kernel.org/xen-devel/20250624035443.344099-16-dmukhin@xxxxxxxx/
   Required for emulator.

   Patch 2 adds missing NS16550 definitions, required for emulator.

   Patches 3-4 introduces the basic emulator skeleton - state machine
   initialization stubs, I/O port handler stub, logging, etc.

   Patches 5-12 incrementally populate the minimal NS16550 register emulation.

   Patch 13 hooks vUART state debugging (disabled by default).

   Patch 14-16 adds Kconfig for enabling minimal NS16550 UART (disabled by 
default).

   Patches 17-21 introduce necessary changes to enable NS16550 on dom0 (and 
PVH).

   Patches 22-23 documentation updates. Note, that vuart= setting is not
   documented since it will likely change with hyperlanch landing on mainline.

   Patches 24-26 tests updates.

Link to CI: 
https://gitlab.com/xen-project/people/dmukhin/xen/-/pipelines/3055921295
Link to XTF branch: 
https://gitlab.com/xen-project/people/dmukhin/xtf/-/commits/emul-16x50
Link to Xen branch: 
https://gitlab.com/xen-project/people/dmukhin/xen/-/tree/vuart-ns8250-v8?ref_type=heads


I built every patch of the series on x86 (defconfig + EXPERT + DEBUG,
gcc 16.2) and a few of them don't build:

- 18/26, 19/26, 20/26 with CONFIG_VUART_NS16X50=y: ns16x50_deinit() uses
  d, which is declared only in 21/26.

- 16/26 up to 26/26 with CONFIG_VUART_NS16X50_DEBUG=y: in
  ns16x50_dump_state() (13/26) the initializer of as dereferences info
  before info = vdev->info, so -Werror=uninitialized rejects it. It
shows up only from 16/26 on because nothing compiles ns16x50.c before the Kconfig option is introduced.

~ Oleksii




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.