[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 07/24] xen/console: introduce framework for UART emulators
- To: <dmukhin@xxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Jason Andryuk <jason.andryuk@xxxxxxx>
- Date: Mon, 27 Jan 2025 19:25:59 -0500
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=ford.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UwRU4nxk5uvPUHcrM/kNF4IzdzGLXo7Ym7SK0HWhYmM=; b=yAOsnDqH14NkzcHO4w4994E8kLdIsjyMaMU5X876aD2W/dNkZ6PQ1Cync6hRwGV/SIw6gPcTbpPOSP81gQGRUEAv8ISyCWD0JsUBCwKhzJ3aGtQQ/K0PFKG+olYGe3cfAJepeNs2zCMzHB7LlkqdduAxwuRmonojx6Cf5Gbmnsy7P2h7J6vAwLVEN+AOskt1uY9+mBatHKjaR6UlRCLuNKa5LPHGTlCBAsvgyteO7yyOMhqOKKR89PTENuvsg98KlQOPYZsrRLDzzWmD2Att+wlS8gCdcco09dBs4AfGL6NlqF3spEPO9gOADL25b10f31qo6Yn9J97xre7+6efZsg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KmbF3FlH7x9HNWP3YYHbwDpsSBiNqAhuou51GAztEEePO5GWBztp7Ql+G8tbVvgEg4zL7djFE7/Dd5c71WrzMa+cpS2jWfehYn88ukl2z6obcg6Hmd737zFxegHtY0y2EX7o7W7eS02qihPtD0kRzABFYz7+T6IFhU0rv998Lpn90iFuocJYwhC37geAl1C3ZYIxOQMbQrw79v9I6qu9x8obN7EH20IA2yqOBVTyHFH161GlPQz+WLpU8VQFRke5CH8cnNqpIFFeVIMl7+RRoyobutRk54iz7xy+rEu+u3PoRBWbsa2goHf4fux/DDkXjS8lUMsxGj4rRvcQTC4RlQ==
- Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Delivery-date: Tue, 28 Jan 2025 01:01:30 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 2025-01-03 20:58, Denis Mukhin via B4 Relay wrote:
From: Denis Mukhin <dmukhin@xxxxxxxx>
Introduce a driver framework to abstract UART emulators in the hypervisor.
That allows for architecture-independent handling of virtual UARTs from Xen
console driver and simplifies enabling new architecture-dependent UART
emulators.
The framework is built under CONFIG_HAS_VUART, which is automatically enabled
once the user selects a specific UART emulator.
All domains w/ enabled vUART will have VIRTDEV_UART bit set in
d->arch.emulation_flags.
Current implementation supports maximum of one vUART per domain, excluding
emulators for hardware domains.
Use domain_has_vuart() in Xen console driver code to check whether the
domain can own the physical console focus.
Note, arm/vuart.c emulator is not hooked to virtdev-uart framework because the
emulator is limited to the hardware domains only and was not designed to own
the physical console input. Updated arm/vuart.c APIs to have 'hwdom_' prefix
instead of generic 'domain_' to avoid possible confusion.
It might be good to renmae xen/arch/arm/vuart.c to
xen/arch/arm/hwdom-vuart.c and then use just the shorter vuart prefix
instead virtdev_uart.
Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
diff --git a/xen/drivers/Kconfig b/xen/drivers/Kconfig
index
20050e9bb8b32bd16c2da76c2c3e0f68dab89394..355719c3af67683c153a4f7a35dad4944992846e
100644
--- a/xen/drivers/Kconfig
+++ b/xen/drivers/Kconfig
@@ -19,4 +19,9 @@ config HAS_VPCI_GUEST_SUPPORT
bool
select HAS_VPCI
+config HAS_VUART
+ bool "UART emulation framework"
+ help
+ This selects UART emulation framework.
This can be hidden, so just:
config HAS_VUART
bool
+
endmenu
+int virtdev_uart_init(struct domain *d, struct virtdev_uart_params *params)
+{
+ int rc;
+
+ ASSERT(__start_virtdev_uart);
+
+ rc = __start_virtdev_uart->init(d, params);
+ if ( rc )
+ return rc;
+
+#if !defined(__i386__) && !defined(__x86_64__)
+ d->arch.emulation_flags |= VIRTDEV_UART;
+#endif
+
+ return 0;
+}
+
+void virtdev_uart_exit(struct domain *d)
+{
+ ASSERT(__start_virtdev_uart);
+
+ __start_virtdev_uart->exit(d);
+
+#if !defined(__i386__) && !defined(__x86_64__)
+ d->arch.emulation_flags &= ~VIRTDEV_UART;
+#endif
I think this is only called at domain teardown, so you don't need to
clear flags.
+}
+
+int virtdev_uart_putchar(struct domain *d, char c)
+{
+ ASSERT(__start_virtdev_uart);
+ ASSERT(d->arch.emulation_flags & VIRTDEV_UART);
+
+ return __start_virtdev_uart->putchar(d, c);
+}
+
+void virtdev_uart_dump(struct domain *d)
+{
+ ASSERT(__start_virtdev_uart);
+
+ __start_virtdev_uart->dump(d);
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/include/xen/virtdev-uart.h b/xen/include/xen/virtdev-uart.h
new file mode 100644
index
0000000000000000000000000000000000000000..fbe48e513996404d793d011747b3f40c236a6a57
--- /dev/null
+++ b/xen/include/xen/virtdev-uart.h
@@ -0,0 +1,72 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef XEN__VIRTDEV_UART_H
+#define XEN__VIRTDEV_UART_H
+
+#include <public/xen.h>
+#include <public/event_channel.h>
+#include <xen/types.h>
+
+struct virtdev_uart_params {
+ domid_t console_domid;
+ gfn_t gfn;
+ evtchn_port_t evtchn;
+};
+
+struct virtdev_uart {
+ int (*putchar)(struct domain *d, char c);
+ int (*init)(struct domain *d, struct virtdev_uart_params *params);
+ void (*exit)(struct domain *d);
+ void (*dump)(struct domain *d);
+};
+
+#define VIRTDEV_UART_REGISTER(x) \
+ static const struct virtdev_uart *x##_entry \
+ __used_section(".data.virtdev.uart") = \
+ &(const struct virtdev_uart){ \
+ .init = x ## _init, \
+ .exit = x ## _exit, \
+ .dump = x ## _dump, \
+ .putchar = x ## _putchar, \
+ }
Are multiple types of uarts for a given architecture expected? If only
a single implemention is needed per-architecture, using defines or
wrappers seems simpler to me.
Regards,
Jason
|