From mboxrd@z Thu Jan 1 00:00:00 1970 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 5CD8CCDE008 for ; Thu, 25 Jun 2026 10:08:53 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1345420.1604282 (Exim 4.92) (envelope-from ) id 1wch0d-0002SK-3A; Thu, 25 Jun 2026 10:08:35 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1345420.1604282; Thu, 25 Jun 2026 10:08:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wch0d-0002SD-0X; Thu, 25 Jun 2026 10:08:35 +0000 Received: by outflank-mailman (input) for mailman id 1345420; Thu, 25 Jun 2026 10:08:33 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wch0b-0002S7-R7 for xen-devel@lists.xenproject.org; Thu, 25 Jun 2026 10:08:33 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wch0b-00D4yZ-7d for xen-devel@lists.xenproject.org; Thu, 25 Jun 2026 12:08:33 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3cfe18-e002-0a2a0a5209dd-0a2a4501adb8-38 for ; Thu, 25 Jun 2026 12:08:33 +0200 Received: from [52.101.85.39] (helo=BYAPR05CU005.outbound.protection.outlook.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3cfe1f-400f-0a2a45010019-34655527ecd7-3 for ; Thu, 25 Jun 2026 12:08:32 +0200 Received: from CH7PR03MB7860.namprd03.prod.outlook.com (2603:10b6:610:24e::14) by PH0PR03MB6335.namprd03.prod.outlook.com (2603:10b6:510:aa::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.159.16; Thu, 25 Jun 2026 10:08:29 +0000 Received: from CH7PR03MB7860.namprd03.prod.outlook.com ([fe80::f5ba:35df:1c9f:b343]) by CH7PR03MB7860.namprd03.prod.outlook.com ([fe80::f5ba:35df:1c9f:b343%4]) with mapi id 15.21.0159.015; Thu, 25 Jun 2026 10:08:29 +0000 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QZXJ8o7HtCWJCt6jI5FpGHo+m6+b1PbFN125hMtDl40drZdDsQC5khRp51N1Y5leFi03NDZ2WtpsQ9JpffYJI6VFTlxK1ObgZTcUXQert4rIVBYs4HBd+iBgT1zRDY8Xv8QdVWV/0O8BAzXm9al1bzH7/Qjbt1Nii8yv12wN5S1sMqeAsIWGW1k9q7GdBTxa/WT+NjMhy6HoDszdwa7xhop7LIovmBifuZTg1z81jvaoz8CH8YblL9tlNXUmsYy072e5skOVotQVep+weo9Ce7OxQJ2bmB+d4xMvezswZQ1BmeOV3ZKleHXoDMtikdF/iay3bAGB1wSVDnLx3HVxQA== 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=4LiqmLRnTzxqyK4VsYEs4YJ+niQ6u4TWLFbYGpPfmC4=; b=iXoPPKiWOvqMb4xeeCNy68Ti7xQL79ZTfJw2W5GgzZnxzz2dSTk5IU297Lu2+oRM487O13FHdbScGifGAoCf0/2GKDcRtgQsuM2k4ze1fGG2H4IUHrcfgSY1WLn5i5p46d0P6slyitClqzSnlLsJ6igOOYkmcLtqgrp49K3UrK8JEe+GX6fkvMgapH7VA/x+HHQ5CV9S2oiVD0WsYtigTbYkd0XDXBAr9l2pDUvFpJL2kxp6RSwPXL8AccAvS7Iu8ACAuV/pT26E32XC7wJ8845n7HhK5Mw/5lf1kgH05PJFvbN3Qkz77CPlJb+cyoJI13F0zHDEA7VyCStH7jtLVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4LiqmLRnTzxqyK4VsYEs4YJ+niQ6u4TWLFbYGpPfmC4=; b=NcJCdA2FWiaanzpMa1darIFDYQ/+JxTSCrzpNC2hw2m4A+7auY+3v9KCRZTOifc67kEXSMQTpCAF4uSyEuGaBqgcm+dbdB/W1Dh0/yLB6cqRp2HbcA3nWRRp0ilSFT3QWh/m3CNmxo5LsUMoGfm7aoGsKcbcGFrtgLmP3/0S2dc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; Date: Thu, 25 Jun 2026 12:08:25 +0200 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: Jan Beulich Cc: Oleksii Kurochko , Andrew Cooper , Anthony PERARD , Michal Orzel , Julien Grall , Stefano Stabellini , xen-devel@lists.xenproject.org Subject: Re: [PATCH for-4.22] char/ns16550: bound execution time of ns16550_interrupt() Message-ID: References: <20260623103145.76383-1-roger.pau@citrix.com> <06c8caab-4722-4b02-991f-bdc4a4ac0ea6@suse.com> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: MA2P292CA0015.ESPP292.PROD.OUTLOOK.COM (2603:10a6:250:1::12) To CH7PR03MB7860.namprd03.prod.outlook.com (2603:10b6:610:24e::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH7PR03MB7860:EE_|PH0PR03MB6335:EE_ X-MS-Office365-Filtering-Correlation-Id: 06e96d17-c63f-4cc2-c5c8-08ded2a1b448 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|376014|366016|1800799024|6133799003|11063799006|56012099006|4143699003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: LIusd/xdnVgDocdW49Lf/rg44HZ6hiCfsR912EQ44KWvTFmaWAV7hcaV5/EBiyM9ouIlU5zDN16MebwLYfo6/WhNwCcHxCSxuRGTltgyZyDvai3AzFzVgkEBMVEx5fJDRtVJQg2R5cHtQrclF1Z0L3UWEuu6jmtIjWGXnHi0nom+ScGo65MgkzIoEdH+OnsQ886Vg2p295juKy6tANgEa62ch5SmOGYNDCgfZy5I/HvLVMX3weoNhl0tDk8n0CiYbwCydGSPSVjAz77wzJLATfCRYZHBQ3BbocJefk+pBOTqbEB6tAR/Z4UDo4cZz8/ed4iGXZl7T4gzlAMo2MHfhhhk+O6K/i3F6MEm3HBRZsw0TmRmv1cVvp3HcOLD+VD3p+JyZK9EGrBZ2kR8o5JtXWr3/sU1XNMisQtIzoTGxC9YaqdM21fQbjNdlXZPCclNx6MHP1cv5c3AoW6qL4vKhiUox11ikX96tcNHHWZr9nBB1KutGDOE5LwdugGGUniO/pc/5+H9vaF/ReHrvk+WGT92ESJkO9i1djqnPFCoB49d6OaLi8IegaYzamuvLWvgdw1lfd5c+rty3wwhDUCHJhboeaGtMun1AejSI9SuXeNsV2WCMHe1OhWF5Q/U+n8Eu/MC+bIBb94euqVIg2p22HnlNhuwD27yCQuHBGPKW5Y= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH7PR03MB7860.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(376014)(366016)(1800799024)(6133799003)(11063799006)(56012099006)(4143699003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?M1I2Sy9SdFVib0lra0pvTVRHeFJkMi9qaXVFRmZFWkFST05kSGtXejhNQU1K?= =?utf-8?B?T3hOR29kMUVqcFlNYmtOUThWcXlOMzFxK3ZYUnFKOFpFMVBLWDNiNDJXMTVn?= =?utf-8?B?RXA4aHJPck1OUGxpNk1OSnBhVlhmYjR2Znc1dFluR2tDOHNhU1d2QURnMW40?= =?utf-8?B?dktvbmFpeHlsMXg5T0hhd1hTbHpsTFh3NGh2ZnpKcjZ1TUljM2RxOVNlWlE1?= =?utf-8?B?dDZSRkZGYnBwWHYzTWZ0MlQ4dlVOUnRtbjMzaGFEdDR5a3c0STVQbnVMVWhG?= =?utf-8?B?QmVyWDJRd0dvMk80ZjJpZ0dIN3RBallJU3F2MWtxSCs3UkNsWTFiUUhlQmZ5?= =?utf-8?B?OW1PcS9tUndVSEFnSitTb1QrTjhtQkc5VU8vc0pVYmFhT0tOeXhZVGV4ZkJX?= =?utf-8?B?K0s4RnF6ZXltRFZtQ09DVGovVU5MSkh6bWdxcEViRVUyOGpsUUlJZFB2NkxX?= =?utf-8?B?VjBXN2M0WVh6dXJOMndwZCtUWE9QUGMwUFhVS2JnYU1CS1pOVmkxbHY3Y1dK?= =?utf-8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bmwrZFF3L3NpWjNmcDYxS0tXQT09?= X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 06e96d17-c63f-4cc2-c5c8-08ded2a1b448 X-MS-Exchange-CrossTenant-AuthSource: CH7PR03MB7860.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2026 10:08:29.1368 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YwFcOoOFE35XwoUTjuVkP2xIDAKhLT7P71//GWkHrT2C5ryiIirkljMTpe/UiVv+gtScIGrCnqAGl3e5oJcMmQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR03MB6335 X-purgate-ID: tlsNG-d62444/1782382113-820DC1E0-469107C9/0/0 X-purgate-type: clean X-purgate-size: 3096 On Wed, Jun 24, 2026 at 10:01:36AM +0200, Jan Beulich wrote: > On 23.06.2026 17:54, Roger Pau Monné wrote: > > On Tue, Jun 23, 2026 at 04:27:12PM +0200, Jan Beulich wrote: > >> On 23.06.2026 16:16, Roger Pau Monné wrote: > >>> On Tue, Jun 23, 2026 at 03:44:06PM +0200, Jan Beulich wrote: > >>>> On 23.06.2026 12:31, Roger Pau Monne wrote: > >>>>> + if ( uart->force_polling ) > >>>>> + return; > >>>> > >>>> As the IRQ was disabled, is this even possible? I.e. should this be some > >>>> kind of assertion or alike? > >>> > >>> Hm, I wasn't setting IRQ_DISABLED before, and hence needed this guard. > >>> But now with IRQ_DISABLED being set in ->status do_IRQ() should filter > >>> any stray interrupts. I will attempt to add an ASSERT_UNREACHABLE() > >>> here. > >> > >> Simply ASSERT(!uart->force_polling) should do here? It is not wrong to > >> run the code below in release builds in such an event. If we kept getting > >> interrupts (perhaps at a high frequency) we'd be in trouble anyway. > > > > No, I'm afraid I can't do it like that, I can't put an ASSERT there, > > because we can still get into ns16550_interrupt() after the interrupt > > has been disabled. In do_IRQ() we have the following loop: > > > > while ( desc->status & IRQ_PENDING ) > > { > > desc->status &= ~IRQ_PENDING; > > spin_unlock_irq(&desc->lock); > > > > tsc_in = tb_init_done ? get_cycles() : 0; > > action->handler(irq, action->dev_id); > > TRACE_TIME(TRC_HW_IRQ_HANDLED, irq, tsc_in, get_cycles()); > > > > spin_lock_irq(&desc->lock); > > } > > > > So if the device is generating further interrupts in the window with > > IRQs enabled (while we execute the handler), we will keep looping > > around this, without taking into account the setting of IRQ_DISABLED. > > Ah yes. > > > This is something that we might want to fix, so that the loop is bound > > by IRQ_PENDING being set, and IRQ_DISABLED not, ie: > > > > while ( (desc->status & (IRQ_PENDING | IRQ_DISABLED)) == IRQ_PENDING ) > > Or perhaps ahead of the loop > > desc->status &= ~IRQ_REPLAY; > > if ( desc->status & IRQ_DISABLED ) > goto out; > > desc->status |= IRQ_PENDING; > > /* > * Since we set PENDING, if another processor is handling a different > * instance of this same irq, the other processor will take care of it. > */ > if ( desc->status & IRQ_INPROGRESS ) > goto out; > > desc->status |= IRQ_INPROGRESS; > > thus also having the comment no longer describe only part of the conditional. I think this is racy. An interrupt hitting in the window with interrupts enabled ahead of the handler having set IRQ_DISABLED will still set IRQ_PENDING, and thus the loop would get executed a further time, and the handler called after IRQ_DISABLED having been set. I think we need an extra condition in the loop, I see no way this can be solved only by dealing with the concurrent setting of IRQ_PENDING. Thanks, Roger.