From bdd5de3d9e2da45852d0d21313af3a02f0e0626e Mon Sep 17 00:00:00 2001 From: Jason Andryuk Date: Wed, 18 Mar 2026 19:53:26 -0400 Subject: hvc/xen: Check console connection flag When the console out buffer is filled, __write_console() will return 0 as it cannot send any data. domU_write_console() will then spin in `while (len)` as len doesn't decrement until xenconsoled attaches. This would block a domU and nullify the parallelism of Hyperlaunch until dom0 userspace starts xenconsoled, which empties the buffer. Xen 4.21 added a connection field to the xen console page. This is set to XENCONSOLE_DISCONNECTED (1) when a domain is built, and xenconsoled will set it to XENCONSOLE_CONNECTED (0) when it connects. Update the hvc_xen driver to check the field. When the field is disconnected, drop the write with -ENOTCONN. We only drop the write when the field is XENCONSOLE_DISCONNECTED (1) to try for maximum compatibility. The Xen toolstack has historically zero initialized the console, so it should see XENCONSOLE_CONNECTED (0) by default. If an implemenation used uninitialized memory, only checking for XENCONSOLE_DISCONNECTED could have the lowest chance of not connecting. This lets the hyperlaunched domU boot without stalling. Once dom0 starts xenconsoled, xl console can be used to access the domU's hvc0. Paritally sync console.h from xen.git to bring in the new field. Reviewed-by: Stefano Stabellini Signed-off-by: Jason Andryuk Signed-off-by: Juergen Gross Message-ID: <20260318235326.14568-1-jason.andryuk@amd.com> --- include/xen/interface/io/console.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include') diff --git a/include/xen/interface/io/console.h b/include/xen/interface/io/console.h index cf17e89ed861..687949bdebb1 100644 --- a/include/xen/interface/io/console.h +++ b/include/xen/interface/io/console.h @@ -19,6 +19,19 @@ struct xencons_interface { char out[2048]; XENCONS_RING_IDX in_cons, in_prod; XENCONS_RING_IDX out_cons, out_prod; +/* + * Flag values signaling from backend to frontend whether the console is + * connected. i.e. Whether it will be serviced and emptied. + * + * The flag starts as disconnected. + */ +#define XENCONSOLE_DISCONNECTED 1 +/* + * The flag is set to connected when the backend connects and the console + * will be serviced. + */ +#define XENCONSOLE_CONNECTED 0 + uint8_t connection; }; #endif /* __XEN_PUBLIC_IO_CONSOLE_H__ */ -- cgit v1.2.3 From 3f100dd61ad4ee7c1fb6a44775a928dcdba7515b Mon Sep 17 00:00:00 2001 From: Pengpeng Hou Date: Tue, 10 Mar 2026 08:08:00 +0000 Subject: xen/grant-table: guard gnttab_suspend/resume with CONFIG_HIBERNATE_CALLBACKS In current linux.git, gnttab_suspend() and gnttab_resume() are defined and declared unconditionally. However, their only in-tree callers reside in drivers/xen/manage.c, which are guarded by CONFIG_HIBERNATE_CALLBACKS. Match the helper scope to their callers by wrapping the definitions in CONFIG_HIBERNATE_CALLBACKS and providing no-op stubs in the header. This fixes the config-scope mismatch and reduces the code footprint when hibernation callbacks are disabled. Signed-off-by: Pengpeng Hou Signed-off-by: Juergen Gross Message-ID: <20260310080800.742223-1-pengpeng.hou@isrc.iscas.ac.cn> --- drivers/xen/grant-table.c | 3 ++- include/xen/grant_table.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 97e27f754d39..a6abf1ccd54c 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c @@ -1579,7 +1579,7 @@ static int gnttab_setup(void) } return gnttab_map(0, nr_grant_frames - 1); } - +#ifdef CONFIG_HIBERNATE_CALLBACKS int gnttab_resume(void) { gnttab_request_version(); @@ -1592,6 +1592,7 @@ int gnttab_suspend(void) gnttab_interface->unmap_frames(); return 0; } +#endif static int gnttab_expand(unsigned int req_entries) { diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h index 69ac6d80a006..a33a60a2ea72 100644 --- a/include/xen/grant_table.h +++ b/include/xen/grant_table.h @@ -84,8 +84,20 @@ struct gntab_unmap_queue_data }; int gnttab_init(void); +#ifdef CONFIG_HIBERNATE_CALLBACKS int gnttab_suspend(void); int gnttab_resume(void); +#else +static inline int gnttab_suspend(void) +{ + return 0; +} + +static inline int gnttab_resume(void) +{ + return 0; +} +#endif int gnttab_grant_foreign_access(domid_t domid, unsigned long frame, int readonly); -- cgit v1.2.3