xen: framework for UART emulators
cover xen: framework for UART emulators
The series introduces a driver framework to abstract UART emulators in the hypervisor under drivers/vuart.
That allows for architecture-independent handling of virtual UARTs in the console driver and simplifies enabling new UART emulators.
The framework is gated by CONFIG_HAS_VUART, which is automatically enabled once the user enables any UART emulator.
Current implementation supports maximum of one vUART of each kind per domain.
All current UART emulators (Arm) are switched to the new framework.
This works origins from [1].
Conceptually, there are 3 parts in the series:
- PL011 emulator cleanup: patches 1-6
- Simple MMIO-based UART emulator cleanup: patches 7-10, depends on the common header introduced in vpl011 cleanup
- vUART driver framework: patches 11-16, depends on the cleanup part
[1] https://lore.kernel.org/xen-devel/[email protected]/
[2] CI: https://gitlab.com/xen-project/people/dmukhin/xen/-/pipelines/1885641957
Denis Mukhin (16):
arm/vpl011: rename virtual PL011 Kconfig option arm/vpl011: move DT node parsing to PL011 emulator code arm/vpl011: use vuart_ prefix in vpl011 public calls arm/vpl011: use raw spin_lock_{irqrestore,irqsave} arm/vpl011: use void pointer in domain struct
arm/vpl011: remove vpl011 header file
arm/vuart: rename 'virtual UART' Kconfig option
arm/vuart: move simple MMIO-based vUART declarations to common header arm/vuart: use void pointer in domain struct
arm/vuart: merge vuart_print_char() with vuart_mmio_write() xen/domain: introduce common emulation flags
xen/domain: introduce domain-emu.h
drivers/vuart: move PL011 emulator code
drivers/vuart: move simple MMIO-based UART emulator drivers/vuart: introduce framework for UART emulators drivers/vuart: hook simple MMIO-based UART to vUART framework
xen/arch/arm/Kconfig | 15 -
xen/arch/arm/Makefile | 2 -
xen/arch/arm/configs/tiny64_defconfig | 2 +-
xen/arch/arm/dom0less-build.c | 76 +---
xen/arch/arm/domain.c | 11 +-
xen/arch/arm/domctl.c | 15 +-
xen/arch/arm/include/asm/domain.h | 20 +-
xen/arch/arm/include/asm/kernel.h | 3 -
xen/arch/arm/include/asm/vpl011.h | 91 -----
xen/arch/arm/vuart.c | 139 -------
xen/arch/arm/vuart.h | 54 ---
xen/arch/arm/xen.lds.S | 1 +
xen/arch/ppc/include/asm/domain.h | 1 +
xen/arch/ppc/xen.lds.S | 1 +
xen/arch/riscv/include/asm/domain.h | 1 +
xen/arch/riscv/xen.lds.S | 1 +
xen/arch/x86/domain.c | 2 +-
xen/arch/x86/domctl.c | 2 +-
xen/arch/x86/include/asm/domain.h | 48 ++-
xen/arch/x86/xen.lds.S | 1 +
xen/common/domain.c | 13 +
xen/common/keyhandler.c | 4 +
xen/drivers/Kconfig | 2 +
xen/drivers/Makefile | 1 +
xen/drivers/char/console.c | 11 +-
xen/drivers/vuart/Kconfig | 23 ++
xen/drivers/vuart/Makefile | 3 +
xen/drivers/vuart/vuart-mmio.c | 189 ++++++++++
.../vpl011.c => drivers/vuart/vuart-pl011.c} | 347 +++++++++++++-----
xen/drivers/vuart/vuart.c | 95 +++++
xen/include/xen/domain-emu.h | 33 ++
xen/include/xen/domain.h | 2 +
xen/include/xen/sched.h | 2 +
xen/include/xen/vuart.h | 72 ++++
xen/include/xen/xen.lds.h | 10 +
35 files changed, 771 insertions(+), 522 deletions(-)
delete mode 100644 xen/arch/arm/include/asm/vpl011.h
delete mode 100644 xen/arch/arm/vuart.c
delete mode 100644 xen/arch/arm/vuart.h
create mode 100644 xen/drivers/vuart/Kconfig
create mode 100644 xen/drivers/vuart/Makefile
create mode 100644 xen/drivers/vuart/vuart-mmio.c
rename xen/{arch/arm/vpl011.c => drivers/vuart/vuart-pl011.c} (71%)
create mode 100644 xen/drivers/vuart/vuart.c
create mode 100644 xen/include/xen/domain-emu.h
create mode 100644 xen/include/xen/vuart.hSignature · 1 line
2.34.1
PATCH 1/16 arm/vpl011: rename virtual PL011 Kconfig option
From: Denis Mukhin <[email protected]>
Rename CONFIG_SBSA_VUART_CONSOLE to CONFIG_HAS_VUART_PL011.
No functional change.
--- xen/arch/arm/Kconfig | 2 +- xen/arch/arm/Makefile | 2 +- xen/arch/arm/configs/tiny64_defconfig | 2 +- xen/arch/arm/dom0less-build.c | 4 ++-- xen/arch/arm/include/asm/domain.h | 2 +- xen/arch/arm/include/asm/vpl011.h | 2 +- xen/drivers/char/console.c | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-)
xen/arch/arm/Kconfig +1 -1
@@ -170,7 +170,7 @@ config NEW_VGIC problems with the standard emulation. At the moment this implementation is not security supported. -config SBSA_VUART_CONSOLE +config HAS_VUART_PL011 bool "Emulated SBSA UART console support" default y help
xen/arch/arm/Makefile +1 -1
@@ -65,7 +65,7 @@ obj-$(CONFIG_HAS_ITS) += vgic-v3-its.o endif obj-$(CONFIG_VM_EVENT) += vm_event.o obj-y += vtimer.o -obj-$(CONFIG_SBSA_VUART_CONSOLE) += vpl011.o +obj-$(CONFIG_HAS_VUART_PL011) += vpl011.o obj-y += vsmc.o obj-y += vpsci.o obj-$(CONFIG_HWDOM_VUART) += vuart.o
xen/arch/arm/configs/tiny64_defconfig +1 -1
@@ -6,7 +6,7 @@ CONFIG_ARM=y # # CONFIG_GICV3 is not set # CONFIG_VM_EVENT is not set -# CONFIG_SBSA_VUART_CONSOLE is not set +# CONFIG_HAS_VUART_PL011 is not set # # Common Features
xen/arch/arm/dom0less-build.c +2 -2
@@ -167,7 +167,7 @@ int __init make_intc_domU_node(struct kernel_info *kinfo) } } -#ifdef CONFIG_SBSA_VUART_CONSOLE +#ifdef CONFIG_HAS_VUART_PL011 static int __init make_vpl011_uart_node (struct kernel_info *kinfo) {void *fdt = kinfo->fdt;
@@ -226,7 +226,7 @@ int __init make_arch_nodes(struct kernel_info *kinfo)if ( kinfo->arch.vpl011 ) { -#ifdef CONFIG_SBSA_VUART_CONSOLE +#ifdef CONFIG_HAS_VUART_PL011 ret =make_vpl011_uart_node (kinfo);#endif if ( ret )
xen/arch/arm/include/asm/domain.h +1 -1
@@ -113,7 +113,7 @@ struct arch_domain uint8_t privileged_call_enabled : 1; } monitor; -#ifdef CONFIG_SBSA_VUART_CONSOLE +#ifdef CONFIG_HAS_VUART_PL011 struct vpl011 vpl011;#endif
xen/arch/arm/include/asm/vpl011.h +1 -1
@@ -65,7 +65,7 @@ struct vpl011_init_info {evtchn_port_t evtchn; }; -#ifdef CONFIG_SBSA_VUART_CONSOLE +#ifdef CONFIG_HAS_VUART_PL011 int domain_vpl011_init (struct domain *d,struct vpl011_init_info *info);void domain_vpl011_deinit (struct domain *d);
xen/drivers/char/console.c +2 -2
@@ -37,7 +37,7 @@#ifdef CONFIG_X86 #include <asm/guest.h> #endif -#ifdef CONFIG_SBSA_VUART_CONSOLE +#ifdef CONFIG_HAS_VUART_PL011 #include <asm/vpl011.h> #endif
@@ -606,7 +606,7 @@ static void __serial_rx(char c)*/ send_global_virq (VIRQ_CONSOLE ); } -#ifdef CONFIG_SBSA_VUART_CONSOLE +#ifdef CONFIG_HAS_VUART_PL011 else/* Deliver input to the emulated UART. */ rc =vpl011_rx_char_xen (d, c);
Signature · 1 line
2.34.1
Re: [PATCH v1 01/16] arm/vpl011: rename virtual PL011 Kconfig option
Quoted 3 lines · On 24/06/2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Rename
CONFIG_SBSA_VUART_CONSOLEtoCONFIG_HAS_VUART_PL011.
Why? We emulate SBSA UART and not PL011. Despite the similarities (the former is a subset of the latter) they are not the same. I find it confusing and drivers for PL011 might not work with SBSA UART. Also, in the future we may want to emulate full PL011 in which case it will be even more confusing.
Also, why HAS_?
~Michal
Re: [PATCH v1 01/16] arm/vpl011: rename virtual PL011 Kconfig option
Quoted 10 lines · Michal
Quoted 3 lines · On 24/06/2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Rename
CONFIG_SBSA_VUART_CONSOLEtoCONFIG_HAS_VUART_PL011.Why? We emulate SBSA UART and not PL011. Despite the similarities (the former is a subset of the latter) they are not the same. I find it confusing and drivers for PL011 might not work with SBSA UART. Also, in the future we may want to emulate full PL011 in which case it will be even more confusing.
That's because the emulator is called vpl011, but yes, it is SBSA UART. I will adjust to SBSA, thanks!
Quoted 2 lines
Also, why
HAS_?
My understanding is that HAS_ is the desired naming convention throughout the code (not documented, though), e.g. all Arm UART drivers are gated by HAS_XXX (e.g. arch/arm/platforms/Kconfig).
Quoted 3 lines
~Michal
Re: [PATCH v1 01/16] arm/vpl011: rename virtual PL011 Kconfig option
Quoted 16 lines · dmkhn
Quoted 10 lines · Michal
Quoted 3 lines · On 24/06/2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Rename
CONFIG_SBSA_VUART_CONSOLEtoCONFIG_HAS_VUART_PL011.Why? We emulate SBSA UART and not PL011. Despite the similarities (the former is a subset of the latter) they are not the same. I find it confusing and drivers for PL011 might not work with SBSA UART. Also, in the future we may want to emulate full PL011 in which case it will be even more confusing.
That's because the emulator is called vpl011, but yes, it is SBSA UART. I will adjust to SBSA, thanks!
Quoted 1 line
Quoted 5 lines
Quoted 1 line
Also, why
HAS_?My understanding is that
HAS_is the desired naming convention throughout the code (not documented, though), e.g. all Arm UART drivers are gated byHAS_XXX(e.g.arch/arm/platforms/Kconfig).
HAS_ is a non-selectable property dependent on the arch. Think HAS_PCI, or HAS_EHCI, etc. IOW: HAS_X means "you may implement feature X on this arch", which is why some options have X and HAS_X variants, where X is selectable while HAS_X is not.
Cheers,
Alejandro
Re: [PATCH v1 01/16] arm/vpl011: rename virtual PL011 Kconfig option
Quoted 19 lines · Alejandro Vallejo
Quoted 18 lines · dmkhn
Quoted 10 lines · Michal
Quoted 3 lines · On 24/06/2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Rename
CONFIG_SBSA_VUART_CONSOLEtoCONFIG_HAS_VUART_PL011.Why? We emulate SBSA UART and not PL011. Despite the similarities (the former is a subset of the latter) they are not the same. I find it confusing and drivers for PL011 might not work with SBSA UART. Also, in the future we may want to emulate full PL011 in which case it will be even more confusing.
That's because the emulator is called vpl011, but yes, it is SBSA UART. I will adjust to SBSA, thanks!
Quoted 2 lines
Also, why
HAS_?
Quoted 8 lines
Quoted 3 lines
My understanding is that
HAS_is the desired naming convention throughout the code (not documented, though), e.g. all Arm UART drivers are gated byHAS_XXX(e.g.arch/arm/platforms/Kconfig).
HAS_is a non-selectable property dependent on the arch. ThinkHAS_PCI, orHAS_EHCI, etc. IOW:HAS_Xmeans "you may implement feature X on this arch", which is why some options have X andHAS_Xvariants, where X is selectable whileHAS_Xis not.
Thanks; I will fix that.
Jan explained the difference here [1] and [2]:
[1] https://lore.kernel.org/xen-devel/[email protected]/
[2] https://lore.kernel.org/xen-devel/[email protected]/
It's just there's a lot of drivers (UARTs) which are selectable by the user via HAS_ symbols (drivers/char/Kconfig)
Quoted 4 lines
Cheers,
Alejandro
Re: [PATCH v1 01/16] arm/vpl011: rename virtual PL011 Kconfig option
Quoted 29 lines · dmkhn
Quoted 19 lines · Alejandro Vallejo
Quoted 18 lines · dmkhn
Quoted 10 lines · Michal
Quoted 3 lines · On 24/06/2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Rename
CONFIG_SBSA_VUART_CONSOLEtoCONFIG_HAS_VUART_PL011.Why? We emulate SBSA UART and not PL011. Despite the similarities (the former is a subset of the latter) they are not the same. I find it confusing and drivers for PL011 might not work with SBSA UART. Also, in the future we may want to emulate full PL011 in which case it will be even more confusing.
That's because the emulator is called vpl011, but yes, it is SBSA UART. I will adjust to SBSA, thanks!
Quoted 2 lines
Also, why
HAS_?Quoted 8 lines
Quoted 3 lines
My understanding is that
HAS_is the desired naming convention throughout the code (not documented, though), e.g. all Arm UART drivers are gated byHAS_XXX(e.g.arch/arm/platforms/Kconfig).
HAS_is a non-selectable property dependent on the arch. ThinkHAS_PCI, orHAS_EHCI, etc. IOW:HAS_Xmeans "you may implement feature X on this arch", which is why some options have X andHAS_Xvariants, where X is selectable whileHAS_Xis not.
Quoted 8 lines
Thanks; I will fix that.
Jan explained the difference here [1] and [2]:
[1] https://lore.kernel.org/xen-devel/[email protected]/
[2] https://lore.kernel.org/xen-devel/[email protected]/It's just there's a lot of drivers (UARTs) which are selectable by the user via
HAS_symbols (drivers/char/Kconfig)
IMO, HAS_IMX_LPUART should be selected by ARM_64, then IMX_LPUART would depend on HAS_IMX_LPUART. I don't know how those (and you're right, there's lots) got there. Same with NS16550, etc.
That allows to decouple the device from the architectures where it might be found.
Cheers,
Alejandro
PATCH 2/16 arm/vpl011: move DT node parsing to PL011 emulator code
In reply to [email protected]From: Denis Mukhin <[email protected]>
Move vpl011 DT node parsing from common Arm code to PL011 emulator code.
While doing it pick the generic name vuart_add_fwnode() for DT parser function and place the declaration in the common header in include/xen/vuart.h.
No functional change.
--- xen/arch/arm/dom0less-build.c | 52 ++--------------------------------- xen/arch/arm/vpl011.c | 52 +++++++++++++++++++++++++++++++++++ xen/include/xen/vuart.h | 23 ++++++++++++++++ 3 files changed, 77 insertions(+), 50 deletions(-) create mode 100644 xen/include/xen/vuart.h
xen/arch/arm/dom0less-build.c +2 -50
@@ -15,6 +15,7 @@#include <xen/static-memory.h> #include <xen/static-shmem.h> #include <xen/vmap.h> +#include <xen/vuart.h> #include <public/bootfdt.h> #include <public/io/xs_wire.h>
@@ -167,55 +168,6 @@ int __init make_intc_domU_node(struct kernel_info *kinfo) } } -#ifdef CONFIG_HAS_VUART_PL011 -static int __init make_vpl011_uart_node (struct kernel_info *kinfo) -{ -void *fdt = kinfo->fdt; -int res; -gic_interrupt_t intr; -__be32 reg[GUEST_ROOT_ADDRESS_CELLS +GUEST_ROOT_SIZE_CELLS ]; -__be32 *cells; -struct domain *d = kinfo->d; - - res =domain_fdt_begin_node (fdt,"sbsa-uart" , d->arch.vpl011.base_addr); -if ( res ) -return res; - - res =fdt_property_string (fdt,"compatible" ,"arm,sbsa-uart" ); -if ( res ) -return res; - - cells = ®[0 ]; -dt_child_set_range (&cells,GUEST_ROOT_ADDRESS_CELLS , -GUEST_ROOT_SIZE_CELLS , d->arch.vpl011.base_addr, -GUEST_PL011_SIZE ); - - res =fdt_property (fdt,"reg" , reg,sizeof (reg)); -if ( res ) -return res; - -set_interrupt (intr, d->arch.vpl011.virq,0xf ,DT_IRQ_TYPE_LEVEL_HIGH ); - - res =fdt_property (fdt,"interrupts" , intr,sizeof (intr)); -if ( res ) -return res; - - res =fdt_property_cell (fdt,"interrupt-parent" , - kinfo->phandle_intc); -if ( res ) -return res; - -/* Use a default baud rate of 115200. */ -fdt_property_u32 (fdt,"current-speed" ,115200 ); - - res =fdt_end_node (fdt); -if ( res ) -return res; - -return 0 ; -} -#endif -int __init make_arch_nodes (struct kernel_info *kinfo) {int ret;
@@ -227,7 +179,7 @@ int __init make_arch_nodes(struct kernel_info *kinfo)if ( kinfo->arch.vpl011 ) {#ifdef CONFIG_HAS_VUART_PL011 - ret =make_vpl011_uart_node (kinfo); + ret =vuart_add_fwnode (kinfo->d, kinfo);#endif if ( ret )return -EINVAL ;
xen/arch/arm/vpl011.c +52 -0
73 lines not on this page · raw message
xen/include/xen/vuart.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef XEN_VUART_H +#define XEN_VUART_H + +#ifdef CONFIG_HAS_VUART_PL011 +int __init vuart_add_fwnode (struct domain *d,void *node); +#else +static inline int __init vuart_add_fwnode (struct domain *d,void *node) +{ +return 0 ; +} +#endif + +#endif /* XEN_VUART_H */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
2.34.1
Re: [PATCH v1 02/16] arm/vpl011: move DT node parsing to PL011 emulator code
Quoted 3 lines · On 24/06/2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Move vpl011 DT node parsing from common Arm code to PL011 emulator code.
It's not parsing, it's DT node generation.
We usually keep all the DT node generation functions in one place. I'm not sure if we want to move them to respective drivers (i.e. vpl011 to vpl011.c, gicv3 to gicv3.c, etc.). Not sure what other maintainers think.
Quoted 2 lines
While doing it pick the generic name
vuart_add_fwnode()for DT parser function
What 'fw' stands for? Firmware? This function creates DT node for domU, so it should better be sth like vuart_add_dt_node().
~Michal
Re: [PATCH v1 02/16] arm/vpl011: move DT node parsing to PL011 emulator code
Quoted 7 lines · Michal
Quoted 3 lines · On 24/06/2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Move vpl011 DT node parsing from common Arm code to PL011 emulator code.
It's not parsing, it's DT node generation.
Oh, that's right, overlooked.
Thanks, will update.
Quoted 9 lines
We usually keep all the DT node generation functions in one place. I'm not sure if we want to move them to respective drivers (i.e. vpl011 to
vpl011.c, gicv3 togicv3.c, etc.). Not sure what other maintainers think.Quoted 2 lines
While doing it pick the generic name
vuart_add_fwnode()for DT parser functionWhat 'fw' stands for? Firmware? This function creates DT node for domU, so it should better be sth like
vuart_add_dt_node().
'fw' stands for 'firmware'.
It should be some generic name because the function will be used on x86 to generate to generate the guest ACPI tables.
Quoted 4 lines
~Michal
Re: [PATCH v1 02/16] arm/vpl011: move DT node parsing to PL011 emulator code
Quoted 18 lines · On 24/06/2025 23:56, [email protected] wrote:
Quoted 7 lines · Michal
Quoted 3 lines · On 24/06/2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Move vpl011 DT node parsing from common Arm code to PL011 emulator code.
It's not parsing, it's DT node generation.
Oh, that's right, overlooked.
Thanks, will update.Quoted 6 lines
We usually keep all the DT node generation functions in one place. I'm not sure if we want to move them to respective drivers (i.e. vpl011 to
vpl011.c, gicv3 togicv3.c, etc.). Not sure what other maintainers think.Quoted 1 line
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
While doing it pick the generic name
vuart_add_fwnode()for DT parser functionWhat 'fw' stands for? Firmware? This function creates DT node for domU, so it should better be sth like
vuart_add_dt_node().'fw' stands for 'firmware'.
It should be some generic name because the function will be used on x86 to generate to generate the guest ACPI tables.
I see but maybe vuart_add_node() would be a better choice here.
~Michal
Re: [PATCH v1 02/16] arm/vpl011: move DT node parsing to PL011 emulator code
Quoted 22 lines · Michal
Quoted 19 lines · On 24/06/2025 23:56, [email protected] wrote:
Quoted 7 lines · Michal
Quoted 3 lines · On 24/06/2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Move vpl011 DT node parsing from common Arm code to PL011 emulator code.
It's not parsing, it's DT node generation.
Oh, that's right, overlooked.
Thanks, will update.Quoted 7 lines
We usually keep all the DT node generation functions in one place. I'm not sure if we want to move them to respective drivers (i.e. vpl011 to
vpl011.c, gicv3 togicv3.c, etc.). Not sure what other maintainers think.Quoted 2 lines
While doing it pick the generic name
vuart_add_fwnode()for DT parser function
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
What 'fw' stands for? Firmware? This function creates DT node for domU, so it should better be sth like
vuart_add_dt_node().'fw' stands for 'firmware'.
It should be some generic name because the function will be used on x86 to generate to generate the guest ACPI tables.
I see but maybe
vuart_add_node()would be a better choice here.
Ack.
Quoted 3 lines
~Michal
PATCH 3/16 arm/vpl011: use vuart_ prefix in vpl011 public calls
In reply to [email protected]From: Denis Mukhin <[email protected]>
Use generic names prefixed with 'vuart_' in public PL011 emulator data structures and functions.
No functional change intended.
--- xen/arch/arm/dom0less-build.c | 4 ++-- xen/arch/arm/domain.c | 3 ++- xen/arch/arm/domctl.c | 14 +++++++------ xen/arch/arm/include/asm/vpl011.h | 20 ------------------ xen/arch/arm/vpl011.c | 24 +++++++++++----------- xen/drivers/char/console.c | 6 ++---- xen/include/xen/vuart.h | 34 ++++++++++++++++++++++++++++++- 7 files changed, 59 insertions(+), 46 deletions(-)
xen/arch/arm/dom0less-build.c +2 -2
@@ -216,7 +216,7 @@ int __init init_vuart(struct domain *d, struct kernel_info *kinfo,*/ if ( kinfo->arch.vpl011 ) { - rc =domain_vpl011_init (d,NULL ); + rc =vuart_init (d,NULL );if ( rc <0 )return rc; }
@@ -247,7 +247,7 @@ void __init arch_create_domUs(struct dt_device_node *node,* d->arch.vpl011.irq. So the logic to find the vIRQ has to * be hardcoded. * The logic here shall be consistent with the one in -* domain_vpl011_init(). +* vuart_init(). */ if ( flags & CDF_directmap ) {
xen/arch/arm/domain.c +2 -1
@@ -11,6 +11,7 @@#include <xen/sched.h> #include <xen/softirq.h> #include <xen/wait.h> +#include <xen/vuart.h> #include <asm/arm64/sve.h> #include <asm/cpuerrata.h>
@@ -1072,7 +1073,7 @@ int domain_relinquish_resources(struct domain *d)* Release the resources allocated for vpl011 which were * allocated via a DOMCTL call XEN_DOMCTL_vuart_op. */ -domain_vpl011_deinit (d); +vuart_exit (d);#ifdef CONFIG_IOREQ_SERVER ioreq_server_destroy_all (d);
xen/arch/arm/domctl.c +8 -6
@@ -14,6 +14,7 @@#include <xen/mm.h> #include <xen/sched.h> #include <xen/types.h> +#include <xen/vuart.h> #include <xsm/xsm.h> #include <public/domctl.h>
@@ -30,10 +31,11 @@ static int handle_vuart_init(struct domain *d, struct xen_domctl_vuart_op *vuart_op) {int rc; -struct vpl011_init_info info; - - info.console_domid = vuart_op->console_domid; - info.gfn =_gfn (vuart_op->gfn); +struct vuart_params params = { + .console_domid = vuart_op->console_domid, + .gfn =_gfn (vuart_op->gfn), + .evtchn =0 , + };if ( d->creation_finished )return -EPERM ;
@@ -41,10 +43,10 @@ static int handle_vuart_init(struct domain *d,if ( vuart_op->type !=XEN_DOMCTL_VUART_TYPE_VPL011 )return -EOPNOTSUPP ; - rc =domain_vpl011_init (d, &info); + rc =vuart_init (d, ¶ms);if ( !rc ) - vuart_op->evtchn = info.evtchn; + vuart_op->evtchn = params.evtchn;return rc; }
xen/arch/arm/include/asm/vpl011.h +0 -20
@@ -59,26 +59,6 @@ struct vpl011 { evtchn_port_t evtchn; }; -struct vpl011_init_info { -domid_t console_domid; -gfn_t gfn; -evtchn_port_t evtchn; -}; - -#ifdef CONFIG_HAS_VUART_PL011 -int domain_vpl011_init (struct domain *d, -struct vpl011_init_info *info); -void domain_vpl011_deinit (struct domain *d); -int vpl011_rx_char_xen (struct domain *d,char c); -#else -static inline int domain_vpl011_init (struct domain *d, -struct vpl011_init_info *info) -{ -return -ENOSYS ; -} - -static inline void domain_vpl011_deinit (struct domain *d) { } -#endif #endif /* _VPL011_H_ */ /*
xen/arch/arm/vpl011.c +12 -12
@@ -134,7 +134,7 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t data)/* * vpl011_read_data_xen reads data when the backend is xen. Characters -* are added to the vpl011 receive buffer by vpl011_rx_char_xen. +* are added to the vpl011 receive buffer by vuart_putchar. */ static uint8_t vpl011_read_data_xen (struct domain *d) {
@@ -571,9 +571,9 @@ static void vpl011_data_avail(struct domain *d, }/* -* vpl011_rx_char_xen adds a char to a domain's vpl011 receive buffer. +* vuart_putchar adds a char to a domain's vpl011 receive buffer. */ -int vpl011_rx_char_xen (struct domain *d,char c) +int vuart_putchar (struct domain *d,char c) {unsigned long flags;struct vpl011 *vpl011 = &d->arch.vpl011;
@@ -642,7 +642,7 @@ static void vpl011_notification(struct vcpu *v, unsigned int port)VPL011_UNLOCK (d, flags); } -int domain_vpl011_init (struct domain *d,struct vpl011_init_info *info) +int vuart_init (struct domain *d,struct vuart_params *params) {int rc;struct vpl011 *vpl011 = &d->arch.vpl011;
@@ -694,27 +694,27 @@ int domain_vpl011_init(struct domain *d, struct vpl011_init_info *info) }/* -* info is NULL when the backend is in Xen. -* info is != NULL when the backend is in a domain. +* params is NULL when the backend is in Xen. +* params is != NULL when the backend is in a domain. */ -if ( info !=NULL ) +if ( params !=NULL ) { vpl011->backend_in_domain = true;/* Map the guest PFN to Xen address space. */ rc =prepare_ring_for_helper (d, -gfn_x (info->gfn), +gfn_x (params->gfn), &vpl011->backend.dom.ring_page, &vpl011->backend.dom.ring_buf);if ( rc <0 ) goto out; - rc =alloc_unbound_xen_event_channel (d,0 , info->console_domid, + rc =alloc_unbound_xen_event_channel (d,0 , params->console_domid, vpl011_notification);if ( rc <0 ) goto out1; - vpl011->evtchn = info->evtchn = rc; + vpl011->evtchn = params->evtchn = rc; }else {
@@ -746,13 +746,13 @@ int domain_vpl011_init(struct domain *d, struct vpl011_init_info *info)return 0 ; out1: -domain_vpl011_deinit (d); +vuart_exit (d); out:return rc; } -void domain_vpl011_deinit (struct domain *d) +void vuart_exit (struct domain *d) {struct vpl011 *vpl011 = &d->arch.vpl011;
xen/drivers/char/console.c +2 -4
@@ -33,13 +33,11 @@#include <asm/setup.h> #include <xen/sections.h> #include <xen/consoled.h> +#include <xen/vuart.h> #ifdef CONFIG_X86 #include <asm/guest.h> #endif -#ifdef CONFIG_HAS_VUART_PL011 -#include <asm/vpl011.h> -#endif /* Internal console flags. */ enum {
@@ -609,7 +607,7 @@ static void __serial_rx(char c)#ifdef CONFIG_HAS_VUART_PL011 else/* Deliver input to the emulated UART. */ - rc =vpl011_rx_char_xen (d, c); + rc =vuart_putchar (d, c);#endif if (consoled_is_enabled () )
xen/include/xen/vuart.h +33 -1
@@ -2,14 +2,46 @@#ifndef XEN_VUART_H #define XEN_VUART_H +#include <public/xen.h> +#include <public/event_channel.h> +#include <xen/types.h> + +struct vuart_params { +domid_t console_domid; +gfn_t gfn; +evtchn_port_t evtchn; +}; +#ifdef CONFIG_HAS_VUART_PL011 +int __init vuart_add_fwnode (struct domain *d,void *node); +int vuart_init (struct domain *d,struct vuart_params *params); +void vuart_exit (struct domain *d); +int vuart_putchar (struct domain *d,char c); +#else +static inline int __init vuart_add_fwnode (struct domain *d,void *node) {return 0 ; } -#endif + +static inline int vuart_init (struct domain *d,struct vuart_params *params) +{ +return 0 ; +} + +static inline void vuart_exit (struct domain *d) +{ +} + +static inline int vuart_putchar (struct domain *d,char c) +{ +ASSERT_UNREACHABLE (); +return -ENODEV ; +} + +#endif /* CONFIG_HAS_VUART_PL011 */ #endif /* XEN_VUART_H */
Signature · 1 line
2.34.1
Re: [PATCH v1 03/16] arm/vpl011: use vuart_ prefix in vpl011 public calls
xen/arch/arm/dom0less-build.c int __init init_vuart(struct domain *d, struct kernel_info *kinfo,
Quoted 23 lines · On 24/06/2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Use generic names prefixed with '
vuart_' in public PL011 emulator data structures and functions.No functional change intended.
Signed-off-by Denis Mukhin <[email protected]>--- xen/arch/arm/dom0less-build.c | 4 ++-- xen/arch/arm/domain.c | 3 ++- xen/arch/arm/domctl.c | 14 +++++++------ xen/arch/arm/include/asm/vpl011.h | 20 ------------------ xen/arch/arm/vpl011.c | 24 +++++++++++----------- xen/drivers/char/console.c | 6 ++---- xen/include/xen/vuart.h | 34 ++++++++++++++++++++++++++++++- 7 files changed, 59 insertions(+), 46 deletions(-)xen/arch/arm/dom0less-build.c +0
-0@@ -216,7 +216,7 @@ int __init init_vuart(struct domain *d, struct kernel_info *kinfo,
As can be seen here ...
xen/arch/arm/dom0less-build.c int __init init_vuart(struct domain *d, struct kernel_info *kinfo, · line 219
Quoted 5 lines
xen/arch/arm/dom0less-build.c +1
-1*/ if ( kinfo->arch.vpl011 ) { - rc =domain_vpl011_init (d,NULL ); + rc =vuart_init (d,NULL );
we end up with init_vuart() and vuart_init(). That's quite confusing. Maybe domain_vuart_init() or alike?
Quoted 25 lines
xen/arch/arm/dom0less-build.c +1
-1if ( rc <0 )return rc; }@@ -247,7 +247,7 @@ void __init arch_create_domUs(struct dt_device_node *node,* d->arch.vpl011.irq. So the logic to find the vIRQ has to * be hardcoded. * The logic here shall be consistent with the one in -* domain_vpl011_init(). +* vuart_init(). */ if ( flags & CDF_directmap ) {xen/arch/arm/domain.c +1
-0@@ -11,6 +11,7 @@#include <xen/sched.h> #include <xen/softirq.h> #include <xen/wait.h> +#include <xen/vuart.h> #include <asm/arm64/sve.h> #include <asm/cpuerrata.h>
xen/arch/arm/domain.c int domain_relinquish_resources(struct domain *d) · line 1076
Quoted 5 lines
xen/arch/arm/domain.c +1
-1@@ -1072,7 +1073,7 @@ int domain_relinquish_resources(struct domain *d)* Release the resources allocated for vpl011 which were * allocated via a DOMCTL call XEN_DOMCTL_vuart_op. */ -domain_vpl011_deinit (d); +vuart_exit (d);
IMO, deinit is more meaningful here.
Quoted 89 lines
xen/arch/arm/domain.c +0
-0#ifdef CONFIG_IOREQ_SERVER ioreq_server_destroy_all (d);xen/arch/arm/domctl.c +8
-6@@ -14,6 +14,7 @@#include <xen/mm.h> #include <xen/sched.h> #include <xen/types.h> +#include <xen/vuart.h> #include <xsm/xsm.h> #include <public/domctl.h> @@ -30,10 +31,11 @@ static int handle_vuart_init(struct domain *d, struct xen_domctl_vuart_op *vuart_op) {int rc; -struct vpl011_init_info info; - - info.console_domid = vuart_op->console_domid; - info.gfn =_gfn (vuart_op->gfn); +struct vuart_params params = { + .console_domid = vuart_op->console_domid, + .gfn =_gfn (vuart_op->gfn), + .evtchn =0 , + };if ( d->creation_finished )return -EPERM ;@@ -41,10 +43,10 @@ static int handle_vuart_init(struct domain *d,if ( vuart_op->type !=XEN_DOMCTL_VUART_TYPE_VPL011 )return -EOPNOTSUPP ; - rc =domain_vpl011_init (d, &info); + rc =vuart_init (d, ¶ms);if ( !rc ) - vuart_op->evtchn = info.evtchn; + vuart_op->evtchn = params.evtchn;return rc; }xen/arch/arm/include/asm/vpl011.h +0
-20@@ -59,26 +59,6 @@ struct vpl011 { evtchn_port_t evtchn; }; -struct vpl011_init_info { -domid_t console_domid; -gfn_t gfn; -evtchn_port_t evtchn; -}; - -#ifdef CONFIG_HAS_VUART_PL011 -int domain_vpl011_init (struct domain *d, -struct vpl011_init_info *info); -void domain_vpl011_deinit (struct domain *d); -int vpl011_rx_char_xen (struct domain *d,char c); -#else -static inline int domain_vpl011_init (struct domain *d, -struct vpl011_init_info *info) -{ -return -ENOSYS ; -} - -static inline void domain_vpl011_deinit (struct domain *d) { } -#endif #endif /* _VPL011_H_ */ /* xen/arch/arm/vpl011.c +1
-1@@ -134,7 +134,7 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t data)/* * vpl011_read_data_xen reads data when the backend is xen. Characters -* are added to the vpl011 receive buffer by vpl011_rx_char_xen. +* are added to the vpl011 receive buffer by vuart_putchar. */ static uint8_t vpl011_read_data_xen (struct domain *d) {
xen/arch/arm/vpl011.c static void vpl011_data_avail(struct domain *d, · line 576
Quoted 8 lines
xen/arch/arm/vpl011.c +2
-2@@ -571,9 +571,9 @@ static void vpl011_data_avail(struct domain *d, }/* -* vpl011_rx_char_xen adds a char to a domain's vpl011 receive buffer. +* vuart_putchar adds a char to a domain's vpl011 receive buffer. */ -int vpl011_rx_char_xen (struct domain *d,char c) +int vuart_putchar (struct domain *d,char c)
How can putchar refer to RX? By definition putchar() is used to print data to STDOUT. Here we receive a character and put it in the RX FIFO.
~Michal
Re: [PATCH v1 03/16] arm/vpl011: use vuart_ prefix in vpl011 public calls
Quoted 28 lines · Michal
xen/arch/arm/dom0less-build.c int __init init_vuart(struct domain *d, struct kernel_info *kinfo,
Quoted 23 lines · On 24/06/2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Use generic names prefixed with '
vuart_' in public PL011 emulator data structures and functions.No functional change intended.
Signed-off-by Denis Mukhin <[email protected]>--- xen/arch/arm/dom0less-build.c | 4 ++-- xen/arch/arm/domain.c | 3 ++- xen/arch/arm/domctl.c | 14 +++++++------ xen/arch/arm/include/asm/vpl011.h | 20 ------------------ xen/arch/arm/vpl011.c | 24 +++++++++++----------- xen/drivers/char/console.c | 6 ++---- xen/include/xen/vuart.h | 34 ++++++++++++++++++++++++++++++- 7 files changed, 59 insertions(+), 46 deletions(-)xen/arch/arm/dom0less-build.c +0
-0@@ -216,7 +216,7 @@ int __init init_vuart(struct domain *d, struct kernel_info *kinfo,As can be seen here ...
Quoted 7 lines
xen/arch/arm/dom0less-build.c int __init init_vuart(struct domain *d, struct kernel_info *kinfo, · line 219
Quoted 5 lines
xen/arch/arm/dom0less-build.c +1
-1*/ if ( kinfo->arch.vpl011 ) { - rc =domain_vpl011_init (d,NULL ); + rc =vuart_init (d,NULL );we end up with
init_vuart()andvuart_init(). That's quite confusing. Maybedomain_vuart_init()or alike?
That's right!
But domain_vuart_init() is used by MMIO-based variant :)
I will write an extra patch and put it to the end of the series to update the name here.
Quoted 23 lines
Quoted 23 lines
xen/arch/arm/dom0less-build.c +1
-1if ( rc <0 )return rc; }@@ -247,7 +247,7 @@ void __init arch_create_domUs(struct dt_device_node *node,* d->arch.vpl011.irq. So the logic to find the vIRQ has to * be hardcoded. * The logic here shall be consistent with the one in -* domain_vpl011_init(). +* vuart_init(). */ if ( flags & CDF_directmap ) {xen/arch/arm/domain.c +1
-0@@ -11,6 +11,7 @@#include <xen/sched.h> #include <xen/softirq.h> #include <xen/wait.h> +#include <xen/vuart.h>
Quoted 9 lines
xen/arch/arm/domain.c int domain_relinquish_resources(struct domain *d) · line 1076
Quoted 8 lines
xen/arch/arm/domain.c +1
-1#include <asm/arm64/sve.h> #include <asm/cpuerrata.h> @@ -1072,7 +1073,7 @@ int domain_relinquish_resources(struct domain *d)* Release the resources allocated for vpl011 which were * allocated via a DOMCTL call XEN_DOMCTL_vuart_op. */ -domain_vpl011_deinit (d); +vuart_exit (d);IMO, deinit is more meaningful here.
Yeah, it's just MMIO UART uses init/free, here it is init/deinit.
So I just picked init/exit similar to module_{init,exit} in Linux driver model and applied to all existing vUARTs.
Can update all vUARTs to deinit()
Quoted 92 lines
Quoted 92 lines
xen/arch/arm/domain.c +0
-0#ifdef CONFIG_IOREQ_SERVER ioreq_server_destroy_all (d);xen/arch/arm/domctl.c +8
-6@@ -14,6 +14,7 @@#include <xen/mm.h> #include <xen/sched.h> #include <xen/types.h> +#include <xen/vuart.h> #include <xsm/xsm.h> #include <public/domctl.h> @@ -30,10 +31,11 @@ static int handle_vuart_init(struct domain *d, struct xen_domctl_vuart_op *vuart_op) {int rc; -struct vpl011_init_info info; - - info.console_domid = vuart_op->console_domid; - info.gfn =_gfn (vuart_op->gfn); +struct vuart_params params = { + .console_domid = vuart_op->console_domid, + .gfn =_gfn (vuart_op->gfn), + .evtchn =0 , + };if ( d->creation_finished )return -EPERM ;@@ -41,10 +43,10 @@ static int handle_vuart_init(struct domain *d,if ( vuart_op->type !=XEN_DOMCTL_VUART_TYPE_VPL011 )return -EOPNOTSUPP ; - rc =domain_vpl011_init (d, &info); + rc =vuart_init (d, ¶ms);if ( !rc ) - vuart_op->evtchn = info.evtchn; + vuart_op->evtchn = params.evtchn;return rc; }xen/arch/arm/include/asm/vpl011.h +0
-20@@ -59,26 +59,6 @@ struct vpl011 { evtchn_port_t evtchn; }; -struct vpl011_init_info { -domid_t console_domid; -gfn_t gfn; -evtchn_port_t evtchn; -}; - -#ifdef CONFIG_HAS_VUART_PL011 -int domain_vpl011_init (struct domain *d, -struct vpl011_init_info *info); -void domain_vpl011_deinit (struct domain *d); -int vpl011_rx_char_xen (struct domain *d,char c); -#else -static inline int domain_vpl011_init (struct domain *d, -struct vpl011_init_info *info) -{ -return -ENOSYS ; -} - -static inline void domain_vpl011_deinit (struct domain *d) { } -#endif #endif /* _VPL011_H_ */ /* xen/arch/arm/vpl011.c +1
-1@@ -134,7 +134,7 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t data)/* * vpl011_read_data_xen reads data when the backend is xen. Characters -* are added to the vpl011 receive buffer by vpl011_rx_char_xen. +* are added to the vpl011 receive buffer by vuart_putchar. */ static uint8_t vpl011_read_data_xen (struct domain *d) {@@ -571,9 +571,9 @@ static void vpl011_data_avail(struct domain *d, }
Quoted 8 lines
xen/arch/arm/vpl011.c static void vpl011_data_avail(struct domain *d, · line 576
Quoted 6 lines
xen/arch/arm/vpl011.c +2
-2/* -* vpl011_rx_char_xen adds a char to a domain's vpl011 receive buffer. +* vuart_putchar adds a char to a domain's vpl011 receive buffer. */ -int vpl011_rx_char_xen (struct domain *d,char c) +int vuart_putchar (struct domain *d,char c)How can putchar refer to RX? By definition
putchar()is used to print data to STDOUT. Here we receive a character and put it in the RX FIFO.
That's confusing, I agree; I think this is a leftover from the earlier vUART series.
Will update, thanks!
Quoted 4 lines
~Michal
Re: [PATCH v1 03/16] arm/vpl011: use vuart_ prefix in vpl011 public calls
In reply to Orzel, MichalQuoted 28 lines · Michal
xen/arch/arm/dom0less-build.c int __init init_vuart(struct domain *d, struct kernel_info *kinfo,
Quoted 23 lines · On 24/06/2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Use generic names prefixed with '
vuart_' in public PL011 emulator data structures and functions.No functional change intended.
Signed-off-by Denis Mukhin <[email protected]>--- xen/arch/arm/dom0less-build.c | 4 ++-- xen/arch/arm/domain.c | 3 ++- xen/arch/arm/domctl.c | 14 +++++++------ xen/arch/arm/include/asm/vpl011.h | 20 ------------------ xen/arch/arm/vpl011.c | 24 +++++++++++----------- xen/drivers/char/console.c | 6 ++---- xen/include/xen/vuart.h | 34 ++++++++++++++++++++++++++++++- 7 files changed, 59 insertions(+), 46 deletions(-)xen/arch/arm/dom0less-build.c +0
-0@@ -216,7 +216,7 @@ int __init init_vuart(struct domain *d, struct kernel_info *kinfo,As can be seen here ...
Quoted 7 lines
xen/arch/arm/dom0less-build.c int __init init_vuart(struct domain *d, struct kernel_info *kinfo, · line 219
Quoted 5 lines
xen/arch/arm/dom0less-build.c +1
-1*/ if ( kinfo->arch.vpl011 ) { - rc =domain_vpl011_init (d,NULL ); + rc =vuart_init (d,NULL );we end up with
init_vuart()andvuart_init(). That's quite confusing. Maybedomain_vuart_init()or alike?
Agreed, will update.
Quoted 23 lines
Quoted 23 lines
xen/arch/arm/dom0less-build.c +1
-1if ( rc <0 )return rc; }@@ -247,7 +247,7 @@ void __init arch_create_domUs(struct dt_device_node *node,* d->arch.vpl011.irq. So the logic to find the vIRQ has to * be hardcoded. * The logic here shall be consistent with the one in -* domain_vpl011_init(). +* vuart_init(). */ if ( flags & CDF_directmap ) {xen/arch/arm/domain.c +1
-0@@ -11,6 +11,7 @@#include <xen/sched.h> #include <xen/softirq.h> #include <xen/wait.h> +#include <xen/vuart.h>
Quoted 9 lines
xen/arch/arm/domain.c int domain_relinquish_resources(struct domain *d) · line 1076
Quoted 8 lines
xen/arch/arm/domain.c +1
-1#include <asm/arm64/sve.h> #include <asm/cpuerrata.h> @@ -1072,7 +1073,7 @@ int domain_relinquish_resources(struct domain *d)* Release the resources allocated for vpl011 which were * allocated via a DOMCTL call XEN_DOMCTL_vuart_op. */ -domain_vpl011_deinit (d); +vuart_exit (d);IMO, deinit is more meaningful here.
Ack
Quoted 92 lines
Quoted 92 lines
xen/arch/arm/domain.c +0
-0#ifdef CONFIG_IOREQ_SERVER ioreq_server_destroy_all (d);xen/arch/arm/domctl.c +8
-6@@ -14,6 +14,7 @@#include <xen/mm.h> #include <xen/sched.h> #include <xen/types.h> +#include <xen/vuart.h> #include <xsm/xsm.h> #include <public/domctl.h> @@ -30,10 +31,11 @@ static int handle_vuart_init(struct domain *d, struct xen_domctl_vuart_op *vuart_op) {int rc; -struct vpl011_init_info info; - - info.console_domid = vuart_op->console_domid; - info.gfn =_gfn (vuart_op->gfn); +struct vuart_params params = { + .console_domid = vuart_op->console_domid, + .gfn =_gfn (vuart_op->gfn), + .evtchn =0 , + };if ( d->creation_finished )return -EPERM ;@@ -41,10 +43,10 @@ static int handle_vuart_init(struct domain *d,if ( vuart_op->type !=XEN_DOMCTL_VUART_TYPE_VPL011 )return -EOPNOTSUPP ; - rc =domain_vpl011_init (d, &info); + rc =vuart_init (d, ¶ms);if ( !rc ) - vuart_op->evtchn = info.evtchn; + vuart_op->evtchn = params.evtchn;return rc; }xen/arch/arm/include/asm/vpl011.h +0
-20@@ -59,26 +59,6 @@ struct vpl011 { evtchn_port_t evtchn; }; -struct vpl011_init_info { -domid_t console_domid; -gfn_t gfn; -evtchn_port_t evtchn; -}; - -#ifdef CONFIG_HAS_VUART_PL011 -int domain_vpl011_init (struct domain *d, -struct vpl011_init_info *info); -void domain_vpl011_deinit (struct domain *d); -int vpl011_rx_char_xen (struct domain *d,char c); -#else -static inline int domain_vpl011_init (struct domain *d, -struct vpl011_init_info *info) -{ -return -ENOSYS ; -} - -static inline void domain_vpl011_deinit (struct domain *d) { } -#endif #endif /* _VPL011_H_ */ /* xen/arch/arm/vpl011.c +1
-1@@ -134,7 +134,7 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t data)/* * vpl011_read_data_xen reads data when the backend is xen. Characters -* are added to the vpl011 receive buffer by vpl011_rx_char_xen. +* are added to the vpl011 receive buffer by vuart_putchar. */ static uint8_t vpl011_read_data_xen (struct domain *d) {@@ -571,9 +571,9 @@ static void vpl011_data_avail(struct domain *d, }
Quoted 8 lines
xen/arch/arm/vpl011.c static void vpl011_data_avail(struct domain *d, · line 576
Quoted 6 lines
xen/arch/arm/vpl011.c +2
-2/* -* vpl011_rx_char_xen adds a char to a domain's vpl011 receive buffer. +* vuart_putchar adds a char to a domain's vpl011 receive buffer. */ -int vpl011_rx_char_xen (struct domain *d,char c) +int vuart_putchar (struct domain *d,char c)How can putchar refer to RX? By definition
putchar()is used to print data to STDOUT. Here we receive a character and put it in the RX FIFO.
Yeah, that may be confusing.
I will use vuart_put_rx().
Quoted 4 lines
~Michal
PATCH 4/16 arm/vpl011: use raw spin_lock_{irqrestore,irqsave}
In reply to [email protected]From: Denis Mukhin <[email protected]>
Replace VPL011_{LOCK,UNLOCK} macros with raw spinlock calls to improve readability.
No functional change.
--- xen/arch/arm/include/asm/vpl011.h | 4 --- xen/arch/arm/vpl011.c | 50 +++++++++++++++---------------- 2 files changed, 25 insertions(+), 29 deletions(-)
xen/arch/arm/include/asm/vpl011.h +0 -4
@@ -24,10 +24,6 @@#include <public/io/console.h> #include <xen/mm.h> -/* helper macros */ -#define VPL011_LOCK (d,flags) spin_lock_irqsave(&(d)->arch.vpl011.lock, flags) -#define VPL011_UNLOCK (d,flags) spin_unlock_irqrestore(&(d)->arch.vpl011.lock, flags) -#define SBSA_UART_FIFO_SIZE 32/* Same size as VUART_BUF_SIZE, used in vuart.c */ #define SBSA_UART_OUT_BUF_SIZE 128
xen/arch/arm/vpl011.c +25 -25
168 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v1 04/16] arm/vpl011: use raw spin_lock_{irqrestore,irqsave}
Quoted 4 lines · On 24.06.2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Replace VPL011_{LOCK,UNLOCK} macros with raw spinlock calls to improve readability.
I'm not an Arm maintainer, so I have limited say here, but: How is this improving readability? It better utilizes available local variables, yes, so this may be a little bit of an optimization, but otherwise to me this looks to rather hamper readability.
Jan
Re: [PATCH v1 04/16] arm/vpl011: use raw spin_lock_{irqrestore,irqsave}
Quoted 10 lines · Jan Beulich
Quoted 4 lines · On 24.06.2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Replace VPL011_{LOCK,UNLOCK} macros with raw spinlock calls to improve readability.
I'm not an Arm maintainer, so I have limited say here, but: How is this improving readability? It better utilizes available local variables, yes, so this may be a little bit of an optimization, but otherwise to me this looks to rather hamper readability.
I agree with Jan here. I don't think it improves readability, therefore I don't think such change is needed.
~Michal
Re: [PATCH v1 04/16] arm/vpl011: use raw spin_lock_{irqrestore,irqsave}
Quoted 9 lines · Michal
Quoted 6 lines · Jan Beulich
Quoted 4 lines · On 24.06.2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Replace VPL011_{LOCK,UNLOCK} macros with raw spinlock calls to improve readability.
Quoted 6 lines
Quoted 4 lines
I'm not an Arm maintainer, so I have limited say here, but: How is this improving readability? It better utilizes available local variables, yes, so this may be a little bit of an optimization, but otherwise to me this looks to rather hamper readability.
I agree with Jan here. I don't think it improves readability, therefore I don't think such change is needed.
I think exdanding macros helps to understand the code since is explicitly shows what kind of locking *really* used, so this aspect is actually getting more readable; yes, that's a bit of more text.
But, MMIO-based flavor does not define such helpers for example, so now vUARTs follow similar coding pattern which is easy to read/follow.
Quoted 3 lines
~Michal
Re: [PATCH v1 04/16] arm/vpl011: use raw spin_lock_{irqrestore,irqsave}
Quoted 17 lines · On 24/06/2025 23:46, [email protected] wrote:
Quoted 9 lines · Michal
Quoted 6 lines · Jan Beulich
Quoted 4 lines · On 24.06.2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Replace VPL011_{LOCK,UNLOCK} macros with raw spinlock calls to improve readability.
Quoted 6 lines
Quoted 4 lines
I'm not an Arm maintainer, so I have limited say here, but: How is this improving readability? It better utilizes available local variables, yes, so this may be a little bit of an optimization, but otherwise to me this looks to rather hamper readability.
I agree with Jan here. I don't think it improves readability, therefore I don't think such change is needed.
Quoted 6 lines
I think exdanding macros helps to understand the code since is explicitly shows what kind of locking *really* used, so this aspect is actually getting more readable; yes, that's a bit of more text.
But, MMIO-based flavor does not define such helpers for example, so now vUARTs follow similar coding pattern which is easy to read/follow.
I understand your point of view. It's more like a matter of taste here, so I won't oppose to it. Others may chime in.
~Michal
Re: [PATCH v1 04/16] arm/vpl011: use raw spin_lock_{irqrestore,irqsave}
Quoted 20 lines · Michal
Quoted 17 lines · On 24/06/2025 23:46, [email protected] wrote:
Quoted 15 lines · Michal
Quoted 10 lines · Jan Beulich
Quoted 4 lines · On 24.06.2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Replace VPL011_{LOCK,UNLOCK} macros with raw spinlock calls to improve readability.
I'm not an Arm maintainer, so I have limited say here, but: How is this improving readability? It better utilizes available local variables, yes, so this may be a little bit of an optimization, but otherwise to me this looks to rather hamper readability.
I agree with Jan here. I don't think it improves readability, therefore I don't think such change is needed.
Quoted 8 lines
Quoted 6 lines
I think exdanding macros helps to understand the code since is explicitly shows what kind of locking *really* used, so this aspect is actually getting more readable; yes, that's a bit of more text.
But, MMIO-based flavor does not define such helpers for example, so now vUARTs follow similar coding pattern which is easy to read/follow.
I understand your point of view. It's more like a matter of taste here, so I won't oppose to it. Others may chime in.
Thank you.
Quoted 3 lines
~Michal
PATCH 5/16 arm/vpl011: use void pointer in domain struct
In reply to [email protected]From: Denis Mukhin <[email protected]>
Switch to using void pointer in domain struct to reduce compile-time dependencies for PL011 emulator.
--- xen/arch/arm/include/asm/domain.h | 3 +- xen/arch/arm/vpl011.c | 139 +++++++++++++++++------------- 2 files changed, 79 insertions(+), 63 deletions(-)
xen/arch/arm/include/asm/domain.h +1 -2
@@ -9,7 +9,6 @@#include <asm/mmio.h> #include <asm/gic.h> #include <asm/vgic.h> -#include <asm/vpl011.h> #include <public/hvm/params.h> struct hvm_domain
@@ -114,7 +113,7 @@ struct arch_domain } monitor;#ifdef CONFIG_HAS_VUART_PL011 -struct vpl011 vpl011; +void *vpl011;#endif #ifdef CONFIG_TEE
xen/arch/arm/vpl011.c +78 -61
289 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v1 05/16] arm/vpl011: use void pointer in domain struct
Quoted 4 lines · On 24/06/2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Switch to using void pointer in domain struct to reduce compile-time dependencies for PL011 emulator.
I don't understand the rationale very well. Could you provide more details? Why can't we keep struct vpl011 in domain struct given? I would understand the need for void if we used a single member that could map to different vUARTs depending on selection. That's clearly not the case. If it is just to avoid the header, then I don't think we need such churn.
Quoted 41 lines
Signed-off-by Denis Mukhin <[email protected]>--- xen/arch/arm/include/asm/domain.h | 3 +- xen/arch/arm/vpl011.c | 139 +++++++++++++++++------------- 2 files changed, 79 insertions(+), 63 deletions(-)xen/arch/arm/include/asm/domain.h +1
-2@@ -9,7 +9,6 @@#include <asm/mmio.h> #include <asm/gic.h> #include <asm/vgic.h> -#include <asm/vpl011.h> #include <public/hvm/params.h> struct hvm_domain @@ -114,7 +113,7 @@ struct arch_domain } monitor;#ifdef CONFIG_HAS_VUART_PL011 -struct vpl011 vpl011; +void *vpl011;#endif #ifdef CONFIG_TEE xen/arch/arm/vpl011.c +1
-0@@ -22,6 +22,7 @@#include <xen/console.h> #include <xen/serial.h> #include <xen/vuart.h> +#include <xen/xvmalloc.h> #include <public/domctl.h> #include <public/io/console.h> #include <asm/domain_build.h>
xen/arch/arm/vpl011.c line 35
Quoted 4 lines
xen/arch/arm/vpl011.c +1
-0@@ -31,6 +32,43 @@#include <asm/vpl011.h> #include <asm/vreg.h> +static void __vpl011_exit(struct vpl011 *vpl011, struct domain *d
Names starting with '__' are reserved and forbidden by MISRA C rule that AFAIR we accepted (don't remember what rule exactly).
Quoted 211 lines
xen/arch/arm/vpl011.c +62
-23+{ +if ( vpl011->virq ) + { +vgic_free_virq (d, vpl011->virq); + +/* +* Set to invalid irq (we use SPI) to prevent extra free and to avoid +* freeing irq that could have already been reserved by someone else. +*/ + vpl011->virq =0 ; + } + +if ( vpl011->backend_in_domain ) + { +if ( vpl011->backend.dom.ring_buf ) +destroy_ring_for_helper (&vpl011->backend.dom.ring_buf, + vpl011->backend.dom.ring_page); + +if ( vpl011->evtchn ) + { +free_xen_event_channel (d, vpl011->evtchn); + +/* +* Set to invalid event channel port to prevent extra free and to +* avoid freeing port that could have already been allocated for +* other purposes. +*/ + vpl011->evtchn =0 ; + } + } +else +XFREE (vpl011->backend.xen); + +xfree (vpl011); +} +/* * Since pl011 registers are 32-bit registers, all registers * are handled similarly allowing 8-bit, 16-bit and 32-bit @@ -43,7 +81,7 @@ static bool vpl011_reg32_check_access(struct hsr_dabt dabt)static void vpl011_update_interrupt_status (struct domain *d) { -struct vpl011 *vpl011 = &d->arch.vpl011; +struct vpl011 *vpl011 = d->arch.vpl011;uint32_t uartmis = vpl011->uartris & vpl011->uartimsc;/* @@ -81,7 +119,7 @@ static void vpl011_update_interrupt_status(struct domain *d)static void vpl011_write_data_xen (struct domain *d,uint8_t data) {unsigned long flags; -struct vpl011 *vpl011 = &d->arch.vpl011; +struct vpl011 *vpl011 = d->arch.vpl011;struct vpl011_xen_backend *intf = vpl011->backend.xen;struct domain *input =console_get_domain ();@@ -140,7 +178,7 @@ static uint8_t vpl011_read_data_xen(struct domain *d) {unsigned long flags;uint8_t data =0 ; -struct vpl011 *vpl011 = &d->arch.vpl011; +struct vpl011 *vpl011 = d->arch.vpl011;struct vpl011_xen_backend *intf = vpl011->backend.xen;XENCONS_RING_IDX in_cons, in_prod;@@ -199,7 +237,7 @@ static uint8_t vpl011_read_data(struct domain *d) {unsigned long flags;uint8_t data =0 ; -struct vpl011 *vpl011 = &d->arch.vpl011; +struct vpl011 *vpl011 = d->arch.vpl011;struct xencons_interface *intf = vpl011->backend.dom.ring_buf;XENCONS_RING_IDX in_cons, in_prod;@@ -284,7 +322,7 @@ static void vpl011_update_tx_fifo_status(struct vpl011 *vpl011,static void vpl011_write_data (struct domain *d,uint8_t data) {unsigned long flags; -struct vpl011 *vpl011 = &d->arch.vpl011; +struct vpl011 *vpl011 = d->arch.vpl011;struct xencons_interface *intf = vpl011->backend.dom.ring_buf;XENCONS_RING_IDX out_cons, out_prod;@@ -350,10 +388,9 @@ static int vpl011_mmio_read(struct vcpu *v, register_t *r, void *priv) { +struct vpl011 *vpl011 = v->domain->arch.vpl011;struct hsr_dabt dabt = info->dabt; -uint32_t vpl011_reg = (uint32_t )(info->gpa - - v->domain->arch.vpl011.base_addr); -struct vpl011 *vpl011 = &v->domain->arch.vpl011; +uint32_t vpl011_reg = (uint32_t )(info->gpa - vpl011->base_addr);struct domain *d = v->domain;unsigned long flags;@@ -439,10 +476,9 @@ static int vpl011_mmio_write(struct vcpu *v,register_t r, void *priv) { + struct vpl011 *vpl011 = v->domain->arch.vpl011;struct hsr_dabt dabt = info->dabt; -uint32_t vpl011_reg = (uint32_t )(info->gpa - - v->domain->arch.vpl011.base_addr); -struct vpl011 *vpl011 = &v->domain->arch.vpl011; +uint32_t vpl011_reg = (uint32_t )(info->gpa - vpl011->base_addr);struct domain *d = v->domain;unsigned long flags;@@ -518,7 +554,7 @@ static void vpl011_data_avail(struct domain *d, XENCONS_RING_IDX out_fifo_level, XENCONS_RING_IDX out_size) { -struct vpl011 *vpl011 = &d->arch.vpl011; +struct vpl011 *vpl011 = d->arch.vpl011;/**** Update the UART RX state ****/ @@ -576,7 +612,7 @@ static void vpl011_data_avail(struct domain *d,int vuart_putchar (struct domain *d,char c) {unsigned long flags; -struct vpl011 *vpl011 = &d->arch.vpl011; +struct vpl011 *vpl011 = d->arch.vpl011;struct vpl011_xen_backend *intf = vpl011->backend.xen;XENCONS_RING_IDX in_cons, in_prod, in_fifo_level;@@ -614,7 +650,7 @@ static void vpl011_notification(struct vcpu *v, unsigned int port) {unsigned long flags;struct domain *d = v->domain; -struct vpl011 *vpl011 = &d->arch.vpl011; +struct vpl011 *vpl011 = d->arch.vpl011;struct xencons_interface *intf = vpl011->backend.dom.ring_buf;XENCONS_RING_IDX in_cons, in_prod, out_cons, out_prod;XENCONS_RING_IDX in_fifo_level, out_fifo_level;@@ -644,11 +680,14 @@ static void vpl011_notification(struct vcpu *v, unsigned int port)int vuart_init (struct domain *d,struct vuart_params *params) { +struct vpl011 *vpl011;int rc; -struct vpl011 *vpl011 = &d->arch.vpl011; -if ( vpl011->backend.dom.ring_buf ) -return -EINVAL ; +BUG_ON (d->arch.vpl011); + + vpl011 =xvzalloc (typeof (*vpl011)); +if ( !vpl011 ) +return -ENOMEM ;/* * The VPL011 virq is GUEST_VPL011_SPI, except for direct-map domains @@ -670,7 +709,8 @@ int vuart_init(struct domain *d, struct vuart_params *params) {printk (XENLOG_ERR "vpl011: Unable to re-use the Xen UART information.\n" ); -return -EINVAL ; + rc = -EINVAL ; + goto err_out; }/* @@ -684,7 +724,8 @@ int vuart_init(struct domain *d, struct vuart_params *params) {printk (XENLOG_ERR "vpl011: Can't re-use the Xen UART MMIO region as it is too small.\n" ); -return -EINVAL ; + rc = -EINVAL ; + goto err_out; } }else @@ -707,12 +748,12 @@ int vuart_init(struct domain *d, struct vuart_params *params) &vpl011->backend.dom.ring_page, &vpl011->backend.dom.ring_buf);if ( rc <0 ) - goto out; + goto err_out; rc =alloc_unbound_xen_event_channel (d,0 , params->console_domid, vpl011_notification);if ( rc <0 ) - goto out1; + goto err_out; vpl011->evtchn = params->evtchn = rc; }@@ -725,7 +766,7 @@ int vuart_init(struct domain *d, struct vuart_params *params)if ( vpl011->backend.xen ==NULL ) { rc = -ENOMEM ; - goto out; + goto err_out; } }@@ -733,7 +774,7 @@ int vuart_init(struct domain *d, struct vuart_params *params)if ( !rc ) { rc = -EINVAL ; - goto out1; + goto err_out; } vpl011->uartfr =TXFE |RXFE ;@@ -743,50 +784,22 @@ int vuart_init(struct domain *d, struct vuart_params *params)register_mmio_handler (d, &vpl011_mmio_handler, vpl011->base_addr,GUEST_PL011_SIZE ,NULL );
xen/arch/arm/vpl011.c int vuart_init(struct domain *d, struct vuart_params *params) · line 791
Quoted 10 lines
xen/arch/arm/vpl011.c +3
-4+ d->arch.vpl011 = vpl011; +return 0 ; -out1: -vuart_exit (d); - -out: +err_out:
Labels should be indented by one space.
~Michal
PATCH 6/16 arm/vpl011: remove vpl011 header file
In reply to [email protected]From: Denis Mukhin <[email protected]>
Make all PL011 emulator declarations private to emulator's code.
No functional change.
--- xen/arch/arm/include/asm/vpl011.h | 67 ------------------------------- xen/arch/arm/vpl011.c | 39 ++++++++++++++++-- 2 files changed, 35 insertions(+), 71 deletions(-) delete mode 100644 xen/arch/arm/include/asm/vpl011.h
xen/arch/arm/include/asm/vpl011.h deleted +0 -67
@@ -1,67 +0,0 @@ -/* -* include/xen/vpl011.h -* -* Virtual PL011 UART -* -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2, as published by the Free Software Foundation. -* -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along with -* this program; If not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef _VPL011_H_ -#define _VPL011_H_ - -#include <public/domctl.h> -#include <public/io/ring.h> -#include <public/io/console.h> -#include <xen/mm.h> - -#define SBSA_UART_FIFO_SIZE 32 -/* Same size as VUART_BUF_SIZE, used in vuart.c */ -#define SBSA_UART_OUT_BUF_SIZE 128 -struct vpl011_xen_backend { -char in[SBSA_UART_FIFO_SIZE ]; -char out[SBSA_UART_OUT_BUF_SIZE ]; -XENCONS_RING_IDX in_cons, in_prod; -XENCONS_RING_IDX out_prod; -}; - -struct vpl011 { -bool backend_in_domain; -union { -struct { -void *ring_buf; -struct page_info *ring_page; - } dom; -struct vpl011_xen_backend *xen; - } backend; -uint32_t uartfr;/* Flag register */ -uint32_t uartcr;/* Control register */ -uint32_t uartimsc;/* Interrupt mask register*/ -uint32_t uarticr;/* Interrupt clear register */ -uint32_t uartris;/* Raw interrupt status register */ -uint32_t shadow_uartmis;/* shadow masked interrupt register */ -paddr_t base_addr; -unsigned int virq; -spinlock_t lock; -evtchn_port_t evtchn; -}; - -#endif /* _VPL011_H_ */ - -/* -* Local variables: -* mode: C -* c-file-style: "BSD" -* c-basic-offset: 4 -* indent-tabs-mode: nil -* End: -*/
xen/arch/arm/vpl011.c +35 -4
@@ -7,9 +7,6 @@#define XEN_WANT_FLEX_CONSOLE_RING 1 -/* We assume the PL011 default of "1/2 way" for the FIFO trigger level. */ -#define SBSA_UART_FIFO_LEVEL (SBSA_UART_FIFO_SIZE / 2) -#include <xen/errno.h> #include <xen/event.h> #include <xen/device_tree.h>
@@ -25,13 +22,47 @@#include <xen/xvmalloc.h> #include <public/domctl.h> #include <public/io/console.h> +#include <public/io/ring.h> #include <asm/domain_build.h> #include <asm/kernel.h> #include <asm/pl011-uart.h> #include <asm/vgic-emul.h> -#include <asm/vpl011.h> #include <asm/vreg.h> +#define SBSA_UART_FIFO_SIZE 32 +/* Same size as VUART_BUF_SIZE, used in simple MMIO-based vUART */ +#define SBSA_UART_OUT_BUF_SIZE 128 +/* We assume the PL011 default of "1/2 way" for the FIFO trigger level. */ +#define SBSA_UART_FIFO_LEVEL (SBSA_UART_FIFO_SIZE / 2) + +struct vpl011_xen_backend { +char in[SBSA_UART_FIFO_SIZE ]; +char out[SBSA_UART_OUT_BUF_SIZE ]; +XENCONS_RING_IDX in_cons, in_prod; +XENCONS_RING_IDX out_prod; +}; + +struct vpl011 { +bool backend_in_domain; +union { +struct { +void *ring_buf; +struct page_info *ring_page; + } dom; +struct vpl011_xen_backend *xen; + } backend; +uint32_t uartfr;/* Flag register */ +uint32_t uartcr;/* Control register */ +uint32_t uartimsc;/* Interrupt mask register*/ +uint32_t uarticr;/* Interrupt clear register */ +uint32_t uartris;/* Raw interrupt status register */ +uint32_t shadow_uartmis;/* shadow masked interrupt register */ +paddr_t base_addr; +unsigned int virq; +spinlock_t lock; +evtchn_port_t evtchn; +}; +static void __vpl011_exit (struct vpl011 *vpl011,struct domain *d) {if ( vpl011->virq )
Signature · 1 line
2.34.1
PATCH 7/16 arm/vuart: rename 'virtual UART' Kconfig option
In reply to [email protected]From: Denis Mukhin <[email protected]>
Rename HWDOM_VUART to HAS_VUART_MMIO.
This emulator emulates only one register and the use of the emulator is limited to early boot console in the guest OS.
No functional change.
--- xen/arch/arm/Kconfig | 2 +- xen/arch/arm/Makefile | 2 +- xen/arch/arm/include/asm/domain.h | 2 +- xen/arch/arm/vuart.h | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-)
xen/arch/arm/Kconfig +1 -1
@@ -177,7 +177,7 @@ config HAS_VUART_PL011 Allows a guest to use SBSA Generic UART as a console. The SBSA Generic UART implements a subset of ARM PL011 UART. -config HWDOM_VUART +config HAS_VUART_MMIO bool "Emulated UART for hardware domain" default y help
xen/arch/arm/Makefile +1 -1
@@ -68,7 +68,7 @@ obj-y += vtimer.o obj-$(CONFIG_HAS_VUART_PL011) += vpl011.o obj-y += vsmc.o obj-y += vpsci.o -obj-$(CONFIG_HWDOM_VUART) += vuart.o +obj-$(CONFIG_HAS_VUART_MMIO) += vuart.o extra-y += xen.lds
xen/arch/arm/include/asm/domain.h +1 -1
@@ -90,7 +90,7 @@ struct arch_domainstruct vgic_dist vgic; -#ifdef CONFIG_HWDOM_VUART +#ifdef CONFIG_HAS_VUART_MMIO struct vuart { #define VUART_BUF_SIZE 128 char *buf;
xen/arch/arm/vuart.h +2 -2
@@ -22,7 +22,7 @@struct domain ; -#ifdef CONFIG_HWDOM_VUART +#ifdef CONFIG_HAS_VUART_MMIO int domain_vuart_init (struct domain *d);void domain_vuart_free (struct domain *d);
@@ -40,7 +40,7 @@ static inline int domain_vuart_init(struct domain *d)static inline void domain_vuart_free (struct domain *d) {}; -#endif /* CONFIG_HWDOM_VUART */ +#endif /* CONFIG_HAS_VUART_MMIO */ #endif /* __ARCH_ARM_VUART_H__ */
Signature · 1 line
2.34.1
Re: [PATCH v1 07/16] arm/vuart: rename 'virtual UART' Kconfig option
Quoted 22 lines · On 24/06/2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Rename
HWDOM_VUARTtoHAS_VUART_MMIO.This emulator emulates only one register and the use of the emulator is limited to early boot console in the guest OS.
No functional change.
Signed-off-by Denis Mukhin <[email protected]>--- xen/arch/arm/Kconfig | 2 +- xen/arch/arm/Makefile | 2 +- xen/arch/arm/include/asm/domain.h | 2 +- xen/arch/arm/vuart.h | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-)xen/arch/arm/Kconfig +0
-0
xen/arch/arm/Kconfig config HAS_VUART_PL011 · line 180
Quoted 5 lines
xen/arch/arm/Kconfig +1
-1@@ -177,7 +177,7 @@ config HAS_VUART_PL011 Allows a guest to use SBSA Generic UART as a console. The SBSA Generic UART implements a subset of ARM PL011 UART. -config HWDOM_VUART +config HAS_VUART_MMIO
I personally don't like this change. The current config option name reads much better and clearly denotes the purpose.
~Michal
Re: [PATCH v1 07/16] arm/vuart: rename 'virtual UART' Kconfig option
Quoted 28 lines · Michal
Quoted 25 lines · On 24/06/2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Rename
HWDOM_VUARTtoHAS_VUART_MMIO.This emulator emulates only one register and the use of the emulator is limited to early boot console in the guest OS.
No functional change.
Signed-off-by Denis Mukhin <[email protected]>--- xen/arch/arm/Kconfig | 2 +- xen/arch/arm/Makefile | 2 +- xen/arch/arm/include/asm/domain.h | 2 +- xen/arch/arm/vuart.h | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-)xen/arch/arm/Kconfig +0
-0@@ -177,7 +177,7 @@ config HAS_VUART_PL011 Allows a guest to use SBSA Generic UART as a console. The SBSA Generic UART implements a subset of ARM PL011 UART.
Quoted 4 lines
xen/arch/arm/Kconfig config HAS_VUART_PL011 · line 180
Quoted 2 lines
xen/arch/arm/Kconfig +1
-1-config HWDOM_VUART +config HAS_VUART_MMIOI personally don't like this change. The current config option name reads much better and clearly denotes the purpose.
In my opinion, the MMIO-based UART is a useful debugging tool for early guest boot, even when the guest doesn't run in hwdom or on Arm system.
Quoted 3 lines
~Michal
Re: [PATCH v1 07/16] arm/vuart: rename 'virtual UART' Kconfig option
Quoted 29 lines · On 24/06/2025 09:14, [email protected] wrote:
Quoted 28 lines · Michal
Quoted 25 lines · On 24/06/2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Rename
HWDOM_VUARTtoHAS_VUART_MMIO.This emulator emulates only one register and the use of the emulator is limited to early boot console in the guest OS.
No functional change.
Signed-off-by Denis Mukhin <[email protected]>--- xen/arch/arm/Kconfig | 2 +- xen/arch/arm/Makefile | 2 +- xen/arch/arm/include/asm/domain.h | 2 +- xen/arch/arm/vuart.h | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-)xen/arch/arm/Kconfig +0
-0@@ -177,7 +177,7 @@ config HAS_VUART_PL011 Allows a guest to use SBSA Generic UART as a console. The SBSA Generic UART implements a subset of ARM PL011 UART.
Quoted 7 lines
Quoted 4 lines
xen/arch/arm/Kconfig config HAS_VUART_PL011 · line 180
Quoted 2 lines
xen/arch/arm/Kconfig +1
-1-config HWDOM_VUART +config HAS_VUART_MMIOI personally don't like this change. The current config option name reads much better and clearly denotes the purpose.
In my opinion, the MMIO-based UART is a useful debugging tool for early guest boot, even when the guest doesn't run in hwdom or on Arm system.
The reason why this vUART is for hwdom is that is uses information from dtuart (physical UART used by Xen probed from DT). This is to enable kernels used as dom0 that had early printk/earlycon set for this serial device (as if they run baremetal). Regular domUs have vPL011 and don't need hwdom vUART.
~Michal
Re: [PATCH v1 07/16] arm/vuart: rename 'virtual UART' Kconfig option
Hi Michal,
Quoted 37 lines · Michal
Quoted 34 lines · On 24/06/2025 09:14, [email protected] wrote:
Quoted 32 lines · Michal
Quoted 22 lines · On 24/06/2025 05:55, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Rename
HWDOM_VUARTtoHAS_VUART_MMIO.This emulator emulates only one register and the use of the emulator is limited to early boot console in the guest OS.
No functional change.
Signed-off-by Denis Mukhin <[email protected]>--- xen/arch/arm/Kconfig | 2 +- xen/arch/arm/Makefile | 2 +- xen/arch/arm/include/asm/domain.h | 2 +- xen/arch/arm/vuart.h | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-)xen/arch/arm/Kconfig +0
-0xen/arch/arm/Kconfig config HAS_VUART_PL011 · line 180
Quoted 5 lines
xen/arch/arm/Kconfig +1
-1@@ -177,7 +177,7 @@ config HAS_VUART_PL011 Allows a guest to use SBSA Generic UART as a console. The SBSA Generic UART implements a subset of ARM PL011 UART. -config HWDOM_VUART +config HAS_VUART_MMIOI personally don't like this change. The current config option name reads much better and clearly denotes the purpose.
Quoted 6 lines
Quoted 2 lines
In my opinion, the MMIO-based UART is a useful debugging tool for early guest boot, even when the guest doesn't run in hwdom or on Arm system.
The reason why this vUART is for hwdom is that is uses information from dtuart (physical UART used by Xen probed from DT). This is to enable kernels used as dom0 that had early printk/earlycon set for this serial device (as if they run baremetal). Regular domUs have vPL011 and don't need hwdom vUART.
OK, I'll keep hwdom, hope there will be no need to change it again.
I think dtuart may be useful for bringing up some exotic OSes which do not have pl011 driver.
But then, I want to do s/HWDOM_VUART/VUART_HWDOM/g so all vUART build-time settings have the same naming convention:
VUART_SBSA
VUART_NS16550Will that be OK with you?
--
Denis
Quoted 3 lines
~Michal
PATCH 8/16 arm/vuart: move simple MMIO-based vUART declarations to common header
In reply to [email protected]From: Denis Mukhin <[email protected]>
Merge arch/arm/vuart.h with include/xen/vuart.h.
No functional change.
--- xen/arch/arm/domain.c | 1 - xen/arch/arm/vuart.c | 3 +-- xen/arch/arm/vuart.h | 54 ----------------------------------------- xen/include/xen/vuart.h | 20 +++++++++++++++ 4 files changed, 21 insertions(+), 57 deletions(-) delete mode 100644 xen/arch/arm/vuart.h
xen/arch/arm/domain.c +0 -1
@@ -31,7 +31,6 @@#include <asm/vtimer.h> #include "vpci.h" -#include "vuart.h" DEFINE_PER_CPU(struct vcpu *, curr_vcpu);
xen/arch/arm/vuart.c +1 -2
@@ -28,8 +28,7 @@#include <xen/serial.h> #include <asm/mmio.h> #include <xen/perfc.h> - -#include "vuart.h" +#include <xen/vuart.h> #define domain_has_vuart (d) ((d)->arch.vuart.info != NULL)
xen/arch/arm/vuart.h deleted +0 -54
54 lines not on this page · raw message
xen/include/xen/vuart.h +20 -0
@@ -43,6 +43,26 @@ static inline int vuart_putchar(struct domain *d, char c)#endif /* CONFIG_HAS_VUART_PL011 */ +#ifdef CONFIG_HAS_VUART_MMIO + +int domain_vuart_init (struct domain *d); +void domain_vuart_free (struct domain *d); + +#else + +static inline int domain_vuart_init (struct domain *d) +{ +/* +* The vUART is unconditionally inialized for the hw domain. So we +* can't return an error. +*/ +return 0 ; +} + +static inline void domain_vuart_free (struct domain *d) {}; + +#endif /* CONFIG_HAS_VUART_MMIO */ +#endif /* XEN_VUART_H */ /*
Signature · 1 line
2.34.1
PATCH 9/16 arm/vuart: use void pointer in domain struct
In reply to [email protected]From: Denis Mukhin <[email protected]>
Make all public data structures private to simple MMIO-based vUART implementation and switch struct domain to using void pointer to reduce compile-time dependencies.
--- xen/arch/arm/include/asm/domain.h | 14 ++----- xen/arch/arm/vuart.c | 68 ++++++++++++++++++++++--------- 2 files changed, 52 insertions(+), 30 deletions(-)
xen/arch/arm/include/asm/domain.h +4 -10
@@ -90,16 +90,6 @@ struct arch_domainstruct vgic_dist vgic; -#ifdef CONFIG_HAS_VUART_MMIO -struct vuart { -#define VUART_BUF_SIZE 128 -char *buf; -int idx; -const struct vuart_info *info; -spinlock_t lock; - } vuart; -#endif -unsigned int evtchn_irq;#ifdef CONFIG_ACPI void *efi_acpi_table;
@@ -116,6 +106,10 @@ struct arch_domainvoid *vpl011;#endif +#ifdef CONFIG_HAS_VUART_MMIO +void *vuart; +#endif +#ifdef CONFIG_TEE void *tee;#endif
xen/arch/arm/vuart.c +48 -20
122 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 10/16 arm/vuart: merge vuart_print_char() with vuart_mmio_write()
In reply to [email protected]From: Denis Mukhin <[email protected]>
Simplify code a bit since there's only one user of vuart_print_char().
No functional change.
--- xen/arch/arm/vuart.c | 45 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 27 deletions(-)
xen/arch/arm/vuart.c +18 -27
@@ -1,7 +1,5 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ /* -* xen/arch/arm/vuart.c -* * Virtual UART Emulator. * * This emulator uses the information from dtuart. This is not intended to be
@@ -21,6 +19,7 @@* Ian Campbell <[email protected]> * Copyright (c) 2012 Citrix Systems. */ +#include <xen/lib.h> #include <xen/sched.h> #include <xen/errno.h>
@@ -99,27 +98,6 @@ void domain_vuart_free(struct domain *d) } } -static void vuart_print_char (struct vcpu *v,char c) -{ -struct domain *d = v->domain; -struct vuart *uart = d->arch.vuart; - -if ( !is_console_printable (c) ) -return ; - -spin_lock (&uart->lock); - uart->buf[uart->idx++] = c; -if ( (uart->idx == (VUART_BUF_SIZE -2 )) || (c =='\n' ) ) - { -if ( c !='\n' ) - uart->buf[uart->idx++] ='\n' ; - uart->buf[uart->idx] ='\0' ; -printk (XENLOG_G_DEBUG "DOM%u: %s" , d->domain_id, uart->buf); - uart->idx =0 ; - } -spin_unlock (&uart->lock); -} -static int vuart_mmio_read (struct vcpu *v,mmio_info_t *info,register_t *r,void *priv) {
@@ -145,12 +123,26 @@ static int vuart_mmio_write(struct vcpu *v, mmio_info_t *info,struct domain *d = v->domain;struct vuart *vdev = d->arch.vuart;paddr_t offset = info->gpa - vdev->info->base_addr; +char ch = r &0xFF ;/* ignore any status bits */ perfc_incr (vuart_writes); -if ( offset == vdev->info->data_off ) -/* ignore any status bits */ -vuart_print_char (v, r &0xFF ); +if ( !vdev || offset != vdev->info->data_off || !is_console_printable (ch) ) +return 1 ; + +spin_lock (&vdev->lock); + + vdev->buf[vdev->idx++] = ch; +if ( (vdev->idx == (VUART_BUF_SIZE -2 )) || (ch =='\n' ) ) + { +if ( ch !='\n' ) + vdev->buf[vdev->idx++] ='\n' ; + vdev->buf[vdev->idx] ='\0' ; +printk (XENLOG_G_DEBUG "DOM%u: %s" , d->domain_id, vdev->buf); + vdev->idx =0 ; + } + +spin_unlock (&vdev->lock);return 1 ; }
@@ -163,4 +155,3 @@ static int vuart_mmio_write(struct vcpu *v, mmio_info_t *info,* indent-tabs-mode: nil * End: */ -
Signature · 1 line
2.34.1
PATCH 11/16 xen/domain: introduce common emulation flags
In reply to [email protected]From: Denis Mukhin <[email protected]>
Add common emulation_flags for configuring domain emulation features.
Print d->emulation_flags from 'q' keyhandler for better traceability while debugging.
---
Original patch: https://lore.kernel.org/r/[email protected]
--- xen/arch/x86/domain.c | 2 +- xen/arch/x86/domctl.c | 2 +- xen/arch/x86/include/asm/domain.h | 25 +++++++++++-------------- xen/common/keyhandler.c | 1 + xen/include/xen/sched.h | 2 ++ 5 files changed, 16 insertions(+), 16 deletions(-)
xen/arch/x86/domain.c +1 -1
@@ -881,7 +881,7 @@ int arch_domain_create(struct domain *d, emflags);return -EOPNOTSUPP ; } - d->arch.emulation_flags = emflags; + d->emulation_flags = emflags;#ifdef CONFIG_PV32 HYPERVISOR_COMPAT_VIRT_START(d) =
xen/arch/x86/domctl.c +1 -1
@@ -144,7 +144,7 @@ void arch_get_domain_info(const struct domain *d,if (paging_mode_hap (d) ) info->flags |= XEN_DOMINF_hap; - info->arch_config.emulation_flags = d->arch.emulation_flags; + info->arch_config.emulation_flags = d->emulation_flags; info->gpaddr_bits = hap_paddr_bits; }
xen/arch/x86/include/asm/domain.h +11 -14
@@ -455,9 +455,6 @@ struct arch_domain/* Don't unconditionally inject #GP for unhandled MSRs. */ bool msr_relaxed; - -/* Emulated devices enabled bitmap. */ -uint32_t emulation_flags; } __cacheline_aligned;#ifdef CONFIG_HVM
@@ -494,17 +491,17 @@ struct arch_domain X86_EMU_PIT | X86_EMU_USE_PIRQ | \ X86_EMU_VPCI) -#define has_vlapic (d) (!!((d)->arch.emulation_flags & X86_EMU_LAPIC)) -#define has_vhpet (d) (!!((d)->arch.emulation_flags & X86_EMU_HPET)) -#define has_vpm (d) (!!((d)->arch.emulation_flags & X86_EMU_PM)) -#define has_vrtc (d) (!!((d)->arch.emulation_flags & X86_EMU_RTC)) -#define has_vioapic (d) (!!((d)->arch.emulation_flags & X86_EMU_IOAPIC)) -#define has_vpic (d) (!!((d)->arch.emulation_flags & X86_EMU_PIC)) -#define has_vvga (d) (!!((d)->arch.emulation_flags & X86_EMU_VGA)) -#define has_viommu (d) (!!((d)->arch.emulation_flags & X86_EMU_IOMMU)) -#define has_vpit (d) (!!((d)->arch.emulation_flags & X86_EMU_PIT)) -#define has_pirq (d) (!!((d)->arch.emulation_flags & X86_EMU_USE_PIRQ)) -#define has_vpci (d) (!!((d)->arch.emulation_flags & X86_EMU_VPCI)) +#define has_vlapic (d) (!!((d)->emulation_flags & X86_EMU_LAPIC)) +#define has_vhpet (d) (!!((d)->emulation_flags & X86_EMU_HPET)) +#define has_vpm (d) (!!((d)->emulation_flags & X86_EMU_PM)) +#define has_vrtc (d) (!!((d)->emulation_flags & X86_EMU_RTC)) +#define has_vioapic (d) (!!((d)->emulation_flags & X86_EMU_IOAPIC)) +#define has_vpic (d) (!!((d)->emulation_flags & X86_EMU_PIC)) +#define has_vvga (d) (!!((d)->emulation_flags & X86_EMU_VGA)) +#define has_viommu (d) (!!((d)->emulation_flags & X86_EMU_IOMMU)) +#define has_vpit (d) (!!((d)->emulation_flags & X86_EMU_PIT)) +#define has_pirq (d) (!!((d)->emulation_flags & X86_EMU_USE_PIRQ)) +#define has_vpci (d) (!!((d)->emulation_flags & X86_EMU_VPCI))#define gdt_ldt_pt_idx (v) \ ((v)->vcpu_id >> (PAGETABLE_ORDER - GDT_LDT_VCPU_SHIFT))
xen/common/keyhandler.c +1 -0
@@ -306,6 +306,7 @@ static void cf_check dump_domains(unsigned char key)if (test_bit (i, &d->watchdog_inuse_map) )printk (" watchdog %d expires in %d seconds\n" , i, (u32)((d->watchdog_timer[i].expires -NOW ()) >>30 )); +printk (" emulation_flags %#x\n" , d->emulation_flags);arch_dump_domain_info (d);
xen/include/xen/sched.h +2 -0
@@ -652,6 +652,8 @@ struct domainconst unsigned int *llc_colors;#endif +uint32_t emulation_flags; +/* Console settings. */ struct {/* Permission to take ownership of the physical console input. */
Signature · 1 line
2.34.1
PATCH 12/16 xen/domain: introduce domain-emu.h
In reply to [email protected]From: Denis Mukhin <[email protected]>
Define an architecture-independent location for describing domain emulation flags.
---
Original code: https://lore.kernel.org/xen-devel/[email protected]/
--- xen/arch/x86/include/asm/domain.h | 23 ++++++++++++----------- xen/include/xen/domain-emu.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 xen/include/xen/domain-emu.h
xen/arch/x86/include/asm/domain.h +12 -11
@@ -3,6 +3,7 @@#include <xen/mm.h> #include <xen/radix-tree.h> +#include <xen/domain-emu.h> #include <asm/hvm/vcpu.h> #include <asm/hvm/domain.h> #include <asm/e820.h>
@@ -458,16 +459,16 @@ struct arch_domain } __cacheline_aligned;#ifdef CONFIG_HVM -#define X86_EMU_LAPIC XEN_X86_EMU_LAPIC -#define X86_EMU_HPET XEN_X86_EMU_HPET -#define X86_EMU_PM XEN_X86_EMU_PM -#define X86_EMU_RTC XEN_X86_EMU_RTC -#define X86_EMU_IOAPIC XEN_X86_EMU_IOAPIC -#define X86_EMU_PIC XEN_X86_EMU_PIC -#define X86_EMU_VGA XEN_X86_EMU_VGA -#define X86_EMU_IOMMU XEN_X86_EMU_IOMMU -#define X86_EMU_USE_PIRQ XEN_X86_EMU_USE_PIRQ -#define X86_EMU_VPCI XEN_X86_EMU_VPCI +#define X86_EMU_LAPIC DOMAIN_EMU_LAPIC +#define X86_EMU_HPET DOMAIN_EMU_HPET +#define X86_EMU_PM DOMAIN_EMU_PM +#define X86_EMU_RTC DOMAIN_EMU_RTC +#define X86_EMU_IOAPIC DOMAIN_EMU_IOAPIC +#define X86_EMU_PIC DOMAIN_EMU_PIC +#define X86_EMU_VGA DOMAIN_EMU_VGA +#define X86_EMU_IOMMU DOMAIN_EMU_IOMMU +#define X86_EMU_USE_PIRQ DOMAIN_EMU_PIRQ +#define X86_EMU_VPCI DOMAIN_EMU_PCI#else #define X86_EMU_LAPIC 0#define X86_EMU_HPET 0
@@ -481,7 +482,7 @@ struct arch_domain#define X86_EMU_VPCI 0#endif -#define X86_EMU_PIT XEN_X86_EMU_PIT +#define X86_EMU_PIT DOMAIN_EMU_PIT/* This must match XEN_X86_EMU_ALL in xen.h */ #define X86_EMU_ALL (X86_EMU_LAPIC | X86_EMU_HPET | \
xen/include/xen/domain-emu.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef XEN_DOMAIN_EMU_H +#define XEN_DOMAIN_EMU_H + +/* +* Domain emulation flags. +*/ +#define DOMAIN_EMU_LAPIC (1U << 0) +#define DOMAIN_EMU_HPET (1U << 1) +#define DOMAIN_EMU_PM (1U << 2) +#define DOMAIN_EMU_RTC (1U << 3) +#define DOMAIN_EMU_IOAPIC (1U << 4) +#define DOMAIN_EMU_PIC (1U << 5) +#define DOMAIN_EMU_VGA (1U << 6) +#define DOMAIN_EMU_IOMMU (1U << 7) +#define DOMAIN_EMU_PIT (1U << 8) +#define DOMAIN_EMU_PIRQ (1U << 9) +#define DOMAIN_EMU_PCI (1U << 10) + +#endif /* XEN_DOMAIN_EMU_H */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
2.34.1
Re: [PATCH v1 12/16] xen/domain: introduce domain-emu.h
Quoted 4 lines · On 24.06.2025 05:56, [email protected] wrote:
xen/arch/x86/include/asm/domain.h +0
-0@@ -458,16 +459,16 @@ struct arch_domain } __cacheline_aligned;#ifdef CONFIG_HVM
xen/arch/x86/include/asm/domain.h struct arch_domain · line 470
Quoted 10 lines
xen/arch/x86/include/asm/domain.h +0
-10-#define X86_EMU_LAPIC XEN_X86_EMU_LAPIC -#define X86_EMU_HPET XEN_X86_EMU_HPET -#define X86_EMU_PM XEN_X86_EMU_PM -#define X86_EMU_RTC XEN_X86_EMU_RTC -#define X86_EMU_IOAPIC XEN_X86_EMU_IOAPIC -#define X86_EMU_PIC XEN_X86_EMU_PIC -#define X86_EMU_VGA XEN_X86_EMU_VGA -#define X86_EMU_IOMMU XEN_X86_EMU_IOMMU -#define X86_EMU_USE_PIRQ XEN_X86_EMU_USE_PIRQ -#define X86_EMU_VPCI XEN_X86_EMU_VPCI
The old code deliberately used values from the public interface.
Quoted 11 lines
xen/include/xen/domain-emu.h new file +8
-0@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef XEN_DOMAIN_EMU_H +#define XEN_DOMAIN_EMU_H + +/* +* Domain emulation flags. +*/ +#define DOMAIN_EMU_LAPIC (1U << 0)
xen/include/xen/domain-emu.h line 18
Quoted 10 lines
xen/include/xen/domain-emu.h new file +10
-0+#define DOMAIN_EMU_HPET (1U << 1) +#define DOMAIN_EMU_PM (1U << 2) +#define DOMAIN_EMU_RTC (1U << 3) +#define DOMAIN_EMU_IOAPIC (1U << 4) +#define DOMAIN_EMU_PIC (1U << 5) +#define DOMAIN_EMU_VGA (1U << 6) +#define DOMAIN_EMU_IOMMU (1U << 7) +#define DOMAIN_EMU_PIT (1U << 8) +#define DOMAIN_EMU_PIRQ (1U << 9) +#define DOMAIN_EMU_PCI (1U << 10)
There's nothing in the new code making sure that the values won't go out of sync.
Jan
Re: [PATCH v1 12/16] xen/domain: introduce domain-emu.h
Hi Jan,
Quoted 4 lines · Jan Beulich
Quoted 3 lines · On 24.06.2025 05:56, [email protected] wrote:
xen/arch/x86/include/asm/domain.h +0
-0@@ -458,16 +459,16 @@ struct arch_domain } __cacheline_aligned;
Quoted 13 lines
xen/arch/x86/include/asm/domain.h struct arch_domain · line 470
Quoted 11 lines
xen/arch/x86/include/asm/domain.h +0
-10#ifdef CONFIG_HVM -#define X86_EMU_LAPIC XEN_X86_EMU_LAPIC -#define X86_EMU_HPET XEN_X86_EMU_HPET -#define X86_EMU_PM XEN_X86_EMU_PM -#define X86_EMU_RTC XEN_X86_EMU_RTC -#define X86_EMU_IOAPIC XEN_X86_EMU_IOAPIC -#define X86_EMU_PIC XEN_X86_EMU_PIC -#define X86_EMU_VGA XEN_X86_EMU_VGA -#define X86_EMU_IOMMU XEN_X86_EMU_IOMMU -#define X86_EMU_USE_PIRQ XEN_X86_EMU_USE_PIRQ -#define X86_EMU_VPCI XEN_X86_EMU_VPCIThe old code deliberately used values from the public interface.
In next version I am building, I moved all of XEN_X86_EMU_XXX definitions as is to a new public header under include/public/xen-emu.h:
https://gitlab.com/xen-project/people/dmukhin/xen/-/commit/9b0bc5ffa5710114df8523ae2aa7680b7c6f0942
That looks less invasive.
Will that work?
There should be a common header with emulation flags somewhere, since there will be SBSA and hwdom vUART definitions there.
--
Denis
Re: [PATCH v1 12/16] xen/domain: introduce domain-emu.h
Quoted 22 lines · On 31.07.2025 22:55, [email protected] wrote:
Quoted 4 lines · Jan Beulich
Quoted 3 lines · On 24.06.2025 05:56, [email protected] wrote:
xen/arch/x86/include/asm/domain.h +0
-0@@ -458,16 +459,16 @@ struct arch_domain } __cacheline_aligned;Quoted 13 lines
xen/arch/x86/include/asm/domain.h struct arch_domain · line 470
Quoted 11 lines
xen/arch/x86/include/asm/domain.h +0
-10#ifdef CONFIG_HVM -#define X86_EMU_LAPIC XEN_X86_EMU_LAPIC -#define X86_EMU_HPET XEN_X86_EMU_HPET -#define X86_EMU_PM XEN_X86_EMU_PM -#define X86_EMU_RTC XEN_X86_EMU_RTC -#define X86_EMU_IOAPIC XEN_X86_EMU_IOAPIC -#define X86_EMU_PIC XEN_X86_EMU_PIC -#define X86_EMU_VGA XEN_X86_EMU_VGA -#define X86_EMU_IOMMU XEN_X86_EMU_IOMMU -#define X86_EMU_USE_PIRQ XEN_X86_EMU_USE_PIRQ -#define X86_EMU_VPCI XEN_X86_EMU_VPCIThe old code deliberately used values from the public interface.
In next version I am building, I moved all of
XEN_X86_EMU_XXXdefinitions as is to a new public header underinclude/public/xen-emu.h:
Quoted 8 lines
https://gitlab.com/xen-project/people/dmukhin/xen/-/commit/9b0bc5ffa5710114df8523ae2aa7680b7c6f0942
That looks less invasive.
Will that work?
There should be a common header with emulation flags somewhere, since there will be SBSA and hwdom vUART definitions there.
Yet will there be a strict need for any constants to be identical (i.e. not only have the same name, but also the same value) across architectures?
Jan
Re: [PATCH v1 12/16] xen/domain: introduce domain-emu.h
Quoted 27 lines · Jan Beulich
Quoted 26 lines · On 31.07.2025 22:55, [email protected] wrote:
Quoted 4 lines · Jan Beulich
Quoted 3 lines · On 24.06.2025 05:56, [email protected] wrote:
xen/arch/x86/include/asm/domain.h +0
-0@@ -458,16 +459,16 @@ struct arch_domain } __cacheline_aligned;Quoted 13 lines
xen/arch/x86/include/asm/domain.h struct arch_domain · line 470
Quoted 11 lines
xen/arch/x86/include/asm/domain.h +0
-10#ifdef CONFIG_HVM -#define X86_EMU_LAPIC XEN_X86_EMU_LAPIC -#define X86_EMU_HPET XEN_X86_EMU_HPET -#define X86_EMU_PM XEN_X86_EMU_PM -#define X86_EMU_RTC XEN_X86_EMU_RTC -#define X86_EMU_IOAPIC XEN_X86_EMU_IOAPIC -#define X86_EMU_PIC XEN_X86_EMU_PIC -#define X86_EMU_VGA XEN_X86_EMU_VGA -#define X86_EMU_IOMMU XEN_X86_EMU_IOMMU -#define X86_EMU_USE_PIRQ XEN_X86_EMU_USE_PIRQ -#define X86_EMU_VPCI XEN_X86_EMU_VPCIThe old code deliberately used values from the public interface.
In next version I am building, I moved all of
XEN_X86_EMU_XXXdefinitions as is to a new public header underinclude/public/xen-emu.h:https://gitlab.com/xen-project/people/dmukhin/xen/-/commit/9b0bc5ffa5710114df8523ae2aa7680b7c6f0942
That looks less invasive.
Quoted 7 lines
Quoted 4 lines
Will that work?
There should be a common header with emulation flags somewhere, since there will be SBSA and hwdom vUART definitions there.
Yet will there be a strict need for any constants to be identical (i.e. not only have the same name, but also the same value) across architectures?
I don't think there's strict need for identical values across achitectures. But some of the constants _may_ be reused for non-x86 arches, like VPCI bit and, perhaps, IOMMU, PIRQ and future NS16550 (after adding MMIO).
Re: [PATCH v1 12/16] xen/domain: introduce domain-emu.h
Quoted 30 lines · On 01.08.2025 21:30, [email protected] wrote:
Quoted 29 lines · Jan Beulich
Quoted 28 lines · On 31.07.2025 22:55, [email protected] wrote:
Quoted 4 lines · Jan Beulich
Quoted 3 lines · On 24.06.2025 05:56, [email protected] wrote:
xen/arch/x86/include/asm/domain.h +0
-0@@ -458,16 +459,16 @@ struct arch_domain } __cacheline_aligned;Quoted 13 lines
xen/arch/x86/include/asm/domain.h struct arch_domain · line 470
Quoted 11 lines
xen/arch/x86/include/asm/domain.h +0
-10#ifdef CONFIG_HVM -#define X86_EMU_LAPIC XEN_X86_EMU_LAPIC -#define X86_EMU_HPET XEN_X86_EMU_HPET -#define X86_EMU_PM XEN_X86_EMU_PM -#define X86_EMU_RTC XEN_X86_EMU_RTC -#define X86_EMU_IOAPIC XEN_X86_EMU_IOAPIC -#define X86_EMU_PIC XEN_X86_EMU_PIC -#define X86_EMU_VGA XEN_X86_EMU_VGA -#define X86_EMU_IOMMU XEN_X86_EMU_IOMMU -#define X86_EMU_USE_PIRQ XEN_X86_EMU_USE_PIRQ -#define X86_EMU_VPCI XEN_X86_EMU_VPCIThe old code deliberately used values from the public interface.
In next version I am building, I moved all of
XEN_X86_EMU_XXXdefinitions as is to a new public header underinclude/public/xen-emu.h:https://gitlab.com/xen-project/people/dmukhin/xen/-/commit/9b0bc5ffa5710114df8523ae2aa7680b7c6f0942
That looks less invasive.
Will that work?
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
There should be a common header with emulation flags somewhere, since there will be SBSA and hwdom vUART definitions there.
Yet will there be a strict need for any constants to be identical (i.e. not only have the same name, but also the same value) across architectures?
I don't think there's strict need for identical values across achitectures.
That's what I was expecting.
Quoted 2 lines
But some of the constants _may_ be reused for non-x86 arches, like VPCI bit and, perhaps, IOMMU, PIRQ and future NS16550 (after adding MMIO).
Right, but as you say - they want to use the same name, but they could easily have a different value there. I hope you understand that what I'm questioning is the introduction of a single header covering all architectures.
Jan
Re: [PATCH v1 12/16] xen/domain: introduce domain-emu.h
Quoted 39 lines · Jan Beulich
Quoted 30 lines · On 01.08.2025 21:30, [email protected] wrote:
Quoted 29 lines · Jan Beulich
Quoted 28 lines · On 31.07.2025 22:55, [email protected] wrote:
Quoted 4 lines · Jan Beulich
Quoted 3 lines · On 24.06.2025 05:56, [email protected] wrote:
xen/arch/x86/include/asm/domain.h +0
-0@@ -458,16 +459,16 @@ struct arch_domain } __cacheline_aligned;Quoted 13 lines
xen/arch/x86/include/asm/domain.h struct arch_domain · line 470
Quoted 11 lines
xen/arch/x86/include/asm/domain.h +0
-10#ifdef CONFIG_HVM -#define X86_EMU_LAPIC XEN_X86_EMU_LAPIC -#define X86_EMU_HPET XEN_X86_EMU_HPET -#define X86_EMU_PM XEN_X86_EMU_PM -#define X86_EMU_RTC XEN_X86_EMU_RTC -#define X86_EMU_IOAPIC XEN_X86_EMU_IOAPIC -#define X86_EMU_PIC XEN_X86_EMU_PIC -#define X86_EMU_VGA XEN_X86_EMU_VGA -#define X86_EMU_IOMMU XEN_X86_EMU_IOMMU -#define X86_EMU_USE_PIRQ XEN_X86_EMU_USE_PIRQ -#define X86_EMU_VPCI XEN_X86_EMU_VPCIThe old code deliberately used values from the public interface.
In next version I am building, I moved all of
XEN_X86_EMU_XXXdefinitions as is to a new public header underinclude/public/xen-emu.h:https://gitlab.com/xen-project/people/dmukhin/xen/-/commit/9b0bc5ffa5710114df8523ae2aa7680b7c6f0942
That looks less invasive.
Will that work?
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
There should be a common header with emulation flags somewhere, since there will be SBSA and hwdom vUART definitions there.
Yet will there be a strict need for any constants to be identical (i.e. not only have the same name, but also the same value) across architectures?
I don't think there's strict need for identical values across achitectures.
Quoted 8 lines
That's what I was expecting.
Quoted 2 lines
But some of the constants _may_ be reused for non-x86 arches, like VPCI bit and, perhaps, IOMMU, PIRQ and future NS16550 (after adding MMIO).
Right, but as you say - they want to use the same name, but they could easily have a different value there. I hope you understand that what I'm questioning is the introduction of a single header covering all architectures.
Yes, I understand your point wrt common header and identical values in emulation flags.
I think I can add missing per-vUART fields to per-arch xen_arch_domainconfig, populate them by the toolstack and be done for now, i.e. I can drop that patch.
--
Denis
PATCH 13/16 drivers/vuart: move PL011 emulator code
In reply to [email protected]From: Denis Mukhin <[email protected]>
Move PL011 emulator to the new location for UART emulators.
No functional change intended.
---
xen/arch/arm/Kconfig | 7 -------
xen/arch/arm/Makefile | 1 -
xen/drivers/Kconfig | 2 ++
xen/drivers/Makefile | 1 +
xen/drivers/vuart/Kconfig | 14 ++++++++++++++
xen/drivers/vuart/Makefile | 1 +
.../arm/vpl011.c => drivers/vuart/vuart-pl011.c} | 0
7 files changed, 18 insertions(+), 8 deletions(-)
create mode 100644 xen/drivers/vuart/Kconfig
create mode 100644 xen/drivers/vuart/Makefile
rename xen/{arch/arm/vpl011.c => drivers/vuart/vuart-pl011.c} (100%)xen/arch/arm/Kconfig +0 -7
@@ -170,13 +170,6 @@ config NEW_VGIC problems with the standard emulation. At the moment this implementation is not security supported. -config HAS_VUART_PL011 - bool "Emulated SBSA UART console support" - default y - help - Allows a guest to use SBSA Generic UART as a console. The - SBSA Generic UART implements a subset of ARM PL011 UART. - config HAS_VUART_MMIO bool "Emulated UART for hardware domain" default y
xen/arch/arm/Makefile +0 -1
@@ -65,7 +65,6 @@ obj-$(CONFIG_HAS_ITS) += vgic-v3-its.o endif obj-$(CONFIG_VM_EVENT) += vm_event.o obj-y += vtimer.o -obj-$(CONFIG_HAS_VUART_PL011) += vpl011.o obj-y += vsmc.o obj-y += vpsci.o obj-$(CONFIG_HAS_VUART_MMIO) += vuart.o
xen/drivers/Kconfig +2 -0
@@ -12,6 +12,8 @@ source "drivers/pci/Kconfig" source "drivers/video/Kconfig" +source "drivers/vuart/Kconfig" + config HAS_VPCI bool
xen/drivers/Makefile +1 -0
@@ -2,6 +2,7 @@ obj-y += char/ obj-$(CONFIG_HAS_CPUFREQ) += cpufreq/ obj-$(CONFIG_HAS_PCI) += pci/ obj-$(CONFIG_HAS_VPCI) += vpci/ +obj-$(CONFIG_HAS_VUART) += vuart/ obj-$(CONFIG_HAS_PASSTHROUGH) += passthrough/ obj-$(CONFIG_ACPI) += acpi/ obj-$(CONFIG_VIDEO) += video/
xen/drivers/vuart/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +config HAS_VUART + bool + +if (ARM_32 || ARM_64) + +config HAS_VUART_PL011 + bool "Emulated PL011 UART support" + default y + select HAS_VUART + help + Allows a guest to use SBSA Generic UART as a console. The + SBSA Generic UART implements a subset of ARM PL011 UART. + +endif
xen/drivers/vuart/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_HAS_VUART_PL011) += vuart-pl011.o
xen/drivers/vuart/vuart-pl011.c renamed from xen/arch/arm/vpl011.c +0 -0
Signature · 1 line
2.34.1
Re: [PATCH v1 13/16] drivers/vuart: move PL011 emulator code
Quoted 7 lines · On 24.06.2025 05:56, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Move PL011 emulator to the new location for UART emulators.
No functional change intended.
Signed-off-by Denis Mukhin <[email protected]>
Quoted 12 lines
---
xen/arch/arm/Kconfig | 7 -------
xen/arch/arm/Makefile | 1 -
xen/drivers/Kconfig | 2 ++
xen/drivers/Makefile | 1 +
xen/drivers/vuart/Kconfig | 14 ++++++++++++++
xen/drivers/vuart/Makefile | 1 +
.../arm/vpl011.c => drivers/vuart/vuart-pl011.c} | 0
7 files changed, 18 insertions(+), 8 deletions(-)
create mode 100644 xen/drivers/vuart/Kconfig
create mode 100644 xen/drivers/vuart/Makefile
rename xen/{arch/arm/vpl011.c => drivers/vuart/vuart-pl011.c} (100%)I question the placement under drivers/. To me, driver != emulator. I wonder what others think. But yes, we already have drivers/vpci/. That may want moving then ...
Jan
Re: [PATCH v1 13/16] drivers/vuart: move PL011 emulator code
Quoted 21 lines · Jan Beulich
Quoted 7 lines · On 24.06.2025 05:56, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Move PL011 emulator to the new location for UART emulators.
No functional change intended.
Signed-off-by Denis Mukhin <[email protected]>Quoted 12 lines
--- xen/arch/arm/Kconfig | 7 ------- xen/arch/arm/Makefile | 1 - xen/drivers/Kconfig | 2 ++ xen/drivers/Makefile | 1 + xen/drivers/vuart/Kconfig | 14 ++++++++++++++ xen/drivers/vuart/Makefile | 1 + .../arm/vpl011.c => drivers/vuart/vuart-pl011.c} | 0 7 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 xen/drivers/vuart/Kconfig create mode 100644 xen/drivers/vuart/Makefile rename xen/{arch/arm/vpl011.c => drivers/vuart/vuart-pl011.c} (100%)
Quoted 3 lines
I question the placement under
drivers/. To me, driver != emulator. I wonder what others think. But yes, we already havedrivers/vpci/. That may want moving then ...
re: driver != emulator: I agree; but I followed drivers/vpci.
Do you think common/vuart would be a better location?
Quoted 2 lines
Jan
Re: [PATCH v1 13/16] drivers/vuart: move PL011 emulator code
Quoted 22 lines · On 24.06.2025 09:31, [email protected] wrote:
Quoted 21 lines · Jan Beulich
Quoted 19 lines · On 24.06.2025 05:56, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Move PL011 emulator to the new location for UART emulators.
No functional change intended.
Signed-off-by Denis Mukhin <[email protected]>--- xen/arch/arm/Kconfig | 7 ------- xen/arch/arm/Makefile | 1 - xen/drivers/Kconfig | 2 ++ xen/drivers/Makefile | 1 + xen/drivers/vuart/Kconfig | 14 ++++++++++++++ xen/drivers/vuart/Makefile | 1 + .../arm/vpl011.c => drivers/vuart/vuart-pl011.c} | 0 7 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 xen/drivers/vuart/Kconfig create mode 100644 xen/drivers/vuart/Makefile rename xen/{arch/arm/vpl011.c => drivers/vuart/vuart-pl011.c} (100%)
Quoted 7 lines
Quoted 3 lines
I question the placement under
drivers/. To me, driver != emulator. I wonder what others think. But yes, we already havedrivers/vpci/. That may want moving then ...re: driver != emulator: I agree; but I followed
drivers/vpci.Do you think common/vuart would be a better location?
Or maybe common/emul/... This wants discussing, I think.
Jan
Re: [PATCH v1 13/16] drivers/vuart: move PL011 emulator code
Quoted 27 lines · Jan Beulich
Quoted 26 lines · On 24.06.2025 09:31, [email protected] wrote:
Quoted 24 lines · Jan Beulich
Quoted 7 lines · On 24.06.2025 05:56, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Move PL011 emulator to the new location for UART emulators.
No functional change intended.
Signed-off-by Denis Mukhin <[email protected]>Quoted 12 lines
--- xen/arch/arm/Kconfig | 7 ------- xen/arch/arm/Makefile | 1 - xen/drivers/Kconfig | 2 ++ xen/drivers/Makefile | 1 + xen/drivers/vuart/Kconfig | 14 ++++++++++++++ xen/drivers/vuart/Makefile | 1 + .../arm/vpl011.c => drivers/vuart/vuart-pl011.c} | 0 7 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 xen/drivers/vuart/Kconfig create mode 100644 xen/drivers/vuart/Makefile rename xen/{arch/arm/vpl011.c => drivers/vuart/vuart-pl011.c} (100%)I question the placement under
drivers/. To me, driver != emulator. I wonder what others think. But yes, we already havedrivers/vpci/. That may want moving then ...
Quoted 5 lines
Quoted 3 lines
re: driver != emulator: I agree; but I followed
drivers/vpci.Do you think common/vuart would be a better location?
Or maybe common/emul/... This wants discussing, I think.
Will something like the following work
common/hvm/vuart
?
Quoted 2 lines
Jan
Re: [PATCH v1 13/16] drivers/vuart: move PL011 emulator code
Quoted 30 lines · On 10.07.2025 03:59, [email protected] wrote:
Quoted 29 lines · Jan Beulich
Quoted 28 lines · On 24.06.2025 09:31, [email protected] wrote:
Quoted 21 lines · Jan Beulich
Quoted 7 lines · On 24.06.2025 05:56, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Move PL011 emulator to the new location for UART emulators.
No functional change intended.
Signed-off-by Denis Mukhin <[email protected]>Quoted 12 lines
--- xen/arch/arm/Kconfig | 7 ------- xen/arch/arm/Makefile | 1 - xen/drivers/Kconfig | 2 ++ xen/drivers/Makefile | 1 + xen/drivers/vuart/Kconfig | 14 ++++++++++++++ xen/drivers/vuart/Makefile | 1 + .../arm/vpl011.c => drivers/vuart/vuart-pl011.c} | 0 7 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 xen/drivers/vuart/Kconfig create mode 100644 xen/drivers/vuart/Makefile rename xen/{arch/arm/vpl011.c => drivers/vuart/vuart-pl011.c} (100%)Quoted 3 lines
I question the placement under
drivers/. To me, driver != emulator. I wonder what others think. But yes, we already havedrivers/vpci/. That may want moving then ...re: driver != emulator: I agree; but I followed
drivers/vpci.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Do you think common/vuart would be a better location?
Or maybe common/emul/... This wants discussing, I think.
Will something like the following work
common/hvm/vuart
?
Not really, emulators may not be limited to HVM. But iirc common/emul/ is what we settled on anyway at the last Community Call?
Jan
Re: [PATCH v1 13/16] drivers/vuart: move PL011 emulator code
Quoted 33 lines · Jan Beulich
Quoted 32 lines · On 10.07.2025 03:59, [email protected] wrote:
Quoted 31 lines · Jan Beulich
Quoted 29 lines · On 24.06.2025 09:31, [email protected] wrote:
Quoted 21 lines · Jan Beulich
Quoted 7 lines · On 24.06.2025 05:56, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Move PL011 emulator to the new location for UART emulators.
No functional change intended.
Signed-off-by Denis Mukhin <[email protected]>Quoted 12 lines
--- xen/arch/arm/Kconfig | 7 ------- xen/arch/arm/Makefile | 1 - xen/drivers/Kconfig | 2 ++ xen/drivers/Makefile | 1 + xen/drivers/vuart/Kconfig | 14 ++++++++++++++ xen/drivers/vuart/Makefile | 1 + .../arm/vpl011.c => drivers/vuart/vuart-pl011.c} | 0 7 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 xen/drivers/vuart/Kconfig create mode 100644 xen/drivers/vuart/Makefile rename xen/{arch/arm/vpl011.c => drivers/vuart/vuart-pl011.c} (100%)Quoted 3 lines
I question the placement under
drivers/. To me, driver != emulator. I wonder what others think. But yes, we already havedrivers/vpci/. That may want moving then ...re: driver != emulator: I agree; but I followed
drivers/vpci.Do you think common/vuart would be a better location?
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Or maybe common/emul/... This wants discussing, I think.
Will something like the following work
common/hvm/vuart
?Not really, emulators may not be limited to HVM. But iirc common/emul/ is what we settled on anyway at the last Community Call?
Yes, that is what I recall as well
Re: [PATCH v1 13/16] drivers/vuart: move PL011 emulator code
Quoted 36 lines · Stefano Stabellini
Quoted 35 lines · Jan Beulich
Quoted 34 lines · On 10.07.2025 03:59, [email protected] wrote:
Quoted 32 lines · Jan Beulich
Quoted 22 lines · On 24.06.2025 09:31, [email protected] wrote:
Quoted 21 lines · Jan Beulich
Quoted 19 lines · On 24.06.2025 05:56, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Move PL011 emulator to the new location for UART emulators.
No functional change intended.
Signed-off-by Denis Mukhin <[email protected]>--- xen/arch/arm/Kconfig | 7 ------- xen/arch/arm/Makefile | 1 - xen/drivers/Kconfig | 2 ++ xen/drivers/Makefile | 1 + xen/drivers/vuart/Kconfig | 14 ++++++++++++++ xen/drivers/vuart/Makefile | 1 + .../arm/vpl011.c => drivers/vuart/vuart-pl011.c} | 0 7 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 xen/drivers/vuart/Kconfig create mode 100644 xen/drivers/vuart/Makefile rename xen/{arch/arm/vpl011.c => drivers/vuart/vuart-pl011.c} (100%)Quoted 7 lines
Quoted 3 lines
I question the placement under
drivers/. To me, driver != emulator. I wonder what others think. But yes, we already havedrivers/vpci/. That may want moving then ...re: driver != emulator: I agree; but I followed
drivers/vpci.Do you think common/vuart would be a better location?
Or maybe common/emul/... This wants discussing, I think.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Will something like the following work
common/hvm/vuart
?Not really, emulators may not be limited to HVM. But iirc common/emul/ is what we settled on anyway at the last Community Call?
Yes, that is what I recall as well
Ack, will use common/emul/
Re: [PATCH v1 13/16] drivers/vuart: move PL011 emulator code
In reply to Jan BeulichQuoted 33 lines · Jan Beulich
Quoted 32 lines · On 10.07.2025 03:59, [email protected] wrote:
Quoted 31 lines · Jan Beulich
Quoted 29 lines · On 24.06.2025 09:31, [email protected] wrote:
Quoted 21 lines · Jan Beulich
Quoted 7 lines · On 24.06.2025 05:56, [email protected] wrote:
From: Denis Mukhin <[email protected]>
Move PL011 emulator to the new location for UART emulators.
No functional change intended.
Signed-off-by Denis Mukhin <[email protected]>Quoted 12 lines
--- xen/arch/arm/Kconfig | 7 ------- xen/arch/arm/Makefile | 1 - xen/drivers/Kconfig | 2 ++ xen/drivers/Makefile | 1 + xen/drivers/vuart/Kconfig | 14 ++++++++++++++ xen/drivers/vuart/Makefile | 1 + .../arm/vpl011.c => drivers/vuart/vuart-pl011.c} | 0 7 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 xen/drivers/vuart/Kconfig create mode 100644 xen/drivers/vuart/Makefile rename xen/{arch/arm/vpl011.c => drivers/vuart/vuart-pl011.c} (100%)Quoted 3 lines
I question the placement under
drivers/. To me, driver != emulator. I wonder what others think. But yes, we already havedrivers/vpci/. That may want moving then ...re: driver != emulator: I agree; but I followed
drivers/vpci.Do you think common/vuart would be a better location?
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Or maybe common/emul/... This wants discussing, I think.
Will something like the following work
common/hvm/vuart
?Not really, emulators may not be limited to HVM. But iirc common/emul/ is what we settled on anyway at the last Community Call?
Sorry, I missed today's call, did not know about the decision.
Quoted 3 lines
Jan
PATCH 14/16 drivers/vuart: move simple MMIO-based UART emulator
In reply to [email protected]From: Denis Mukhin <[email protected]>
Move simple MMIO-based UART emulator under drivers/vuart and rename it to vuart-mmio.c to keep "vuart" for the vUART framework.
No functional change intended.
---
xen/arch/arm/Kconfig | 8 --------
xen/arch/arm/Makefile | 1 -
xen/drivers/vuart/Kconfig | 9 +++++++++
xen/drivers/vuart/Makefile | 1 +
xen/{arch/arm/vuart.c => drivers/vuart/vuart-mmio.c} | 0
5 files changed, 10 insertions(+), 9 deletions(-)
rename xen/{arch/arm/vuart.c => drivers/vuart/vuart-mmio.c} (100%)xen/arch/arm/Kconfig +0 -8
@@ -170,14 +170,6 @@ config NEW_VGIC problems with the standard emulation. At the moment this implementation is not security supported. -config HAS_VUART_MMIO - bool "Emulated UART for hardware domain" - default y - help - Allows a hardware domain to use a minimalistic UART (single transmit - and status register) which takes information from dtuart. Note that this - UART is not intended to be exposed (e.g. via device-tree) to a domain. - config ARM_SSBD bool "Speculative Store Bypass Disable" if EXPERT depends on HAS_ALTERNATIVE
xen/arch/arm/Makefile +0 -1
@@ -67,7 +67,6 @@ obj-$(CONFIG_VM_EVENT) += vm_event.o obj-y += vtimer.o obj-y += vsmc.o obj-y += vpsci.o -obj-$(CONFIG_HAS_VUART_MMIO) += vuart.o extra-y += xen.lds
xen/drivers/vuart/Kconfig +9 -0
@@ -3,6 +3,15 @@ config HAS_VUART if (ARM_32 || ARM_64) +config HAS_VUART_MMIO + bool "Simple MMIO-based emulated UART support" + default y + select HAS_VUART + help + Enables minimalistic UART (single transmit and status register) which + takes information from dtuart. Note that this UART is not intended to + be exposed (e.g. via device-tree) to a domain. + config HAS_VUART_PL011 bool "Emulated PL011 UART support" default y
xen/drivers/vuart/Makefile +1 -0
@@ -1 +1,2 @@ +obj-$(CONFIG_HAS_VUART_MMIO) += vuart-mmio.o obj-$(CONFIG_HAS_VUART_PL011) += vuart-pl011.o
xen/drivers/vuart/vuart-mmio.c renamed from xen/arch/arm/vuart.c +0 -0
Signature · 1 line
2.34.1
Re: [PATCH v1 14/16] drivers/vuart: move simple MMIO-based UART emulator
xen/drivers/vuart/Kconfig config HAS_VUART · line 7
Quoted 8 lines · On 24.06.2025 05:57, [email protected] wrote:
xen/drivers/vuart/Kconfig +2
-0@@ -3,6 +3,15 @@ config HAS_VUART if (ARM_32 || ARM_64) +config HAS_VUART_MMIO + bool "Simple MMIO-based emulated UART support"
Perhaps in a separate change this should be renamed. HAS_* should never have prompts.
xen/drivers/vuart/Kconfig config HAS_VUART · line 9
Quoted 2 lines
xen/drivers/vuart/Kconfig +2
-0+ default y + select HAS_VUART
This is questionable too (for still being controlled by a prompt), but may need to remain as is.
Jan
Re: [PATCH v1 14/16] drivers/vuart: move simple MMIO-based UART emulator
Quoted 5 lines · Jan Beulich
Quoted 4 lines · On 24.06.2025 05:57, [email protected] wrote:
xen/drivers/vuart/Kconfig +0
-0@@ -3,6 +3,15 @@ config HAS_VUART
Quoted 7 lines
xen/drivers/vuart/Kconfig config HAS_VUART · line 7
Quoted 4 lines
xen/drivers/vuart/Kconfig +2
-0if (ARM_32 || ARM_64) +config HAS_VUART_MMIO + bool "Simple MMIO-based emulated UART support"Perhaps in a separate change this should be renamed. HAS_* should never have prompts.
Oh, so HAS_ flags are non-interactive selectors by design? I did not find explanation in the docs :-/
Can you please explain?
(and I will add a note to docs for that)
Quoted 8 lines
xen/drivers/vuart/Kconfig config HAS_VUART · line 9
Quoted 3 lines
xen/drivers/vuart/Kconfig +2
-0+ default y + select HAS_VUARTThis is questionable too (for still being controlled by a prompt), but may need to remain as is.
Jan
Re: [PATCH v1 14/16] drivers/vuart: move simple MMIO-based UART emulator
Quoted 8 lines · On 24.06.2025 09:36, [email protected] wrote:
Quoted 7 lines · Jan Beulich
Quoted 6 lines · On 24.06.2025 05:57, [email protected] wrote:
xen/drivers/vuart/Kconfig +0
-0@@ -3,6 +3,15 @@ config HAS_VUART if (ARM_32 || ARM_64)
Quoted 7 lines
Quoted 5 lines
xen/drivers/vuart/Kconfig config HAS_VUART · line 7
Quoted 2 lines
xen/drivers/vuart/Kconfig +2
-0+config HAS_VUART_MMIO + bool "Simple MMIO-based emulated UART support"Perhaps in a separate change this should be renamed. HAS_* should never have prompts.
Oh, so
HAS_flags are non-interactive selectors by design?
Well "has" simply by the word means "this is available". Any user-selectable item deriving from the mere availability would then have a "depends on HAS_...", thus hiding the option in situation where the functionality isn't available (be it per arch or for other reasons).
Jan
Re: [PATCH v1 14/16] drivers/vuart: move simple MMIO-based UART emulator
Quoted 15 lines · Jan Beulich
Quoted 14 lines · On 24.06.2025 09:36, [email protected] wrote:
Quoted 12 lines · Jan Beulich
xen/drivers/vuart/Kconfig config HAS_VUART · line 7
Quoted 8 lines · On 24.06.2025 05:57, [email protected] wrote:
xen/drivers/vuart/Kconfig +2
-0@@ -3,6 +3,15 @@ config HAS_VUART if (ARM_32 || ARM_64) +config HAS_VUART_MMIO + bool "Simple MMIO-based emulated UART support"Perhaps in a separate change this should be renamed. HAS_* should never have prompts.
Quoted 6 lines
Quoted 1 line
Oh, so
HAS_flags are non-interactive selectors by design?Well "has" simply by the word means "this is available". Any user-selectable item deriving from the mere availability would then have a "depends on
HAS_...", thus hiding the option in situation where the functionality isn't available (be it per arch or for other reasons).
I see there's a lot of drivers (UARTs) which are selectable by the user via HAS_ symbols (drivers/char/Kconfig), e.g:
CONFIG_HAS_NS16550: │ │ │ │ This selects the 16550-series UART support. For most systems, say Y. │ │ │ │ Symbol: HAS_NS16550 [=y] │ │ Type : bool │ │ Prompt: NS16550 UART driver │ │ Location: │ │ -> Device Drivers │ │ Defined at drivers/char/Kconfig:4
Quoted 2 lines
Jan
Re: [PATCH v1 14/16] drivers/vuart: move simple MMIO-based UART emulator
Quoted 23 lines · On 25.06.2025 00:54, [email protected] wrote:
Quoted 15 lines · Jan Beulich
Quoted 14 lines · On 24.06.2025 09:36, [email protected] wrote:
Quoted 12 lines · Jan Beulich
xen/drivers/vuart/Kconfig config HAS_VUART · line 7
Quoted 8 lines · On 24.06.2025 05:57, [email protected] wrote:
xen/drivers/vuart/Kconfig +2
-0@@ -3,6 +3,15 @@ config HAS_VUART if (ARM_32 || ARM_64) +config HAS_VUART_MMIO + bool "Simple MMIO-based emulated UART support"Perhaps in a separate change this should be renamed. HAS_* should never have prompts.
Quoted 6 lines
Quoted 1 line
Oh, so
HAS_flags are non-interactive selectors by design?Well "has" simply by the word means "this is available". Any user-selectable item deriving from the mere availability would then have a "depends on
HAS_...", thus hiding the option in situation where the functionality isn't available (be it per arch or for other reasons).
Quoted 4 lines
I see there's a lot of drivers (UARTs) which are selectable by the user via
HAS_symbols (drivers/char/Kconfig), e.g:
CONFIG_HAS_NS16550:
Iirc it was prompt-less up to some point. And when the prompt was added, the name wasn't changed / split. Other UARTs then followed suit (when they shouldn't have).
Jan
Re: [PATCH v1 14/16] drivers/vuart: move simple MMIO-based UART emulator
Quoted 24 lines · Jan Beulich
Quoted 23 lines · On 25.06.2025 00:54, [email protected] wrote:
Quoted 21 lines · Jan Beulich
Quoted 8 lines · On 24.06.2025 09:36, [email protected] wrote:
Quoted 7 lines · Jan Beulich
Quoted 6 lines · On 24.06.2025 05:57, [email protected] wrote:
xen/drivers/vuart/Kconfig +0
-0@@ -3,6 +3,15 @@ config HAS_VUART if (ARM_32 || ARM_64)Quoted 7 lines
Quoted 5 lines
xen/drivers/vuart/Kconfig config HAS_VUART · line 7
Quoted 2 lines
xen/drivers/vuart/Kconfig +2
-0+config HAS_VUART_MMIO + bool "Simple MMIO-based emulated UART support"Perhaps in a separate change this should be renamed. HAS_* should never have prompts.
Oh, so
HAS_flags are non-interactive selectors by design?Well "has" simply by the word means "this is available". Any user-selectable item deriving from the mere availability would then have a "depends on
HAS_...", thus hiding the option in situation where the functionality isn't available (be it per arch or for other reasons).
Quoted 7 lines
Quoted 4 lines
I see there's a lot of drivers (UARTs) which are selectable by the user via
HAS_symbols (drivers/char/Kconfig), e.g:
CONFIG_HAS_NS16550:Iirc it was prompt-less up to some point. And when the prompt was added, the name wasn't changed / split. Other UARTs then followed suit (when they shouldn't have).
I can submit a separate patch to address the naming, if there are no objections.
Quoted 3 lines
Jan
PATCH 15/16 drivers/vuart: introduce framework for UART emulators
In reply to [email protected]From: Denis Mukhin <[email protected]>
Introduce a driver framework to abstract UART emulators in the hypervisor.
That allows for architecture-independent handling of virtual UARTs in the console driver and simplifies enabling new UART emulators.
The framework is built under CONFIG_HAS_VUART, which is automatically enabled once the user enables any UART emulator.
Current implementation supports maximum of one vUART of each kind per domain.
All domains with enabled virtual PL011 will have DOMAIN_EMU_UART_PL011 bit set in d->arch.emulation_flags. Introduce domain_has_vuart() in arch code to check whether domain has virtual UART.
Use domain_has_vuart() in the console driver code to check whether to forward console input to the domain using vUART.
Hook existing PL011 UART emulator to the new driver framework.
---
Original code: https://lore.kernel.org/xen-devel/[email protected]/
--- xen/arch/arm/dom0less-build.c | 22 +++---- xen/arch/arm/domctl.c | 3 +- xen/arch/arm/include/asm/domain.h | 1 + xen/arch/arm/include/asm/kernel.h | 3 - xen/arch/arm/xen.lds.S | 1 + xen/arch/ppc/include/asm/domain.h | 1 + xen/arch/ppc/xen.lds.S | 1 + xen/arch/riscv/include/asm/domain.h | 1 + xen/arch/riscv/xen.lds.S | 1 + xen/arch/x86/xen.lds.S | 1 + xen/common/domain.c | 10 +++ xen/common/keyhandler.c | 3 + xen/drivers/char/console.c | 5 +- xen/drivers/vuart/Makefile | 1 + xen/drivers/vuart/vuart-pl011.c | 71 +++++++++++++++++++-- xen/drivers/vuart/vuart.c | 95 +++++++++++++++++++++++++++++ xen/include/xen/domain-emu.h | 2 + xen/include/xen/domain.h | 2 + xen/include/xen/vuart.h | 25 ++++++-- xen/include/xen/xen.lds.h | 10 +++ 20 files changed, 227 insertions(+), 32 deletions(-) create mode 100644 xen/drivers/vuart/vuart.c
xen/arch/arm/dom0less-build.c +7 -15
@@ -176,14 +176,9 @@ int __init make_arch_nodes(struct kernel_info *kinfo)if ( ret )return -EINVAL ; -if ( kinfo->arch.vpl011 ) - { -#ifdef CONFIG_HAS_VUART_PL011 - ret =vuart_add_fwnode (kinfo->d, kinfo); -#endif -if ( ret ) -return -EINVAL ; - } + ret =vuart_add_fwnode (kinfo->d, kinfo); +if ( ret ) +return ret;return 0 ; }
@@ -207,19 +202,16 @@ int __init init_vuart(struct domain *d, struct kernel_info *kinfo, {int rc =0 ; - kinfo->arch.vpl011 =dt_property_read_bool (node,"vpl011" ); -/* * Base address and irq number are needed when creating vpl011 device * tree node in prepare_dtb_domU, so initialization on related variables * shall be done first. */ -if ( kinfo->arch.vpl011 ) - { +if (dt_property_read_bool (node,"vpl011" ) ) + d->emulation_flags |=DOMAIN_EMU_UART_PL011 ; + +if (domain_has_vuart (d) ) rc =vuart_init (d,NULL ); -if ( rc <0 ) -return rc; - }return rc; }
xen/arch/arm/domctl.c +2 -1
@@ -43,8 +43,9 @@ static int handle_vuart_init(struct domain *d,if ( vuart_op->type !=XEN_DOMCTL_VUART_TYPE_VPL011 )return -EOPNOTSUPP ; - rc =vuart_init (d, ¶ms); + d->emulation_flags |=DOMAIN_EMU_UART_PL011 ; + rc =vuart_init (d, ¶ms);if ( !rc ) vuart_op->evtchn = params.evtchn;
xen/arch/arm/include/asm/domain.h +1 -0
@@ -2,6 +2,7 @@#define __ASM_DOMAIN_H__#include <xen/cache.h> +#include <xen/domain-emu.h> #include <xen/timer.h> #include <asm/page.h> #include <asm/p2m.h>
xen/arch/arm/include/asm/kernel.h +0 -3
@@ -13,9 +13,6 @@ struct arch_kernel_info#ifdef CONFIG_ARM_64 enum domain_type type; #endif - -/* Enable pl011 emulation */ - bool vpl011; };#endif /* #ifdef __ARCH_ARM_KERNEL_H__ */
xen/arch/arm/xen.lds.S +1 -0
@@ -66,6 +66,7 @@ SECTIONS __proc_info_end = .; VPCI_ARRAY + VUART_ARRAY } :text #if defined(BUILD_ID)
xen/arch/ppc/include/asm/domain.h +1 -0
@@ -2,6 +2,7 @@#ifndef __ASM_PPC_DOMAIN_H__#define __ASM_PPC_DOMAIN_H__ +#include <xen/domain-emu.h> #include <xen/xmalloc.h> #include <public/hvm/params.h>
xen/arch/ppc/xen.lds.S +1 -0
@@ -55,6 +55,7 @@ SECTIONS *(.data.rel.ro.*) VPCI_ARRAY + VUART_ARRAY . = ALIGN(POINTER_ALIGN); } :text
xen/arch/riscv/include/asm/domain.h +1 -0
@@ -2,6 +2,7 @@#ifndef ASM__RISCV__DOMAIN_H #define ASM__RISCV__DOMAIN_H +#include <xen/domain-emu.h> #include <xen/xmalloc.h> #include <public/hvm/params.h>
xen/arch/riscv/xen.lds.S +1 -0
@@ -50,6 +50,7 @@ SECTIONS *(.data.rel.ro.*) VPCI_ARRAY + VUART_ARRAY . = ALIGN(POINTER_ALIGN); } :text
xen/arch/x86/xen.lds.S +1 -0
@@ -149,6 +149,7 @@ SECTIONS __note_gnu_build_id_end = .; #endif VPCI_ARRAY + VUART_ARRAY } PHDR(text) #if defined(CONFIG_PVH_GUEST) && !defined(EFI)
xen/common/domain.c +10 -0
@@ -2436,6 +2436,16 @@ void thaw_domains(void)rcu_read_unlock (&domlist_read_lock); } +bool domain_has_vuart (const struct domain *d) +{ +uint32_t mask =0 ; + +if (IS_ENABLED (CONFIG_HAS_VUART_PL011 ) ) + mask |=DOMAIN_EMU_UART_PL011 ; + +return !!(d->emulation_flags & mask); +} +/* * Local variables: * mode: C
xen/common/keyhandler.c +3 -0
@@ -22,6 +22,7 @@#include <xen/mm.h> #include <xen/watchdog.h> #include <xen/init.h> +#include <xen/vuart.h> #include <asm/div64.h> static unsigned char keypress_key;
@@ -354,6 +355,8 @@ static void cf_check dump_domains(unsigned char key) v->periodic_period / 1000000); } } + +vuart_dump (d); }for_each_domain ( d )
xen/drivers/char/console.c +2 -3
@@ -594,6 +594,7 @@ static void __serial_rx(char c)/* * Deliver input to the hardware domain buffer, unless it is * already full. +* NB: must be the first check: hardware domain may have emulated UART. */ if ( (serial_rx_prod - serial_rx_cons) !=SERIAL_RX_SIZE ) serial_rx_ring[SERIAL_RX_MASK (serial_rx_prod++)] = c;
@@ -604,11 +605,9 @@ static void __serial_rx(char c)*/ send_global_virq (VIRQ_CONSOLE ); } -#ifdef CONFIG_HAS_VUART_PL011 - else +else if (domain_has_vuart (d) )/* Deliver input to the emulated UART. */ rc =vuart_putchar (d, c); -#endif if (consoled_is_enabled () )/* Deliver input to the PV shim console. */
xen/drivers/vuart/Makefile +1 -0
@@ -1,2 +1,3 @@ +obj-$(CONFIG_HAS_VUART) += vuart.o obj-$(CONFIG_HAS_VUART_MMIO) += vuart-mmio.o obj-$(CONFIG_HAS_VUART_PL011) += vuart-pl011.o
xen/drivers/vuart/vuart-pl011.c +65 -6
103 lines not on this page · raw message
xen/drivers/vuart/vuart.c new file +95 -0
95 lines not on this page · raw message
xen/include/xen/domain-emu.h +2 -0
@@ -17,6 +17,8 @@#define DOMAIN_EMU_PIRQ (1U << 9)#define DOMAIN_EMU_PCI (1U << 10) +#define DOMAIN_EMU_UART_PL011 (1U << 15) +#endif /* XEN_DOMAIN_EMU_H */ /*
xen/include/xen/domain.h +2 -0
@@ -59,6 +59,8 @@ domid_t get_initial_domain_id(void);#define is_domain_direct_mapped (d) ((d)->cdf & CDF_directmap)#define is_domain_using_staticmem (d) ((d)->cdf & CDF_staticmem) +bool domain_has_vuart (const struct domain *d); +/* * Arch-specifics. */
xen/include/xen/vuart.h +21 -4
@@ -12,16 +12,29 @@ struct vuart_params {evtchn_port_t evtchn; }; -#ifdef CONFIG_HAS_VUART_PL011 +struct vuart_ops { +int (*add_fwnode)(struct domain *d,void *node); +int (*init)(struct domain *d,struct vuart_params *params); +void (*exit)(struct domain *d); +void (*dump)(const struct domain *d); +int (*putchar)(struct domain *d,char c); +}; -int __init vuart_add_fwnode (struct domain *d,void *node); +#define VUART_REGISTER (name, x) \ + static const struct vuart_ops *const __name##_entry \ + __used_section(".data.vuart." #name) = (x); + +#ifdef CONFIG_HAS_VUART + +int vuart_add_fwnode (struct domain *d,void *node);int vuart_init (struct domain *d,struct vuart_params *params);void vuart_exit (struct domain *d); +void vuart_dump (const struct domain *d);int vuart_putchar (struct domain *d,char c);#else -static inline int __init vuart_add_fwnode (struct domain *d,void *node) +static inline int vuart_add_fwnode (struct domain *d,void *node) {return 0 ; }
@@ -35,13 +48,17 @@ static inline void vuart_exit(struct domain *d) { } +static inline void vuart_dump (const struct domain *d) +{ +} +static inline int vuart_putchar (struct domain *d,char c) {ASSERT_UNREACHABLE ();return -ENODEV ; } -#endif /* CONFIG_HAS_VUART_PL011 */ +#endif /* CONFIG_HAS_VUART */ #ifdef CONFIG_HAS_VUART_MMIO
xen/include/xen/xen.lds.h +10 -0
@@ -194,4 +194,14 @@#define VPCI_ARRAY #endif +#ifdef CONFIG_HAS_VUART +#define VUART_ARRAY \ + . = ALIGN(POINTER_ALIGN); \ + __vuart_array_start = .; \ + *(SORT(.data.vuart.*)) \ + __vuart_array_end = .; +#else +#define VUART_ARRAY +#endif +#endif /* __XEN_LDS_H__ */
Signature · 1 line
2.34.1
PATCH 16/16 drivers/vuart: hook simple MMIO-based UART to vUART framework
In reply to [email protected]From: Denis Mukhin <[email protected]>
Add new emulation flag DOMAIN_EMU_UART_MMIO and add it to domain_has_vuart().
Add needed shims for vuart framework integration to MMIO-based UART emulator.
Remove domain_vuart_{init,free}() and use generic vuart_{init,exit}() calls.
No functional change intended.
--- xen/arch/arm/domain.c | 7 +++++-- xen/common/domain.c | 3 +++ xen/drivers/vuart/vuart-mmio.c | 36 ++++++++++++++++++++++++++++++++-- xen/include/xen/domain-emu.h | 1 + xen/include/xen/vuart.h | 20 ------------------- 5 files changed, 43 insertions(+), 24 deletions(-)
xen/arch/arm/domain.c +5 -2
@@ -780,7 +780,10 @@ int arch_domain_create(struct domain *d,* Only use it for the hardware domain because the linux kernel may not * support multi-platform. */ -if (is_hardware_domain (d) && (rc =domain_vuart_init (d)) ) +if (is_hardware_domain (d) &&IS_ENABLED (CONFIG_HAS_VUART_MMIO ) ) + d->emulation_flags |=DOMAIN_EMU_UART_MMIO ; + +if (domain_has_vuart (d) && (rc =vuart_init (d,NULL )) !=0 ) goto fail;if ( (rc =domain_vpci_init (d)) !=0 )
@@ -849,7 +852,7 @@ void arch_domain_destroy(struct domain *d)iommu_domain_destroy (d);p2m_final_teardown (d);domain_vgic_free (d); -domain_vuart_free (d); +vuart_exit (d);free_xenheap_page (d->shared_info);#ifdef CONFIG_ACPI free_xenheap_pages(d->arch.efi_acpi_table,
xen/common/domain.c +3 -0
@@ -2443,6 +2443,9 @@ bool domain_has_vuart(const struct domain *d)if (IS_ENABLED (CONFIG_HAS_VUART_PL011 ) ) mask |=DOMAIN_EMU_UART_PL011 ; +if (IS_ENABLED (CONFIG_HAS_VUART_MMIO ) ) + mask |=DOMAIN_EMU_UART_MMIO ; +return !!(d->emulation_flags & mask); }
xen/drivers/vuart/vuart-mmio.c +34 -2
@@ -49,7 +49,7 @@ static const struct mmio_handler_ops vuart_mmio_handler = { .write = vuart_mmio_write, }; -int domain_vuart_init (struct domain *d) +static int cf_check vuart_mmio_init(struct domain *d, struct vuart_params *params) {const struct vuart_info *info;struct vuart *vdev;
@@ -86,7 +86,7 @@ int domain_vuart_init(struct domain *d)return 0 ; } -void domain_vuart_free (struct domain *d) +static void cf_check vuart_mmio_exit(struct domain *d) {struct vuart *vdev = d->arch.vuart;
@@ -147,6 +147,38 @@ static int vuart_mmio_write(struct vcpu *v, mmio_info_t *info,return 1 ; } +static void cf_check vuart_mmio_dump(const struct domain *d) +{ +struct vuart *vdev = d->arch.vuart; + +if ( !vdev ) +return ; + +/* Allow printing state in case of a deadlock. */ +if ( !spin_trylock (&vdev->lock) ) +return ; + +printk ("Virtual MMIO UART@%" PRIpaddr" owner %pd\n" , + vdev->info->base_addr, d); +printk (" RX FIFO size %u idx %u\n" , +VUART_BUF_SIZE , vdev->idx); +printk (" status 0x%lx 0x%lx\n" , + vdev->info->status_off, vdev->info->status); + +spin_unlock (&vdev->lock); +} + +static const struct vuart_ops vuart_mmio_ops = { + .add_fwnode =NULL , + .init = vuart_mmio_init, + .exit = vuart_mmio_exit, + .dump = vuart_mmio_dump, +/* Physical console focus is not supported */ + .putchar =NULL , +}; + +VUART_REGISTER (mmio, &vuart_mmio_ops); +/* * Local variables: * mode: C
xen/include/xen/domain-emu.h +1 -0
@@ -18,6 +18,7 @@#define DOMAIN_EMU_PCI (1U << 10)#define DOMAIN_EMU_UART_PL011 (1U << 15) +#define DOMAIN_EMU_UART_MMIO (1U << 16)#endif /* XEN_DOMAIN_EMU_H */
xen/include/xen/vuart.h +0 -20
@@ -60,26 +60,6 @@ static inline int vuart_putchar(struct domain *d, char c)#endif /* CONFIG_HAS_VUART */ -#ifdef CONFIG_HAS_VUART_MMIO - -int domain_vuart_init (struct domain *d); -void domain_vuart_free (struct domain *d); - -#else - -static inline int domain_vuart_init (struct domain *d) -{ -/* -* The vUART is unconditionally inialized for the hw domain. So we -* can't return an error. -*/ -return 0 ; -} - -static inline void domain_vuart_free (struct domain *d) {}; - -#endif /* CONFIG_HAS_VUART_MMIO */ -#endif /* XEN_VUART_H */ /*
Signature · 1 line
2.34.1