From nobody Mon May 13 21:08:47 2024 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-Seal: i=1; a=rsa-sha256; t=1692366317; cv=none; d=zohomail.com; s=zohoarc; b=E3XBT+DdU0OeUebcVuL7AD4uosgBruUWepLjFK+F5xaz9/qWunfxtkc8T8801bsyj8WYgtoFwlP/MVUCMq0u2wC8t/uisl4WGY4eYVT2qZKVUMOEUmiyIQbldAPfM0SzdigsqnlJuTqOAxMs2u0rCnh19G6XpJ1wnBGBlWPp4Kw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692366317; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BWbxLpVcdsByN5EAo3XWXuGnYzzBqiMaCs+W1sR2CtM=; b=VzZDAqCuyq892O3HPrThb1AL9HdZGZL68E2NQhjIpAH0qqalrzVHKw916ol7Kd4y4NXueQQ3fPbG//9TZVACDrb9S9Da3azFTGto6hAwRBQZfFuGjK7lDS8dtgxyLdDyi1+u1E2bb03qVDyR0/7ydvRXWUgO7UpaRPRRLXrhpC4= ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1692366317312131.11821776200725; Fri, 18 Aug 2023 06:45:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.586327.917542 (Exim 4.92) (envelope-from ) id 1qWzmV-0003A9-Vp; Fri, 18 Aug 2023 13:44:51 +0000 Received: by outflank-mailman (output) from mailman id 586327.917542; Fri, 18 Aug 2023 13:44:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qWzmV-0003A2-Sc; Fri, 18 Aug 2023 13:44:51 +0000 Received: by outflank-mailman (input) for mailman id 586327; Fri, 18 Aug 2023 13:44:50 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qWzmU-0002v7-6t for xen-devel@lists.xenproject.org; Fri, 18 Aug 2023 13:44:50 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qWzmU-0002FH-2Z; Fri, 18 Aug 2023 13:44:50 +0000 Received: from 54-240-197-232.amazon.com ([54.240.197.232] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1qWzmT-00023L-Ot; Fri, 18 Aug 2023 13:44:49 +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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=BWbxLpVcdsByN5EAo3XWXuGnYzzBqiMaCs+W1sR2CtM=; b=XMFfOQU69Z2v/hs5HEQwqQrRKn uAVOYjQ8bZJZUmUytMc2iHxKKF8KUIgeLWwrBUvNcsdSFvuXLC8heMhKIu3yZbLvgIobQDjE7kzhK wDV/YRfTsjh69Lge3KLwu2VOphcKk84hDXIv1lkjLe66M3V2P7evp5A1BLBE0JC5feLk=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Andrew Cooper , George Dunlap , Jan Beulich , Stefano Stabellini , Wei Liu , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 1/2] xen/x86: io_apic: Introduce a command line option to skip timer check Date: Fri, 18 Aug 2023 14:44:40 +0100 Message-Id: <20230818134441.45586-2-julien@xen.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230818134441.45586-1-julien@xen.org> References: <20230818134441.45586-1-julien@xen.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) X-ZM-MESSAGEID: 1692366318619100001 Content-Type: text/plain; charset="utf-8" From: Julien Grall Currently, Xen will spend ~100ms to check if the timer works. If the Admin knows their platform have a working timer, then it would be handy to be able to bypass the check. Introduce a command line option 'no_timer_check' (the name is matching the Linux parameter) for this purpose. Signed-off-by: Julien Grall --- docs/misc/xen-command-line.pandoc | 7 +++++++ xen/arch/x86/io_apic.c | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line= .pandoc index 4872b9098e83..1f9d3106383f 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -1896,6 +1896,13 @@ This option is ignored in **pv-shim** mode. ### nr_irqs (x86) > `=3D ` =20 +### no_timer_works (x86) +> `=3D` + +> Default: `true` + +Disables the code which tests for broken timer IRQ sources. + ### irq-max-guests (x86) > `=3D ` =20 diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c index b3afef8933d7..4875bb97003f 100644 --- a/xen/arch/x86/io_apic.c +++ b/xen/arch/x86/io_apic.c @@ -57,6 +57,14 @@ bool __initdata ioapic_ack_forced; int __read_mostly nr_ioapic_entries[MAX_IO_APICS]; int __read_mostly nr_ioapics; =20 +/* + * The logic to check if the timer is working is expensive. So allow + * the admin to bypass it if they know their platform doesn't have + * a buggy timer. + */ +static bool __initdata no_timer_check; +boolean_param("no_timer_check", no_timer_check); + /* * Rough estimation of how many shared IRQs there are, can * be changed anytime. @@ -1502,6 +1510,9 @@ static int __init timer_irq_works(void) { unsigned long t1, flags; =20 + if ( no_timer_check ) + return 1; + t1 =3D ACCESS_ONCE(pit0_ticks); =20 local_save_flags(flags); --=20 2.40.1 From nobody Mon May 13 21:08:47 2024 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-Seal: i=1; a=rsa-sha256; t=1692366318; cv=none; d=zohomail.com; s=zohoarc; b=B4dByYUgqQS2ygBbuxCl7rJGSPTydEaYGTBz6hPLzWWZp81H41eJ4pXnYMRRwJ9pO8OBfMfhbxl2V1+EO98drV7EIHXEJsF8GbknaUZ/hbu5OkQigusQVSzxkwPTPlcP+ROfE+DXlbr29oIENKm6yGQ40nJBzYCyf3odSafLC3k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692366318; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lf3E6qWM/eYtxtUMYYrXFPP69s9JP5c1zgdxZnGHfo4=; b=H929XiAbqHlVE57hSUt9G4vDlpHmsHi7Vr5qQwMB8HyHtPnl2Ac2HJS85LQ2p95Q3E9neOThHvKfMbAOMMK28kzvaQVdhATBBsu9BPfboNkFL13RcpIfYIhpY3KFUG+Sf9Wcd8J8/8AjAFtFmobDnywm8Yebb9ZH6mmU3UKeJcM= ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1692366318967874.3920299300439; Fri, 18 Aug 2023 06:45:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.586328.917551 (Exim 4.92) (envelope-from ) id 1qWzmX-0003Pz-5r; Fri, 18 Aug 2023 13:44:53 +0000 Received: by outflank-mailman (output) from mailman id 586328.917551; Fri, 18 Aug 2023 13:44:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qWzmX-0003Pq-32; Fri, 18 Aug 2023 13:44:53 +0000 Received: by outflank-mailman (input) for mailman id 586328; Fri, 18 Aug 2023 13:44:51 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qWzmV-00034T-6g for xen-devel@lists.xenproject.org; Fri, 18 Aug 2023 13:44:51 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qWzmV-0002FT-36; Fri, 18 Aug 2023 13:44:51 +0000 Received: from 54-240-197-232.amazon.com ([54.240.197.232] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1qWzmU-00023L-Rg; Fri, 18 Aug 2023 13:44:51 +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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=lf3E6qWM/eYtxtUMYYrXFPP69s9JP5c1zgdxZnGHfo4=; b=swKHiGCGFvxejmKdL/hpiUNxhz 8ZF+q6EvrHvFPpN8MQQm0/6gaNJgVZLE9eioHmEJ57dct1wC911FKpZLKKiBsr7201nAVfRkO7NZ5 ulmZuuFDt9abwG4IWVonkSF4HDFu8Dc0oFmXP4nL3SQ15/xBPoq4GCu5k1XScQiCznZM=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH 2/2] xen/x86: ioapic: Bail out from timer_irq_works() as soon as possible Date: Fri, 18 Aug 2023 14:44:41 +0100 Message-Id: <20230818134441.45586-3-julien@xen.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230818134441.45586-1-julien@xen.org> References: <20230818134441.45586-1-julien@xen.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) X-ZM-MESSAGEID: 1692366320236100004 Content-Type: text/plain; charset="utf-8" From: Julien Grall Currently timer_irq_works() will wait the full 100ms before checking that pit0_ticks has been incremented at least 4 times. However, the bulk of the BIOS/platform should not have a buggy timer. So waiting for the full 100ms is a bit harsh. Rework the logic to only wait until 100ms passed or we saw more than 4 ticks. So now, in the good case, this will reduce the wait time to ~50ms. Signed-off-by: Julien Grall --- xen/arch/x86/io_apic.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c index 4875bb97003f..0bd774962a68 100644 --- a/xen/arch/x86/io_apic.c +++ b/xen/arch/x86/io_apic.c @@ -1509,6 +1509,8 @@ static void __init setup_ioapic_ids_from_mpc(void) static int __init timer_irq_works(void) { unsigned long t1, flags; + /* Wait for maximum 10 ticks */ + unsigned long msec =3D (10 * 1000) / HZ; =20 if ( no_timer_check ) return 1; @@ -1517,19 +1519,25 @@ static int __init timer_irq_works(void) =20 local_save_flags(flags); local_irq_enable(); - /* Let ten ticks pass... */ - mdelay((10 * 1000) / HZ); - local_irq_restore(flags); =20 - /* - * Expect a few ticks at least, to be sure some possible - * glue logic does not lock up after one or two first - * ticks in a non-ExtINT mode. Also the local APIC - * might have cached one ExtINT interrupt. Finally, at - * least one tick may be lost due to delays. - */ - if ( (ACCESS_ONCE(pit0_ticks) - t1) > 4 ) + while ( msec-- ) + { + mdelay(1); + /* + * Expect a few ticks at least, to be sure some possible + * glue logic does not lock up after one or two first + * ticks in a non-ExtINT mode. Also the local APIC + * might have cached one ExtINT interrupt. Finally, at + * least one tick may be lost due to delays. + */ + if ( (ACCESS_ONCE(pit0_ticks) - t1) <=3D 4 ) + continue; + + local_irq_restore(flags); return 1; + } + + local_irq_restore(flags); =20 return 0; } --=20 2.40.1