From nobody Fri Oct 31 03:39:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1750737334; cv=none; d=zohomail.com; s=zohoarc; b=Cq/vEfrrsOjLZMji9qWcKYGz6FoKQVmBL8R1ipc3jW9J/K05497G5DUfkS11Ulj7A+vrst7MzsK1rN4XDxhDqdRDZH7XHQDOiTB/1Ih8uUW3QOpOUb46NgCf/UiiQu2OIdu9x5236/eNbOzAEqNthbSREGBUE3A2UCFuepYtwkA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750737334; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yCudMdFYgoXw08jE2y4zALqq0ZHl0jnLUlz0092mkm0=; b=X2uDt1+GaE4FF1AE7LReLs6yc7NLKQQG0IWozOFKbBnc9EO6YA7nfhqk/hH4fW9iwJss0tzELb/TBlxRvjNaxPxxfrPOj08gZ9I2hI19j3mTW/YKGrgDzYZaT43m7oWo81+9CzAxAYwJfTDjm+YkpFBL1Awg8oJLvvIXmWd1JIs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1750737334100201.89040699798124; Mon, 23 Jun 2025 20:55:34 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1022909.1398773 (Exim 4.92) (envelope-from ) id 1uTuke-0006JI-Ef; Tue, 24 Jun 2025 03:55:16 +0000 Received: by outflank-mailman (output) from mailman id 1022909.1398773; Tue, 24 Jun 2025 03:55:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTuke-0006JB-Bo; Tue, 24 Jun 2025 03:55:16 +0000 Received: by outflank-mailman (input) for mailman id 1022909; Tue, 24 Jun 2025 03:55:14 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTukc-0006IZ-NT for xen-devel@lists.xenproject.org; Tue, 24 Jun 2025 03:55:14 +0000 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 065924b8-50af-11f0-a30f-13f23c93f187; Tue, 24 Jun 2025 05:55:11 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 065924b8-50af-11f0-a30f-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1750737309; x=1750996509; bh=yCudMdFYgoXw08jE2y4zALqq0ZHl0jnLUlz0092mkm0=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=AENORXkaGdRBMqyIDZm2j2Lx0HCUTLgil2vFuaRYeGKBW/udVYVvpUPY0HMHskM1Z s5Y+IsudnMkiJJOppGB8eDrpfBrPNgCGCM910oiprpKZcEpTx7B9qfI6r4efMJaAlH cJfbBJwNlwj/0fn+WsGqHwncS1vnzRFTQiny3jl5RsB/k+YqQJU/wAPbBXqyB6ho+J oYugEYX1efulWDlpRM10GZSXVpMYIlNCQ9QALVBKCx0nnHjWYxYfAvV9QZu2YEXe3L wm/zBqhMBbwq90XBsp0BJF7eL9Q2Xmn65TUtyGO0TAaJRpGXguP/G2QunjQVQAQRZp 4poMtcJYlb5ww== Date: Tue, 24 Jun 2025 03:55:04 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, oleksii.kurochko@gmail.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v1 01/16] arm/vpl011: rename virtual PL011 Kconfig option Message-ID: <20250624035443.344099-2-dmukhin@ford.com> In-Reply-To: <20250624035443.344099-1-dmukhin@ford.com> References: <20250624035443.344099-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: e843f1976d3f637ab52c7c2c4788aa3930d7bf95 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1750737336344116600 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 Rename CONFIG_SBSA_VUART_CONSOLE to CONFIG_HAS_VUART_PL011. No functional change. Signed-off-by: Denis Mukhin --- 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(-) diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 3f25da3ca5fd..03888569f38c 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -170,7 +170,7 @@ config NEW_VGIC problems with the standard emulation. At the moment this implementation is not security supported. =20 -config SBSA_VUART_CONSOLE +config HAS_VUART_PL011 bool "Emulated SBSA UART console support" default y help diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index ab0a0c2be6d8..2d6787fb03bc 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -65,7 +65,7 @@ obj-$(CONFIG_HAS_ITS) +=3D vgic-v3-its.o endif obj-$(CONFIG_VM_EVENT) +=3D vm_event.o obj-y +=3D vtimer.o -obj-$(CONFIG_SBSA_VUART_CONSOLE) +=3D vpl011.o +obj-$(CONFIG_HAS_VUART_PL011) +=3D vpl011.o obj-y +=3D vsmc.o obj-y +=3D vpsci.o obj-$(CONFIG_HWDOM_VUART) +=3D vuart.o diff --git a/xen/arch/arm/configs/tiny64_defconfig b/xen/arch/arm/configs/t= iny64_defconfig index 469a1eb9f99d..acc227262d81 100644 --- a/xen/arch/arm/configs/tiny64_defconfig +++ b/xen/arch/arm/configs/tiny64_defconfig @@ -6,7 +6,7 @@ CONFIG_ARM=3Dy # # 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 =20 # # Common Features diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 4b285cff5ee2..2a5531a2b892 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -167,7 +167,7 @@ int __init make_intc_domU_node(struct kernel_info *kinf= o) } } =20 -#ifdef CONFIG_SBSA_VUART_CONSOLE +#ifdef CONFIG_HAS_VUART_PL011 static int __init make_vpl011_uart_node(struct kernel_info *kinfo) { void *fdt =3D kinfo->fdt; @@ -226,7 +226,7 @@ int __init make_arch_nodes(struct kernel_info *kinfo) =20 if ( kinfo->arch.vpl011 ) { -#ifdef CONFIG_SBSA_VUART_CONSOLE +#ifdef CONFIG_HAS_VUART_PL011 ret =3D make_vpl011_uart_node(kinfo); #endif if ( ret ) diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/d= omain.h index a3487ca71303..746ea687d523 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -113,7 +113,7 @@ struct arch_domain uint8_t privileged_call_enabled : 1; } monitor; =20 -#ifdef CONFIG_SBSA_VUART_CONSOLE +#ifdef CONFIG_HAS_VUART_PL011 struct vpl011 vpl011; #endif =20 diff --git a/xen/arch/arm/include/asm/vpl011.h b/xen/arch/arm/include/asm/v= pl011.h index cc838682815c..be64883b8628 100644 --- a/xen/arch/arm/include/asm/vpl011.h +++ b/xen/arch/arm/include/asm/vpl011.h @@ -65,7 +65,7 @@ struct vpl011_init_info { evtchn_port_t evtchn; }; =20 -#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); diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 5879e31786ba..0f37badc471e 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -37,7 +37,7 @@ #ifdef CONFIG_X86 #include #endif -#ifdef CONFIG_SBSA_VUART_CONSOLE +#ifdef CONFIG_HAS_VUART_PL011 #include #endif =20 @@ -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 =3D vpl011_rx_char_xen(d, c); --=20 2.34.1 From nobody Fri Oct 31 03:39:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1750737335; cv=none; d=zohomail.com; s=zohoarc; b=iItuZEFvIBFfXlwr2DLrcl1BoW0rufuM+Gdv5gKVypzlDwMSETneYLokaoS06DhqMwXzvc6Abo3Uyui40wjc7XlY02dN9vfvKJVwqyh16zqwX2RQw1nXOU9jLyWcKrQaElKxBMU5k3E2YUIY+9Tkc3DiZxQ6q+QIJDAq4oOCofg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750737335; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fU+A+CPMQ76T5nM/3fv4rEH7OqjnjtaOzr8CFYG64PM=; b=iHVXfiIfnRP2dReuwEhCcEeFkC/QRjxKpqj9vEOR/lMIvaccZQbpawCkjSQJDxvXmmKL5b+Qmk3rlTQ2xQCAav7Xggr1NwbcE4/PYL0SQfv5e+f18kEtGfB+LyGC5NxlWNet+aDgtLTVgESTCat3qXJuscf4/hLuWXceyEQsbSw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1750737335646664.4098496153508; Mon, 23 Jun 2025 20:55:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1022910.1398783 (Exim 4.92) (envelope-from ) id 1uTukk-0006as-Lc; Tue, 24 Jun 2025 03:55:22 +0000 Received: by outflank-mailman (output) from mailman id 1022910.1398783; Tue, 24 Jun 2025 03:55:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTukk-0006al-Ic; Tue, 24 Jun 2025 03:55:22 +0000 Received: by outflank-mailman (input) for mailman id 1022910; Tue, 24 Jun 2025 03:55:21 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTukj-000639-9F for xen-devel@lists.xenproject.org; Tue, 24 Jun 2025 03:55:21 +0000 Received: from mail-10630.protonmail.ch (mail-10630.protonmail.ch [79.135.106.30]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0bab80d8-50af-11f0-b894-0df219b8e170; Tue, 24 Jun 2025 05:55:19 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0bab80d8-50af-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1750737317; x=1750996517; bh=fU+A+CPMQ76T5nM/3fv4rEH7OqjnjtaOzr8CFYG64PM=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=a7w3v6wpxPr5LAgXe7c9kHpVKcAvzPEezqByuvtPqrQtTcVfV8JH/y+a3PmDOyKY2 /IGKgkhq6C+hdTiTb6ti4n92Soa/iw7uzkT3rNQv2VZ9UEwBFbjnzAbpNqKQcNhvzJ GnWOgLpNrCeGWMPU50UbkUsePQYKCCJmwi/LDPWFwsN+AoLTDUOxo5/ziIQI3I2C0S fR86bYc7leg2w9/zIDhqE3oF/7IghHcCsak0zPWgzuX2vUXKms0t/Ut5xy1iou8dFB ap7OCeeUdLRI/JRRz0hd5qnz98v/waBJk3uSAwjhPUHAnmRqHz9+Nj/xfo/sN5RGG5 G5pKkHlZSg8Pw== Date: Tue, 24 Jun 2025 03:55:12 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, oleksii.kurochko@gmail.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v1 02/16] arm/vpl011: move DT node parsing to PL011 emulator code Message-ID: <20250624035443.344099-3-dmukhin@ford.com> In-Reply-To: <20250624035443.344099-1-dmukhin@ford.com> References: <20250624035443.344099-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: 0cd9e5aac8ded32fc4e555ba40515db5f5c24244 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1750737336250116600 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 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 funct= ion and place the declaration in the common header in include/xen/vuart.h. No functional change. Signed-off-by: Denis Mukhin --- 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 diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 2a5531a2b892..7c1b59750fb5 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -15,6 +15,7 @@ #include #include #include +#include =20 #include #include @@ -167,55 +168,6 @@ int __init make_intc_domU_node(struct kernel_info *kin= fo) } } =20 -#ifdef CONFIG_HAS_VUART_PL011 -static int __init make_vpl011_uart_node(struct kernel_info *kinfo) -{ - void *fdt =3D kinfo->fdt; - int res; - gic_interrupt_t intr; - __be32 reg[GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS]; - __be32 *cells; - struct domain *d =3D kinfo->d; - - res =3D domain_fdt_begin_node(fdt, "sbsa-uart", d->arch.vpl011.base_ad= dr); - if ( res ) - return res; - - res =3D fdt_property_string(fdt, "compatible", "arm,sbsa-uart"); - if ( res ) - return res; - - cells =3D ®[0]; - dt_child_set_range(&cells, GUEST_ROOT_ADDRESS_CELLS, - GUEST_ROOT_SIZE_CELLS, d->arch.vpl011.base_addr, - GUEST_PL011_SIZE); - - res =3D 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 =3D fdt_property(fdt, "interrupts", intr, sizeof (intr)); - if ( res ) - return res; - - res =3D 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 =3D 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 =3D make_vpl011_uart_node(kinfo); + ret =3D vuart_add_fwnode(kinfo->d, kinfo); #endif if ( ret ) return -EINVAL; diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index 480fc664fc62..cafc532cf028 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -12,15 +12,20 @@ =20 #include #include +#include #include #include #include +#include #include #include #include #include +#include #include #include +#include +#include #include #include #include @@ -784,6 +789,53 @@ void domain_vpl011_deinit(struct domain *d) XFREE(vpl011->backend.xen); } =20 +int __init vuart_add_fwnode(struct domain *d, void *node) +{ + struct kernel_info *kinfo =3D node; + void *fdt =3D kinfo->fdt; + int res; + gic_interrupt_t intr; + __be32 reg[GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS]; + __be32 *cells; + + res =3D domain_fdt_begin_node(fdt, "sbsa-uart", d->arch.vpl011.base_ad= dr); + if ( res ) + return res; + + res =3D fdt_property_string(fdt, "compatible", "arm,sbsa-uart"); + if ( res ) + return res; + + cells =3D ®[0]; + dt_child_set_range(&cells, GUEST_ROOT_ADDRESS_CELLS, + GUEST_ROOT_SIZE_CELLS, d->arch.vpl011.base_addr, + GUEST_PL011_SIZE); + + res =3D 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 =3D fdt_property(fdt, "interrupts", intr, sizeof (intr)); + if ( res ) + return res; + + res =3D 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 =3D fdt_end_node(fdt); + if ( res ) + return res; + + return 0; +} + /* * Local variables: * mode: C diff --git a/xen/include/xen/vuart.h b/xen/include/xen/vuart.h new file mode 100644 index 000000000000..bb883823ea31 --- /dev/null +++ b/xen/include/xen/vuart.h @@ -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: + */ --=20 2.34.1 From nobody Fri Oct 31 03:39:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1750737344; cv=none; d=zohomail.com; s=zohoarc; b=FPSKOqv6wo/Mz074i1jbm/EfV7xdLJ76j47lgoF6oMq2rNQN96feJ1+wGIl4bHvsoFtm1DvPql5IbgIKwINxkiek/+OWEdP8KBM+4Wz8HxFJuJ76SVh9O0z54RaZAk5zSZjH7aP12RtTeJ1l+JpScy7HbY0qTUVyOFCUsBH0B4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750737344; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dPqyJU0mYRSIBJYCmrPsH7iYJx5buk1sy890qmF0Tmw=; b=NV7gk+VopCJEfQf52LJe7J8lcXSDn22bSJMacBLl/Kpoc/eEXrOx7tYnnsbLf2f9DvqChSdFB1wTmzy7A3hV6GAonFZVCMTqipJA6R6GjJ8kuZNTr8KY0oQ2P6FqZrKZZY3Hi7owVm9uHSlS4Xx27No1j2qDwbwgVwqAofyf8bE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1750737344783771.9382616981576; Mon, 23 Jun 2025 20:55:44 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1022915.1398793 (Exim 4.92) (envelope-from ) id 1uTukv-00077T-3w; Tue, 24 Jun 2025 03:55:33 +0000 Received: by outflank-mailman (output) from mailman id 1022915.1398793; Tue, 24 Jun 2025 03:55:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTukv-00077K-0j; Tue, 24 Jun 2025 03:55:33 +0000 Received: by outflank-mailman (input) for mailman id 1022915; Tue, 24 Jun 2025 03:55:32 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTuku-000639-8e for xen-devel@lists.xenproject.org; Tue, 24 Jun 2025 03:55:32 +0000 Received: from mail-24417.protonmail.ch (mail-24417.protonmail.ch [109.224.244.17]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 107216de-50af-11f0-b894-0df219b8e170; Tue, 24 Jun 2025 05:55:27 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 107216de-50af-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=7g7ds4sgnbbihb27j7qq7z4iwq.protonmail; t=1750737326; x=1750996526; bh=dPqyJU0mYRSIBJYCmrPsH7iYJx5buk1sy890qmF0Tmw=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=dvpyMqsUZLPINvEcjflIliFXuDqRJcrcIFmcNj3RMVV7DuwyIOwnnu+Z/rOMJEKN4 b8rTXJ/TJaNkSuXk6TaogyMTjh8AxSzl6pLTnfQGZs4ToQKkwpTLk79ii5kk64asWW 3ekwlv4wz33ItTBn26fwejLk/lDSIkxjOcWOoIFL/r4ds7YE48TJFobUXL59sKQeQc NYg3UzzFbcVEf5C2kvg9KWUuCqdNjqcWRGzNcm0kCL2zUFv4nDVAc22nu+QSvwNONK JxcjhvegN+K6ud4KKrwXHstZfH9ahuRJv5aAC6Wl44bAZWM1JPWPRKKGa04kX+v1Gf cr5PkBy9rQqpQ== Date: Tue, 24 Jun 2025 03:55:22 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, oleksii.kurochko@gmail.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v1 03/16] arm/vpl011: use vuart_ prefix in vpl011 public calls Message-ID: <20250624035443.344099-4-dmukhin@ford.com> In-Reply-To: <20250624035443.344099-1-dmukhin@ford.com> References: <20250624035443.344099-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: 3253eba4e882246fd04bbb7112b4eac0d3f069ba MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1750737346556116600 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 Use generic names prefixed with 'vuart_' in public PL011 emulator data structures and functions. No functional change intended. Signed-off-by: Denis Mukhin --- 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(-) diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 7c1b59750fb5..11b8498d3b22 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -216,7 +216,7 @@ int __init init_vuart(struct domain *d, struct kernel_i= nfo *kinfo, */ if ( kinfo->arch.vpl011 ) { - rc =3D domain_vpl011_init(d, NULL); + rc =3D vuart_init(d, NULL); if ( rc < 0 ) return rc; } @@ -247,7 +247,7 @@ void __init arch_create_domUs(struct dt_device_node *no= de, * 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 ) { diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index be58a23dd725..68297e619bad 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -11,6 +11,7 @@ #include #include #include +#include =20 #include #include @@ -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); =20 #ifdef CONFIG_IOREQ_SERVER ioreq_server_destroy_all(d); diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c index ad914c915f81..dde25ceff6d0 100644 --- a/xen/arch/arm/domctl.c +++ b/xen/arch/arm/domctl.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include =20 @@ -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 =3D vuart_op->console_domid; - info.gfn =3D _gfn(vuart_op->gfn); + struct vuart_params params =3D { + .console_domid =3D vuart_op->console_domid, + .gfn =3D _gfn(vuart_op->gfn), + .evtchn =3D 0, + }; =20 if ( d->creation_finished ) return -EPERM; @@ -41,10 +43,10 @@ static int handle_vuart_init(struct domain *d, if ( vuart_op->type !=3D XEN_DOMCTL_VUART_TYPE_VPL011 ) return -EOPNOTSUPP; =20 - rc =3D domain_vpl011_init(d, &info); + rc =3D vuart_init(d, ¶ms); =20 if ( !rc ) - vuart_op->evtchn =3D info.evtchn; + vuart_op->evtchn =3D params.evtchn; =20 return rc; } diff --git a/xen/arch/arm/include/asm/vpl011.h b/xen/arch/arm/include/asm/v= pl011.h index be64883b8628..5c308cc8c148 100644 --- a/xen/arch/arm/include/asm/vpl011.h +++ b/xen/arch/arm/include/asm/vpl011.h @@ -59,26 +59,6 @@ struct vpl011 { evtchn_port_t evtchn; }; =20 -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_ */ =20 /* diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index cafc532cf028..2cf88a70ecdb 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -134,7 +134,7 @@ static void vpl011_write_data_xen(struct domain *d, uin= t8_t data) =20 /* * 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, } =20 /* - * 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 =3D &d->arch.vpl011; @@ -642,7 +642,7 @@ static void vpl011_notification(struct vcpu *v, unsigne= d int port) VPL011_UNLOCK(d, flags); } =20 -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 =3D &d->arch.vpl011; @@ -694,27 +694,27 @@ int domain_vpl011_init(struct domain *d, struct vpl01= 1_init_info *info) } =20 /* - * info is NULL when the backend is in Xen. - * info is !=3D NULL when the backend is in a domain. + * params is NULL when the backend is in Xen. + * params is !=3D NULL when the backend is in a domain. */ - if ( info !=3D NULL ) + if ( params !=3D NULL ) { vpl011->backend_in_domain =3D true; =20 /* Map the guest PFN to Xen address space. */ rc =3D 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; =20 - rc =3D alloc_unbound_xen_event_channel(d, 0, info->console_domid, + rc =3D alloc_unbound_xen_event_channel(d, 0, params->console_domid, vpl011_notification); if ( rc < 0 ) goto out1; =20 - vpl011->evtchn =3D info->evtchn =3D rc; + vpl011->evtchn =3D params->evtchn =3D rc; } else { @@ -746,13 +746,13 @@ int domain_vpl011_init(struct domain *d, struct vpl01= 1_init_info *info) return 0; =20 out1: - domain_vpl011_deinit(d); + vuart_exit(d); =20 out: return rc; } =20 -void domain_vpl011_deinit(struct domain *d) +void vuart_exit(struct domain *d) { struct vpl011 *vpl011 =3D &d->arch.vpl011; =20 diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 0f37badc471e..f322d59515ab 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -33,13 +33,11 @@ #include #include #include +#include =20 #ifdef CONFIG_X86 #include #endif -#ifdef CONFIG_HAS_VUART_PL011 -#include -#endif =20 /* 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 =3D vpl011_rx_char_xen(d, c); + rc =3D vuart_putchar(d, c); #endif =20 if ( consoled_is_enabled() ) diff --git a/xen/include/xen/vuart.h b/xen/include/xen/vuart.h index bb883823ea31..cae72ac9c6b9 100644 --- a/xen/include/xen/vuart.h +++ b/xen/include/xen/vuart.h @@ -2,14 +2,46 @@ #ifndef XEN_VUART_H #define XEN_VUART_H =20 +#include +#include +#include + +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 */ =20 #endif /* XEN_VUART_H */ =20 --=20 2.34.1 From nobody Fri Oct 31 03:39:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1750737351; cv=none; d=zohomail.com; s=zohoarc; b=Wa1MjpEL4cId1LUWFU8QFosiKSN17j3yZYHBOq8m8POdY2zhNJp4hdGmyuBTOEmziZq6NbCt14H2ERTykrmKMoj4V9zgyQ6wgYWnkKsWdyQ5zEWffc/Klap5lpjkPZcegfi6JuPzom7ZLGeFOmdEKvk/rI/RCE4dgmYtf9MPY2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750737351; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pr9da8QLriKGRhTHle+NhpCJzocZTv/fv9SkYEq/Fhw=; b=BVQMaBEe4604InOYp+yZ1B/krfKW2nDCESuslSOJaXG6OD3oMwAPZz1i3VfkU3nsAmbd1SPrgsp4GkbwFx3lTBqTtf4xGOymDl/uzylJ0FpHJnlcEQ+M6r5KLnuBAY7GlVYOp0CRip5+VF9kfjbBvuMQi88YhJf1XKSl3WDlsbk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1750737350997531.813707824984; Mon, 23 Jun 2025 20:55:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1022919.1398804 (Exim 4.92) (envelope-from ) id 1uTul2-0007aF-Bl; Tue, 24 Jun 2025 03:55:40 +0000 Received: by outflank-mailman (output) from mailman id 1022919.1398804; Tue, 24 Jun 2025 03:55:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTul2-0007a8-8c; Tue, 24 Jun 2025 03:55:40 +0000 Received: by outflank-mailman (input) for mailman id 1022919; Tue, 24 Jun 2025 03:55:39 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTul1-000639-Dx for xen-devel@lists.xenproject.org; Tue, 24 Jun 2025 03:55:39 +0000 Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 16912773-50af-11f0-b894-0df219b8e170; Tue, 24 Jun 2025 05:55:37 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 16912773-50af-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=2aczlvp72nbmndnpqwlicus3vi.protonmail; t=1750737336; x=1750996536; bh=pr9da8QLriKGRhTHle+NhpCJzocZTv/fv9SkYEq/Fhw=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=HN7U28yX6dmUEKHGm/r6clneTH6+QaKfBhDYbs05T9ULKQdU2S3jIuRiYTjoMIpff zBkh/VPLe52KF7nBfZ5z0UqVCLvsfXyNY9VOw22ttyPwGtCzG965dnDXjAAwz7rUXG j5xx23SMLVs0cuziGpfnDLpYzC7Cv7b/p5rcjVNTB/iGtg+3IYSZGVDoptBOIHYKDH PuEqcfmtmbBPiWWF165El32XL0iJprRddQWGUnEOnsDVGBY1J8pF1rFGa/h74eWZuW VdEKukowFiGjAM2HCnQQPWe0llZv//fK+BGtlRPzpfCgO2QhoPVanhpTi4xg58vI3u K6nE8yBa+BpBw== Date: Tue, 24 Jun 2025 03:55:32 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, oleksii.kurochko@gmail.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v1 04/16] arm/vpl011: use raw spin_lock_{irqrestore,irqsave} Message-ID: <20250624035443.344099-5-dmukhin@ford.com> In-Reply-To: <20250624035443.344099-1-dmukhin@ford.com> References: <20250624035443.344099-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: 6453bdc58832958b3427c6bbd46d5bfab2dde158 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1750737352414116600 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 Replace VPL011_{LOCK,UNLOCK} macros with raw spinlock calls to improve readability. No functional change. Signed-off-by: Denis Mukhin --- xen/arch/arm/include/asm/vpl011.h | 4 --- xen/arch/arm/vpl011.c | 50 +++++++++++++++---------------- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/xen/arch/arm/include/asm/vpl011.h b/xen/arch/arm/include/asm/v= pl011.h index 5c308cc8c148..8f6ea0005e72 100644 --- a/xen/arch/arm/include/asm/vpl011.h +++ b/xen/arch/arm/include/asm/vpl011.h @@ -24,10 +24,6 @@ #include #include =20 -/* helper macros */ -#define VPL011_LOCK(d,flags) spin_lock_irqsave(&(d)->arch.vpl011.lock, fla= gs) -#define VPL011_UNLOCK(d,flags) spin_unlock_irqrestore(&(d)->arch.vpl011.lo= ck, flags) - #define SBSA_UART_FIFO_SIZE 32 /* Same size as VUART_BUF_SIZE, used in vuart.c */ #define SBSA_UART_OUT_BUF_SIZE 128 diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index 2cf88a70ecdb..a97c3b74208c 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -85,7 +85,7 @@ static void vpl011_write_data_xen(struct domain *d, uint8= _t data) struct vpl011_xen_backend *intf =3D vpl011->backend.xen; struct domain *input =3D console_get_domain(); =20 - VPL011_LOCK(d, flags); + spin_lock_irqsave(&vpl011->lock, flags); =20 intf->out[intf->out_prod++] =3D data; if ( d =3D=3D input ) @@ -127,7 +127,7 @@ static void vpl011_write_data_xen(struct domain *d, uin= t8_t data) vpl011->uartfr |=3D TXFE; vpl011_update_interrupt_status(d); =20 - VPL011_UNLOCK(d, flags); + spin_unlock_irqrestore(&vpl011->lock, flags); =20 console_put_domain(input); } @@ -144,7 +144,7 @@ static uint8_t vpl011_read_data_xen(struct domain *d) struct vpl011_xen_backend *intf =3D vpl011->backend.xen; XENCONS_RING_IDX in_cons, in_prod; =20 - VPL011_LOCK(d, flags); + spin_lock_irqsave(&vpl011->lock, flags); =20 in_cons =3D intf->in_cons; in_prod =3D intf->in_prod; @@ -190,7 +190,7 @@ static uint8_t vpl011_read_data_xen(struct domain *d) */ vpl011->uartfr &=3D ~RXFF; =20 - VPL011_UNLOCK(d, flags); + spin_unlock_irqrestore(&vpl011->lock, flags); =20 return data; } @@ -203,7 +203,7 @@ static uint8_t vpl011_read_data(struct domain *d) struct xencons_interface *intf =3D vpl011->backend.dom.ring_buf; XENCONS_RING_IDX in_cons, in_prod; =20 - VPL011_LOCK(d, flags); + spin_lock_irqsave(&vpl011->lock, flags); =20 in_cons =3D intf->in_cons; in_prod =3D intf->in_prod; @@ -249,7 +249,7 @@ static uint8_t vpl011_read_data(struct domain *d) */ vpl011->uartfr &=3D ~RXFF; =20 - VPL011_UNLOCK(d, flags); + spin_unlock_irqrestore(&vpl011->lock, flags); =20 /* * Send an event to console backend to indicate that data has been @@ -288,7 +288,7 @@ static void vpl011_write_data(struct domain *d, uint8_t= data) struct xencons_interface *intf =3D vpl011->backend.dom.ring_buf; XENCONS_RING_IDX out_cons, out_prod; =20 - VPL011_LOCK(d, flags); + spin_lock_irqsave(&vpl011->lock, flags); =20 out_cons =3D intf->out_cons; out_prod =3D intf->out_prod; @@ -336,7 +336,7 @@ static void vpl011_write_data(struct domain *d, uint8_t= data) =20 vpl011->uartfr &=3D ~TXFE; =20 - VPL011_UNLOCK(d, flags); + spin_unlock_irqrestore(&vpl011->lock, flags); =20 /* * Send an event to console backend to indicate that there is @@ -378,34 +378,34 @@ static int vpl011_mmio_read(struct vcpu *v, case FR: if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; =20 - VPL011_LOCK(d, flags); + spin_lock_irqsave(&vpl011->lock, flags); *r =3D vreg_reg32_extract(vpl011->uartfr, info); - VPL011_UNLOCK(d, flags); + spin_unlock_irqrestore(&vpl011->lock, flags); return 1; =20 case RIS: if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; =20 - VPL011_LOCK(d, flags); + spin_lock_irqsave(&vpl011->lock, flags); *r =3D vreg_reg32_extract(vpl011->uartris, info); - VPL011_UNLOCK(d, flags); + spin_unlock_irqrestore(&vpl011->lock, flags); return 1; =20 case MIS: if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; =20 - VPL011_LOCK(d, flags); + spin_lock_irqsave(&vpl011->lock, flags); *r =3D vreg_reg32_extract(vpl011->uartris & vpl011->uartimsc, info); - VPL011_UNLOCK(d, flags); + spin_unlock_irqrestore(&vpl011->lock, flags); return 1; =20 case IMSC: if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; =20 - VPL011_LOCK(d, flags); + spin_lock_irqsave(&vpl011->lock, flags); *r =3D vreg_reg32_extract(vpl011->uartimsc, info); - VPL011_UNLOCK(d, flags); + spin_unlock_irqrestore(&vpl011->lock, flags); return 1; =20 case ICR: @@ -476,19 +476,19 @@ static int vpl011_mmio_write(struct vcpu *v, case IMSC: if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; =20 - VPL011_LOCK(d, flags); + spin_lock_irqsave(&vpl011->lock, flags); vreg_reg32_update(&vpl011->uartimsc, r, info); vpl011_update_interrupt_status(v->domain); - VPL011_UNLOCK(d, flags); + spin_unlock_irqrestore(&vpl011->lock, flags); return 1; =20 case ICR: if ( !vpl011_reg32_check_access(dabt) ) goto bad_width; =20 - VPL011_LOCK(d, flags); + spin_lock_irqsave(&vpl011->lock, flags); vreg_reg32_clearbits(&vpl011->uartris, r, info); vpl011_update_interrupt_status(d); - VPL011_UNLOCK(d, flags); + spin_unlock_irqrestore(&vpl011->lock, flags); return 1; =20 default: @@ -587,13 +587,13 @@ int vuart_putchar(struct domain *d, char c) if ( intf =3D=3D NULL ) return -ENODEV; =20 - VPL011_LOCK(d, flags); + spin_lock_irqsave(&vpl011->lock, flags); =20 in_cons =3D intf->in_cons; in_prod =3D intf->in_prod; if ( xencons_queued(in_prod, in_cons, sizeof(intf->in)) =3D=3D sizeof(= intf->in) ) { - VPL011_UNLOCK(d, flags); + spin_unlock_irqrestore(&vpl011->lock, flags); return -ENOSPC; } =20 @@ -605,7 +605,7 @@ int vuart_putchar(struct domain *d, char c) sizeof(intf->in)); =20 vpl011_data_avail(d, in_fifo_level, sizeof(intf->in), 0, SBSA_UART_FIF= O_SIZE); - VPL011_UNLOCK(d, flags); + spin_unlock_irqrestore(&vpl011->lock, flags); =20 return 0; } @@ -619,7 +619,7 @@ static void vpl011_notification(struct vcpu *v, unsigne= d int port) XENCONS_RING_IDX in_cons, in_prod, out_cons, out_prod; XENCONS_RING_IDX in_fifo_level, out_fifo_level; =20 - VPL011_LOCK(d, flags); + spin_lock_irqsave(&vpl011->lock, flags); =20 in_cons =3D intf->in_cons; in_prod =3D intf->in_prod; @@ -639,7 +639,7 @@ static void vpl011_notification(struct vcpu *v, unsigne= d int port) vpl011_data_avail(v->domain, in_fifo_level, sizeof(intf->in), out_fifo_level, sizeof(intf->out)); =20 - VPL011_UNLOCK(d, flags); + spin_unlock_irqrestore(&vpl011->lock, flags); } =20 int vuart_init(struct domain *d, struct vuart_params *params) --=20 2.34.1 From nobody Fri Oct 31 03:39:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1750737361; cv=none; d=zohomail.com; s=zohoarc; b=MQgbT2P66TSbcEZ+0OUjwnBpskiU2VZGqmRxUNaGnwSG+HLKQu1bHZ7Zb1xpyU6LWDdELF5TsboN/t8M+Bk7WelwGcfhB2eiTJRhT+H/NoZGZdaDgz2GOaQKjL33vOSCPaT7dbFC4ZG3bXGvwC2e96EEy8RKaRZ4Vhmkb8DO4fg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750737361; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lHc3ACLw6pt7GkNxldMDTQDd1/xX/S5inv8S6C9xx9k=; b=NJyA3v4HIrfgkfT2il21mqcxwNuxlJWEN94Xjs1w8CUsrCi6A/SSt2klpUE2GATk5HZP69reSl7+MXrDV0QPR+GkF0W2lk/WnhcEurhBOL09mfOoO1Bzf4Lqx55k2v4i7mZBMDyuACtx+sfM6qHR17XkuN3S3j6ZhGg7mKbOQUo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1750737361180469.41065609825057; Mon, 23 Jun 2025 20:56:01 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1022929.1398814 (Exim 4.92) (envelope-from ) id 1uTulC-00087n-Jc; Tue, 24 Jun 2025 03:55:50 +0000 Received: by outflank-mailman (output) from mailman id 1022929.1398814; Tue, 24 Jun 2025 03:55:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTulC-00087g-Ge; Tue, 24 Jun 2025 03:55:50 +0000 Received: by outflank-mailman (input) for mailman id 1022929; Tue, 24 Jun 2025 03:55:49 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTulB-0006IZ-IV for xen-devel@lists.xenproject.org; Tue, 24 Jun 2025 03:55:49 +0000 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1d221973-50af-11f0-a30f-13f23c93f187; Tue, 24 Jun 2025 05:55:48 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1d221973-50af-11f0-a30f-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1750737347; x=1750996547; bh=lHc3ACLw6pt7GkNxldMDTQDd1/xX/S5inv8S6C9xx9k=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=UyOkXxLnpo9E6dxPOgu5HimdTcmUCgQkr+Qdq1DTRW1QF9vMcC78WwzQQCqabOBta L8Ffb4RLzCkB7jJeVbk6LzzVTbffTP+u+maRLHL9qaKBOh/iOrLTSu0/SEkLWdaJAv RxQkkK5vgXFzOL8c5Cif7CyTZvOEu2bqdnro/sRyiY4tUHbQsqvq3ap3aK43+Y42Gt 3p7hovWsFFKZNq37WlljpxELXXSZQmhBe1Bbuj4yyZPzl4vYXjbPgdWRqKUw6zcY9w LnZtEAO2Y0AMShp1Ely9lx0u3Lmeyl4k8Ht9gHVfyPheMjZxpHkHjw4xO76G3yhIGo 2vIrVLydr6gRA== Date: Tue, 24 Jun 2025 03:55:41 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, oleksii.kurochko@gmail.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v1 05/16] arm/vpl011: use void pointer in domain struct Message-ID: <20250624035443.344099-6-dmukhin@ford.com> In-Reply-To: <20250624035443.344099-1-dmukhin@ford.com> References: <20250624035443.344099-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: 0ae6ac912a722d1d6ffe02af0bdd19ee8312a069 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1750737362553116600 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 Switch to using void pointer in domain struct to reduce compile-time dependencies for PL011 emulator. Signed-off-by: Denis Mukhin --- xen/arch/arm/include/asm/domain.h | 3 +- xen/arch/arm/vpl011.c | 139 +++++++++++++++++------------- 2 files changed, 79 insertions(+), 63 deletions(-) diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/d= omain.h index 746ea687d523..2ee9976b55a8 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -9,7 +9,6 @@ #include #include #include -#include #include =20 struct hvm_domain @@ -114,7 +113,7 @@ struct arch_domain } monitor; =20 #ifdef CONFIG_HAS_VUART_PL011 - struct vpl011 vpl011; + void *vpl011; #endif =20 #ifdef CONFIG_TEE diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index a97c3b74208c..3c027ccf0b4e 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,43 @@ #include #include =20 +static void __vpl011_exit(struct vpl011 *vpl011, struct domain *d) +{ + if ( vpl011->virq ) + { + vgic_free_virq(d, vpl011->virq); + + /* + * Set to invalid irq (we use SPI) to prevent extra free and to av= oid + * freeing irq that could have already been reserved by someone el= se. + */ + vpl011->virq =3D 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 f= or + * other purposes. + */ + vpl011->evtchn =3D 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 dab= t) =20 static void vpl011_update_interrupt_status(struct domain *d) { - struct vpl011 *vpl011 =3D &d->arch.vpl011; + struct vpl011 *vpl011 =3D d->arch.vpl011; uint32_t uartmis =3D vpl011->uartris & vpl011->uartimsc; =20 /* @@ -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 =3D &d->arch.vpl011; + struct vpl011 *vpl011 =3D d->arch.vpl011; struct vpl011_xen_backend *intf =3D vpl011->backend.xen; struct domain *input =3D console_get_domain(); =20 @@ -140,7 +178,7 @@ static uint8_t vpl011_read_data_xen(struct domain *d) { unsigned long flags; uint8_t data =3D 0; - struct vpl011 *vpl011 =3D &d->arch.vpl011; + struct vpl011 *vpl011 =3D d->arch.vpl011; struct vpl011_xen_backend *intf =3D vpl011->backend.xen; XENCONS_RING_IDX in_cons, in_prod; =20 @@ -199,7 +237,7 @@ static uint8_t vpl011_read_data(struct domain *d) { unsigned long flags; uint8_t data =3D 0; - struct vpl011 *vpl011 =3D &d->arch.vpl011; + struct vpl011 *vpl011 =3D d->arch.vpl011; struct xencons_interface *intf =3D vpl011->backend.dom.ring_buf; XENCONS_RING_IDX in_cons, in_prod; =20 @@ -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 =3D &d->arch.vpl011; + struct vpl011 *vpl011 =3D d->arch.vpl011; struct xencons_interface *intf =3D vpl011->backend.dom.ring_buf; XENCONS_RING_IDX out_cons, out_prod; =20 @@ -350,10 +388,9 @@ static int vpl011_mmio_read(struct vcpu *v, register_t *r, void *priv) { + struct vpl011 *vpl011 =3D v->domain->arch.vpl011; struct hsr_dabt dabt =3D info->dabt; - uint32_t vpl011_reg =3D (uint32_t)(info->gpa - - v->domain->arch.vpl011.base_addr); - struct vpl011 *vpl011 =3D &v->domain->arch.vpl011; + uint32_t vpl011_reg =3D (uint32_t)(info->gpa - vpl011->base_addr); struct domain *d =3D v->domain; unsigned long flags; =20 @@ -439,10 +476,9 @@ static int vpl011_mmio_write(struct vcpu *v, register_t r, void *priv) { + struct vpl011 *vpl011 =3D v->domain->arch.vpl011; struct hsr_dabt dabt =3D info->dabt; - uint32_t vpl011_reg =3D (uint32_t)(info->gpa - - v->domain->arch.vpl011.base_addr); - struct vpl011 *vpl011 =3D &v->domain->arch.vpl011; + uint32_t vpl011_reg =3D (uint32_t)(info->gpa - vpl011->base_addr); struct domain *d =3D v->domain; unsigned long flags; =20 @@ -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 =3D &d->arch.vpl011; + struct vpl011 *vpl011 =3D d->arch.vpl011; =20 /**** Update the UART RX state ****/ =20 @@ -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 =3D &d->arch.vpl011; + struct vpl011 *vpl011 =3D d->arch.vpl011; struct vpl011_xen_backend *intf =3D vpl011->backend.xen; XENCONS_RING_IDX in_cons, in_prod, in_fifo_level; =20 @@ -614,7 +650,7 @@ static void vpl011_notification(struct vcpu *v, unsigne= d int port) { unsigned long flags; struct domain *d =3D v->domain; - struct vpl011 *vpl011 =3D &d->arch.vpl011; + struct vpl011 *vpl011 =3D d->arch.vpl011; struct xencons_interface *intf =3D 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, unsig= ned int port) =20 int vuart_init(struct domain *d, struct vuart_params *params) { + struct vpl011 *vpl011; int rc; - struct vpl011 *vpl011 =3D &d->arch.vpl011; =20 - if ( vpl011->backend.dom.ring_buf ) - return -EINVAL; + BUG_ON(d->arch.vpl011); + + vpl011 =3D xvzalloc(typeof(*vpl011)); + if ( !vpl011 ) + return -ENOMEM; =20 /* * 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 *p= arams) { printk(XENLOG_ERR "vpl011: Unable to re-use the Xen UART information.\n"); - return -EINVAL; + rc =3D -EINVAL; + goto err_out; } =20 /* @@ -684,7 +724,8 @@ int vuart_init(struct domain *d, struct vuart_params *p= arams) { printk(XENLOG_ERR "vpl011: Can't re-use the Xen UART MMIO region as it is= too small.\n"); - return -EINVAL; + rc =3D -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; =20 rc =3D alloc_unbound_xen_event_channel(d, 0, params->console_domid, vpl011_notification); if ( rc < 0 ) - goto out1; + goto err_out; =20 vpl011->evtchn =3D params->evtchn =3D rc; } @@ -725,7 +766,7 @@ int vuart_init(struct domain *d, struct vuart_params *p= arams) if ( vpl011->backend.xen =3D=3D NULL ) { rc =3D -ENOMEM; - goto out; + goto err_out; } } =20 @@ -733,7 +774,7 @@ int vuart_init(struct domain *d, struct vuart_params *p= arams) if ( !rc ) { rc =3D -EINVAL; - goto out1; + goto err_out; } =20 vpl011->uartfr =3D 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); =20 + d->arch.vpl011 =3D vpl011; + return 0; =20 -out1: - vuart_exit(d); - -out: +err_out: + __vpl011_exit(vpl011, d); return rc; } =20 void vuart_exit(struct domain *d) { - struct vpl011 *vpl011 =3D &d->arch.vpl011; - - if ( vpl011->virq ) + if ( d->arch.vpl011 ) { - vgic_free_virq(d, vpl011->virq); - - /* - * Set to invalid irq (we use SPI) to prevent extra free and to av= oid - * freeing irq that could have already been reserved by someone el= se. - */ - vpl011->virq =3D 0; + __vpl011_exit(d->arch.vpl011, d); + d->arch.vpl011 =3D NULL; } - - 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 f= or - * other purposes. - */ - vpl011->evtchn =3D 0; - } - } - else - XFREE(vpl011->backend.xen); } =20 int __init vuart_add_fwnode(struct domain *d, void *node) @@ -797,8 +810,12 @@ int __init vuart_add_fwnode(struct domain *d, void *no= de) gic_interrupt_t intr; __be32 reg[GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS]; __be32 *cells; + struct vpl011 *vpl011 =3D d->arch.vpl011; =20 - res =3D domain_fdt_begin_node(fdt, "sbsa-uart", d->arch.vpl011.base_ad= dr); + if ( !vpl011 ) + return 0; + + res =3D domain_fdt_begin_node(fdt, "sbsa-uart", vpl011->base_addr); if ( res ) return res; =20 @@ -808,14 +825,14 @@ int __init vuart_add_fwnode(struct domain *d, void *n= ode) =20 cells =3D ®[0]; dt_child_set_range(&cells, GUEST_ROOT_ADDRESS_CELLS, - GUEST_ROOT_SIZE_CELLS, d->arch.vpl011.base_addr, + GUEST_ROOT_SIZE_CELLS, vpl011->base_addr, GUEST_PL011_SIZE); =20 res =3D fdt_property(fdt, "reg", reg, sizeof(reg)); if ( res ) return res; =20 - set_interrupt(intr, d->arch.vpl011.virq, 0xf, DT_IRQ_TYPE_LEVEL_HIGH); + set_interrupt(intr, vpl011->virq, 0xf, DT_IRQ_TYPE_LEVEL_HIGH); =20 res =3D fdt_property(fdt, "interrupts", intr, sizeof (intr)); if ( res ) --=20 2.34.1 From nobody Fri Oct 31 03:39:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1750737676; cv=none; d=zohomail.com; s=zohoarc; b=JxFTI23D/a6a4sHQrFnVhLFlLZntXkurB5bTANn9sOzRFMrpag/G15mDXJjJIy0jgcKNbR3bNYhnNngqsbjRv3dF3jagdFM78ZU99dRCcLvO9gjWDSVwgSmrcsvj3Z/rH22e2nfnXZ2pZebzHane2PSIx1Kaeb0h6iu6mn9XG4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750737676; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Hr/ZkUe3+2HPidIdCTxwSDIZWzLYqjdMotIU52bRYqY=; b=HUgQX9qt1xdng/RMPoe1LjP4eHIQIRIjBnZNPFW80T6/uatvmTQoxaUPv3JLHRafsFioiM9+ICcpzsKuqiY4T2WvyrP2dI9wAxWkac0WwfoFGKPqbcq1t0DDCXpO4r2P5Hb0o7+gU67/Fe/eyDIRRNujPvSEsir9jmEu6yCf5p0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1750737676655629.2746892381668; Mon, 23 Jun 2025 21:01:16 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1022952.1398824 (Exim 4.92) (envelope-from ) id 1uTuq1-0001y6-9V; Tue, 24 Jun 2025 04:00:49 +0000 Received: by outflank-mailman (output) from mailman id 1022952.1398824; Tue, 24 Jun 2025 04:00:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTuq1-0001xz-6Y; Tue, 24 Jun 2025 04:00:49 +0000 Received: by outflank-mailman (input) for mailman id 1022952; Tue, 24 Jun 2025 04:00:47 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTulM-000639-HU for xen-devel@lists.xenproject.org; Tue, 24 Jun 2025 03:56:00 +0000 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2338276b-50af-11f0-b894-0df219b8e170; Tue, 24 Jun 2025 05:55:59 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2338276b-50af-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=vvcfptfpireknpma5nle5ez43y.protonmail; t=1750737357; x=1750996557; bh=Hr/ZkUe3+2HPidIdCTxwSDIZWzLYqjdMotIU52bRYqY=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=J9G5q+amCTOYNYSoOOYXFdP4tBeAGCM4ONZaVMGNf4RzbNrjBtEysWAfEXI8f/niw sstjwf8ILPI7wTiUJF7/JsT6Z0ol7hRXGhFXEjrl6LZrK0IvPFZMXDgdHmQSwuw8qp H/SWgr9Qwe9pRIOsGtXEQG7WaKIhy54LRxKlVGJC+ZrJg9v91/omJQNwYfmmobsIl5 rKBOesy3pi4DxHVoKYqMjBsDJKa9X6kKZv/rEa/v9IYwKJgnz4asxCXnoZOAlP59hs FZKYDfdZ8qpsMdb6zb9qCp8sVslCc9okbF60n4GoOgU+Qy9yUTCb983COC133u9rQQ 4Tvx0fvs0BwWA== Date: Tue, 24 Jun 2025 03:55:51 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, oleksii.kurochko@gmail.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v1 06/16] arm/vpl011: remove vpl011 header file Message-ID: <20250624035443.344099-7-dmukhin@ford.com> In-Reply-To: <20250624035443.344099-1-dmukhin@ford.com> References: <20250624035443.344099-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: 23672e309d6359726fd79b9e87ec955d61d4c858 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1750737678139116600 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 Make all PL011 emulator declarations private to emulator's code. No functional change. Signed-off-by: Denis Mukhin --- 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 diff --git a/xen/arch/arm/include/asm/vpl011.h b/xen/arch/arm/include/asm/v= pl011.h deleted file mode 100644 index 8f6ea0005e72..000000000000 --- a/xen/arch/arm/include/asm/vpl011.h +++ /dev/null @@ -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 f= or - * more details. - * - * You should have received a copy of the GNU General Public License along= with - * this program; If not, see . - */ - -#ifndef _VPL011_H_ -#define _VPL011_H_ - -#include -#include -#include -#include - -#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: - */ diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index 3c027ccf0b4e..bebfb5e0365c 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -7,9 +7,6 @@ =20 #define XEN_WANT_FLEX_CONSOLE_RING 1 =20 -/* 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 #include #include @@ -25,13 +22,47 @@ #include #include #include +#include #include #include #include #include -#include #include =20 +#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 ) --=20 2.34.1 From nobody Fri Oct 31 03:39:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1750737681; cv=none; d=zohomail.com; s=zohoarc; b=GEnFZz2ef7tKSir2NlomrZhN3kvX/wIVO9gbzambaLECRBvoAUzyeFxaowVytfWcCROqZcxbF0mXpqjkJwi2/yq1ni6k6vap4pYwLPIfdK8QsNwM1tM2l96tiCtWA2pc0yAf74bWEBERbakFfXsx11AaCEsWc+Ytv5K+XSamWPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750737681; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kg+n/kedKNW1A1xHbIIccq1oruQHzzJGTEwBEt6y32w=; b=e8lrMzhwzbSScbeUQqyTiupejthtuv0OvVxVZm9K4WGWnxqyAbPSAb4Sxp+1FhiXDRylce2z16FXIuaze8xncCwwpAz51SW65FXRcZ98sq2pA4AeqCy7YVa0TKYHETHPT2HxDhmEm7Bn9MaraRH01dy9LuTALsLrmcjuAGmvK38= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1750737681302222.81214998283292; Mon, 23 Jun 2025 21:01:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1022956.1398854 (Exim 4.92) (envelope-from ) id 1uTuqB-0002qX-T6; Tue, 24 Jun 2025 04:00:59 +0000 Received: by outflank-mailman (output) from mailman id 1022956.1398854; Tue, 24 Jun 2025 04:00:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTuqB-0002qM-PR; Tue, 24 Jun 2025 04:00:59 +0000 Received: by outflank-mailman (input) for mailman id 1022956; Tue, 24 Jun 2025 04:00:59 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTulV-000639-Om for xen-devel@lists.xenproject.org; Tue, 24 Jun 2025 03:56:09 +0000 Received: from mail-10630.protonmail.ch (mail-10630.protonmail.ch [79.135.106.30]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 28aa697f-50af-11f0-b894-0df219b8e170; Tue, 24 Jun 2025 05:56:08 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 28aa697f-50af-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1750737366; x=1750996566; bh=kg+n/kedKNW1A1xHbIIccq1oruQHzzJGTEwBEt6y32w=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=cbhvZjKl4wEvGLp+l1O52nOJvnAZ2JMOfL05zGSFYWO4ALt/qaMxhZSW9tNjra3ZR TU+g7u+h8q/Qp9d/gq8Kva0F6DL3Ngb1+A8oP+7Q5/yTX9fSPSurvUjwGmIRCb3MMU QhyLTtmOICf89QtllzI7Klxj52FIAGoH1vyuVwUPbti7HGx779cAPppShCVODo3HQR iW4C2J6jHSFd52luVPAMAM7UiBRSGGs0n/KP0xtIHAGbteUWri0h22qAjNXE1SPPHa TN9vpbtVbYI09asbKwMoUBxmfH9IJciAB3NrfcCtUwMFI8FRC4EsSwJuUi7X2R8m8l PVNzdW50N+kUA== Date: Tue, 24 Jun 2025 03:55:59 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, oleksii.kurochko@gmail.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v1 07/16] arm/vuart: rename 'virtual UART' Kconfig option Message-ID: <20250624035443.344099-8-dmukhin@ford.com> In-Reply-To: <20250624035443.344099-1-dmukhin@ford.com> References: <20250624035443.344099-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: 9bd0188e159941caa349c4817e61032d44273f78 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1750737682014116600 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 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. Signed-off-by: Denis Mukhin --- 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(-) diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 03888569f38c..b11cb583a763 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -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. =20 -config HWDOM_VUART +config HAS_VUART_MMIO bool "Emulated UART for hardware domain" default y help diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 2d6787fb03bc..dd015a2a19e8 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -68,7 +68,7 @@ obj-y +=3D vtimer.o obj-$(CONFIG_HAS_VUART_PL011) +=3D vpl011.o obj-y +=3D vsmc.o obj-y +=3D vpsci.o -obj-$(CONFIG_HWDOM_VUART) +=3D vuart.o +obj-$(CONFIG_HAS_VUART_MMIO) +=3D vuart.o =20 extra-y +=3D xen.lds =20 diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/d= omain.h index 2ee9976b55a8..d668c11d7e2c 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -90,7 +90,7 @@ struct arch_domain =20 struct vgic_dist vgic; =20 -#ifdef CONFIG_HWDOM_VUART +#ifdef CONFIG_HAS_VUART_MMIO struct vuart { #define VUART_BUF_SIZE 128 char *buf; diff --git a/xen/arch/arm/vuart.h b/xen/arch/arm/vuart.h index e90d84c6eddb..726846355c3b 100644 --- a/xen/arch/arm/vuart.h +++ b/xen/arch/arm/vuart.h @@ -22,7 +22,7 @@ =20 struct domain; =20 -#ifdef CONFIG_HWDOM_VUART +#ifdef CONFIG_HAS_VUART_MMIO =20 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) =20 static inline void domain_vuart_free(struct domain *d) {}; =20 -#endif /* CONFIG_HWDOM_VUART */ +#endif /* CONFIG_HAS_VUART_MMIO */ =20 #endif /* __ARCH_ARM_VUART_H__ */ =20 --=20 2.34.1 From nobody Fri Oct 31 03:39:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1750737674; cv=none; d=zohomail.com; s=zohoarc; b=eJFoQZf0Dm4uxarATcvcCXGurVCYA3szhcyKeuBarItMThMA7tqsPGnrEiUytsePMbZBZ1u6hTynWKTGFQPWVrZHIcWcMISk5HF1lOYOBnCS7SW9qpf75Ge0dK1rNh9L8q96SBls245JV6WqTbAI4TuX6XE1SZPy2Oa6h2EPBUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750737674; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EZPSUcu7la0M45CwJVaWkAOhNHBB8cLtWWRrJ9AK15Q=; b=JSwoFPFyEJedHSBjfc2swAKi6+nAPL+nE7AzT/2s22iQzrQMI0XzKM0Vt7BSbuYmnEB1OgKx5zG2RbInT7Y0dW4cmDwit3WMzcnC+2y+JnW7LaQ1eYE9kLhZJ51yIbDdOebeqYSu7BsWk6D0jDqymVAbyC3slexfzfuU/zTJfSw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1750737674790428.5485600053347; Mon, 23 Jun 2025 21:01:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1022955.1398840 (Exim 4.92) (envelope-from ) id 1uTuq4-0002Gs-Py; Tue, 24 Jun 2025 04:00:52 +0000 Received: by outflank-mailman (output) from mailman id 1022955.1398840; Tue, 24 Jun 2025 04:00:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTuq4-0002FM-Iu; Tue, 24 Jun 2025 04:00:52 +0000 Received: by outflank-mailman (input) for mailman id 1022955; Tue, 24 Jun 2025 04:00:51 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTulb-0006IZ-GS for xen-devel@lists.xenproject.org; Tue, 24 Jun 2025 03:56:15 +0000 Received: from mail-24417.protonmail.ch (mail-24417.protonmail.ch [109.224.244.17]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2c8d3310-50af-11f0-a30f-13f23c93f187; Tue, 24 Jun 2025 05:56:14 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2c8d3310-50af-11f0-a30f-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1750737373; x=1750996573; bh=EZPSUcu7la0M45CwJVaWkAOhNHBB8cLtWWRrJ9AK15Q=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=cDkAGXIxwmH2Q6b45ukKQqCRljR8aIantC+Yo2I9dkyIfGby3MAZxLEiS9PJiq5A9 7TneQ+1A3wYc9m+sTTeRnDH+leZfPfqgpoNL/wdirJ682s47muibdxni48t0sc5KHS Wi0RaXeKMJvriUfARBRDSN0/bkYiOVPdYvAVOjqA5Q+tlHXj6CJT+SX/g/sjozDO3N qnFYsQ6kMzapzR/Xx42PKfPK+mb43s7C6DWMZX45DVd5PSH4PcQPBUFIbuj0Q+bxMf AM74dmkPd1GOGYx3vRSnJBltwBDAu7epwcNR3vVet8V7vLhlvMO4S1Y8xza2SeI77f pFzjvfz6Pyacg== Date: Tue, 24 Jun 2025 03:56:09 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, oleksii.kurochko@gmail.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v1 08/16] arm/vuart: move simple MMIO-based vUART declarations to common header Message-ID: <20250624035443.344099-9-dmukhin@ford.com> In-Reply-To: <20250624035443.344099-1-dmukhin@ford.com> References: <20250624035443.344099-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: 41115d32da3b21d594ea62d30a415d088e6afb20 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1750737676072116600 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 Merge arch/arm/vuart.h with include/xen/vuart.h. No functional change. Signed-off-by: Denis Mukhin --- 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 diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 68297e619bad..3579d10d7e1d 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -31,7 +31,6 @@ #include =20 #include "vpci.h" -#include "vuart.h" =20 DEFINE_PER_CPU(struct vcpu *, curr_vcpu); =20 diff --git a/xen/arch/arm/vuart.c b/xen/arch/arm/vuart.c index bd2f425214b7..5403ed284846 100644 --- a/xen/arch/arm/vuart.c +++ b/xen/arch/arm/vuart.c @@ -28,8 +28,7 @@ #include #include #include - -#include "vuart.h" +#include =20 #define domain_has_vuart(d) ((d)->arch.vuart.info !=3D NULL) =20 diff --git a/xen/arch/arm/vuart.h b/xen/arch/arm/vuart.h deleted file mode 100644 index 726846355c3b..000000000000 --- a/xen/arch/arm/vuart.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * xen/arch/arm/vuart.h - * - * Virtual UART Emulation Support - * - * Ian Campbell - * Copyright (c) 2012 Citrix Systems. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that 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. - */ - -#ifndef __ARCH_ARM_VUART_H__ -#define __ARCH_ARM_VUART_H__ - -struct domain; - -#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 /* __ARCH_ARM_VUART_H__ */ - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/xen/include/xen/vuart.h b/xen/include/xen/vuart.h index cae72ac9c6b9..928b60bbb4e2 100644 --- a/xen/include/xen/vuart.h +++ b/xen/include/xen/vuart.h @@ -43,6 +43,26 @@ static inline int vuart_putchar(struct domain *d, char c) =20 #endif /* CONFIG_HAS_VUART_PL011 */ =20 +#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 */ =20 /* --=20 2.34.1 From nobody Fri Oct 31 03:39:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1750737693; cv=none; d=zohomail.com; s=zohoarc; b=mbkBHIwfWemsBarDaHcgfP1HKpYE30wHi5s2QtOdbxwj833TXQ+4t/VIuXjaXklWxlpgwSBFomliInHTAVMlXzchvUw9YcuPV5l88xwTaqqliuidA+UCvtxanXZecLOYEfMDByLgYIpn41YH2s6jpOIWBBbeBHha0XBCTLL5lOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750737693; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7T+qIgAVUUiUK7ZTM4nraoYQpj7JidPaaBMAqs8DTzI=; b=LCKAP5OfOzYuZSaXc29DsPpBPWQNBur6SXT4AQ3+DoJjNc2q/iEB3ldKyRmGvpFZXwMcW10AbSKNlkcXod/NQbT9IzofG+ywiMJx0EF4PgWNec3Lrmf2vvbXoWpefe9VmjRYHvZfLX/gO8F3eRhzcwEkNsXfsJVzIcWaqBy4zNw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1750737693419715.8578640261228; Mon, 23 Jun 2025 21:01:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1022973.1398903 (Exim 4.92) (envelope-from ) id 1uTuqP-0004p9-LF; Tue, 24 Jun 2025 04:01:13 +0000 Received: by outflank-mailman (output) from mailman id 1022973.1398903; Tue, 24 Jun 2025 04:01:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTuqP-0004ov-Gm; Tue, 24 Jun 2025 04:01:13 +0000 Received: by outflank-mailman (input) for mailman id 1022973; Tue, 24 Jun 2025 04:01:12 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTulk-000639-8f for xen-devel@lists.xenproject.org; Tue, 24 Jun 2025 03:56:24 +0000 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 31584067-50af-11f0-b894-0df219b8e170; Tue, 24 Jun 2025 05:56:22 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 31584067-50af-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1750737381; x=1750996581; bh=7T+qIgAVUUiUK7ZTM4nraoYQpj7JidPaaBMAqs8DTzI=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=gYTSUmos3OTm/ib6bGqk3P2QXZpmK3ZA3efPElwsFB2j22ReGJzpzlNg/hquCDDue 7duJ8O/RT7lI2OM25Y7EdJfmy1QuD9NuWx6QIJ6ry0bfqReywOxhqHw1OtudLm72EB F6nNLRX4EHVYMKSuPNlFoaJ4uJuv4lhfH1R/GhCAmS0ZikHydlXeHnNstFZFox5RfV kM+roRK/2OKyym7xane8d04kqrd22y3FCSMZCmbbPOVjSFzWKafr56a7NdvGFT7eaJ I/KLSS/GUTESRGJDgZlpLS1xZNil924ILXHbxpnlNWW5mCeGOIyY/wGe3aRyHrKrc2 2PBDgcb6cXXnw== Date: Tue, 24 Jun 2025 03:56:17 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, oleksii.kurochko@gmail.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v1 09/16] arm/vuart: use void pointer in domain struct Message-ID: <20250624035443.344099-10-dmukhin@ford.com> In-Reply-To: <20250624035443.344099-1-dmukhin@ford.com> References: <20250624035443.344099-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: 73cbc7bdf76c47a54c44afdb6056201ea0f919a1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1750737694199116600 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 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. Signed-off-by: Denis Mukhin --- xen/arch/arm/include/asm/domain.h | 14 ++----- xen/arch/arm/vuart.c | 68 ++++++++++++++++++++++--------- 2 files changed, 52 insertions(+), 30 deletions(-) diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/d= omain.h index d668c11d7e2c..38873c66f1f8 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -90,16 +90,6 @@ struct arch_domain =20 struct vgic_dist vgic; =20 -#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_domain void *vpl011; #endif =20 +#ifdef CONFIG_HAS_VUART_MMIO + void *vuart; +#endif + #ifdef CONFIG_TEE void *tee; #endif diff --git a/xen/arch/arm/vuart.c b/xen/arch/arm/vuart.c index 5403ed284846..d2f90ab0c64f 100644 --- a/xen/arch/arm/vuart.c +++ b/xen/arch/arm/vuart.c @@ -29,8 +29,16 @@ #include #include #include +#include =20 -#define domain_has_vuart(d) ((d)->arch.vuart.info !=3D NULL) +#define VUART_BUF_SIZE 128 + +struct vuart { + char *buf; + int idx; + const struct vuart_info *info; + spinlock_t lock; +}; =20 static int vuart_mmio_read(struct vcpu *v, mmio_info_t *info, register_t *r, void *priv); @@ -44,39 +52,57 @@ static const struct mmio_handler_ops vuart_mmio_handler= =3D { =20 int domain_vuart_init(struct domain *d) { - ASSERT( is_hardware_domain(d) ); + const struct vuart_info *info; + struct vuart *vdev; =20 - d->arch.vuart.info =3D serial_vuart_info(SERHND_DTUART); - if ( !d->arch.vuart.info ) + if ( !is_hardware_domain(d) ) return 0; =20 - spin_lock_init(&d->arch.vuart.lock); - d->arch.vuart.idx =3D 0; + info =3D serial_vuart_info(SERHND_DTUART); + if ( !info ) + return 0; =20 - d->arch.vuart.buf =3D xzalloc_array(char, VUART_BUF_SIZE); - if ( !d->arch.vuart.buf ) + vdev =3D xvzalloc(typeof(*vdev)); + if ( !vdev ) return -ENOMEM; =20 - register_mmio_handler(d, &vuart_mmio_handler, - d->arch.vuart.info->base_addr, - d->arch.vuart.info->size, + vdev->buf =3D xzalloc_array(char, VUART_BUF_SIZE); + if ( !vdev->buf ) + { + xfree(vdev); + return -ENOMEM; + } + + spin_lock_init(&vdev->lock); + + register_mmio_handler(d, + &vuart_mmio_handler, + info->base_addr, + info->size, NULL); =20 + vdev->info =3D info; + d->arch.vuart =3D vdev; + return 0; } =20 void domain_vuart_free(struct domain *d) { - if ( !domain_has_vuart(d) ) - return; + struct vuart *vdev =3D d->arch.vuart; =20 - xfree(d->arch.vuart.buf); + if ( vdev ) + { + xfree(vdev->buf); + xfree(vdev); + d->arch.vuart =3D NULL; + } } =20 static void vuart_print_char(struct vcpu *v, char c) { struct domain *d =3D v->domain; - struct vuart *uart =3D &d->arch.vuart; + struct vuart *uart =3D d->arch.vuart; =20 if ( !is_console_printable(c) ) return ; @@ -98,16 +124,17 @@ static int vuart_mmio_read(struct vcpu *v, mmio_info_t= *info, register_t *r, void *priv) { struct domain *d =3D v->domain; - paddr_t offset =3D info->gpa - d->arch.vuart.info->base_addr; + struct vuart *vdev =3D d->arch.vuart; + paddr_t offset =3D info->gpa - vdev->info->base_addr; =20 perfc_incr(vuart_reads); =20 /* By default zeroed the register */ *r =3D 0; =20 - if ( offset =3D=3D d->arch.vuart.info->status_off ) + if ( offset =3D=3D vdev->info->status_off ) /* All holding registers empty, ready to send etc */ - *r =3D d->arch.vuart.info->status; + *r =3D vdev->info->status; =20 return 1; } @@ -116,11 +143,12 @@ static int vuart_mmio_write(struct vcpu *v, mmio_info= _t *info, register_t r, void *priv) { struct domain *d =3D v->domain; - paddr_t offset =3D info->gpa - d->arch.vuart.info->base_addr; + struct vuart *vdev =3D d->arch.vuart; + paddr_t offset =3D info->gpa - vdev->info->base_addr; =20 perfc_incr(vuart_writes); =20 - if ( offset =3D=3D d->arch.vuart.info->data_off ) + if ( offset =3D=3D vdev->info->data_off ) /* ignore any status bits */ vuart_print_char(v, r & 0xFF); =20 --=20 2.34.1 From nobody Fri Oct 31 03:39:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1750737684; cv=none; d=zohomail.com; s=zohoarc; b=Rx/jg5JBaxlaUfYbDrtRBhHlW2NtuDxTpETZZngmVXHEEw+6tkpWdLyQ2nu0W7l+49b/UqzEhD5XAEM5uNQSzIS3lo9cP/8f+luSH8ONzMV7rXBXpBgvoJu+R0P7gFbh9MG/iuNFGZ5Ntj68OoyFL+qbt7fq6IgIBL4FDl3qjbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750737684; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WzrROE+QI/UTY1xrOQAZvzV0WY59/mzY+ZWQRvx/c2U=; b=XY5a6Gf057hCzlMN1fOZGIPS7rQfvnPr9zTmXK3TmaTdwWlN/A13oxiC2cbkIz9dedral02IeJyo2oezy9gLMd3HiWqBSXKHPojO1FBAdwDWjQPTQd0Cb8PuTTg15+YUaZd96BYl9XaJ+m2E/BSjjWTy/1f86fmcfOZOwXPns5g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 175073768424333.03663111166213; Mon, 23 Jun 2025 21:01:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1022966.1398894 (Exim 4.92) (envelope-from ) id 1uTuqL-0004I0-Cd; Tue, 24 Jun 2025 04:01:09 +0000 Received: by outflank-mailman (output) from mailman id 1022966.1398894; Tue, 24 Jun 2025 04:01:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTuqL-0004Gj-8L; Tue, 24 Jun 2025 04:01:09 +0000 Received: by outflank-mailman (input) for mailman id 1022966; Tue, 24 Jun 2025 04:01:07 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTult-0006IZ-Ez for xen-devel@lists.xenproject.org; Tue, 24 Jun 2025 03:56:33 +0000 Received: from mail-24418.protonmail.ch (mail-24418.protonmail.ch [109.224.244.18]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 366a6e5a-50af-11f0-a30f-13f23c93f187; Tue, 24 Jun 2025 05:56:31 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 366a6e5a-50af-11f0-a30f-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=4ck5bogpevd5jkat5koiapv2s4.protonmail; t=1750737390; x=1750996590; bh=WzrROE+QI/UTY1xrOQAZvzV0WY59/mzY+ZWQRvx/c2U=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=N2YwSZg3r4hR7riv+uBnF0UBwlN1gRkqsvv+3BT4xrwLNYpVhqnZhDa0zxlZ0Iusp u7EIDsUs/S14/DgcmNqpZjKBcRu0WU2QrWObJxudWFfkwcwCI/+yTgSp0FqGJdwSES jGQDFubrdcEcSG9LYTK77vfFyytjeDmde6Rk7yxbbfCFc9cKuFm3g4ixixJMFHMMRx ms8OtGTspelJmSpil2R52j+pjL4VB8Mt9noLv9Y44kS2uBHVDzaba8PJ/eTxF1eOst XiJHUD7KiYG9btHXVjGSBwuGGWpmhf9ZODETJf2AQuPEW0aZvlyjm+BSslwim8FtjF ObhvNwkfMJPGw== Date: Tue, 24 Jun 2025 03:56:26 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, oleksii.kurochko@gmail.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v1 10/16] arm/vuart: merge vuart_print_char() with vuart_mmio_write() Message-ID: <20250624035443.344099-11-dmukhin@ford.com> In-Reply-To: <20250624035443.344099-1-dmukhin@ford.com> References: <20250624035443.344099-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: 5a420a27ef110bf70270096b3b46a04f5ae9dc1f MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1750737686078116600 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 Simplify code a bit since there's only one user of vuart_print_char(). No functional change. Signed-off-by: Denis Mukhin --- xen/arch/arm/vuart.c | 45 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/xen/arch/arm/vuart.c b/xen/arch/arm/vuart.c index d2f90ab0c64f..66fac6c994ce 100644 --- a/xen/arch/arm/vuart.c +++ b/xen/arch/arm/vuart.c @@ -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 * Copyright (c) 2012 Citrix Systems. */ + #include #include #include @@ -99,27 +98,6 @@ void domain_vuart_free(struct domain *d) } } =20 -static void vuart_print_char(struct vcpu *v, char c) -{ - struct domain *d =3D v->domain; - struct vuart *uart =3D d->arch.vuart; - - if ( !is_console_printable(c) ) - return ; - - spin_lock(&uart->lock); - uart->buf[uart->idx++] =3D c; - if ( (uart->idx =3D=3D (VUART_BUF_SIZE - 2)) || (c =3D=3D '\n') ) - { - if ( c !=3D '\n' ) - uart->buf[uart->idx++] =3D '\n'; - uart->buf[uart->idx] =3D '\0'; - printk(XENLOG_G_DEBUG "DOM%u: %s", d->domain_id, uart->buf); - uart->idx =3D 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 =3D v->domain; struct vuart *vdev =3D d->arch.vuart; paddr_t offset =3D info->gpa - vdev->info->base_addr; + char ch =3D r & 0xFF; /* ignore any status bits */ =20 perfc_incr(vuart_writes); =20 - if ( offset =3D=3D vdev->info->data_off ) - /* ignore any status bits */ - vuart_print_char(v, r & 0xFF); + if ( !vdev || offset !=3D vdev->info->data_off || !is_console_printabl= e(ch) ) + return 1; + + spin_lock(&vdev->lock); + + vdev->buf[vdev->idx++] =3D ch; + if ( (vdev->idx =3D=3D (VUART_BUF_SIZE - 2)) || (ch =3D=3D '\n') ) + { + if ( ch !=3D '\n' ) + vdev->buf[vdev->idx++] =3D '\n'; + vdev->buf[vdev->idx] =3D '\0'; + printk(XENLOG_G_DEBUG "DOM%u: %s", d->domain_id, vdev->buf); + vdev->idx =3D 0; + } + + spin_unlock(&vdev->lock); =20 return 1; } @@ -163,4 +155,3 @@ static int vuart_mmio_write(struct vcpu *v, mmio_info_t= *info, * indent-tabs-mode: nil * End: */ - --=20 2.34.1 From nobody Fri Oct 31 03:39:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1750737682; cv=none; d=zohomail.com; s=zohoarc; b=ZfysALSobxZ/0DxmTE8JBhEm7gr2rurdaTE7wG+nc76Ek4v/+thwmmS/yr9MWqhQ3c8IQ1T+vwY/lAPl0yds48j5w9DcC/Wa9fkgERRIaS7rKLmi2cR/UAXJHP+FE5NhaNEb/wOXxaElYwJafvENDBXi3GDjG/A3Zj2hCR9LapM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750737682; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sQjr1X/MYLsD22+VDl+MPDWcSEB3K5kISaVn/vZXiZc=; b=GHciGl3vzxBMLblVuv7EqY1INoNfgSMBo3LCTavU0CfHwQUxXWA5nLZG3h5TTkqLIOmdy4C2i+SnfYQeaaBhhC9VXlCtJMBOVo6JcJraGSwWwDj7MR1qLBK10dmIE9PbSxyQcowbb0p2bj3bPxgh2rz4ic0N0L8o3Vk+jYAZv7Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1750737682821624.2627597033564; Mon, 23 Jun 2025 21:01:22 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1022962.1398884 (Exim 4.92) (envelope-from ) id 1uTuqH-0003hB-2S; Tue, 24 Jun 2025 04:01:05 +0000 Received: by outflank-mailman (output) from mailman id 1022962.1398884; Tue, 24 Jun 2025 04:01:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTuqG-0003gr-Qv; Tue, 24 Jun 2025 04:01:04 +0000 Received: by outflank-mailman (input) for mailman id 1022962; Tue, 24 Jun 2025 04:01:03 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTum2-000639-16 for xen-devel@lists.xenproject.org; Tue, 24 Jun 2025 03:56:42 +0000 Received: from mail-24417.protonmail.ch (mail-24417.protonmail.ch [109.224.244.17]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3bdf5ff5-50af-11f0-b894-0df219b8e170; Tue, 24 Jun 2025 05:56:40 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3bdf5ff5-50af-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1750737399; x=1750996599; bh=sQjr1X/MYLsD22+VDl+MPDWcSEB3K5kISaVn/vZXiZc=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=b1UKBbzULeg7v54z7Ljx0Z2VGSOue5K5SfB0yMBtMo5kUuzLqPQzSRzovKOZHOO6M XEfZGXLk/gHD7qNu+UBG1200PuQCdUI4WpK9GpR80v0hSUj20CynlwI10o7Mx7pa+W Q/QvFBDaiysSBIY/ujsNxFa8WoTM5ZwFUNRHmZcsJgduvqBM2GKPAHwWNlEb+VMICa hhKIsfjknRIypUH8rmNnoA88OgLqmvyVNnGKPUknShYXblDowddLL6ugQm4OTe0Zze FHO4j1PECK3Hb8diDvzqrmdSMfq4FVtDm5VHMsb4VsIyWya3mnNvV0gYYEYMw4Px46 8uHpEY7CfmYZQ== Date: Tue, 24 Jun 2025 03:56:34 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, oleksii.kurochko@gmail.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v1 11/16] xen/domain: introduce common emulation flags Message-ID: <20250624035443.344099-12-dmukhin@ford.com> In-Reply-To: <20250624035443.344099-1-dmukhin@ford.com> References: <20250624035443.344099-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: 46118646609cefd37d47d7fd8541f13c82208d7c MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1750737684127116600 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 Add common emulation_flags for configuring domain emulation features. Print d->emulation_flags from 'q' keyhandler for better traceability while debugging. Signed-off-by: Denis Mukhin Reviewed-by: Stefano Stabellini --- Original patch: https://lore.kernel.org/r/20250602191717.148361-2-dmukhin@f= ord.com --- 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(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index d025befe3d8e..fc310b1164f4 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -881,7 +881,7 @@ int arch_domain_create(struct domain *d, emflags); return -EOPNOTSUPP; } - d->arch.emulation_flags =3D emflags; + d->emulation_flags =3D emflags; =20 #ifdef CONFIG_PV32 HYPERVISOR_COMPAT_VIRT_START(d) =3D diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 3044f706de1c..37d848f68339 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -144,7 +144,7 @@ void arch_get_domain_info(const struct domain *d, if ( paging_mode_hap(d) ) info->flags |=3D XEN_DOMINF_hap; =20 - info->arch_config.emulation_flags =3D d->arch.emulation_flags; + info->arch_config.emulation_flags =3D d->emulation_flags; info->gpaddr_bits =3D hap_paddr_bits; } =20 diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/d= omain.h index 8c0dea12a526..eafd5cfc903d 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -455,9 +455,6 @@ struct arch_domain =20 /* Don't unconditionally inject #GP for unhandled MSRs. */ bool msr_relaxed; - - /* Emulated devices enabled bitmap. */ - uint32_t emulation_flags; } __cacheline_aligned; =20 #ifdef CONFIG_HVM @@ -494,17 +491,17 @@ struct arch_domain X86_EMU_PIT | X86_EMU_USE_PIRQ | \ X86_EMU_VPCI) =20 -#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_PIR= Q)) -#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)) =20 #define gdt_ldt_pt_idx(v) \ ((v)->vcpu_id >> (PAGETABLE_ORDER - GDT_LDT_VCPU_SHIFT)) diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c index b0a2051408d5..eccd97c565c6 100644 --- a/xen/common/keyhandler.c +++ b/xen/common/keyhandler.c @@ -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); =20 arch_dump_domain_info(d); =20 diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index fe53d4fab7ba..8b16efe6afd8 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -652,6 +652,8 @@ struct domain const unsigned int *llc_colors; #endif =20 + uint32_t emulation_flags; + /* Console settings. */ struct { /* Permission to take ownership of the physical console input. */ --=20 2.34.1 From nobody Fri Oct 31 03:39:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1750737698; cv=none; d=zohomail.com; s=zohoarc; b=Q8yGSSRfkAI8ZaMQtXv2jhtpplYSpE8vi+LMoqI9GHLiNybB1tmknOeo5kS7IwrhFKLEsBsxkQPDmCeOT9tt3sFIbWJ10pxjeQ9t6ApA30WZdtukQQVnQcYKW33IGjWCYE2VceQ61PeM6ITeVsQ123788RDGtFhkdmbrnjvX+zQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750737698; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5yXPb6SqgHIQ4PIoB8k8GBXcIv2K6UWy6GJUDsY9e8g=; b=c7uZbR2irqCN9hjLK32Co9vfJ8HoJc1sBzEAi3Lb+n1lJjfPSoJFaXHz8iRXDuUJ4lDdFSK8DM0z7SirDnaQ3p7k1W+5nSgCKFeFMnd1Np532bhI+iGP7CWDnsVIqbyuCsd9JBXt+5YIek49N4zfXjXPshtLZdZosmKoljRqTq8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1750737698522730.0426697341182; Mon, 23 Jun 2025 21:01:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1022988.1398920 (Exim 4.92) (envelope-from ) id 1uTuqV-0005a0-FD; Tue, 24 Jun 2025 04:01:19 +0000 Received: by outflank-mailman (output) from mailman id 1022988.1398920; Tue, 24 Jun 2025 04:01:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTuqV-0005Y3-4l; Tue, 24 Jun 2025 04:01:19 +0000 Received: by outflank-mailman (input) for mailman id 1022988; Tue, 24 Jun 2025 04:01:18 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTum8-0006IZ-Oh for xen-devel@lists.xenproject.org; Tue, 24 Jun 2025 03:56:48 +0000 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4084eed8-50af-11f0-a30f-13f23c93f187; Tue, 24 Jun 2025 05:56:48 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4084eed8-50af-11f0-a30f-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1750737407; x=1750996607; bh=5yXPb6SqgHIQ4PIoB8k8GBXcIv2K6UWy6GJUDsY9e8g=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=SYKGEdQ5sWCwPY6yPcDMhM+HBEIdbuJpsGuY1gSC5qpUJMqIPkoUdzIRKnJX92uNP MtKjJZhD31QHJnIrXD3+gq0mUqzI+lntp6G9A7J+8LQoLloHKNR4y7nHbaF3gKskyH eDP/biNweisrUTzDLZiOuR8GTlCbzMJ45wL7RNwjbVI67aLTi0eQGRNbTIe6tAnIUY TUn/rRdBOC42Dlj6R7FwM6X4Ce4djcKH1za6o7mWN1Z4LtGpc8jF1BNmUzkFiJ6XOP N0rING2hWudN/qmy8gMJy/8U/pUYjJRLFySPmXhXYLpxr0eAG86XD/v/3CDftMAoCF PlFQw/m8y4cUQ== Date: Tue, 24 Jun 2025 03:56:43 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, oleksii.kurochko@gmail.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v1 12/16] xen/domain: introduce domain-emu.h Message-ID: <20250624035443.344099-13-dmukhin@ford.com> In-Reply-To: <20250624035443.344099-1-dmukhin@ford.com> References: <20250624035443.344099-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: b341b04a459a662589cb5e9b9a7be4c7a9828afd MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1750737700214116600 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 Define an architecture-independent location for describing domain emulation flags. Signed-off-by: Denis Mukhin --- Original code: https://lore.kernel.org/xen-devel/20250103-vuart-ns8250-v3-v= 1-6-c5d36b31d66c@ford.com/ --- 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 diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/d= omain.h index eafd5cfc903d..c6bc83b4abe0 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -3,6 +3,7 @@ =20 #include #include +#include #include #include #include @@ -458,16 +459,16 @@ struct arch_domain } __cacheline_aligned; =20 #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 =20 -#define X86_EMU_PIT XEN_X86_EMU_PIT +#define X86_EMU_PIT DOMAIN_EMU_PIT =20 /* This must match XEN_X86_EMU_ALL in xen.h */ #define X86_EMU_ALL (X86_EMU_LAPIC | X86_EMU_HPET | \ diff --git a/xen/include/xen/domain-emu.h b/xen/include/xen/domain-emu.h new file mode 100644 index 000000000000..410963ff480c --- /dev/null +++ b/xen/include/xen/domain-emu.h @@ -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: + */ --=20 2.34.1 From nobody Fri Oct 31 03:39:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1750737691; cv=none; d=zohomail.com; s=zohoarc; b=Cp5QVDAOBiYvfHdfmiu8eoAapukRrYrkVGO7x3p7DddU9SyKLHY9dF4ICHWBrJ7Y3WWD68oe7HqTe3PrO1nC3LXgpwLM0wIItzSmCSulYrQ4XqLJbE3b1D8JsPMpD2CNOr1d1ZCikBzZmauDClIrXxU7MKEgjX69WRbRjZ/R/Wg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750737691; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BmcXMAPQmruv+WgoSlVyAgGhsw5O69P+wvMsGyq48aU=; b=b20qJEV5ki6S8mcm73ZFkCaQhGdgk4CrQxBnNpeUWYJPXKvXo66nInhctbKhEgiE/wtdHGrssyNKx26ABzt0t0mVHkrg1n38gzzPiBm1IMKWmUAZsB9lcygdi6qLd8UoI5bjfgDniiHvrzutbZiWbKl1/0U/9YkW+SwBlU+JxIE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1750737691675631.24486752018; Mon, 23 Jun 2025 21:01:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1022984.1398914 (Exim 4.92) (envelope-from ) id 1uTuqU-0005WE-UL; Tue, 24 Jun 2025 04:01:18 +0000 Received: by outflank-mailman (output) from mailman id 1022984.1398914; Tue, 24 Jun 2025 04:01:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTuqU-0005W7-Qi; Tue, 24 Jun 2025 04:01:18 +0000 Received: by outflank-mailman (input) for mailman id 1022984; Tue, 24 Jun 2025 04:01:17 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTumJ-000639-FV for xen-devel@lists.xenproject.org; Tue, 24 Jun 2025 03:56:59 +0000 Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 465b7409-50af-11f0-b894-0df219b8e170; Tue, 24 Jun 2025 05:56:58 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 465b7409-50af-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=ecvvigt2f5a3rbsqkhru7efk5u.protonmail; t=1750737417; x=1750996617; bh=BmcXMAPQmruv+WgoSlVyAgGhsw5O69P+wvMsGyq48aU=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=PjQXMLRiOIdDXwsAC5JMhvzlQLkF+5gHcJhwudnRGG5aoUajK2Ng3TwWnFghbBGfT J84eCTNPDiL/etV6bkLSNqdoy4GsJxlUeXHjYbJ3uS5qFevV+IUUD902Do8yVvnLd9 GJtyOWYKtl2O57HQ4WQI4otmrChDOLWiU00QIzPwPCTH7efVh0vwPsEUgvYdzMP1WS SPY0QrYpWPdxfqSKJGvUDFRXGIfvKy82MKIY+glrf5t3Qg0JdQkbxEAwuu8iyT02XK kWhJyPNfDIjR7bKPZncrulrFjCrn2Ee0IVl9QCGzakZDC9LUcAHBVbPjZlM0fwZKdC ho6K91g/1xHvg== Date: Tue, 24 Jun 2025 03:56:52 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, oleksii.kurochko@gmail.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v1 13/16] drivers/vuart: move PL011 emulator code Message-ID: <20250624035443.344099-14-dmukhin@ford.com> In-Reply-To: <20250624035443.344099-1-dmukhin@ford.com> References: <20250624035443.344099-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: e703f20ca9c0a634a9318d220f2e9539bd9eca76 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1750737692241116600 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 Move PL011 emulator to the new location for UART emulators. No functional change intended. Signed-off-by: Denis Mukhin --- 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 =3D> 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 =3D> drivers/vuart/vuart-pl011.c} (100%) diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index b11cb583a763..6eeae97293f2 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -170,13 +170,6 @@ config NEW_VGIC problems with the standard emulation. At the moment this implementation is not security supported. =20 -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 diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index dd015a2a19e8..8475043d8701 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -65,7 +65,6 @@ obj-$(CONFIG_HAS_ITS) +=3D vgic-v3-its.o endif obj-$(CONFIG_VM_EVENT) +=3D vm_event.o obj-y +=3D vtimer.o -obj-$(CONFIG_HAS_VUART_PL011) +=3D vpl011.o obj-y +=3D vsmc.o obj-y +=3D vpsci.o obj-$(CONFIG_HAS_VUART_MMIO) +=3D vuart.o diff --git a/xen/drivers/Kconfig b/xen/drivers/Kconfig index 20050e9bb8b3..5e533b260004 100644 --- a/xen/drivers/Kconfig +++ b/xen/drivers/Kconfig @@ -12,6 +12,8 @@ source "drivers/pci/Kconfig" =20 source "drivers/video/Kconfig" =20 +source "drivers/vuart/Kconfig" + config HAS_VPCI bool =20 diff --git a/xen/drivers/Makefile b/xen/drivers/Makefile index 2a1ae8ad130a..510820472938 100644 --- a/xen/drivers/Makefile +++ b/xen/drivers/Makefile @@ -2,6 +2,7 @@ obj-y +=3D char/ obj-$(CONFIG_HAS_CPUFREQ) +=3D cpufreq/ obj-$(CONFIG_HAS_PCI) +=3D pci/ obj-$(CONFIG_HAS_VPCI) +=3D vpci/ +obj-$(CONFIG_HAS_VUART) +=3D vuart/ obj-$(CONFIG_HAS_PASSTHROUGH) +=3D passthrough/ obj-$(CONFIG_ACPI) +=3D acpi/ obj-$(CONFIG_VIDEO) +=3D video/ diff --git a/xen/drivers/vuart/Kconfig b/xen/drivers/vuart/Kconfig new file mode 100644 index 000000000000..d8df0f6d1b3c --- /dev/null +++ b/xen/drivers/vuart/Kconfig @@ -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 diff --git a/xen/drivers/vuart/Makefile b/xen/drivers/vuart/Makefile new file mode 100644 index 000000000000..3b7069f1cf95 --- /dev/null +++ b/xen/drivers/vuart/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_HAS_VUART_PL011) +=3D vuart-pl011.o diff --git a/xen/arch/arm/vpl011.c b/xen/drivers/vuart/vuart-pl011.c similarity index 100% rename from xen/arch/arm/vpl011.c rename to xen/drivers/vuart/vuart-pl011.c --=20 2.34.1 From nobody Fri Oct 31 03:39:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1750737663; cv=none; d=zohomail.com; s=zohoarc; b=lEAMVdI6TEjsTHhoyX8AQDZJ7QOmf5yNuuNP8HN4n3R+t8cFaHMLm0eOZAkv5y9g8Ko9LnT1zgwuweCEUjFskIrUZ6BAwyU5FB4oIyBEhJ/R6YlMRKxEorHGNKduFikMH7x8aXWGx+c1VyJ8Wv0QPtsY/WIUlTg/Qv6OqmxGPO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750737663; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EZ+uMveraa+cDZkwCgDIWFYhH2jzngRaVV7LukeCweg=; b=c8nLhC5gj9YJdZZChlwHhvB0dNlLvu1bLr5wF3B5rE+dT9dNeHXSsOKPl3plDfjlrGI57+7QQvlJxc26rNHxih0c3VIz/FWene6LM8fMo+/owWFai2tEMwG35ULLdj9L06gOY0caoBmJccoQ4CemtZI5aj95pRsq2qsGqlwAotY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1750737663475277.32561497686436; Mon, 23 Jun 2025 21:01:03 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1022953.1398834 (Exim 4.92) (envelope-from ) id 1uTuq4-0002Dp-FE; Tue, 24 Jun 2025 04:00:52 +0000 Received: by outflank-mailman (output) from mailman id 1022953.1398834; Tue, 24 Jun 2025 04:00:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTuq4-0002Di-CH; Tue, 24 Jun 2025 04:00:52 +0000 Received: by outflank-mailman (input) for mailman id 1022953; Tue, 24 Jun 2025 04:00:50 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTumS-000639-86 for xen-devel@lists.xenproject.org; Tue, 24 Jun 2025 03:57:08 +0000 Received: from mail-10629.protonmail.ch (mail-10629.protonmail.ch [79.135.106.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4b73ea28-50af-11f0-b894-0df219b8e170; Tue, 24 Jun 2025 05:57:06 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4b73ea28-50af-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1750737425; x=1750996625; bh=EZ+uMveraa+cDZkwCgDIWFYhH2jzngRaVV7LukeCweg=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=XYoKRTdUwDz/DU7S9mYIwzelOwKSVrRTMDn1HZvw6DdtwhN77jLq6ATpPRZoN/qg3 YmaDRlyNpPIshkXaoGy4WRAn/4qwpjEAAa0aSxqkarl1JfknvJVAcirucw+7wTxtte b+s0q4KQQmHBPSv9xOmruko/r0oi+A7NVBwxaQKKgo2Ky7DOqi5aKlpkNBxTyjrQDo we0wtEUi/OatP7tFJ58T7DSt5p3WkHVYp7zuhcWu8xdmDYgUoaHr4G3sZK/1DPhqJK L3xL/Mbz8KhFT0arBWGp2tnY1nlsVZsz9gaNOmOJ5V0S3ni8eB8xQ+oTO4ytRTAUM1 M0yoalpTT9k2w== Date: Tue, 24 Jun 2025 03:57:00 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, oleksii.kurochko@gmail.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v1 14/16] drivers/vuart: move simple MMIO-based UART emulator Message-ID: <20250624035443.344099-15-dmukhin@ford.com> In-Reply-To: <20250624035443.344099-1-dmukhin@ford.com> References: <20250624035443.344099-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: f583a78ed85278e4f659d4fbdd3a908ebf03d47f MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1750737663838116600 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 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. Signed-off-by: Denis Mukhin --- 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 =3D> drivers/vuart/vuart-mmio.c} | 0 5 files changed, 10 insertions(+), 9 deletions(-) rename xen/{arch/arm/vuart.c =3D> drivers/vuart/vuart-mmio.c} (100%) diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 6eeae97293f2..7b915abc6f18 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -170,14 +170,6 @@ config NEW_VGIC problems with the standard emulation. At the moment this implementation is not security supported. =20 -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 diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 8475043d8701..24bc9c88f7ac 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -67,7 +67,6 @@ obj-$(CONFIG_VM_EVENT) +=3D vm_event.o obj-y +=3D vtimer.o obj-y +=3D vsmc.o obj-y +=3D vpsci.o -obj-$(CONFIG_HAS_VUART_MMIO) +=3D vuart.o =20 extra-y +=3D xen.lds =20 diff --git a/xen/drivers/vuart/Kconfig b/xen/drivers/vuart/Kconfig index d8df0f6d1b3c..6002817152df 100644 --- a/xen/drivers/vuart/Kconfig +++ b/xen/drivers/vuart/Kconfig @@ -3,6 +3,15 @@ config HAS_VUART =20 if (ARM_32 || ARM_64) =20 +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 diff --git a/xen/drivers/vuart/Makefile b/xen/drivers/vuart/Makefile index 3b7069f1cf95..1c775ffb7f1d 100644 --- a/xen/drivers/vuart/Makefile +++ b/xen/drivers/vuart/Makefile @@ -1 +1,2 @@ +obj-$(CONFIG_HAS_VUART_MMIO) +=3D vuart-mmio.o obj-$(CONFIG_HAS_VUART_PL011) +=3D vuart-pl011.o diff --git a/xen/arch/arm/vuart.c b/xen/drivers/vuart/vuart-mmio.c similarity index 100% rename from xen/arch/arm/vuart.c rename to xen/drivers/vuart/vuart-mmio.c --=20 2.34.1 From nobody Fri Oct 31 03:39:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1750737679; cv=none; d=zohomail.com; s=zohoarc; b=QwyEm2WnBPMTxJDTezwMfUZ7Ble4QfWHnK5OuHWzKqovmn4aeLRSkWuUI39YaF2z7hRzN9ViLHo5b4pQH1z40sSAnv7sqQVqbX0hEfCiyqQF5a1yYFCGe98CRf30lMLKTWB3pshscYv3KTxlGOQDcxFmvICVPYPCIOs0T/QWmZk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750737679; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=G+phzEkJh7bBPfUI5tVh5uJv49ZZOGGUY1qVym3PEsU=; b=MHFFIZ9wC+KJr2xX7dk/fySFG1NmQsg0PlSuTnjvGtyLz3b+XyDQjU5LZ3GoD0xuspu+EYHBZZLeSH5WtFKgZLmEkVN98Nj6169/GbKG3YdIcCifJQ7iws2C0CEXtUoDhKbN7h1av5btVljj/DDTJbz/NtwCY60oPkcFky/AQdw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1750737679475228.7555357437318; Mon, 23 Jun 2025 21:01:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1022959.1398864 (Exim 4.92) (envelope-from ) id 1uTuqD-00036H-4L; Tue, 24 Jun 2025 04:01:01 +0000 Received: by outflank-mailman (output) from mailman id 1022959.1398864; Tue, 24 Jun 2025 04:01:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTuqD-000366-15; Tue, 24 Jun 2025 04:01:01 +0000 Received: by outflank-mailman (input) for mailman id 1022959; Tue, 24 Jun 2025 04:00:59 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTumc-0006IZ-Kd for xen-devel@lists.xenproject.org; Tue, 24 Jun 2025 03:57:18 +0000 Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 50f5f1dd-50af-11f0-a30f-13f23c93f187; Tue, 24 Jun 2025 05:57:15 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 50f5f1dd-50af-11f0-a30f-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=suhlavfxo5fcjncdpc7tjndoiq.protonmail; t=1750737434; x=1750996634; bh=G+phzEkJh7bBPfUI5tVh5uJv49ZZOGGUY1qVym3PEsU=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=YGzehV0MRobbiY+vb5LN2ZXUJVWvxD1OCUBrMIbCzKCfh4dQxe3fMG9f8RYkhBV1h or+fkTjdzobaFvZuysUs8aq1DW9wrZeR7s3dWS994aTJXLZvANgHd5TE80KEOjnOlI QPUfnOquaI59Yr/6rVdV+30TNs+3EKBrpMifSBNNJUB6ZhTZpFLHaUO2cqnMoSWqEN jO+1j0xWGhsEZrXecrlwAh0MGYyJfxpYI2ZOgLzn9abxX+DW2R89HRt9nsdqSUNuU4 P4GcErm8bQL5zp1t1jXb7ew5s7CXdEb2afYPRkHXMqWRW/1BJnkEeUMp8RivNwelQl 6S/ypOMHolQ1Q== Date: Tue, 24 Jun 2025 03:57:09 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, oleksii.kurochko@gmail.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v1 15/16] drivers/vuart: introduce framework for UART emulators Message-ID: <20250624035443.344099-16-dmukhin@ford.com> In-Reply-To: <20250624035443.344099-1-dmukhin@ford.com> References: <20250624035443.344099-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: 9444a946e272c03e86bb37c3bab824ff5afa7c2f MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1750737680402116600 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 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 enabl= ed once the user enables any UART emulator. Current implementation supports maximum of one vUART of each kind per domai= n. 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 ch= eck whether domain has virtual UART. Use domain_has_vuart() in the console driver code to check whether to forwa= rd console input to the domain using vUART. Hook existing PL011 UART emulator to the new driver framework. Signed-off-by: Denis Mukhin --- Original code: https://lore.kernel.org/xen-devel/20250103-vuart-ns8250-v3-v= 1-7-c5d36b31d66c@ford.com/ --- 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 diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 11b8498d3b22..c04441ef4657 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -176,14 +176,9 @@ int __init make_arch_nodes(struct kernel_info *kinfo) if ( ret ) return -EINVAL; =20 - if ( kinfo->arch.vpl011 ) - { -#ifdef CONFIG_HAS_VUART_PL011 - ret =3D vuart_add_fwnode(kinfo->d, kinfo); -#endif - if ( ret ) - return -EINVAL; - } + ret =3D vuart_add_fwnode(kinfo->d, kinfo); + if ( ret ) + return ret; =20 return 0; } @@ -207,19 +202,16 @@ int __init init_vuart(struct domain *d, struct kernel= _info *kinfo, { int rc =3D 0; =20 - kinfo->arch.vpl011 =3D 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 variabl= es * shall be done first. */ - if ( kinfo->arch.vpl011 ) - { + if ( dt_property_read_bool(node, "vpl011") ) + d->emulation_flags |=3D DOMAIN_EMU_UART_PL011; + + if ( domain_has_vuart(d) ) rc =3D vuart_init(d, NULL); - if ( rc < 0 ) - return rc; - } =20 return rc; } diff --git a/xen/arch/arm/domctl.c b/xen/arch/arm/domctl.c index dde25ceff6d0..45144eca1ae2 100644 --- a/xen/arch/arm/domctl.c +++ b/xen/arch/arm/domctl.c @@ -43,8 +43,9 @@ static int handle_vuart_init(struct domain *d, if ( vuart_op->type !=3D XEN_DOMCTL_VUART_TYPE_VPL011 ) return -EOPNOTSUPP; =20 - rc =3D vuart_init(d, ¶ms); + d->emulation_flags |=3D DOMAIN_EMU_UART_PL011; =20 + rc =3D vuart_init(d, ¶ms); if ( !rc ) vuart_op->evtchn =3D params.evtchn; =20 diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/d= omain.h index 38873c66f1f8..32ef281151d8 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -2,6 +2,7 @@ #define __ASM_DOMAIN_H__ =20 #include +#include #include #include #include diff --git a/xen/arch/arm/include/asm/kernel.h b/xen/arch/arm/include/asm/k= ernel.h index 7c3b7fde5b64..cfeab792c76e 100644 --- a/xen/arch/arm/include/asm/kernel.h +++ b/xen/arch/arm/include/asm/kernel.h @@ -13,9 +13,6 @@ struct arch_kernel_info #ifdef CONFIG_ARM_64 enum domain_type type; #endif - - /* Enable pl011 emulation */ - bool vpl011; }; =20 #endif /* #ifdef __ARCH_ARM_KERNEL_H__ */ diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S index 5bfbe1e92c1e..e876e3efbe4c 100644 --- a/xen/arch/arm/xen.lds.S +++ b/xen/arch/arm/xen.lds.S @@ -66,6 +66,7 @@ SECTIONS __proc_info_end =3D .; =20 VPCI_ARRAY + VUART_ARRAY } :text =20 #if defined(BUILD_ID) diff --git a/xen/arch/ppc/include/asm/domain.h b/xen/arch/ppc/include/asm/d= omain.h index 3a447272c6f2..426e6297c935 100644 --- a/xen/arch/ppc/include/asm/domain.h +++ b/xen/arch/ppc/include/asm/domain.h @@ -2,6 +2,7 @@ #ifndef __ASM_PPC_DOMAIN_H__ #define __ASM_PPC_DOMAIN_H__ =20 +#include #include #include =20 diff --git a/xen/arch/ppc/xen.lds.S b/xen/arch/ppc/xen.lds.S index 1366e2819eed..56bf4a0638d5 100644 --- a/xen/arch/ppc/xen.lds.S +++ b/xen/arch/ppc/xen.lds.S @@ -55,6 +55,7 @@ SECTIONS *(.data.rel.ro.*) =20 VPCI_ARRAY + VUART_ARRAY =20 . =3D ALIGN(POINTER_ALIGN); } :text diff --git a/xen/arch/riscv/include/asm/domain.h b/xen/arch/riscv/include/a= sm/domain.h index c3d965a559b6..fcde3bc78dc6 100644 --- a/xen/arch/riscv/include/asm/domain.h +++ b/xen/arch/riscv/include/asm/domain.h @@ -2,6 +2,7 @@ #ifndef ASM__RISCV__DOMAIN_H #define ASM__RISCV__DOMAIN_H =20 +#include #include #include =20 diff --git a/xen/arch/riscv/xen.lds.S b/xen/arch/riscv/xen.lds.S index 8c3c06de01f6..45592fca128f 100644 --- a/xen/arch/riscv/xen.lds.S +++ b/xen/arch/riscv/xen.lds.S @@ -50,6 +50,7 @@ SECTIONS *(.data.rel.ro.*) =20 VPCI_ARRAY + VUART_ARRAY =20 . =3D ALIGN(POINTER_ALIGN); } :text diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index bf956b6c5fc0..b04ed1e6138c 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -149,6 +149,7 @@ SECTIONS __note_gnu_build_id_end =3D .; #endif VPCI_ARRAY + VUART_ARRAY } PHDR(text) =20 #if defined(CONFIG_PVH_GUEST) && !defined(EFI) diff --git a/xen/common/domain.c b/xen/common/domain.c index 8c8f70347a91..071fee81fe2c 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -2436,6 +2436,16 @@ void thaw_domains(void) rcu_read_unlock(&domlist_read_lock); } =20 +bool domain_has_vuart(const struct domain *d) +{ + uint32_t mask =3D 0; + + if ( IS_ENABLED(CONFIG_HAS_VUART_PL011) ) + mask |=3D DOMAIN_EMU_UART_PL011; + + return !!(d->emulation_flags & mask); +} + /* * Local variables: * mode: C diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c index eccd97c565c6..21e970aded9a 100644 --- a/xen/common/keyhandler.c +++ b/xen/common/keyhandler.c @@ -22,6 +22,7 @@ #include #include #include +#include #include =20 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); } =20 for_each_domain ( d ) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index f322d59515ab..5ddc05cc44da 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -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) !=3D SERIAL_RX_SIZE ) serial_rx_ring[SERIAL_RX_MASK(serial_rx_prod++)] =3D 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 =3D vuart_putchar(d, c); -#endif =20 if ( consoled_is_enabled() ) /* Deliver input to the PV shim console. */ diff --git a/xen/drivers/vuart/Makefile b/xen/drivers/vuart/Makefile index 1c775ffb7f1d..fa9aab666c2a 100644 --- a/xen/drivers/vuart/Makefile +++ b/xen/drivers/vuart/Makefile @@ -1,2 +1,3 @@ +obj-$(CONFIG_HAS_VUART) +=3D vuart.o obj-$(CONFIG_HAS_VUART_MMIO) +=3D vuart-mmio.o obj-$(CONFIG_HAS_VUART_PL011) +=3D vuart-pl011.o diff --git a/xen/drivers/vuart/vuart-pl011.c b/xen/drivers/vuart/vuart-pl01= 1.c index bebfb5e0365c..312618ad1b6f 100644 --- a/xen/drivers/vuart/vuart-pl011.c +++ b/xen/drivers/vuart/vuart-pl011.c @@ -638,9 +638,9 @@ static void vpl011_data_avail(struct domain *d, } =20 /* - * vuart_putchar adds a char to a domain's vpl011 receive buffer. + * vpl011_putchar adds a char to a domain's vpl011 receive buffer. */ -int vuart_putchar(struct domain *d, char c) +static int cf_check vpl011_putchar(struct domain *d, char c) { unsigned long flags; struct vpl011 *vpl011 =3D d->arch.vpl011; @@ -709,7 +709,8 @@ static void vpl011_notification(struct vcpu *v, unsigne= d int port) spin_unlock_irqrestore(&vpl011->lock, flags); } =20 -int vuart_init(struct domain *d, struct vuart_params *params) +static int cf_check vpl011_init(struct domain *d, + struct vuart_params *params) { struct vpl011 *vpl011; int rc; @@ -824,7 +825,7 @@ err_out: return rc; } =20 -void vuart_exit(struct domain *d) +static void cf_check vpl011_exit(struct domain *d) { if ( d->arch.vpl011 ) { @@ -833,9 +834,57 @@ void vuart_exit(struct domain *d) } } =20 -int __init vuart_add_fwnode(struct domain *d, void *node) +static void cf_check vpl011_dump(const struct domain *d) { - struct kernel_info *kinfo =3D node; + struct vpl011 *vdev =3D d->arch.vpl011; + + if ( !vdev ) + return; + + /* Allow printing state in case of a deadlock. */ + if ( !spin_trylock(&vdev->lock) ) + return; + + printk("Virtual PL011@%"PRIpaddr" IRQ#%d owner %pd\n", + vdev->base_addr, vdev->virq, d); + + if ( vdev->backend_in_domain ) + { + printk(" Event channel %"PRIu32"\n", vdev->evtchn); + } + else + { + const struct vpl011_xen_backend *cons =3D vdev->backend.xen; + + printk(" RX FIFO size %u in_prod %u in_cons %u used %u\n", + SBSA_UART_FIFO_SIZE, cons->in_prod, cons->in_cons, + cons->in_prod - cons->in_cons); + + printk(" TX FIFO size %u out_prod %u used %u\n", + SBSA_UART_OUT_BUF_SIZE, cons->out_prod, cons->out_prod); + } + + printk(" %02"PRIx8" DR %08"PRIx8"\n", DR , 0); + printk(" %02"PRIx8" RSR %08"PRIx8"\n", RSR , 0); + printk(" %02"PRIx8" FR %08"PRIx8"\n", FR , vdev->uartfr); + printk(" %02"PRIx8" ILPR %08"PRIx8"\n", ILPR , 0); + printk(" %02"PRIx8" IBRD %08"PRIx8"\n", IBRD , 0); + printk(" %02"PRIx8" FBRD %08"PRIx8"\n", FBRD , 0); + printk(" %02"PRIx8" LCR_H %08"PRIx8"\n", LCR_H, 0); + printk(" %02"PRIx8" CR %08"PRIx8"\n", CR , vdev->uartcr); + printk(" %02"PRIx8" IFLS %08"PRIx8"\n", IFLS , 0); + printk(" %02"PRIx8" IMSC %08"PRIx8"\n", IMSC , vdev->uartimsc); + printk(" %02"PRIx8" RIS %08"PRIx8"\n", RIS , vdev->uartris); + printk(" %02"PRIX8" MIS %08"PRIX8"\n", MIS , vdev->shadow_uartmis); + printk(" %02"PRIx8" ICR %08"PRIx8"\n", ICR , vdev->uarticr); + printk(" %02"PRIx8" DMACR %08"PRIx8"\n", DMACR, 0); + + spin_unlock(&vdev->lock); +} + +static int cf_check vpl011_add_fwnode(struct domain *d, void *info) +{ + struct kernel_info *kinfo =3D info; void *fdt =3D kinfo->fdt; int res; gic_interrupt_t intr; @@ -884,6 +933,16 @@ int __init vuart_add_fwnode(struct domain *d, void *no= de) return 0; } =20 +static const struct vuart_ops vpl011_ops =3D { + .add_fwnode =3D vpl011_add_fwnode, + .init =3D vpl011_init, + .exit =3D vpl011_exit, + .dump =3D vpl011_dump, + .putchar =3D vpl011_putchar, +}; + +VUART_REGISTER(vpl011, &vpl011_ops); + /* * Local variables: * mode: C diff --git a/xen/drivers/vuart/vuart.c b/xen/drivers/vuart/vuart.c new file mode 100644 index 000000000000..ab3c2504bff5 --- /dev/null +++ b/xen/drivers/vuart/vuart.c @@ -0,0 +1,95 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include + +extern const struct vuart_ops *const __vuart_array_start[]; +extern const struct vuart_ops *const __vuart_array_end[]; + +#define VUART_ARRAY_SIZE (__vuart_array_end - __vuart_array_start) + +#define for_each_vuart(vdev) \ + for (unsigned __i =3D 0; \ + __i < VUART_ARRAY_SIZE && (vdev =3D __vuart_array_start[__i], 1);= \ + __i++) + +int vuart_add_fwnode(struct domain *d, void *node) +{ + const struct vuart_ops *vdev; + int rc; + + for_each_vuart(vdev) + { + if ( !vdev->add_fwnode ) + continue; + + rc =3D vdev->add_fwnode(d, node); + if ( rc ) + return rc; + } + + return 0; +} + +int vuart_init(struct domain *d, struct vuart_params *params) +{ + const struct vuart_ops *vdev; + int rc; + + for_each_vuart(vdev) + { + rc =3D vdev->init(d, params); + if ( rc ) + return rc; + } + + d->console.input_allowed =3D true; + + return 0; +} + +/* + * Release any resources taken by UART emulators. + * + * NB: no flags are cleared, since currently exit() is called only during + * domain destroy. + */ +void vuart_exit(struct domain *d) +{ + const struct vuart_ops *vdev; + + for_each_vuart(vdev) + vdev->exit(d); +} + +void vuart_dump(const struct domain *d) +{ + const struct vuart_ops *vdev; + + for_each_vuart(vdev) + vdev->dump(d); +} + +/* + * Put character to the first suitable emulated UART's FIFO. + */ +int vuart_putchar(struct domain *d, char c) +{ + const struct vuart_ops *vdev =3D NULL; + + for_each_vuart(vdev) + if ( vdev->putchar ) + break; + + return vdev ? vdev->putchar(d, c) : -ENODEV; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/xen/domain-emu.h b/xen/include/xen/domain-emu.h index 410963ff480c..1d3a6c80fadd 100644 --- a/xen/include/xen/domain-emu.h +++ b/xen/include/xen/domain-emu.h @@ -17,6 +17,8 @@ #define DOMAIN_EMU_PIRQ (1U << 9) #define DOMAIN_EMU_PCI (1U << 10) =20 +#define DOMAIN_EMU_UART_PL011 (1U << 15) + #endif /* XEN_DOMAIN_EMU_H */ =20 /* diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index e10baf2615fd..e40906380760 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -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) =20 +bool domain_has_vuart(const struct domain *d); + /* * Arch-specifics. */ diff --git a/xen/include/xen/vuart.h b/xen/include/xen/vuart.h index 928b60bbb4e2..1f4b47575359 100644 --- a/xen/include/xen/vuart.h +++ b/xen/include/xen/vuart.h @@ -12,16 +12,29 @@ struct vuart_params { evtchn_port_t evtchn; }; =20 -#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); +}; =20 -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) =3D (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); =20 #else =20 -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) { } =20 +static inline void vuart_dump(const struct domain *d) +{ +} + static inline int vuart_putchar(struct domain *d, char c) { ASSERT_UNREACHABLE(); return -ENODEV; } =20 -#endif /* CONFIG_HAS_VUART_PL011 */ +#endif /* CONFIG_HAS_VUART */ =20 #ifdef CONFIG_HAS_VUART_MMIO =20 diff --git a/xen/include/xen/xen.lds.h b/xen/include/xen/xen.lds.h index 793d0e11450c..1671257e19ee 100644 --- a/xen/include/xen/xen.lds.h +++ b/xen/include/xen/xen.lds.h @@ -194,4 +194,14 @@ #define VPCI_ARRAY #endif =20 +#ifdef CONFIG_HAS_VUART +#define VUART_ARRAY \ + . =3D ALIGN(POINTER_ALIGN); \ + __vuart_array_start =3D .; \ + *(SORT(.data.vuart.*)) \ + __vuart_array_end =3D .; +#else +#define VUART_ARRAY +#endif + #endif /* __XEN_LDS_H__ */ --=20 2.34.1 From nobody Fri Oct 31 03:39:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1750737684; cv=none; d=zohomail.com; s=zohoarc; b=gY/q1oLDZLs+RhO+g0AL1oqfD38jXNk63nPeb4JMYiFqeHIvC0yJmuEu1bD7yidyxuQOZeAHckFH8RWqw0YaHL1RU1YmE9HJUdMbCfzQ0m0SqY7tfgvJ4GnHE1wwqw6TqlNNyR+/dR4MkFgIf4ndzzU73iGK2F5vdh+vNC/6+3Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750737684; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XBHNSuDbgBBMVwzL8Si36lrzIPH6BlSYi7VpRWP3DmY=; b=ADgZlIhxsFAP2lnB0l+CleN6DGIYj3xrl++YEdi8oAkyQLerMGpI/QEwjK8uHgM2XABYGrsgb6ZmWPr5TsqKy3q+IChcEqqDiE2MdDv7ODnURRqYDBE6/WS4jrAdRwYavAgfM96ejhAT7/M4gwGanzAJP1j2i/wwAZTt+wti9mY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1750737684518543.77043675227; Mon, 23 Jun 2025 21:01:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1022961.1398873 (Exim 4.92) (envelope-from ) id 1uTuqF-0003Qc-Ky; Tue, 24 Jun 2025 04:01:03 +0000 Received: by outflank-mailman (output) from mailman id 1022961.1398873; Tue, 24 Jun 2025 04:01:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTuqF-0003QQ-Gl; Tue, 24 Jun 2025 04:01:03 +0000 Received: by outflank-mailman (input) for mailman id 1022961; Tue, 24 Jun 2025 04:01:01 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uTumk-0006IZ-W9 for xen-devel@lists.xenproject.org; Tue, 24 Jun 2025 03:57:26 +0000 Received: from mail-24417.protonmail.ch (mail-24417.protonmail.ch [109.224.244.17]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 574ca993-50af-11f0-a30f-13f23c93f187; Tue, 24 Jun 2025 05:57:26 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 574ca993-50af-11f0-a30f-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1750737445; x=1750996645; bh=XBHNSuDbgBBMVwzL8Si36lrzIPH6BlSYi7VpRWP3DmY=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=bnXBk56uU4B3o8hqrw5rpChmiKLfMsbyky9ML+81U/L7dns2DqJIL4R1ta73+Zklq LKpZYSEfpMHdCY2aVUJY4tL9ayh0LDCf+3VhOZ2LV0xJ4LVOOkl9p5jN35AK2iI9Wk b7N7D0Vs8PPdDLe1hQ5OGkIRsglVNiwKK6+ak0q+g3wMKi1Mv1pUu5bEg6ymEqmuhh RpcASFCkyjUmFRW2G5bEus6IsUo2rD+3QdeAe7G0aid+QJ7gr6ZLiGR6sClj0zF8ar vg6Au5UQCIdiTa+958eke45qh+SHAPzN0sbrLDKZvjvYZWVzQ/9rbIc8m1Dk6DjFyQ cMzzHsBpp1U8A== Date: Tue, 24 Jun 2025 03:57:18 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, oleksii.kurochko@gmail.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v1 16/16] drivers/vuart: hook simple MMIO-based UART to vUART framework Message-ID: <20250624035443.344099-17-dmukhin@ford.com> In-Reply-To: <20250624035443.344099-1-dmukhin@ford.com> References: <20250624035443.344099-1-dmukhin@ford.com> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: 1977647053db5ab95117f34afa1110e2b05be770 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1750737686421116600 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 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 emulato= r. Remove domain_vuart_{init,free}() and use generic vuart_{init,exit}() calls. No functional change intended. Signed-off-by: Denis Mukhin --- 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(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 3579d10d7e1d..5d7006241be0 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -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 =3D domain_vuart_init(d)) ) + if ( is_hardware_domain(d) && IS_ENABLED(CONFIG_HAS_VUART_MMIO) ) + d->emulation_flags |=3D DOMAIN_EMU_UART_MMIO; + + if ( domain_has_vuart(d) && (rc =3D vuart_init(d, NULL)) !=3D 0 ) goto fail; =20 if ( (rc =3D domain_vpci_init(d)) !=3D 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, diff --git a/xen/common/domain.c b/xen/common/domain.c index 071fee81fe2c..fc0ceb266d88 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -2443,6 +2443,9 @@ bool domain_has_vuart(const struct domain *d) if ( IS_ENABLED(CONFIG_HAS_VUART_PL011) ) mask |=3D DOMAIN_EMU_UART_PL011; =20 + if ( IS_ENABLED(CONFIG_HAS_VUART_MMIO) ) + mask |=3D DOMAIN_EMU_UART_MMIO; + return !!(d->emulation_flags & mask); } =20 diff --git a/xen/drivers/vuart/vuart-mmio.c b/xen/drivers/vuart/vuart-mmio.c index 66fac6c994ce..1888e44e3d94 100644 --- a/xen/drivers/vuart/vuart-mmio.c +++ b/xen/drivers/vuart/vuart-mmio.c @@ -49,7 +49,7 @@ static const struct mmio_handler_ops vuart_mmio_handler = =3D { .write =3D vuart_mmio_write, }; =20 -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; } =20 -void domain_vuart_free(struct domain *d) +static void cf_check vuart_mmio_exit(struct domain *d) { struct vuart *vdev =3D d->arch.vuart; =20 @@ -147,6 +147,38 @@ static int vuart_mmio_write(struct vcpu *v, mmio_info_= t *info, return 1; } =20 +static void cf_check vuart_mmio_dump(const struct domain *d) +{ + struct vuart *vdev =3D 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 =3D { + .add_fwnode =3D NULL, + .init =3D vuart_mmio_init, + .exit =3D vuart_mmio_exit, + .dump =3D vuart_mmio_dump, + /* Physical console focus is not supported */ + .putchar =3D NULL, +}; + +VUART_REGISTER(mmio, &vuart_mmio_ops); + /* * Local variables: * mode: C diff --git a/xen/include/xen/domain-emu.h b/xen/include/xen/domain-emu.h index 1d3a6c80fadd..9ef607666842 100644 --- a/xen/include/xen/domain-emu.h +++ b/xen/include/xen/domain-emu.h @@ -18,6 +18,7 @@ #define DOMAIN_EMU_PCI (1U << 10) =20 #define DOMAIN_EMU_UART_PL011 (1U << 15) +#define DOMAIN_EMU_UART_MMIO (1U << 16) =20 #endif /* XEN_DOMAIN_EMU_H */ =20 diff --git a/xen/include/xen/vuart.h b/xen/include/xen/vuart.h index 1f4b47575359..4c923025b4eb 100644 --- a/xen/include/xen/vuart.h +++ b/xen/include/xen/vuart.h @@ -60,26 +60,6 @@ static inline int vuart_putchar(struct domain *d, char c) =20 #endif /* CONFIG_HAS_VUART */ =20 -#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 */ =20 /* --=20 2.34.1