From patchwork Tue Dec 17 22:24:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 13912601 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 7A34EE77184 for ; Tue, 17 Dec 2024 22:25:21 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.859913.1271999 (Exim 4.92) (envelope-from ) id 1tNfzr-0000rK-LB; Tue, 17 Dec 2024 22:24:55 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 859913.1271999; Tue, 17 Dec 2024 22:24:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tNfzr-0000rD-Id; Tue, 17 Dec 2024 22:24:55 +0000 Received: by outflank-mailman (input) for mailman id 859913; Tue, 17 Dec 2024 22:24:54 +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 1tNfzq-0000r6-0L for xen-devel@lists.xenproject.org; Tue, 17 Dec 2024 22:24:54 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20630.outbound.protection.outlook.com [2a01:111:f403:2416::630]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id bafbf2e5-bcc5-11ef-a0d6-8be0dac302b0; Tue, 17 Dec 2024 23:24:52 +0100 (CET) Received: from BN1PR14CA0004.namprd14.prod.outlook.com (2603:10b6:408:e3::9) by DS0PR12MB7745.namprd12.prod.outlook.com (2603:10b6:8:13c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Tue, 17 Dec 2024 22:24:44 +0000 Received: from BN2PEPF000044AA.namprd04.prod.outlook.com (2603:10b6:408:e3:cafe::e9) by BN1PR14CA0004.outlook.office365.com (2603:10b6:408:e3::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.22 via Frontend Transport; Tue, 17 Dec 2024 22:24:44 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BN2PEPF000044AA.mail.protection.outlook.com (10.167.243.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Tue, 17 Dec 2024 22:24:44 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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; Tue, 17 Dec 2024 16:24:43 -0600 Received: from amd-BIRMANPLUS.mshome.net (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Tue, 17 Dec 2024 16:24:42 -0600 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: bafbf2e5-bcc5-11ef-a0d6-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TJthO2heabp6ruxHX3uxtScD71O0mcMnc4ky6o7UfG0y/bip+7NHFdaNQto9d9/iiupH1PARUvNU87AlewG5qLcjxGKO4VDqYI6/jvmGAafVlybmmTJtVIuWipySkMVLkk1BBA3bc11YhqJeUzcF2dCs7lFFhQxZ6TWqLE6V/Cg5aamfjSue0RUoh/wZ0csD+vQq8WErVYQ6ZX65KZxNRtCVSkvucUR1TPC+TQddPFpUgIFysX/WxsunK8Q0YnHh9Wh7LJbi7Sz8hSH9s7mMxlzMo/ZW0Y0AmswZ11LqUsQ3YhdAtzRvG3bqXQJkFH7CzmPu3cNP1220pgzMyHCSzA== 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=L8xuwI0/yejCLIWz0+Qwjv4SG6qlHBSVP/vH0Ki1GMQ=; b=o1OsAFj71hsGW7QcXlLRZmIB4yGeS0MD0or7ECPyzxlCox9fedJ4+FrWhP6Gl4/T4plFOFBHP0lJAzZsWMo7E4cpVN5TBV2Fv66Z58PG4Y/uKTCjrQ2z9R6IxDI0GW3GbX1p5pVSHfAxvpHL2+2ZrVbI3q2JT7AmYLwHz4oxM+k6Pl5iY77kQxPfXyrFMNndbuGAU01iioS3htoeT/L575Mq07I3yhCxjCEcJ54hWLjjUisAJn+3TH2PpVMrOWRESpUFNyzs8qRIf96hIg4ENNuV3dG+O5xAcHoWHuNHEFN5mBxgPMH6j2gM3GgZlb4Ti3FRqziYNKs9UtSzadxG0Q== 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=L8xuwI0/yejCLIWz0+Qwjv4SG6qlHBSVP/vH0Ki1GMQ=; b=i97GbPu2l/fO/rXCM8vLFcZeL7wtRbwRilMClpJnFyAbxHYgj01hzCOi0amamttkkelwH8R5SVBHwQXdZppfWd0opabYzGr/v4gZ1n+Re/FcrWZd4iKs8hfx7MmDJjHnaGOQ0F0sGQbTvC3FG2q0DLUylCCuul4q/oT1XGNlRvA= 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 From: Jason Andryuk To: CC: Jason Andryuk , Anthony PERARD , Juergen Gross Subject: [RFC PATCH Hyperlaunch] xenconsole: Add connected flag Date: Tue, 17 Dec 2024 17:24:24 -0500 Message-ID: <20241217222424.7632-1-jason.andryuk@amd.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: jason.andryuk@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044AA:EE_|DS0PR12MB7745:EE_ X-MS-Office365-Filtering-Correlation-Id: 9467866e-feb6-4b2b-eec9-08dd1ee99b97 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: JIxnA1Jwk7vnRyvyrAvEQB4vyF0hsUUeTr05VihN/x4Vkx88M8fmD92qW7nheVfpzW7yR/B3QBsSI4M9aDc8uZAPXLdjrQ/T3yWMkz+KcnAeC0tcwibY02t8EIj7l0FJcW9tlXsi6O7yBsrTGZKwJhuqgk9kkQsGce0LiqFlIUtZL9Ry8PMmP2ez2YkFRyv+1wVj1+DbvVldBl1qY1HimIYmmHIYrIvHghRCdS+n70HHw6Aix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DIK4/Z8g1rk+jqn6C5dtETmoLvow95v1mTQNEfgnMPkpv1RJbd/6Jwpb42UlCwdiEbidCqHWiy4QOJ1VnA6u8xqNnyN017ImwRFbs+4HRhQQcJ6vn2WedRyQMiLV7WEYh1ep/RmcUJK7osEx+urjl4Z4m6trfNyg0a9laTEi7moiYbI5rqKmkTxvEfMC1xl2M+dpupDaoIt8saA= 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)(36860700013)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2024 22:24:44.2492 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9467866e-feb6-4b2b-eec9-08dd1ee99b97 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: BN2PEPF000044AA.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7745 Linux will spin in hvc_xen.c:domU_write_console() when it fills its console ring. This blocks hyperlaunch parallel boot since the domU won't progress until dom0 sets up xenconsoled and starts draining the ring. Add a flag to the console ring page. zero-initialized, have xenconsoled set to 1 when it connects. Also send an event channel notification. The linux domU side can keep using the console hypercalls and only transition to the ring when it is connected and won't fill and block. Signed-off-by: Jason Andryuk --- 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); } This patch is similar to the xenstore late init (though the flag is reversed). The idea of the event channel notification is to let the domU receive an indication that xenconsoled is connected. 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. 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 without an optimization. That would work and would make the event channel notification unnecessary. tools/console/daemon/io.c | 6 ++++++ xen/include/public/io/console.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index bb739bdb8c..2a7ecc6369 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -731,6 +731,9 @@ static int console_create_ring(struct console *con) con->ring_ref = ring_ref; } + /* Mark the console as connected */ + con->interface->flag = XENCONSOLE_CONNECTED; + /* Go no further if port has not changed and we are still bound. */ if (remote_port == con->remote_port) { xc_evtchn_status_t status = { @@ -780,6 +783,9 @@ static int console_create_ring(struct console *con) if (log_guest && (con->log_fd == -1)) con->log_fd = create_console_log(con); + /* spurious notify to check flags field */ + xenevtchn_notify(con->xce_handle, con->local_port); + out: return err; } diff --git a/xen/include/public/io/console.h b/xen/include/public/io/console.h index 4509b4b689..2b408f92a3 100644 --- a/xen/include/public/io/console.h +++ b/xen/include/public/io/console.h @@ -19,6 +19,8 @@ struct xencons_interface { char out[2048]; XENCONS_RING_IDX in_cons, in_prod; XENCONS_RING_IDX out_cons, out_prod; + #define XENCONSOLE_CONNECTED 1 + uint32_t flag; }; #ifdef XEN_WANT_FLEX_CONSOLE_RING