Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C40BDC87FCF for ; Thu, 7 Aug 2025 21:57:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1073811.1436633 (Exim 4.92) (envelope-from ) id 1uk8cA-0001sL-GT; Thu, 07 Aug 2025 21:57:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1073811.1436633; Thu, 07 Aug 2025 21:57:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uk8cA-0001sE-Dg; Thu, 07 Aug 2025 21:57:34 +0000 Received: by outflank-mailman (input) for mailman id 1073811; Thu, 07 Aug 2025 21:57:33 +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 1uk8c9-0001s8-7w for xen-devel@lists.xenproject.org; Thu, 07 Aug 2025 21:57:33 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20628.outbound.protection.outlook.com [2a01:111:f403:2418::628]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 836364b9-73d9-11f0-a324-13f23c93f187; Thu, 07 Aug 2025 23:57:30 +0200 (CEST) Received: from BN8PR12CA0027.namprd12.prod.outlook.com (2603:10b6:408:60::40) by LV9PR12MB9832.namprd12.prod.outlook.com (2603:10b6:408:2f3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9009.13; Thu, 7 Aug 2025 21:57:25 +0000 Received: from BN3PEPF0000B06D.namprd21.prod.outlook.com (2603:10b6:408:60:cafe::5) by BN8PR12CA0027.outlook.office365.com (2603:10b6:408:60::40) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9009.14 via Frontend Transport; Thu, 7 Aug 2025 21:57:25 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BN3PEPF0000B06D.mail.protection.outlook.com (10.167.243.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.9031.0 via Frontend Transport; Thu, 7 Aug 2025 21:57:25 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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; Thu, 7 Aug 2025 16:57:25 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 7 Aug 2025 16:57:25 -0500 Received: from [172.29.241.50] (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 7 Aug 2025 16:57:24 -0500 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: 836364b9-73d9-11f0-a324-13f23c93f187 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ok5UyrXDt11YRB5y/NaPlRDuYQ5SVBScu886zkeKFuCytZBgoRn4WW9ML8wKvPc36eV/xLZc5Nx9j9bwXTfBH/wjUXTHGdgiq7LqgrDlv+9wdfUxVhPYxW+kOEeppNT+TWpgOBdToTsW4VA1aeuilfx1emg4oRhcKz3/cmhxH8ktH9+0UpzQoGPqiCLnoXiBpD83BO6EXeuibZfcXNV3tXXzJYDNwGn05jqG7YkdJpIDoIbwWu9kGmFS1St/u1alVM5S7ZcuF6n/mLqyHg7aBjdOaRtMj4Mco+rcJfCQYBWtii5zLfHNqK7JJrpUWGfLMUWpkgqlB2aA5HzJGyaykA== 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=RshG21jZ+iIkiAyrPOkEh1PHxL9Lb1bwV1Ux5hVlX/g=; b=iBU2njBorvPZneBoe8jLGVF0+vK9dP4dxvFb+nYzM56RVPCjRT6jyIiK8WjbwiRc8FjFFIKttVzDXqsL4WDKGjOvlo0rQ5TwN+mVSTO/unDo7Iupe/ShNK/OrX4FctJ7NNxa3pQrrCkc9ClPsaX4Sh4b+UIhLB05Ocfw2i+zGwj18xZg6yPDyAxxJwU8JfDqtASUzJswIlp5tMoLZLOrX7DVUZq4uFfHJYSpGChUycmR+MJyu57jODqLGk5dgjgWJmNYxWWtFscXr23OzrawPTNpM8NnYszUmlEoRuSc1i4ittRXVWdf71Tog1RPdtDiPy1Ihw4HI9y7I6WPkFguhA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.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) 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=RshG21jZ+iIkiAyrPOkEh1PHxL9Lb1bwV1Ux5hVlX/g=; b=klIgvE8h8JszDVLjseUsV0MHrMfD4VpkiBYYfJyFFxMBg7fPF7NF2mqtogWdv6pIcgXusUeYAmcBOT9nL8kSw1Mq6FdJh8b16dFkgUuOI2N9/Z0KvCsslI1oQd9eJPGsq7pN00WKNm3LvON8OQVMQy7baWbdshVNYCV0RyFTbgs= 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 (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 Message-ID: <5d8d1880-242b-46c7-a5da-7b1c2437f66d@amd.com> Date: Thu, 7 Aug 2025 17:57:26 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1] xenconsole: Add connected flag To: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= , CC: Anthony PERARD References: <20250807015606.4427-1-jason.andryuk@amd.com> <25745d45-d506-4277-8ccd-302cd1316707@suse.com> Content-Language: en-US From: Jason Andryuk In-Reply-To: <25745d45-d506-4277-8ccd-302cd1316707@suse.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: None (SATLEXMB05.amd.com: jason.andryuk@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B06D:EE_|LV9PR12MB9832:EE_ X-MS-Office365-Filtering-Correlation-Id: 927f826e-7bcd-4332-56a8-08ddd5fd6543 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?B?SG5BaXN6eDYzNlIvN2ZXb2tFaFp5NG8ydThqbUVZK0UwMjNoemNzNXQ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wc1VFNjN5eG0yTDVLVnNvVTBBU2NsZ3lZ?= =?utf-8?B?ZDJiUXlSWjlDSjJDd04zaE9XOGUyWEdmWUJkKzVOQkhJcFErcW9LSVVqZk1G?= =?utf-8?B?THJMY1dHQUdjbElXN3RoZXk5MVQ4QUxiTkxnVmFUR1dzTXhWWFREeDROa1Ja?= =?utf-8?B?TUYwamp5eTBJSStlM2tWTnZ4SDhudEQwbjFDbmk0c1JWZ1VVcWU1UTU4ODBo?= =?utf-8?Q?gGMPPV?= 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)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2025 21:57:25.8389 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 927f826e-7bcd-4332-56a8-08ddd5fd6543 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: BN3PEPF0000B06D.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV9PR12MB9832 On 2025-08-07 03:00, Jürgen Groß wrote: > On 07.08.25 03:56, Jason Andryuk wrote: >> 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 = __write_console(cons, data, len); >> >>                  if (sent < 0) >>                          return sent; >> >>                  data += sent; >>                  len -= 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. > > I think libxenguest should set XENCONSOLE_DISCONNECTED as well (see below). > >> >> 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 > > Adapt the title of the patch? With Jan's naming suggestion, it'll be "xenconsole: Add connection field" >> --- >> 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 == 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. > > I'd like to consider other cases as well, e.g. a console driver domain. > So any instance creating a domain with a console ring page should set the > flag initially to "disconnected". Sure, that makes sense. I don't have immediate plans for this, but I had the additional thought of placing the event channel inside the page like we do for xenstore. Today xenconsoled uses xenstore for the ring-ref and event channel, thought it tries the reserved console grant first. With the reserved grant, and the event channel inside, that dependency would be removed. Xenconsoled still needs some way to know when domains come and go, and it depends on xenstore's @introduceDomain/@releaseDomain for that. So it couldn't be completely decoupled without some other mechanism. >> This assumes that existing frontends are not using the flag space for >> some other use. >> >> Removed idea: >> Send an event channel notification to let the domU know that xenconsoled >> is connected.  Xenstored does similar, but for xenstore, the xenstore >> driver owns the event channel/irq and can rebind it.  For hvc_xen, the >> hvc subsystem owns the irq, so it isn't readily available for rebinding. >> This is not implemented. >> >> I had the idea for the kernel to use a static key and switch writing >> from the hypercall to the PV ring once connected.  It didn't actually >> work in my short attempt - I think changing the static key from within >> an interupt was wrong.  I fell back to just checking the flag directly > > You'd need to do the static key changing from a worker thread instead. Thanks. I'll investigate. Regards, Jason