From nobody Fri Oct 31 11:16:33 2025 Delivered-To: importer@patchew.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; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1755899007; cv=pass; d=zohomail.com; s=zohoarc; b=mliJRJ7gnDUCIuZ3DXdYE+SRS31W8u1DvQIAbMdCHftvV/6ucFzhKu3WIgp8e4iR35FtsX98uC69eI3HCZA2rq8rCF/rrXBRiH8ULLKSZEOxlpKvnF7T9/eJZys2mcrj/rtq76/TLVchlSV1eszQxLdSmdNw/5ymqGgYHmQTtbY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755899007; 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=b/N6nFU6nO7Za+gT5fLChF8mvH6ExfkAwTdc63kbBaU=; b=lCcaNuI8TaM7vutb0bYko1S2qIVfxm5H+TTpBcmGpOB9oOf4f2OGp0x6Xn28H3Lbpk/XX38Njy0ayh+ro/0W5kn4TrOGDLrtVq23I5FvjPYsSTXwnyHPkJQn8OC0MpWFqsiTKk1ooS3Ce8lOYpAm9VPmASbLuqdTB6twj2GMiO0= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=amd.com); 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 1755899007976697.9850403422327; Fri, 22 Aug 2025 14:43:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1090518.1447687 (Exim 4.92) (envelope-from ) id 1upZXI-0003t9-9Y; Fri, 22 Aug 2025 21:43:00 +0000 Received: by outflank-mailman (output) from mailman id 1090518.1447687; Fri, 22 Aug 2025 21:43:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1upZXI-0003t0-67; Fri, 22 Aug 2025 21:43:00 +0000 Received: by outflank-mailman (input) for mailman id 1090518; Fri, 22 Aug 2025 21:42:58 +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 1upZXG-0003pV-U3 for xen-devel@lists.xenproject.org; Fri, 22 Aug 2025 21:42:58 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2061b.outbound.protection.outlook.com [2a01:111:f403:2417::61b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f699ef56-7fa0-11f0-a32b-13f23c93f187; Fri, 22 Aug 2025 23:42:56 +0200 (CEST) Received: from BYAPR08CA0057.namprd08.prod.outlook.com (2603:10b6:a03:117::34) by DM4PR12MB6181.namprd12.prod.outlook.com (2603:10b6:8:a9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9052.15; Fri, 22 Aug 2025 21:42:51 +0000 Received: from SJ5PEPF00000206.namprd05.prod.outlook.com (2603:10b6:a03:117:cafe::3e) by BYAPR08CA0057.outlook.office365.com (2603:10b6:a03:117::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9052.18 via Frontend Transport; Fri, 22 Aug 2025 21:42:51 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by SJ5PEPF00000206.mail.protection.outlook.com (10.167.244.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.9052.8 via Frontend Transport; Fri, 22 Aug 2025 21:42:50 +0000 Received: from Satlexmb09.amd.com (10.181.42.218) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 22 Aug 2025 16:42:49 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by satlexmb09.amd.com (10.181.42.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1748.10; Fri, 22 Aug 2025 14:42:49 -0700 Received: from fedora.mshome.net (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Fri, 22 Aug 2025 16:42:49 -0500 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: f699ef56-7fa0-11f0-a32b-13f23c93f187 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nb/7RLwVwqO6YBNUJ5zwAwEVm89SVXtNijqxNy9K0jA1pxvI5f7T9ZpjU2DHcCu2MRQrteS6ajgj/P917mJ4RNPKggrfnF6BHEKevvY+Am5O08VkKLJqW7Oo1LG8HfMaMn3LW1D7SUyEJ4s3fd+j0J87azWgH3x4MFkcWVmd/ejuVM7q+U0cc2qf6uxg1uLGe4HfdfoeF41dztBTPC77DeakFoJM6WXD54/ehUpQ7PKykcxW+9b2KGM8rTk/e2yXZ1YUrMnYripRb7ChGgAzAYIq8wI/LMPKdnmGIn527bwp4CszLnVfExpt12Dc0BiNYGui8Bbhcb0X/mvcMX3R4Q== 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=b/N6nFU6nO7Za+gT5fLChF8mvH6ExfkAwTdc63kbBaU=; b=sfOrAugjxVTkBifNNNTMxYHlZ4ZStZBrlPxIQTudwKfvoqTlCHa+K/qWE4mqcJNK/5D7pVVmg5zhhWnVkyaMV6QTQyIkdLYupqfRgNx+EmtAOR0mVbPiiJfN7X+v2OIdRYgn55si+Kh05+Vxmr+NYJww7s0/hbxut9NjrGuwg01GMYrlI5hd5ZVngHNp0l8m/7wE9iqU3whMBPBYKzXTj7N/JXfDVCkjKtxMFv/sYtgXSveS8v8sS20Siu0eMptRmTtJuOO7JUDtmLLA1CsMbD/l5kwENCFF9YXwQ+DJt4b03ypSz/pcDWf6qJyIu+O86MG14lRpmsa/UU4EqGD1dA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=b/N6nFU6nO7Za+gT5fLChF8mvH6ExfkAwTdc63kbBaU=; b=3YF51P2sxyt37/CM/ypUXyKJm/y49M/HmKB+FdhkMB2FKIc9sgWAiT/WWWL430t4c7fYX7Rk4l20XNBgC1yL5E+ILkBcCnfVryOgfFf5hLLznJNSweg9qZKrSQ6D7Dxzdmv5ouih8JKOAlVC7AQwzl9Tu3at3QzyEoBtCGTpS7E= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; 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; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Jason Andryuk To: CC: Alejandro Vallejo , Jason Andryuk , Anthony PERARD , "Juergen Gross" Subject: [PATCH v2 1/3] xenconsole: Add connection flag Date: Fri, 22 Aug 2025 17:39:43 -0400 Message-ID: <20250822213946.245307-2-jason.andryuk@amd.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250822213946.245307-1-jason.andryuk@amd.com> References: <20250822213946.245307-1-jason.andryuk@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF00000206:EE_|DM4PR12MB6181:EE_ X-MS-Office365-Filtering-Correlation-Id: 8dc0d4bb-f572-4067-020c-08dde1c4d7cc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?KBsnoz4eL6xv1gKeeJgs14HklczMCdmqq97vealbXmWxFGZorKUBTwXWj7Yt?= =?us-ascii?Q?2wL+nWX78bFNpAYa/qAncmq1Ti0O80IUPtj8pVTdNF6uC19V7jnHQJZfqqY6?= =?us-ascii?Q?Zk1eufr2sK/wdD/YdIz3HXitrk6p6YOdSQavQfvbcEBCLDUq8HeWytdTBR0F?= =?us-ascii?Q?UnSPlw/x76cknqXRkZOKvj8mCqJhBNl/6aHTJY4OAZUB8fS+jywj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xYfZEyoCdJltTF6eTGtXKhhvC7P8AGezhPvfDa?= =?us-ascii?Q?Rc25QfVaim7B/mKgW7fkSyxTxrMJ/Cfo4iExbk18QRWUNu9pOfWBIQ8hIqXM?= =?us-ascii?Q?h//iqk5PF483L6mIIy/hh4udltf1nwoZo1hghLFsg4isnHqdEztdKwkPJypC?= =?us-ascii?Q?Dad9ZZUWFlHUfvLCa/uaxlHbsfeXUas5tVeCIfaei8s6jE+3VWzTy6ms5SFP?= =?us-ascii?Q?nx3ZaIm6P1hHdwhK69bi/D1iHjpHHaWh/vQO9oGzW0FgZOxXB35HM1V3AsaW?= =?us-ascii?Q?WXVfNdMhGS0+DBLwRzqq1cHBvNcShYGC+W3AVbU1c73I6cCOPMMOFCHuHOkx?= =?us-ascii?Q?SubdaF8pu8V0gbT7Giauu3Fha99EYZTVQfCtJkuwxOXX/Tman2gne0GQX/lP?= =?us-ascii?Q?NeCqc+kPHa99jqLN8ldg3bgAumP5Hy52JagR?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2025 21:42:50.5527 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8dc0d4bb-f572-4067-020c-08dde1c4d7cc X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF00000206.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6181 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1755899008874124100 Content-Type: text/plain; charset="utf-8" With hyperlaunch, a domU can start before its console ring is connected by xenconsoled. With nothing emptying the ring, it can quickly fill during boot. In domU_write_console(), __write_console() returns 0 when the ring is full. This loops spins until xenconsoled starts emptying the ring: while (len) { ssize_t sent =3D __write_console(cons, data, len); if (sent < 0) return sent; data +=3D sent; len -=3D sent; if (unlikely(len)) HYPERVISOR_sched_op(SCHEDOP_yield, NULL); } The goal of this patch is to add a way for the frontend to know when a console is connected. This patch adds a new flag to the end of the console ring structure. It is used for the backend to indicate that it has connected and started servicing the page. The two values are XENCONSOLE_DISCONNECTED 1 XENCONSOLE_CONNECTED 0 XENCONSOLE_DISCONNECTED indicates to the guest that ring is disconnected, so it will not be serviced. The guest can avoid writing into it in that case. A domU can use console hypercalls and only transition to the ring when it is connected and won't fill and block. Once the backend (xenconsoled) maps and starts servicing the console, the flag will be set to XENCONSOLE_CONNECTED (0) to indicate the backend state to the frontend. The connected value as 0 will be match the default of a zero-ed console page. Hyperlaunch can set the flag to XENCONSOLE_DISCONNECTED and let xenconsoled set to XENCONSOLE_CONNECTED. Old domU hvc_xen drivers won't check the flag. New domU hvc_xen running on a new xen/xenconsoled will work properly. New domU hvc_xen on old xen/xenconsoled should only see a 0 for the flag and behave as if connected. Signed-off-by: Jason Andryuk --- v2: Rename "connection" Use uint8_t v1: Remove evtchn notify call Set connected later when there is no error RFC v3: Flip flag values so 0 is connected. The other option would be to add: uint32_t features uint32_t connected New domUs would check features for a magic value and/or flag to know they can rely on connected transitioning. I think making XENCONSOLE_CONNECTED =3D=3D 0 side steps the need for an additional features field. As long as assuming zero-ed memory is acceptable. However, this only matters for a hyperlaunched guest - xenconsoled will normally readily connect the console and set the value. This assumes that existing frontends are not using the flag space for some other use. --- tools/console/daemon/io.c | 4 ++++ xen/include/public/io/console.h | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index bb739bdb8c..43d4973c24 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -781,6 +781,10 @@ static int console_create_ring(struct console *con) con->log_fd =3D create_console_log(con); =20 out: + /* Mark the console connected. */ + if (!err && con->interface) + con->interface->connection =3D XENCONSOLE_CONNECTED; + return err; } =20 diff --git a/xen/include/public/io/console.h b/xen/include/public/io/consol= e.h index 4509b4b689..b9ebfaff3f 100644 --- a/xen/include/public/io/console.h +++ b/xen/include/public/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; }; =20 #ifdef XEN_WANT_FLEX_CONSOLE_RING --=20 2.50.1