From nobody Fri Dec 12 19:40:37 2025 Delivered-To: importer@patchew.org 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; 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=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1764891166; cv=pass; d=zohomail.com; s=zohoarc; b=Pk3W+BcOThnEXCuUSD1wcvw/CxYRjN5o/6hFwXsGjYmcVtseeCmBVgBGdWjMej/TYhjpYqyBzD8ytNTp49aevL6F6bLMlaTtPXk9IhguYlgznsIP1mJT495KWEeb+hh4PHDj4rad8GuV1Oo6W6C5V7h5Fdn3Yrb3vP1onfygXWc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764891166; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mMRJAKsb9K9uB+kPMBEqMhvInS5859NUvvO6Dcxef/k=; b=i1Kd/i9mMH7VsR7qkuVq+Q55nBUm6zA0fnr1gwmYyCN2YuBecr5eYjEWG0VZBAVhzwtESWRmRsNhXott1xKeQFeHRCveHREqV7yHECyTtdYK4SiQhwxFP0vfZY7XNpWHg/fO24HZQ2oBkZqCcNeVsNzGw87URNmmnSyfubnhJKg= 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=epam.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 1764891166025184.99892422463824; Thu, 4 Dec 2025 15:32:46 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1178356.1502216 (Exim 4.92) (envelope-from ) id 1vRIo9-0004xX-G9; Thu, 04 Dec 2025 23:32:21 +0000 Received: by outflank-mailman (output) from mailman id 1178356.1502216; Thu, 04 Dec 2025 23:32:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vRIo9-0004xQ-Cf; Thu, 04 Dec 2025 23:32:21 +0000 Received: by outflank-mailman (input) for mailman id 1178356; Thu, 04 Dec 2025 23:32:20 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vRIo8-0004xK-Gc for xen-devel@lists.xenproject.org; Thu, 04 Dec 2025 23:32:20 +0000 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazlp170100001.outbound.protection.outlook.com [2a01:111:f403:c200::1]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 78c80ba2-d169-11f0-980a-7dc792cee155; Fri, 05 Dec 2025 00:32:18 +0100 (CET) Received: from AM0PR03MB4594.eurprd03.prod.outlook.com (2603:10a6:208:c8::27) by GVXPR03MB8307.eurprd03.prod.outlook.com (2603:10a6:150:6f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9388.11; Thu, 4 Dec 2025 23:32:12 +0000 Received: from AM0PR03MB4594.eurprd03.prod.outlook.com ([fe80::5a:31d6:fee4:ccae]) by AM0PR03MB4594.eurprd03.prod.outlook.com ([fe80::5a:31d6:fee4:ccae%4]) with mapi id 15.20.9366.012; Thu, 4 Dec 2025 23:32:12 +0000 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: 78c80ba2-d169-11f0-980a-7dc792cee155 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PhOsl1krlkS1p6dpVDkX78Zfk4WcyugGgW+4VK6ogOFaXGJzgYClZrZrKF1BxRfKjOi1L1lInbF/u85jwZhdmFnRsg34XzCo7Fuy+1GczD6N1fjEDw9Kal35o+PoCXij6uB6u4Giw6bgYTbLardnoLo7X5vZ+PXgXhUq3JbMrGOE5+mqWrSabUFR0aywDxlELqvetcy0x6QaxgQAo7MVFNgAsjuuCoVojbV3pufUInf5uRh/VhzTXY1MW0AucDwEzN0On/5hgf+X1Gk0lRk2JAvVRmGtWN9CbhI9ZeTIct5QIKrdgXVCJEpaBq/vDlhpIeCDQYMnaFXXKDUOjbcnSg== 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=mMRJAKsb9K9uB+kPMBEqMhvInS5859NUvvO6Dcxef/k=; b=qGePmDnNrT1aYih0otTRaIyGpIFppMdOX3a4U+VwehINOWU4akkflMjKGqvdh87QtIq4DCOjeH7XS5YTUSUChfW5nyntUy5sP9igCHF6jXJnB7g09HZmb64x8jExSbtOpxSx/mNB6u8JaJxULQx9CRgvljDklo0j5IZpY+2FN5bY/IbdD9A9Cwxi0nKM8nrv/ZCzJXUwUiKlzCka0q9EQT+VPhCqoQYn0w+6tPzEm7aRvybooicKzArl0Xqi7S/yBx4EJ4f5luAfJd4YXZxyi+/ZLHluzhvylmJRhxQcTovEPONlQqYw55AzkIATPdouC4zAJapp1mXCaqECq4awwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mMRJAKsb9K9uB+kPMBEqMhvInS5859NUvvO6Dcxef/k=; b=tM4bP/lQVV/f67yC4fWuzKJrwWVbkGkKrQxs+UIfGWm3f6vSEuc/akCN6Qh9hUXIDjHwDS97H2ss2t5pWJ1JYwpWQdw53Lc3orhL1cqCgbnHnVKfAzdejOYv9cKB0M3lkD9Qso4oqqL0/vWeUD9y91bhPJZjuDAD5MTGaODTfBIxxt0fM+at/mrxeiENMKuBEutxLE68IaaleGjXkT1xGs4CnFPk0fs/zrsjaz12FWz9nZsZFs3iURis58BM4TP4JFTN/UFIpf7CEM/wF8eps8aT95uJ98B0lquPHd/PJVLH/ufukrzBXp6vMqtwtfTu74uOC5g38Exml1BH0UHPqw== From: Grygorii Strashko To: "xen-devel@lists.xenproject.org" CC: Grygorii Strashko , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?iso-8859-1?Q?Roger_Pau_Monn=E9?= , Stefano Stabellini , Jason Andryuk , Victor Lira Subject: [XEN][PATCH] console/consoleio: account for xen serial input focus during write Thread-Topic: [XEN][PATCH] console/consoleio: account for xen serial input focus during write Thread-Index: AQHcZXY3Nl349El2IUi++g6UhbChUA== Date: Thu, 4 Dec 2025 23:32:12 +0000 Message-ID: <20251204233211.980862-1-grygorii_strashko@epam.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM0PR03MB4594:EE_|GVXPR03MB8307:EE_ x-ms-office365-filtering-correlation-id: 988e0cac-bef3-4c5d-9a5b-08de338d59cb x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024|38070700021; x-microsoft-antispam-message-info: =?iso-8859-1?Q?VB2b3AV8p4+MEvr2doehmMb1Cadbg7nIsHHeAVc5RsSgSKhNVZnyCVP6bn?= =?iso-8859-1?Q?F4djMHMvrCnJHjVgV42UIzbhFDI0OOmiZthvkVTqxhzw+6mFV2xPqc/ekV?= =?iso-8859-1?Q?MIugoEKTMVRhxqtpVz/V2lHr+vcIYAY/TvBXrEqJC0kWy/fxP5NU51WdCB?= =?iso-8859-1?Q?oToUnpCXgUoBbFuYytO+Y4dlSJ9UHMg1TBm0/T9z6g+SUUCe5QJLkB6kSm?= =?iso-8859-1?Q?JsvMAdLzVzpwk6no4aH9gtE8e93YatsDH0iH5Qq7xOVy4rYL3jMtsMYfWv?= =?iso-8859-1?Q?/gQHbAISeeKKfEt1CyPoKASv4HvhffaETts663x2jK3wg5X+AjCR/HtrIB?= =?iso-8859-1?Q?2r6M8h6ijbU12YAygoFybVOSZbd3uZM9BbSG0XiguMqvHv93bHsd4NmvQ5?= =?iso-8859-1?Q?KWdanfn4YeJjGOIWJ0HduUMCdVv4g6VVL7IVvc1yCDa5/wMLfQG/YgvLjs?= =?iso-8859-1?Q?3LVyyKbmI/tJ7D+KOxQvX/ALwHZpi4OWcUZYdk1x4D7Za/nxX5iOLG5MMy?= =?iso-8859-1?Q?8yAvTvdTDFs/2y0KbYuR55wUZjD1bUnJSYqAlhM/BsHJ57Hvo3XFdS8bqq?= =?iso-8859-1?Q?r+30momJqhqK75MinqvxyPjHdkDesZo/yEiGn1Wp07RHNDdXWfQxPiICu0?= =?iso-8859-1?Q?l+n7Ck3ji7BawMlRUrLKiKsPZOOE8IiSyKsvkdtVQZYQ1O+lHesUgOUj7a?= =?iso-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X9sqrMs?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR03MB4594.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(366016)(1800799024)(38070700021);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?WIH8l+ugyRO+ySJuxLIplOriwkme5d9f7R6zCFaRTthfDI4CKTdZzpPLIk?= =?iso-8859-1?Q?Zv5kfK8INVhfLwM+x8g+ieB4ouyP18hJpwsBeh58jPk408P0Tj6mpCC23F?= =?iso-8859-1?Q?H8NimBWiYHb1E6gEi564ihqk4LR1Htq0RNl3j4XG8Uag02l8JlFgQXB7nr?= =?iso-8859-1?Q?aOrDS+7DtupgkpOsDLSV86dyCjCYSMl2V5idDmBrRTfXFeHgOSITpq+s4Y?= =?iso-8859-1?Q?bULmrJ4RxRv0eEcC+NOsCt7g53RSLPw8sUHmgLKri8SldpAwtxHNMB76nA?= =?iso-8859-1?Q?sdZA4Kwf/IH3O65ak12o3/pIpi9jBSChqUMYagkW182LfrAV85hQj591uQ?= =?iso-8859-1?Q?fvghd0QZIuHUJrFuiLIsc89RV3VO0jUULL3CCdwufVKX0XwopUCulqbV2b?= =?iso-8859-1?Q?XTMKkvdv582qC0nKbaeTT5bX8ptlbj5ZxdzAo2qkTP/scF9cEYMUx5R18P?= =?iso-8859-1?Q?jQmCtWdAV5d0YkF3jvuhtbvnyrCMQ73ch3Mor0smWqZhBr0naJ9QghSYGp?= =?iso-8859-1?Q?ii4loWNrCS0pnvlHFdsENrsPDvO/t/b79mvYw1vP1a7wey+cWBNSwIlEhX?= =?iso-8859-1?Q?vtvnZYkhjUBWDwkykNs66V76BfcKK0TzDsBvTd+60aiOAVUognkSYsCFqX?= =?iso-8859-1?Q?uSyYW6fjPwpO5WogNkYvLG+PhM5TyyTa8fb5QMZig/zja2pw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vesn1AFgO84Hmf3zIPTRT87jtfAO6yNiHWjikS3pzZqU?= =?iso-8859-1?Q?YYQ4HaR39vH4P4kMwnXnbyWU220rQQZwbgDd/xcEkki7PyZ3+PSDufdg?= =?iso-8859-1?Q?=3D=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM0PR03MB4594.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 988e0cac-bef3-4c5d-9a5b-08de338d59cb X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Dec 2025 23:32:12.2729 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: aeLVdAbcYA2gqrE96lN1ukZ+iV9hV1XcLbyMnAuw+HQ0MYPKONzRTC/JE8F4/kSvCwWJnqwv3hGr2JaC+gWiKSmHpzSSLrfDdcDG0cwlFjo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR03MB8307 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1764891167541019200 Content-Type: text/plain; charset="utf-8" From: Grygorii Strashko When 2 or more domains are created and: - one is hwdom with "hvc0" (console_io) console - other DomUs with vpl011 or "hvc0" (console_io) console console output from hwdom may mix with output from other domains. Example: [ 2.288816] Key type id_legacy registered [ 2.291894] n(XEN) DOM1: [ 1.016950] DMA: preallocated 128 KiB GFP_KE= RNEL|GFP_DMA32 pool for atomic allocations fs4filelayout_init: NFSv4 File Layout Driver Registering... (XEN) DOM1: [ 1.018846] audit: initializing netlink subsys (disabled) This happens because for hwdom the console output is produced by domain and handled by Xen as stream of chars, which can be interrupted when hwdom is scheduled out and so, cause console output mix. The Xen consoleio code trying to mimic serial HW behavior for hwdom unconditionally by sending available data to serial HW on arrival. Xen consoleio code does not account for Xen console input focus, comparing to emulated serial hw, like vpl011, which does the same for domain with active Xen console input focus only. Switching console input focus to Xen improves situation, but not enough. This patch changes consoleio code to account for domain with active Xen console input focus - console output will be sent directly to serial HW only if domain has active Xen console input focus. For other domains - console output will be buffered and sync on per-line basis. Example output: (d2) [ 4.263417] Key type id_legacy registered (XEN) DOM1: [ 4.658080] Advanced Linux Sound Architecture Driver Initial= ized. (d2) [ 4.277824] nfs4filelayout_init: NFSv4 File Layout Driver Registeri= ng... Signed-off-by: Grygorii Strashko --- This causes random multi-domain tests failures due to inter-domain console mixing which breaks console parsing checks. xen/drivers/char/console.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index a99605103552..391cefc1a7c6 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -733,6 +733,8 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(= char) buffer, =20 while ( count > 0 ) { + struct domain *input; + if ( kcount && hypercall_preempt_check() ) return hypercall_create_continuation( __HYPERVISOR_console_io, "iih", @@ -742,7 +744,9 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(= char) buffer, if ( copy_from_guest(kbuf, buffer, kcount) ) return -EFAULT; =20 - if ( is_hardware_domain(cd) ) + input =3D console_get_domain(); + + if ( cd =3D=3D input ) { /* Use direct console output as it could be interactive */ nrspin_lock_irq(&console_lock); @@ -783,6 +787,8 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(= char) buffer, spin_unlock(&cons->lock); } =20 + console_put_domain(input); + guest_handle_add_offset(buffer, kcount); count -=3D kcount; } --=20 2.34.1