From nobody Thu Nov 21 16:17:20 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; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1726214387; cv=none; d=zohomail.com; s=zohoarc; b=S8UqTtDynopyGFPS4GQHPB0sumJGSI1OXX7zBJyZ+4XLcrt7zOoDBicRIv3YoEavIPZH8f03TDaD00JVjijm1HPMH/c7aQcQpobVxrgLdv5f5wNjy7v6VPNa+0P5z9Wyfp2eyQRoQBJG+Hcedcmh2l7m2JXUTlAl6CxFU7zSk4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726214387; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KJgIdTeGxaw7ZlxEbyNjVU/dqlACBdHjFk91wT/lMP4=; b=JzAxxGexdlO/vdAtFH4VixvK2wtkCHmN+lE4+ceMYEWy3KwkEZkHU1gZ6dRhm604rz0eS2rlNSepMMspq7AqmqmX3BDy/leJ2B/P6xOQIUiCsMkS0wg+FuVl4GWLSlU3A5wwC9bqJAk1ZYi634mHe8TK2udvKku3atvZFxjroXg= 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; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1726214387023169.5301309350035; Fri, 13 Sep 2024 00:59:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.798036.1208180 (Exim 4.92) (envelope-from ) id 1sp1D9-00049K-Vt; Fri, 13 Sep 2024 07:59:23 +0000 Received: by outflank-mailman (output) from mailman id 798036.1208180; Fri, 13 Sep 2024 07:59:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sp1D9-00049D-TC; Fri, 13 Sep 2024 07:59:23 +0000 Received: by outflank-mailman (input) for mailman id 798036; Fri, 13 Sep 2024 07:59:22 +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 1sp1D8-0003uX-El for xen-devel@lists.xenproject.org; Fri, 13 Sep 2024 07:59:22 +0000 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [2a00:1450:4864:20::32c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 14cf82b4-71a6-11ef-99a2-01e77a169b0f; Fri, 13 Sep 2024 09:59:20 +0200 (CEST) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-428e1915e18so5173605e9.1 for ; Fri, 13 Sep 2024 00:59:20 -0700 (PDT) Received: from localhost ([213.195.124.163]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42d9b16bfbfsm14947075e9.22.2024.09.13.00.59.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2024 00:59:18 -0700 (PDT) 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: 14cf82b4-71a6-11ef-99a2-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1726214359; x=1726819159; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KJgIdTeGxaw7ZlxEbyNjVU/dqlACBdHjFk91wT/lMP4=; b=JGX1pSa8gL8GUiIZ8Ugl45/s/B4RRXBvdzBCbCi2/w4I7cI90UZIKknUICO019NTom 1tGZknKnek+7q2ltvvo4WweiMKFKPmYqCVKwlM8jhWLUwgvWkfSa3hcSCIx3V3QP9lZE I3epSXbeToFFHFDLUcbF6oagyMewZ3ObPN8eA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726214359; x=1726819159; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KJgIdTeGxaw7ZlxEbyNjVU/dqlACBdHjFk91wT/lMP4=; b=J6F2BGdkORd0MiE02oMZWC0quwGek4Pz6ZPaSk/lzh9wZLq5SnEom5XSEGETcGiLRk E2jFCFmzUght/khkA+jsbuq8sKVlAacVTYf+fp9Hw6fDQhvMlZP9LbqVtxir8YuPz2de wAl3PboCc4ZFLyyx+jM3vvHU1cgY2442GwpRn8uxdEnsDbU9IOT/19WwvfheGz+auSUw a8/vVEXGRWgkioHM24EBnlEiviIvxiWijwjMGsCAck0XsiulYXA1rXSXqjSKpYbB+YrS AyG/WFaqGp+f1q2ELREUOxtLvLUit/cxSfX934tBHM424fCr3gzcm1nilHb1ZlVZJqV+ 0vZQ== X-Gm-Message-State: AOJu0YwCkiiYYOss0uXP3yNwMt7171ABAnkkqjq6OaVIq8dQWo1j6Fq1 2xxSnOGjkGiT3VXjIJL94u0p8PYq8kB+88vQWc+5rjdHr3FmnaPCmFTjkK0Knr+G8WE90BETtbP A X-Google-Smtp-Source: AGHT+IEpyjfoR6VNGeeMIaigttSgEqTbHzHjL+L/dZTtd9QUnTteQrtHRhilct47Kt1FsJW1CDYTqw== X-Received: by 2002:a05:600c:4f51:b0:42c:b6db:4270 with SMTP id 5b1f17b1804b1-42d90722068mr11157785e9.11.1726214358750; Fri, 13 Sep 2024 00:59:18 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Roger Pau Monne , Andrew Cooper , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH v7 1/2] x86/time: introduce command line option to select wallclock Date: Fri, 13 Sep 2024 09:59:06 +0200 Message-ID: <20240913075907.34460-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240913075907.34460-1-roger.pau@citrix.com> References: <20240913075907.34460-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1726214387735116600 Allow setting the used wallclock from the command line. When the option is= set to a value different than `auto` the probing is bypassed and the selected implementation is used (as long as it's available). The `xen` and `efi` options require being booted as a Xen guest (with Xen g= uest supported built-in) or from UEFI firmware respectively. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v6: - Clarify documentation regarding repeated using of the wallclock command = line option. Changes since v5: - Do EFI run-time services checking after command line parsing. Changes since v3: - Note xen option is only available if Xen guest support it built. - Fix typo. --- docs/misc/xen-command-line.pandoc | 21 ++++++++++++++++ xen/arch/x86/time.c | 41 ++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line= .pandoc index 959cf45b55d9..2a9b3b9b8975 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -2816,6 +2816,27 @@ vwfi to `native` reduces irq latency significantly. = It can also lead to suboptimal scheduling decisions, but only when the system is oversubscribed (i.e., in total there are more vCPUs than pCPUs). =20 +### wallclock (x86) +> `=3D auto |=C2=A0xen | cmos | efi` + +> Default: `auto` + +Allow forcing the usage of a specific wallclock source. + + * `auto` let the hypervisor select the clocksource based on internal + heuristics. + + * `xen` force usage of the Xen shared_info wallclock when booted as a Xen + guest. This option is only available if the hypervisor was compiled wi= th + `CONFIG_XEN_GUEST` enabled. + + * `cmos` force usage of the CMOS RTC wallclock. + + * `efi` force usage of the EFI_GET_TIME run-time method when booted from = EFI + firmware. + +If the selected option is invalid or not available Xen will default to `au= to`. + ### watchdog (x86) > `=3D force | ` =20 diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 29b026735e5d..e4751684951e 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1552,6 +1552,37 @@ static const char *__init wallclock_type_to_string(v= oid) return ""; } =20 +static int __init cf_check parse_wallclock(const char *arg) +{ + wallclock_source =3D WALLCLOCK_UNSET; + + if ( !arg ) + return -EINVAL; + + if ( !strcmp("auto", arg) ) + ASSERT(wallclock_source =3D=3D WALLCLOCK_UNSET); + else if ( !strcmp("xen", arg) ) + { + if ( !xen_guest ) + return -EINVAL; + + wallclock_source =3D WALLCLOCK_XEN; + } + else if ( !strcmp("cmos", arg) ) + wallclock_source =3D WALLCLOCK_CMOS; + else if ( !strcmp("efi", arg) ) + /* + * Checking if run-time services are available must be done after + * command line parsing. + */ + wallclock_source =3D WALLCLOCK_EFI; + else + return -EINVAL; + + return 0; +} +custom_param("wallclock", parse_wallclock); + static void __init probe_wallclock(void) { ASSERT(wallclock_source =3D=3D WALLCLOCK_UNSET); @@ -2527,7 +2558,15 @@ int __init init_xen_time(void) =20 open_softirq(TIME_CALIBRATE_SOFTIRQ, local_time_calibration); =20 - probe_wallclock(); + /* + * EFI run time services can be disabled from the command line, hence = the + * check for them cannot be done as part of the wallclock option parsi= ng. + */ + if ( wallclock_source =3D=3D WALLCLOCK_EFI && !efi_enabled(EFI_RS) ) + wallclock_source =3D WALLCLOCK_UNSET; + + if ( wallclock_source =3D=3D WALLCLOCK_UNSET ) + probe_wallclock(); =20 printk(XENLOG_INFO "Wallclock source: %s\n", wallclock_type_to_string(= )); =20 --=20 2.46.0 From nobody Thu Nov 21 16:17:20 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; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1726214390; cv=none; d=zohomail.com; s=zohoarc; b=a0ag4EQqlBlYHgc0W7I/A4vAyPwCNiU77x0rC/LikGw/LTfh+J+eHcWpUtPrYBQaFaKX4EnclqSo18O+deNcEvKvXX0RS41M9GhGRkbcBvpSYbUa2bvfMjBoooJcVOWuv8BHyt+vpG7SzZbieUkZ7t6OwJ13dxkKUFy81QvuVFQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726214390; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vVE8Td0DB91LsF/Q4kFEpq7x44WG+vLomrJspkQDYIA=; b=dKkInYupaESBJin6bg2lPe/ApzKlpABq89GlDG801VxL+FO7ea8fJ+RjJ3m8fHjBZgV6SgNvvvlaLscF5tbh5J67ta70RlpTjqw9yNHuGDM/Lixk+v804RiqXgx7Q/+OrpP8PlQZc2BV1c5RnmCj4mAAEU4hGTHkaphH2V9S3J4= 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; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 172621439033043.57371374895081; Fri, 13 Sep 2024 00:59:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.798037.1208186 (Exim 4.92) (envelope-from ) id 1sp1DA-0004CV-8m; Fri, 13 Sep 2024 07:59:24 +0000 Received: by outflank-mailman (output) from mailman id 798037.1208186; Fri, 13 Sep 2024 07:59:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sp1DA-0004At-3Z; Fri, 13 Sep 2024 07:59:24 +0000 Received: by outflank-mailman (input) for mailman id 798037; Fri, 13 Sep 2024 07:59:22 +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 1sp1D8-0003uw-Op for xen-devel@lists.xenproject.org; Fri, 13 Sep 2024 07:59:22 +0000 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [2a00:1450:4864:20::329]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 15e64b44-71a6-11ef-a0b5-8be0dac302b0; Fri, 13 Sep 2024 09:59:21 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-42cb8dac900so17464775e9.3 for ; Fri, 13 Sep 2024 00:59:21 -0700 (PDT) Received: from localhost ([213.195.124.163]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42d9b181ecasm14793085e9.43.2024.09.13.00.59.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2024 00:59:20 -0700 (PDT) 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: 15e64b44-71a6-11ef-a0b5-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1726214360; x=1726819160; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vVE8Td0DB91LsF/Q4kFEpq7x44WG+vLomrJspkQDYIA=; b=I3xXBoHKuCZ2hREuccHJiQK3GKGg4hbWQEc+UBrngXvLihdGaK5dzJFIAGOGMKmEZy H3CzGtOYsDs8EQ62ve5tRUDpuqISQnuFctQtXAaODZrCOnjM94yB/cGOgEu5ezxSCZ59 L8zSbeMmDAYGWIejeqo8w4JdNopHD1t0ydnvk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726214360; x=1726819160; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vVE8Td0DB91LsF/Q4kFEpq7x44WG+vLomrJspkQDYIA=; b=kiz7D/4OhLL6B6x53iuxaG90mCZWEgS3GHpB4qDkreLU/zvzxzmXJfV9n6Uwc7r8+i cFmNO91imD1XiuGzpfiW++SX8ZKL38GA4OzKuN2PCfw/Hyr006G4Z44+yuW4kwJKJj7V CalHf79AlNGe5yhxGrlZxpA+DLMBlrjdAwkk7CW+YuOE4m5SA5xOrNiHeGb+9IkTlKnW PCQ3k8RdKwvHdneBephAv8WgvNegwWBAgy2GsJPSJO6EB89v5UggtRytZowrcNzEpdA3 nvDGoGUpVwym+YU6xSOXzbDXkhJ/zKjm761FSR5Mkx0OKrMmk8k1goDNtKo4fqmtUs9s rmUQ== X-Gm-Message-State: AOJu0YxSqb4v1Ru5uUd56P1xrKJeFha4Kg2E0jJPfMdI+SYAAA0IdQrI dS5FfYkASWoZfAD4PkuyHhyLCh1IFk1Ez5r15jX3bzpnDVFlze5OdxhBezgV89BblBN7YuXTSQx q X-Google-Smtp-Source: AGHT+IGdUcOsAuRBJht8XF1xVxjpss5E+USi/c5Phj6XkWTcAJoXq907AFPf88llPJvUBRFzQwbUWg== X-Received: by 2002:a05:600c:4691:b0:42c:b1e1:a45b with SMTP id 5b1f17b1804b1-42cdb547f39mr41301195e9.19.1726214360298; Fri, 13 Sep 2024 00:59:20 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Roger Pau Monne , Jan Beulich , Andrew Cooper Subject: [PATCH v7 2/2] x86/time: prefer CMOS over EFI_GET_TIME Date: Fri, 13 Sep 2024 09:59:07 +0200 Message-ID: <20240913075907.34460-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240913075907.34460-1-roger.pau@citrix.com> References: <20240913075907.34460-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1726214391800116600 The EFI_GET_TIME implementation is well known to be broken for many firmware implementations, for Xen the result on such implementations are: Acked-by: Andrew Cooper Acked-by: Marek Marczykowski-G=C3=B3recki ----[ Xen-4.19-unstable x86_64 debug=3Dy Tainted: C ]---- CPU: 0 RIP: e008:[<0000000062ccfa70>] 0000000062ccfa70 [...] Xen call trace: [<0000000062ccfa70>] R 0000000062ccfa70 [<00000000732e9a3f>] S 00000000732e9a3f [] F arch/x86/time.c#get_cmos_time+0x1b3/0x26e [] F init_xen_time+0x28/0xa4 [] F __start_xen+0x1ee7/0x2578 [] F __high_start+0x94/0xa0 Pagetable walk from 0000000062ccfa70: L4[0x000] =3D 000000207ef1c063 ffffffffffffffff L3[0x001] =3D 000000005d6c0063 ffffffffffffffff L2[0x116] =3D 8000000062c001e3 ffffffffffffffff (PSE) **************************************** Panic on CPU 0: FATAL PAGE FAULT [error_code=3D0011] Faulting linear address: 0000000062ccfa70 **************************************** Swap the preference to default to CMOS first, and EFI later, in an attempt = to use EFI_GET_TIME as a last resort option only. Note that Linux for example doesn't allow calling the get_time method, and instead provides a dummy han= dler that unconditionally returns EFI_UNSUPPORTED on x86-64. Such change in the preferences requires some re-arranging of the function logic, so that panic messages with workaround suggestions are suitably prin= ted. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v2: - Updated to match previous changes. --- xen/arch/x86/time.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index e4751684951e..b86e4d58b40c 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1592,14 +1592,14 @@ static void __init probe_wallclock(void) wallclock_source =3D WALLCLOCK_XEN; return; } - if ( efi_enabled(EFI_RS) && efi_get_time() ) + if ( cmos_rtc_probe() ) { - wallclock_source =3D WALLCLOCK_EFI; + wallclock_source =3D WALLCLOCK_CMOS; return; } - if ( cmos_rtc_probe() ) + if ( efi_enabled(EFI_RS) && efi_get_time() ) { - wallclock_source =3D WALLCLOCK_CMOS; + wallclock_source =3D WALLCLOCK_EFI; return; } =20 --=20 2.46.0