From nobody Wed Dec 4 08:44:03 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=1725463950; cv=none; d=zohomail.com; s=zohoarc; b=WL4PtfWXJ6o0Bvz8SN8dB2FAdY1zGIVdyBxC8k4mdkaZkxAjiOYDCNvJ7TP8qhs5KLqROz4/SsShuJ6ZzVphBovcgosuBI4R92pDmH6fDQrTkf5vwzcziPwjTl3NgdkRWlDnmVII1RJ1IgIgvy2hOe96Urskg+3QhXfAQfRdP68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725463950; 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=3uSQihnqXCf2hMyHenOR5h3swtTmtaH+EXsprydBl94=; b=TFGlwkEFhXdpiAFMGEZZDmU/FqwBgjUD/quovWqPl+N+dBrZC8ChY0nxat6XX9Ku5fQXfq5LfnYMu6gZFrqlrx+/PuAGmQr0CoDS8AtRmiYWd2bwfw9B2gjQrAXuTmiRSA4Uq7ZSGL0R/R4mku7Ho4vDUeHPoxhZ54yfyiBRb0Q= 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 1725463950184260.55225796725654; Wed, 4 Sep 2024 08:32:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.790491.1200262 (Exim 4.92) (envelope-from ) id 1slrzH-0003kK-J3; Wed, 04 Sep 2024 15:32:03 +0000 Received: by outflank-mailman (output) from mailman id 790491.1200262; Wed, 04 Sep 2024 15:32:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1slrzH-0003kD-GL; Wed, 04 Sep 2024 15:32:03 +0000 Received: by outflank-mailman (input) for mailman id 790491; Wed, 04 Sep 2024 15:32:01 +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 1slrzF-0003Vv-SL for xen-devel@lists.xenproject.org; Wed, 04 Sep 2024 15:32:01 +0000 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [2a00:1450:4864:20::62c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d3e75446-6ad2-11ef-a0b3-8be0dac302b0; Wed, 04 Sep 2024 17:32:00 +0200 (CEST) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a869f6ce2b9so733137566b.2 for ; Wed, 04 Sep 2024 08:32:00 -0700 (PDT) Received: from localhost ([213.195.124.163]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a6236cfb4sm5500966b.100.2024.09.04.08.31.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 08:31:58 -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: d3e75446-6ad2-11ef-a0b3-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725463919; x=1726068719; 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=3uSQihnqXCf2hMyHenOR5h3swtTmtaH+EXsprydBl94=; b=qLcwj5qWBqiyRy6vRlWKzzJLFUIJpICHYXRKOiT75M259/YlyX2aERKvnUuhAIHo+E Tj98jJ9vvbraWZ/AvCcYFCKg6g0QoqPPjSZC+/PNeFjpH6ia9syOig8Q40bGKM1u9Q8S ZpMzH+4G5FKdPN+WGhyv6oBfhcrDsivt/FkeE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725463919; x=1726068719; 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=3uSQihnqXCf2hMyHenOR5h3swtTmtaH+EXsprydBl94=; b=K12M5pWp8miV3zL9b8VInSv1LzVlmKlmfPJ3gsz7QBf/ygeW06mkya9mra5GIZ7g1w R9nBedODf27uhqxKvriMmwDPvsOSIH3bxqwP7pIsIdH+EssWEeidMMGn3LHEwJp5ZUA9 65Fjh+fA/5p8S4skW+Ex/WbAlU2ovfrhH5uy3jBPckUR62Yg8bmvWfFPm8HSgdOZ4QWH ovjW7bSJOqV7m5PAjHYFidsGM7N3DsfX74QWTqXlbzQqo/kUzJjHVTBhgpEOrXZzSp8E DEpM9ElHQeqHh7rXnS64kQ3PZSbc4cgVwObqYqKFHo6MG2VAKMNO3uA+tgmZeVcEKHQu U6/w== X-Gm-Message-State: AOJu0YwUE9Do4ha1K14U+UhsY+fiLNJpy51tI8YnqljPE/FfjOEdRU5J iwzUgBMLINrciccGPe6eyT2lmqrBYQiTOEaz3b172MhuBX7jQphsmC2pyvgAO8rqpZGsbDU9IJd d X-Google-Smtp-Source: AGHT+IHfzxlFNr7URNfg+tTFdYyvwqEKKJAiB7ZDtpDrq5OI9vbmMwcP4p+qHmEqgXi1l3nRowguDA== X-Received: by 2002:a17:907:3f09:b0:a86:8e3d:86e2 with SMTP id a640c23a62f3a-a8a32df30c3mr384486466b.11.1725463918850; Wed, 04 Sep 2024 08:31:58 -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 v4 1/6] x86/time: introduce helper to fetch Xen wallclock when running as a guest Date: Wed, 4 Sep 2024 17:31:46 +0200 Message-ID: <20240904153151.83995-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904153151.83995-1-roger.pau@citrix.com> References: <20240904153151.83995-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: 1725463952329116600 Move the current code in get_wallclock_time() to fetch the Xen wallclock information from the shared page when running as a guest into a separate helper. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 Acked-by: Jan Beulich --- Changes since v3: - Place ifdef blocks inside the function. Changes since v2: - New in this version. --- xen/arch/x86/time.c | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index a97d78484105..1959cc4a4f2b 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -787,6 +787,30 @@ static struct platform_timesource __initdata_cf_clobbe= r plt_xen_timer =3D }; #endif =20 +static unsigned long read_xen_wallclock(void) +{ +#ifdef CONFIG_XEN_GUEST + struct shared_info *sh_info =3D XEN_shared_info; + uint32_t wc_version; + uint64_t wc_sec; + + ASSERT(xen_guest); + + do { + wc_version =3D sh_info->wc_version & ~1; + smp_rmb(); + + wc_sec =3D sh_info->wc_sec; + smp_rmb(); + } while ( wc_version !=3D sh_info->wc_version ); + + return wc_sec + read_xen_timer() / 1000000000; +#else + ASSERT_UNREACHABLE(); + return 0; +#endif +} + #ifdef CONFIG_HYPERV_GUEST /************************************************************ * HYPER-V REFERENCE TSC @@ -1497,24 +1521,8 @@ void rtc_guest_write(unsigned int port, unsigned int= data) =20 static unsigned long get_wallclock_time(void) { -#ifdef CONFIG_XEN_GUEST if ( xen_guest ) - { - struct shared_info *sh_info =3D XEN_shared_info; - uint32_t wc_version; - uint64_t wc_sec; - - do { - wc_version =3D sh_info->wc_version & ~1; - smp_rmb(); - - wc_sec =3D sh_info->wc_sec; - smp_rmb(); - } while ( wc_version !=3D sh_info->wc_version ); - - return wc_sec + read_xen_timer() / 1000000000; - } -#endif + return read_xen_wallclock(); =20 return get_cmos_time(); } --=20 2.46.0 From nobody Wed Dec 4 08:44:03 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=1725463947; cv=none; d=zohomail.com; s=zohoarc; b=SV/tpbAnHqj7AgJyfwEq7CJcvwl5H47pvh1H5y8vsKRyVpLrOwbsZxIv3MSP0Gz8BYhb4UURVLfpsHdHGCsS0Az/Birap+ReLs/CJ30D0cEXD0aLeTy1iNLQt7sQqiwx6inWrfhSYYHfElp//p9abylqWk2cm/oSdYjkgl/YD3I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725463947; 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=NrfOkjyZvcFrm5dtWXhSEszzPb0Micj/yQlfQ2ecmso=; b=I8GjAm5evTWWKD8v+cK6T4I2jkrrgjYXgdTH9ZiDauI6goZqymXY68+v39LGCpwymWd+c0q8kMqZZPzhPSgg4tvF5Frg91t8g5Thv6GheFInAMawRnNIAKBlZpj+E2C2vkxzIjUU32/t4iRgtkR3y1tgNgXRnrNHnlqVY/UpNHI= 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 1725463947018864.1794263109258; Wed, 4 Sep 2024 08:32:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.790492.1200269 (Exim 4.92) (envelope-from ) id 1slrzH-0003mo-VA; Wed, 04 Sep 2024 15:32:03 +0000 Received: by outflank-mailman (output) from mailman id 790492.1200269; Wed, 04 Sep 2024 15:32:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1slrzH-0003mD-Nx; Wed, 04 Sep 2024 15:32:03 +0000 Received: by outflank-mailman (input) for mailman id 790492; Wed, 04 Sep 2024 15:32:02 +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 1slrzG-0003Vv-3E for xen-devel@lists.xenproject.org; Wed, 04 Sep 2024 15:32:02 +0000 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [2a00:1450:4864:20::62a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d45172c2-6ad2-11ef-a0b3-8be0dac302b0; Wed, 04 Sep 2024 17:32:01 +0200 (CEST) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a868b8bb0feso810568766b.0 for ; Wed, 04 Sep 2024 08:32:01 -0700 (PDT) Received: from localhost ([213.195.124.163]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a620840b6sm6025966b.92.2024.09.04.08.31.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 08:31:59 -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: d45172c2-6ad2-11ef-a0b3-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725463920; x=1726068720; 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=NrfOkjyZvcFrm5dtWXhSEszzPb0Micj/yQlfQ2ecmso=; b=Ym5DYgJXb/QqD576iAPE/mxsugL5njBlen98x64KsXPIAEGG4a0i7EwPeCECaI6iXO RgFKVYLUjmX8mqO/AEW0PkL76VnhGmKS/N9sZ7Zd0k5l2AE7VE6Hk1bsck9Y/QIHhHWE lSSWo5NtEVbrrPkEtWAyS7RuG6F4jvDf4uDNo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725463920; x=1726068720; 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=NrfOkjyZvcFrm5dtWXhSEszzPb0Micj/yQlfQ2ecmso=; b=W/9f3DIYhsGG3kKZFGoloZQr2kjKju2Ak/5QG9xK//DYwNQt44BFMH6ghlJnu9nQhV DHckEilLJwxEtcQ8BnwYuZXprxuHm5jL8qKO7plUYES90aGcDM1RvlAUDu3suYQBhq6U chxYY/nsNqoWE/xaNjZwIuakGIIu5q0KRYogXECZpTO3eWXVEYXMQqcje9IGHVAlXOOR vQYK2zAZ6MQ/AlKGRggeL/OyiW44nWsDIiLUBTJJSgTObYD6VCw9EJRS5NYCqOcjQn+o S+ygg7ZSw0issn4TRxyCV4tSs58hi5irP0yqSKNK6BMfcw6CAuwCKCiVgU09w1mM57cq jXBA== X-Gm-Message-State: AOJu0YwWVjUgL+IRn2fQEQWEbJDkUeKgr5Hte8T5dbozP8XxFFoMKDTu hCupx/VHN6GG5CopHy7V6GiEYwzllrRAzAboezzQ7lb/ghy7MsenhQRMmcHUQ4atJ9D3A12PEiP Y X-Google-Smtp-Source: AGHT+IEKwd46aI1FXSeKvqMogs4g+CNs1X3mL1gvBfQn1oSpQxufVbzZyDoD6GdK1DDwCHuEp8mK+w== X-Received: by 2002:a17:907:980c:b0:a86:8f57:7de0 with SMTP id a640c23a62f3a-a89a37aa9famr1280983266b.49.1725463919983; Wed, 04 Sep 2024 08:31:59 -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 v4 2/6] x86/time: move CMOS edge detection into read helper Date: Wed, 4 Sep 2024 17:31:47 +0200 Message-ID: <20240904153151.83995-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904153151.83995-1-roger.pau@citrix.com> References: <20240904153151.83995-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: 1725463948261116600 Move the logic that ensures the CMOS RTC data is read just after it's been updated into the __get_cmos_time() function that does the register reads. = This requires returning a boolean from __get_cmos_time() to signal whether the r= ead has been successfully performed after an update. Note that while __get_cmos_time() can be used without waiting for the update edge, so far the only caller does wait for it, hence move the code inside of the function. The goal, albeit not accomplished by this patch, is to be able to split the probing and the reading of the CMOS RTC data into two separate functions. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 Acked-by: Jan Beulich --- Changes since v3: - Reduce a bit the locked section. Changes since v2: - New in this version. --- xen/arch/x86/time.c | 50 +++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 1959cc4a4f2b..571e23431ccd 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1246,8 +1246,26 @@ struct rtc_time { unsigned int year, mon, day, hour, min, sec; }; =20 -static void __get_cmos_time(struct rtc_time *rtc) +static bool __get_cmos_time(struct rtc_time *rtc) { + s_time_t start, t1, t2; + unsigned long flags; + + spin_lock_irqsave(&rtc_lock, flags); + + /* read RTC exactly on falling edge of update flag */ + start =3D NOW(); + do { /* may take up to 1 second... */ + t1 =3D NOW() - start; + } while ( !(CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP) && + t1 <=3D SECONDS(1) ); + + start =3D NOW(); + do { /* must try at least 2.228 ms */ + t2 =3D NOW() - start; + } while ( (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP) && + t2 < MILLISECS(3) ); + rtc->sec =3D CMOS_READ(RTC_SECONDS); rtc->min =3D CMOS_READ(RTC_MINUTES); rtc->hour =3D CMOS_READ(RTC_HOURS); @@ -1265,13 +1283,17 @@ static void __get_cmos_time(struct rtc_time *rtc) BCD_TO_BIN(rtc->year); } =20 + spin_unlock_irqrestore(&rtc_lock, flags); + if ( (rtc->year +=3D 1900) < 1970 ) rtc->year +=3D 100; + + return t1 <=3D SECONDS(1) && t2 < MILLISECS(3); } =20 static unsigned long get_cmos_time(void) { - unsigned long res, flags; + unsigned long res; struct rtc_time rtc; unsigned int seconds =3D 60; static bool __read_mostly cmos_rtc_probe; @@ -1292,29 +1314,9 @@ static unsigned long get_cmos_time(void) =20 for ( ; ; ) { - s_time_t start, t1, t2; - - spin_lock_irqsave(&rtc_lock, flags); - - /* read RTC exactly on falling edge of update flag */ - start =3D NOW(); - do { /* may take up to 1 second... */ - t1 =3D NOW() - start; - } while ( !(CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP) && - t1 <=3D SECONDS(1) ); - - start =3D NOW(); - do { /* must try at least 2.228 ms */ - t2 =3D NOW() - start; - } while ( (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP) && - t2 < MILLISECS(3) ); - - __get_cmos_time(&rtc); - - spin_unlock_irqrestore(&rtc_lock, flags); + bool success =3D __get_cmos_time(&rtc); =20 - if ( likely(!cmos_rtc_probe) || - t1 > SECONDS(1) || t2 >=3D MILLISECS(3) || + if ( likely(!cmos_rtc_probe) || !success || rtc.sec >=3D 60 || rtc.min >=3D 60 || rtc.hour >=3D 24 || !rtc.day || rtc.day > 31 || !rtc.mon || rtc.mon > 12 ) --=20 2.46.0 From nobody Wed Dec 4 08:44:03 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=1725463943; cv=none; d=zohomail.com; s=zohoarc; b=Y9UqZWnvM84DYXRAK/Gwax7p1Mu62ZJiYEJfyOxwLRQOxvRSOMcGb0rPt5ncCAdPr5k+fLWLmSrxxxmSyqYXdey7xAOUOu6WXbqbbUVL1+zIu6ZaIWWIQuWWNBG66IpJG1yEopX0GxCbb3VKy1pFtjIdKnztDQELtta3Ag7GwwE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725463943; 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=DdGzkJBMdRuuSYc3u2Hg7lyIJS3prPV9F25LIY9VB0g=; b=kbwyFlwQbqGSAup35z8eW+pS2T61ugdes5hsKBWp35/3voJ4GgtL9p8fJ7RZUcX7+fhtdo3Ycvri137kSSGJ7jJl7wYcZ3xhCN5VhSyQQ+WFG6oBEvabrP4eKEMVBO0EErd1mKPk546rfIazai+X3LrAjb1W4/wsRcBcNo0cnwA= 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 1725463943197798.0716139518071; Wed, 4 Sep 2024 08:32:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.790493.1200271 (Exim 4.92) (envelope-from ) id 1slrzI-0003tO-4r; Wed, 04 Sep 2024 15:32:04 +0000 Received: by outflank-mailman (output) from mailman id 790493.1200271; Wed, 04 Sep 2024 15:32:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1slrzH-0003qX-Vx; Wed, 04 Sep 2024 15:32:03 +0000 Received: by outflank-mailman (input) for mailman id 790493; Wed, 04 Sep 2024 15:32:03 +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 1slrzH-0003Vv-9W for xen-devel@lists.xenproject.org; Wed, 04 Sep 2024 15:32:03 +0000 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [2a00:1450:4864:20::630]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d53f1ab9-6ad2-11ef-a0b3-8be0dac302b0; Wed, 04 Sep 2024 17:32:02 +0200 (CEST) Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a86e5e9ff05so788841066b.1 for ; Wed, 04 Sep 2024 08:32:02 -0700 (PDT) Received: from localhost ([213.195.124.163]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a623a9939sm5236366b.158.2024.09.04.08.32.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 08:32:00 -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: d53f1ab9-6ad2-11ef-a0b3-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725463921; x=1726068721; 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=DdGzkJBMdRuuSYc3u2Hg7lyIJS3prPV9F25LIY9VB0g=; b=jIUx0+iD7mdZYl5BppKwSa0orj9+kBko8FYH300AOIR56Fn1ZH2LhB2j6L40aZS/J6 t8JtoOznFJdPZ+SC6iaGfsJqFORRbjHEc5R11gxAGqRsrc1KVZEXN8hD6nHkBbroto6c aGE1QjNAIy846OA3HOzgTgwAxw9uMv/Sa/56w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725463921; x=1726068721; 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=DdGzkJBMdRuuSYc3u2Hg7lyIJS3prPV9F25LIY9VB0g=; b=esvZY81nAF0s4mMLvifvrxLclXLcNRjttOjf6oAQJIkWU4eUDnhkVnIi/D93ATncm1 gSmUHaPMvbws2NcSEFF9lMO+ScqKy8cqDquyYEdD7sK4Ura1d0+erbh1Ra6U1Ih6osO3 WNR4t+hV9yQCgp7tdb/T9hDP9ARA0p18MRlX8s5TgY3UNR9p6vctA1E3OiiOLiyolTps wm4lzgQ9FOJ5ZlSeGDvCRyPmqHcmLKc5lYZjOFcq+wjbfDCWy08gDSljwYcqTUujm/nx 8bzaMw+jOBaO2MBglVed/rMsrFOVJOo9n/U5aYUCtquOjqEj0ZIt57ALrazx/tTn6WcM TV1Q== X-Gm-Message-State: AOJu0Yz6wZXrQVid7tGfvmabRqDdRvANsTG1hOmAiLFa/oOKE2iocBJy Oeo5OmdS+JCDhY/3pKgFP/mHxnGUGPZQvkUxSWrolpbSj4X8B2RtyPi6wSmMpDm6Hb0ba3F83uB B X-Google-Smtp-Source: AGHT+IE6XkMLQoiA77O1qAsVl6/RLfVs+qbzPjMR2qwXAUzpRGwUiFzq5NDzZGUZpra7+nYpqIMQRQ== X-Received: by 2002:a17:907:2da5:b0:a86:9cff:6798 with SMTP id a640c23a62f3a-a8a32ed4b43mr394525566b.30.1725463921126; Wed, 04 Sep 2024 08:32:01 -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 v4 3/6] x86/time: split CMOS read and probe logic into function Date: Wed, 4 Sep 2024 17:31:48 +0200 Message-ID: <20240904153151.83995-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904153151.83995-1-roger.pau@citrix.com> References: <20240904153151.83995-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: 1725463944261116600 The current logic to probe for the CMOS RTC is open-coded in get_cmos_time(= ), move it to a separate function that both serves the purpose of testing for = the CMOS RTC existence and returning its value. The goal is to be able to split the probing and the reading logic into sepa= rate helpers, and putting the current logic in a separate function helps simplif= ying further changes. A transient *rtc_p variable is introduced as a parameter to the function, t= hat will be removed by further changes. Also note that due to the code movemen= t, now cmos_rtc_probe will only get cleared on a second call to get_cmos_time(= ), as the newly introduced cmos_probe() function doesn't modify the variable anymore. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 Acked-by: Jan Beulich --- Changes since v2: - New in this version. --- xen/arch/x86/time.c | 59 +++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 571e23431ccd..1e3c13fc7360 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1291,45 +1291,32 @@ static bool __get_cmos_time(struct rtc_time *rtc) return t1 <=3D SECONDS(1) && t2 < MILLISECS(3); } =20 -static unsigned long get_cmos_time(void) +static bool cmos_probe(struct rtc_time *rtc_p, bool cmos_rtc_probe) { - unsigned long res; - struct rtc_time rtc; unsigned int seconds =3D 60; - static bool __read_mostly cmos_rtc_probe; - boolean_param("cmos-rtc-probe", cmos_rtc_probe); - - if ( efi_enabled(EFI_RS) ) - { - res =3D efi_get_time(); - if ( res ) - return res; - } - - if ( likely(!(acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC)) ) - cmos_rtc_probe =3D false; - else if ( system_state < SYS_STATE_smp_boot && !cmos_rtc_probe ) - panic("System with no CMOS RTC advertised must be booted from EFI" - " (or with command line option \"cmos-rtc-probe\")\n"); =20 for ( ; ; ) { - bool success =3D __get_cmos_time(&rtc); + bool success =3D __get_cmos_time(rtc_p); + struct rtc_time rtc =3D *rtc_p; =20 - if ( likely(!cmos_rtc_probe) || !success || + if ( likely(!cmos_rtc_probe) ) + return true; + + if ( !success || rtc.sec >=3D 60 || rtc.min >=3D 60 || rtc.hour >=3D 24 || !rtc.day || rtc.day > 31 || !rtc.mon || rtc.mon > 12 ) - break; + return false; =20 if ( seconds < 60 ) { if ( rtc.sec !=3D seconds ) { - cmos_rtc_probe =3D false; acpi_gbl_FADT.boot_flags &=3D ~ACPI_FADT_NO_CMOS_RTC; + return true; } - break; + return false; } =20 process_pending_softirqs(); @@ -1337,7 +1324,31 @@ static unsigned long get_cmos_time(void) seconds =3D rtc.sec; } =20 - if ( unlikely(cmos_rtc_probe) ) + ASSERT_UNREACHABLE(); + return false; +} + +static unsigned long get_cmos_time(void) +{ + unsigned long res; + struct rtc_time rtc; + static bool __read_mostly cmos_rtc_probe; + boolean_param("cmos-rtc-probe", cmos_rtc_probe); + + if ( efi_enabled(EFI_RS) ) + { + res =3D efi_get_time(); + if ( res ) + return res; + } + + if ( likely(!(acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC)) ) + cmos_rtc_probe =3D false; + else if ( system_state < SYS_STATE_smp_boot && !cmos_rtc_probe ) + panic("System with no CMOS RTC advertised must be booted from EFI" + " (or with command line option \"cmos-rtc-probe\")\n"); + + if ( !cmos_probe(&rtc, cmos_rtc_probe) ) panic("No CMOS RTC found - system must be booted from EFI\n"); =20 return mktime(rtc.year, rtc.mon, rtc.day, rtc.hour, rtc.min, rtc.sec); --=20 2.46.0 From nobody Wed Dec 4 08:44:03 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=1725463940; cv=none; d=zohomail.com; s=zohoarc; b=TQK7j7AtWeYyGCCvRuzfgrA4fIE5QVMy+IRllMRBku+rMeab4aQ3MFgJjsvlb0y0+k8mQlxGImdE7+wCdSTtW43WHcBlNsWQJng82Lxpdts+fkRCwwXzRYOBiz9zQF6hZFyY55HE0ItivD9966wYfvTxickk30yXFgNc0EE3J2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725463940; 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=ItQoxobOTKqaNEGEL3xN/mYnQHDAMZg8rUbmhpI3k9A=; b=X8TjP2akgoNOHKR1wh3z/RSAJORjko0/1TdFX8sQoNl3YyP2MRlYOmFjXBtkY3tBQN0dt7Ii9D+P6UuyLJ4Hmm3g+8dMqmGx3sC2Qd5q8gKC1hqd834q8kX8kKH7IodX1Cg6n6H4nRlmujVsqjQvTDSX1zUjiPAx1ojMVYNgZrg= 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 1725463940730680.632001123321; Wed, 4 Sep 2024 08:32:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.790494.1200293 (Exim 4.92) (envelope-from ) id 1slrzJ-0004SY-LF; Wed, 04 Sep 2024 15:32:05 +0000 Received: by outflank-mailman (output) from mailman id 790494.1200293; Wed, 04 Sep 2024 15:32:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1slrzJ-0004Ry-HQ; Wed, 04 Sep 2024 15:32:05 +0000 Received: by outflank-mailman (input) for mailman id 790494; Wed, 04 Sep 2024 15:32:04 +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 1slrzI-0003Vv-At for xen-devel@lists.xenproject.org; Wed, 04 Sep 2024 15:32:04 +0000 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [2a00:1450:4864:20::632]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d5d92f24-6ad2-11ef-a0b3-8be0dac302b0; Wed, 04 Sep 2024 17:32:03 +0200 (CEST) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a7aa086b077so100105766b.0 for ; Wed, 04 Sep 2024 08:32:03 -0700 (PDT) Received: from localhost ([213.195.124.163]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a623c3786sm5325366b.185.2024.09.04.08.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 08:32:02 -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: d5d92f24-6ad2-11ef-a0b3-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725463923; x=1726068723; 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=ItQoxobOTKqaNEGEL3xN/mYnQHDAMZg8rUbmhpI3k9A=; b=Gte6u867nbUwNBVMP7EDsIW2202qaBVdZ/Tg9CF9/D3EVztXu6zAeLkxIqFFFMUJlV iL2M6TR0UvD5PHbBEB4xxDgC5atwV2ytPMut/kr68XuaUfR9fYG5XnTr4EAQosD4auUo RZzBSmIl5tUQIhg3FEFCkxdFrhVewqJmvKnuI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725463923; x=1726068723; 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=ItQoxobOTKqaNEGEL3xN/mYnQHDAMZg8rUbmhpI3k9A=; b=skOGQgEIICabmVbZqqbjZsgdtg8lltV5C++SAzDcU3lz1kLK8JIOZA9sqqnJFeftxc 6p5r0a2P3ap6STVtq73BfvIPu3zjV+StQ7UVE+jIxj/9z060zinHer5C4+Wk9NS33F2D RkgU6edfLpwBRWTAHqe/8auce/mY/4b4Hlrm7zrXMFUoECjqNbbyNJxXuyT/T2n09mW0 BX3ghLT9PY06M0p66D9tl9Yp2EPI5cve4+VoodbJHNpx5DJy6ftZNJHRrm8A2ruGixpk V2P03pLOyExjU4qy7z8wRR+op3FHcdG59jgoNFrXqLCEqX0sXstglODrq08RrgydeQ89 rGvA== X-Gm-Message-State: AOJu0YzDkvibMB1rDFF92XH3SrpS0u+Cb0WA+opwoQ7z3mIU/EYsMHGO AsGeaA6QVVlu/vCS7GH/9pZUxQOnB57XgR631d+JNjOtJogBE4kVXxNP1uv1nuMhz1wb9NwnyOX u X-Google-Smtp-Source: AGHT+IFoVlKxWSyraHL31SO7uY0Qy4yIGRs9TMoqYGF7fkINWk4LESaxR2wSm1JlIwuUBN6BOiu4pg== X-Received: by 2002:a17:907:7245:b0:a86:6fb3:fda5 with SMTP id a640c23a62f3a-a8a3f24a7e8mr193811466b.32.1725463922725; Wed, 04 Sep 2024 08:32:02 -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 v4 4/6] x86/time: introduce probing logic for the wallclock Date: Wed, 4 Sep 2024 17:31:49 +0200 Message-ID: <20240904153151.83995-5-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904153151.83995-1-roger.pau@citrix.com> References: <20240904153151.83995-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: 1725463942332116600 Adding such probing allows to clearly separate init vs runtime code, and to place the probing logic into the init section for the CMOS case. Note both the Xen shared_info page wallclock, and the EFI wallclock don't really have= any probing-specific logic. The shared_info wallclock will always be there if booted as a Xen guest, while the EFI_GET_TIME method probing relies on chec= king if it returns a value different than 0. The panic message printed when Xen is unable to find a viable wallclock sou= rce has been adjusted slightly, I believe the printed guidance still provides t= he same amount of information to the user. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v3: - Remove ASSERT from cmos_read(). - Change indentation of panic message arguments in probe_wallclock(). - Add __init attribute. Changes since v2: - New in this version. --- xen/arch/x86/time.c | 118 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 94 insertions(+), 24 deletions(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 1e3c13fc7360..9ebeee61b987 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1291,14 +1291,23 @@ static bool __get_cmos_time(struct rtc_time *rtc) return t1 <=3D SECONDS(1) && t2 < MILLISECS(3); } =20 -static bool cmos_probe(struct rtc_time *rtc_p, bool cmos_rtc_probe) +static bool __initdata cmos_rtc_probe; +boolean_param("cmos-rtc-probe", cmos_rtc_probe); + +static bool __init cmos_probe(void) { unsigned int seconds =3D 60; =20 + if ( !(acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) ) + return true; + + if ( !cmos_rtc_probe ) + return false; + for ( ; ; ) { - bool success =3D __get_cmos_time(rtc_p); - struct rtc_time rtc =3D *rtc_p; + struct rtc_time rtc; + bool success =3D __get_cmos_time(&rtc); =20 if ( likely(!cmos_rtc_probe) ) return true; @@ -1328,28 +1337,12 @@ static bool cmos_probe(struct rtc_time *rtc_p, bool= cmos_rtc_probe) return false; } =20 -static unsigned long get_cmos_time(void) + +static unsigned long cmos_read(void) { - unsigned long res; struct rtc_time rtc; - static bool __read_mostly cmos_rtc_probe; - boolean_param("cmos-rtc-probe", cmos_rtc_probe); =20 - if ( efi_enabled(EFI_RS) ) - { - res =3D efi_get_time(); - if ( res ) - return res; - } - - if ( likely(!(acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC)) ) - cmos_rtc_probe =3D false; - else if ( system_state < SYS_STATE_smp_boot && !cmos_rtc_probe ) - panic("System with no CMOS RTC advertised must be booted from EFI" - " (or with command line option \"cmos-rtc-probe\")\n"); - - if ( !cmos_probe(&rtc, cmos_rtc_probe) ) - panic("No CMOS RTC found - system must be booted from EFI\n"); + __get_cmos_time(&rtc); =20 return mktime(rtc.year, rtc.mon, rtc.day, rtc.hour, rtc.min, rtc.sec); } @@ -1532,12 +1525,85 @@ void rtc_guest_write(unsigned int port, unsigned in= t data) } } =20 -static unsigned long get_wallclock_time(void) +static enum { + WALLCLOCK_UNSET, + WALLCLOCK_XEN, + WALLCLOCK_CMOS, + WALLCLOCK_EFI, +} wallclock_source __ro_after_init; + +static const char *__init wallclock_type_to_string(void) { + switch ( wallclock_source ) + { + case WALLCLOCK_XEN: + return "XEN"; + + case WALLCLOCK_CMOS: + return "CMOS RTC"; + + case WALLCLOCK_EFI: + return "EFI"; + + case WALLCLOCK_UNSET: + return "UNSET"; + } + + ASSERT_UNREACHABLE(); + return ""; +} + +static void __init probe_wallclock(void) +{ + ASSERT(wallclock_source =3D=3D WALLCLOCK_UNSET); + if ( xen_guest ) + { + wallclock_source =3D WALLCLOCK_XEN; + return; + } + if ( efi_enabled(EFI_RS) && efi_get_time() ) + { + wallclock_source =3D WALLCLOCK_EFI; + return; + } + if ( cmos_probe() ) + { + wallclock_source =3D WALLCLOCK_CMOS; + return; + } + + panic("No usable wallclock found, probed:%s%s%s\n%s", + !cmos_rtc_probe && !efi_enabled(EFI_RS) ? " None" : "", + cmos_rtc_probe ? " CMOS" : "", + efi_enabled(EFI_RS) ? " EFI" : "", + !cmos_rtc_probe + ? "Try with command line option \"cmos-rtc-probe\"\n" + : !efi_enabled(EFI_RS) + ? "System must be booted from EFI\n" + : ""); +} + +static unsigned long get_wallclock_time(void) +{ + switch ( wallclock_source ) + { + case WALLCLOCK_XEN: return read_xen_wallclock(); =20 - return get_cmos_time(); + case WALLCLOCK_CMOS: + return cmos_read(); + + case WALLCLOCK_EFI: + return efi_get_time(); + + case WALLCLOCK_UNSET: + /* Unexpected state - handled by the ASSERT_UNREACHABLE() below. */ + break; + } + + ASSERT_UNREACHABLE(); + return 0; } =20 /*************************************************************************= ** @@ -2462,6 +2528,10 @@ int __init init_xen_time(void) =20 open_softirq(TIME_CALIBRATE_SOFTIRQ, local_time_calibration); =20 + probe_wallclock(); + + printk(XENLOG_INFO "Wallclock source: %s\n", wallclock_type_to_string(= )); + /* NB. get_wallclock_time() can take over one second to execute. */ do_settime(get_wallclock_time(), 0, NOW()); =20 --=20 2.46.0 From nobody Wed Dec 4 08:44:03 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=1725463950; cv=none; d=zohomail.com; s=zohoarc; b=PH7jO3B3W/m2BgbxqfF3N9hbKGeqWiP/Kdbs0CqyWiRvveU/rsdF7QS0nP6FhS5E/6I7GY4lnyXAaPr2NWrsm0vbDk9JYeM667z+Lk+DUH1GK1XH+s70CYCOj+AqsIOi5eVQ1QQuBn4UJ6krie/lBh2mFszz5sgp0GQXmfFxBt4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725463950; 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=wttwru9ZqE1vNc2cTpVoP3TJEtmOujc6puRAfHnBzQg=; b=Hv+855R6zY/VqIqmjKoxgsJmpSy5MZadU3pqIwa7oild7CjTzpGUmHWCPzjrax2Z2gFP+JKGF+Gx1GJRDNuc9orjBXxBtD6sEUuJUPUBjIxPrauVRCIi4bVcext1VWm5WKwcwacXeeWlYpetTb0XL4veRSI19S/IRw9mzuwH484= 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 1725463950596221.52447966830323; Wed, 4 Sep 2024 08:32:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.790496.1200308 (Exim 4.92) (envelope-from ) id 1slrzM-0004o7-99; Wed, 04 Sep 2024 15:32:08 +0000 Received: by outflank-mailman (output) from mailman id 790496.1200308; Wed, 04 Sep 2024 15:32:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1slrzM-0004ms-2V; Wed, 04 Sep 2024 15:32:08 +0000 Received: by outflank-mailman (input) for mailman id 790496; Wed, 04 Sep 2024 15:32:07 +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 1slrzL-0003Va-Ft for xen-devel@lists.xenproject.org; Wed, 04 Sep 2024 15:32:07 +0000 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [2a00:1450:4864:20::636]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d727354a-6ad2-11ef-99a1-01e77a169b0f; Wed, 04 Sep 2024 17:32:05 +0200 (CEST) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a869332c2c2so158324966b.0 for ; Wed, 04 Sep 2024 08:32:05 -0700 (PDT) Received: from localhost ([213.195.124.163]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a623a45b0sm5548066b.143.2024.09.04.08.32.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 08:32:03 -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: d727354a-6ad2-11ef-99a1-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725463924; x=1726068724; 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=wttwru9ZqE1vNc2cTpVoP3TJEtmOujc6puRAfHnBzQg=; b=SON+06av0Y+pV3xgXeZt1LHeH0uJbFre9BoYGCikFEpIV1zkDXhKOZwRKBoRmTxwz4 dvy1674C4Afs+OrI0fnwaAtIHFNZ529i9XwlXW3Ds2bmLgxSFtvzF5y6FcRNoc8LCpmQ SrqSLQhtKY4776cVKuY2ica4JBrwpQknlWUog= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725463924; x=1726068724; 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=wttwru9ZqE1vNc2cTpVoP3TJEtmOujc6puRAfHnBzQg=; b=s6LKgZ28lwBx4zKC+5bUi1Nop4j/OIAc2n15AZCPM3w9Z3TYbP3sX2pIoq30C1qYFk Iwi/yc6797bDBAvbSG3CRYNhywS34Nqpxwu5W/3BnKcSmsV19nmrLnZeinb4dSBHjzu+ XsuXp89NzSLCcmybp0zQGCCwjDHlRxYhIcH+4wgPbFA3Dmv+4pTbMc9J+s1VZC9HZmIn UM4MTwzGJIoY0DLypwUQsJgGGsUvs6uxkuhfz43P4Anjj2opkxfhDiUWrr1/xNlYIG/J NMdE/B4uz0f085t6juzxYLAn5e7p3q+Cl/2O79VbL5aG6lVjLE4bisak7zWXIw1RTJ4u 6qnQ== X-Gm-Message-State: AOJu0Yx8jv/cz6usBSLtTyvaO9sQ2fTvn5LxkbDLBP2odK7WbvwmmC02 1IJl+FPVcNIND1CiAB4sx8gwxb4hTh26w1zgs7+FNskxicWz4Y1QV/USGh6oWV/YsM/B9KJkwmN i X-Google-Smtp-Source: AGHT+IFBzXdkAuKaYu8oiD2UdSN5m8OT1z+hLba5AKJcLQo1M7yXW9aHY2tJl8+iVLfn1VeR7WUnCg== X-Received: by 2002:a17:907:7f14:b0:a7a:8284:c8d6 with SMTP id a640c23a62f3a-a8a43140f0emr268958966b.24.1725463924379; Wed, 04 Sep 2024 08:32:04 -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 v4 5/6] x86/time: introduce command line option to select wallclock Date: Wed, 4 Sep 2024 17:31:50 +0200 Message-ID: <20240904153151.83995-6-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904153151.83995-1-roger.pau@citrix.com> References: <20240904153151.83995-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: 1725463952371116600 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. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v3: - Note xen option is only available if Xen guest support it built. - Fix typo. --- docs/misc/xen-command-line.pandoc | 19 ++++++++++++++++++ xen/arch/x86/time.c | 33 ++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line= .pandoc index 0a66e1ee2d7e..1944b9d8eb9d 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -2821,6 +2821,25 @@ 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. + ### watchdog (x86) > `=3D force | ` =20 diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 9ebeee61b987..52944b8fbfde 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1553,6 +1553,36 @@ static const char *__init wallclock_type_to_string(v= oid) return ""; } =20 +static int __init cf_check parse_wallclock(const char *arg) +{ + if ( !arg ) + return -EINVAL; + + if ( !strcmp("auto", arg) ) + wallclock_source =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) ) + { + if ( !efi_enabled(EFI_RS) ) + return -EINVAL; + + 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); @@ -2528,7 +2558,8 @@ int __init init_xen_time(void) =20 open_softirq(TIME_CALIBRATE_SOFTIRQ, local_time_calibration); =20 - probe_wallclock(); + 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 Wed Dec 4 08:44:03 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=1725463951; cv=none; d=zohomail.com; s=zohoarc; b=NTu0qLJ+fgu4OVVIBh7lXshi+MD0CScSV08qYL3VONtgdYNQ+/MURabmsqc2r9dlujTNPKBco2J8u38yyTLZ1p6n+0lb5WqOnhlZCm0rW9b98h6eh/MqTmxg3RvuFHAl+hzD7g1b6ipiMVMOoxSxDwYBInMEA+dOVp6ZusFPdoM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725463951; 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=J5xIEyShiXsG0uS8t4KpTmc8gXLGG9Loy1+FhdabqNM=; b=NpxgjR4fR+7DxlIWamrpcCQrHdXzyckiG9X1IoNT88KuzlK5xGhjeaMK2RVp17nm789xxbqevAo5UCJg1o/jPMFLWLUiGQpSGRxBpvdoUjZKaqAopQuiqalbIEDCG+gAlL4voCjUJvWxPa3gWlv7gvEU3PXldd+NBRmSqse5txk= 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 172546395161418.575139234785865; Wed, 4 Sep 2024 08:32:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.790495.1200303 (Exim 4.92) (envelope-from ) id 1slrzL-0004lB-UL; Wed, 04 Sep 2024 15:32:07 +0000 Received: by outflank-mailman (output) from mailman id 790495.1200303; Wed, 04 Sep 2024 15:32:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1slrzL-0004ky-Qq; Wed, 04 Sep 2024 15:32:07 +0000 Received: by outflank-mailman (input) for mailman id 790495; Wed, 04 Sep 2024 15:32:07 +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 1slrzL-0003Vv-1c for xen-devel@lists.xenproject.org; Wed, 04 Sep 2024 15:32:07 +0000 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [2a00:1450:4864:20::62f]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d78658b1-6ad2-11ef-a0b3-8be0dac302b0; Wed, 04 Sep 2024 17:32:06 +0200 (CEST) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a86c476f679so820004466b.1 for ; Wed, 04 Sep 2024 08:32:06 -0700 (PDT) Received: from localhost ([213.195.124.163]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a62038d4dsm6197966b.51.2024.09.04.08.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 08:32:05 -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: d78658b1-6ad2-11ef-a0b3-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725463926; x=1726068726; 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=J5xIEyShiXsG0uS8t4KpTmc8gXLGG9Loy1+FhdabqNM=; b=tItn/ACFd3uCkoIfLnmc3Rom9thQgySwBEzTgylso8w3UfolM+hsAbZ6eZ39UjJW86 d+fuDvxUYX5Yxup1DJOHDFj8r3Gm6oseKDUdxIeIB2/bTeyXOWz0THlB48oEyUxIvm+h vWclBWZCAaiXeKxN/yeYqyVwFuNLZr7l+MUeE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725463926; x=1726068726; 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=J5xIEyShiXsG0uS8t4KpTmc8gXLGG9Loy1+FhdabqNM=; b=hjmKpHtWzXml7EPKELqTx6Lfh37nwCzjKkPg/+D61qukKHIJkQKApYFV+GzkP5P7Jd yWfGoU38TvmzfEpxgOLn07vC8+UMKYIEoibB+SOTwBMGXTWaHlMjAodI4JnhSqSulRAm rhqqBTShLvVwAb8OnnQsrZ1w+N0eLccF02PLhOa3VPDBeFnqrSGwKqYpEueD1iEFvQ7b YRTXzQe52V1pYSCDguI/gk4jflmpjIxfeyEC+EHP53tEOPX+6b43boAO/k5n83q6oQiK Za4ngpKolQNtySbZOgrrYAnMjm9y1oUQAbruEyhQAVX9U6kQHvC9odOno3twHbbWASJe iHtQ== X-Gm-Message-State: AOJu0Yw2AUWxruBEfr6lq0JdiXsQggTQ3rFyjv2cPC/rDB76bNFBmMDu gq09xXxKPcrjPL8mcAxZn4XgLBdpGaVXaaqPM+gJltdUrCnt8sRh2GlgHkHlha6RwF1ksPwMpsY P X-Google-Smtp-Source: AGHT+IHfdDFhhMzIZlyWzfqK0BBgBrqi/pDSrlmGyX8+0tnV19l/1qChJPdG3vaxKWvMuB/EQizN6A== X-Received: by 2002:a17:907:9483:b0:a86:80ef:4fe5 with SMTP id a640c23a62f3a-a89b96f7106mr1073576066b.47.1725463925528; Wed, 04 Sep 2024 08:32:05 -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 v4 6/6] x86/time: prefer CMOS over EFI_GET_TIME Date: Wed, 4 Sep 2024 17:31:51 +0200 Message-ID: <20240904153151.83995-7-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240904153151.83995-1-roger.pau@citrix.com> References: <20240904153151.83995-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: 1725463952347116600 The EFI_GET_TIME implementation is well known to be broken for many firmware implementations, for Xen the result on such implementations are: ----[ 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 52944b8fbfde..788a12d52fc3 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_probe() ) { - wallclock_source =3D WALLCLOCK_EFI; + wallclock_source =3D WALLCLOCK_CMOS; return; } - if ( cmos_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