From nobody Wed Dec 4 08:33:17 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=1725368621; cv=none; d=zohomail.com; s=zohoarc; b=GL44pfopAqyEH09XR2fvAxlDkZkat7IpM+cspwvgpcc0Rx7+O9iMDkFBGd6YpvijZgYCt+VA8jpPZyofrBuYAQ88epApG7Z7xZOLKX94SZPJ4qcZbpRRxMJoXCbwAsg/ocbqQHZO/eT7gXKzJ6vM6TX7G9IrKGDKt8WEE3uhEGc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725368621; 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=+l129vex/BaLP7ihPKH7R+U8k/cBkm9MNqwH4jVc1hI=; b=jIxzMURZLvonbh7uyJZ94/xDzd+S2NECw2jdqqqlHWhpWU2NF3wYjISpqpSE/tACBT6gIyHI4xc1YYBMBN4phhDIpoU3OEAu0fo+hFM/DOPl+9TAURG594cnyRKRspXcwTdvGWzAV/QMknRv1vblo3HdVJtFwByOr//tc+BFfNY= 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 1725368621401327.1493102358104; Tue, 3 Sep 2024 06:03:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.789148.1198667 (Exim 4.92) (envelope-from ) id 1slTBt-00078n-6b; Tue, 03 Sep 2024 13:03:25 +0000 Received: by outflank-mailman (output) from mailman id 789148.1198667; Tue, 03 Sep 2024 13:03:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1slTBt-00078g-2t; Tue, 03 Sep 2024 13:03:25 +0000 Received: by outflank-mailman (input) for mailman id 789148; Tue, 03 Sep 2024 13:03:23 +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 1slTBr-00075o-Pl for xen-devel@lists.xenproject.org; Tue, 03 Sep 2024 13:03:23 +0000 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [2a00:1450:4864:20::332]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e675c1b3-69f4-11ef-a0b2-8be0dac302b0; Tue, 03 Sep 2024 15:03:23 +0200 (CEST) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-428e0d18666so45261285e9.3 for ; Tue, 03 Sep 2024 06:03:23 -0700 (PDT) Received: from localhost ([213.195.124.163]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374b5e3511dsm11383308f8f.34.2024.09.03.06.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 06:03:21 -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: e675c1b3-69f4-11ef-a0b2-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725368602; x=1725973402; 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=+l129vex/BaLP7ihPKH7R+U8k/cBkm9MNqwH4jVc1hI=; b=T6Y3osc2uKSRQuoyr8QWoQ9XLgOaiAo/HXVq3xAPLKYJtIpZjUdraqZiArdT0iaz8s +ZSu1UsGFuXcASaNq2b7Omv+2adlZRK7542c5L8Iz4LJwb9R73zfFMzlCJw39+PKbqTK 5mebOEFsiD85f6cIYfSzaHlnzwTzyc5W3oRRM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725368602; x=1725973402; 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=+l129vex/BaLP7ihPKH7R+U8k/cBkm9MNqwH4jVc1hI=; b=Ex1FZwpUnwTV5XW4tbV+ryMk3TV2lhp9buNe71lontd4CfNMMXDYC33fpUGPLbyuji x2TkFW03H0Pb5YhU1zEN305LWzwa7ImZ7MACFng7Sg1K2AVRcS13vuhRV6H844tKlF+8 NocEnAgQMKgS63pCHiol6LZxYr0Q4DStXKNwvPYp5lXqnq6k3WFJk35rUBlZmnMEPaPH 04emrgUoIRzRTioq5sHgB5ujIbe2lcs+szoZo4HzhJBONIXZeEwFiJKTxafzTz+qHSye 2OXfouLwz9JG4I5JoTxRoz97Y/kAV3/ba05faIeSD/S3EFDVotdyfxDHXu7LQDOl8Xxd HKVA== X-Gm-Message-State: AOJu0YyZ4h5RiTB3sLVEgw7ilWlUk2jWW8e0l7JJ0zgf2YTT/3APEcdD iIzAs5VHp9x0poNVAZ51yMU9+iNa53OR6ufyqIa2BTEuqCqNbuFm0mqx0A3J8Y/PITDcwedG/0L + X-Google-Smtp-Source: AGHT+IHOPMOd/5hxX84fic4x8CaLUZeeOLLppf+Dl+wGsK+bwntuCuCachvZsnvrLeMKtv36Hf0XyA== X-Received: by 2002:adf:e94a:0:b0:374:c90c:226 with SMTP id ffacd0b85a97d-374c90c0298mr5429728f8f.9.1725368601710; Tue, 03 Sep 2024 06:03:21 -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 v3 1/7] x86/time: introduce helper to fetch Xen wallclock when running as a guest Date: Tue, 3 Sep 2024 15:02:57 +0200 Message-ID: <20240903130303.71334-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240903130303.71334-1-roger.pau@citrix.com> References: <20240903130303.71334-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: 1725368623272116600 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 --- Changes since v2: - New in this version. --- xen/arch/x86/time.c | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index a97d78484105..d022db4bd4a0 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -785,6 +785,31 @@ static struct platform_timesource __initdata_cf_clobbe= r plt_xen_timer =3D .resume =3D resume_xen_timer, .counter_bits =3D 63, }; + +static unsigned long read_xen_wallclock(void) +{ + 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 +static unsigned long read_xen_wallclock(void) +{ + ASSERT_UNREACHABLE(); + return 0; +} #endif =20 #ifdef CONFIG_HYPERV_GUEST @@ -1497,24 +1522,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:33:17 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=1725368622; cv=none; d=zohomail.com; s=zohoarc; b=K2Ki4cvVkn+5zGQ4yopvcnPYadkgujImkfdM7Br5AymkbSJJ3jIdGmALEU3IHhU/luQr9cOVAviETHc4J8hUAHmUCRuwaj6jfDaZCL0ZododA4qkmWg73UVfk909jJHU2c6VGjAGg/VNMstSge2BX+Uo3gJNFl/q68XWuFLYeyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725368622; 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=SWNpjBsAIPK60t6LFlUvJ8Y+91zPGK0954pEXqUaxFA=; b=ZR5MOkdCQi9JLczcmytRXddGzd50/DvhCg0fIdgvQTP5baAnZdzMbGq4+Ad8OuZw9HsEvSB9IAajgCiW3vF0dcubhHRJ/3eKkKcSIpCBOpahIF21Fch/oBfunIfH0CG5gx+LpWmfDQ34Sbj81Y17oqRG7vOUKY0VzxAGQYmQo2s= 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 172536862286818.369349267638654; Tue, 3 Sep 2024 06:03:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.789150.1198687 (Exim 4.92) (envelope-from ) id 1slTBu-0007bx-KY; Tue, 03 Sep 2024 13:03:26 +0000 Received: by outflank-mailman (output) from mailman id 789150.1198687; Tue, 03 Sep 2024 13:03:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1slTBu-0007bL-HI; Tue, 03 Sep 2024 13:03:26 +0000 Received: by outflank-mailman (input) for mailman id 789150; Tue, 03 Sep 2024 13:03:25 +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 1slTBt-00075o-6P for xen-devel@lists.xenproject.org; Tue, 03 Sep 2024 13:03:25 +0000 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [2a00:1450:4864:20::336]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e746b798-69f4-11ef-a0b2-8be0dac302b0; Tue, 03 Sep 2024 15:03:24 +0200 (CEST) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-42bbc70caa4so34704315e9.0 for ; Tue, 03 Sep 2024 06:03:24 -0700 (PDT) Received: from localhost ([213.195.124.163]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42c84fcfa75sm55355515e9.25.2024.09.03.06.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 06:03:22 -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: e746b798-69f4-11ef-a0b2-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725368603; x=1725973403; 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=SWNpjBsAIPK60t6LFlUvJ8Y+91zPGK0954pEXqUaxFA=; b=ZFha+ohE3p0b1zf4NxQyTfYi9++xHzXPFc9u4WbKuazXmiq0J9M39+mZ2zImCrSyLg JkdkX4P+vgt+OZ1Anrlv+E0/zosJZ6s0fe4ZoeTCYr1hhduPsAJCbbcXsg7OlXAcXE6z aKJbpWlKxLVrVa1RXUFqoy83ptffJpNzdQ7t4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725368603; x=1725973403; 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=SWNpjBsAIPK60t6LFlUvJ8Y+91zPGK0954pEXqUaxFA=; b=gXaJTkcD5ki+gFxLapTjx61h9j/3BRXZBdsZLXmi6o9swCEPtzNrPeXIHiYLItcgP7 G5HIZszEE8Lu7Yfnk30DpRfAJzL7plp5zypPg1kKP4MYchKd0n1z6J3Bti2eTIdJE2rN Es2kGfWtt3VzwYirBH3klgUKU39U1Vn7WKWTdTDK3fNnZWvmUU82oEjZ6veuyoeRmjHr to6aoYpbGYc+9YYNpC6tQmPkHTQ5kUDGFGf0rmArvyAnATkjh95DlfD8s/gOkMS7uQm+ XE301COuJ7lWyXViMWHSMsxBqNRUFIfnVeHfCUCmDApw652UbiZvjy9DR65KB7KzColu X/Ug== X-Gm-Message-State: AOJu0YyxWFlxJOeEZxpQxaNsy9sHjMqwIIUNUfbUyCRSkkLhxMK6vaQC j8stIZWLoIHttNO9gWLNBOX9l1hY9w25UMGI16spsBJ/mYUhtgedTpZEUX/+RLwVEAGueCDm66j j X-Google-Smtp-Source: AGHT+IFJPuLIBbs8tmthZcf2mEWK0Tf3VPt1gaXAlZbfd7dD3iHlHbB7Z04kR6ovPjIdRiHJTEsBlQ== X-Received: by 2002:a05:600c:3b85:b0:426:602d:a246 with SMTP id 5b1f17b1804b1-42c8dea66b1mr5528665e9.32.1725368602840; Tue, 03 Sep 2024 06:03:22 -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 v3 2/7] x86/time: move CMOS edge detection into read helper Date: Tue, 3 Sep 2024 15:02:58 +0200 Message-ID: <20240903130303.71334-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240903130303.71334-1-roger.pau@citrix.com> References: <20240903130303.71334-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: 1725368623301116600 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. 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 --- 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 d022db4bd4a0..2a64687bf45b 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1247,8 +1247,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); @@ -1268,11 +1286,15 @@ static void __get_cmos_time(struct rtc_time *rtc) =20 if ( (rtc->year +=3D 1900) < 1970 ) rtc->year +=3D 100; + + spin_unlock_irqrestore(&rtc_lock, flags); + + 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; @@ -1293,29 +1315,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:33:17 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=1725368629; cv=none; d=zohomail.com; s=zohoarc; b=BCiptX8kjQdFZ4wrXV9FnD24Gl5VQZxI6fvlwvZeRnTHcJ9BS+pulFJWEVTTYEIfzuFczalAFp9hp7fvDR5MfxIphBUewQWLckSEO0XaDqRW494x7XNb15GaR7iHHKwYdvX0E8lLGlVCvcGrY5qOuIEyVFiwN2af8aI0bngrFsM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725368629; 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=VlrST8NQvTpSHZQ00XsEmEMoHSo3pwtZjz9imQntHpo=; b=IG3CNFXmQhueccRa94KfUFVdF/rjwke6tfxg4VPljhhN8sMWSb3epjaufverJ9R7kIsPWQn5kDiHT5NUvgJeRq92yV+9pJkt2RF+rXkOV/fZ/UfTd+k7+sLfBmRDjuCgZANqjTgRODRnbW3lRTd0AtenO0V4WbRH+mfYIj/2BRw= 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 1725368629295307.01711081436963; Tue, 3 Sep 2024 06:03:49 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.789151.1198697 (Exim 4.92) (envelope-from ) id 1slTBx-0007uu-1Y; Tue, 03 Sep 2024 13:03:29 +0000 Received: by outflank-mailman (output) from mailman id 789151.1198697; Tue, 03 Sep 2024 13:03:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1slTBw-0007uk-Tv; Tue, 03 Sep 2024 13:03:28 +0000 Received: by outflank-mailman (input) for mailman id 789151; Tue, 03 Sep 2024 13:03:28 +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 1slTBw-0006aM-3A for xen-devel@lists.xenproject.org; Tue, 03 Sep 2024 13:03:28 +0000 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [2a00:1450:4864:20::330]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e8395ab8-69f4-11ef-99a1-01e77a169b0f; Tue, 03 Sep 2024 15:03:26 +0200 (CEST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-42c2e50ec13so28047775e9.0 for ; Tue, 03 Sep 2024 06:03:26 -0700 (PDT) Received: from localhost ([213.195.124.163]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374cd905b7csm4693774f8f.74.2024.09.03.06.03.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 06:03:23 -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: e8395ab8-69f4-11ef-99a1-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725368605; x=1725973405; 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=VlrST8NQvTpSHZQ00XsEmEMoHSo3pwtZjz9imQntHpo=; b=NvLhFVYljyQEoi+jFHz9CHkzXqKlVr7SBzUU+xIb4WQPXQKE0hBGz2GaU06c5Suxpo K6hR3kGq84scZe+ungZKCC3rTithQ/MXhg1sGG+5FqFF/gRA+oHWtMISAZFRbSro5UD1 y+nJqmVrq7RFHNGjo771Xh6s3ukC5SO5k3QJQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725368605; x=1725973405; 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=VlrST8NQvTpSHZQ00XsEmEMoHSo3pwtZjz9imQntHpo=; b=qJoB6/kbj+uDjzhgGqFiTj1vJht838ea6VHK3zOwtkj7o9kbDGWPoyqZ1YynA3HLlr gdv4fnjGhZn28d+0yVk0Fisc8afyEFsj92fJWrXg9I6qDZPcdyA6YPXDpaFcaaod4RVk cdyQ5jmVjjn5J805QDX4jilmjSoeJHT+uQtLs/NMukOWC8zmi+VhFXvrCMffmjLeup7X kFYWidvLhIg7gSiIqCUZPJUzrC7ct1Rm/+NmtBsu4LHhbRF3TYdr4LHEw9vxh+VyGSr0 mfh7H69OJDYz5Res9DK0nMs4I6eBAfQhfkx3y91KzJvzY17atYM8jI6Tp8Sfoyqfutho zOwg== X-Gm-Message-State: AOJu0Yzu3tq/WdpDzOfMv1KalZxZFEApGpHoFdXYx7kk9/NNjKWpvbcQ F6CZ/ua1ITJqDUBJxqyy8sUjIecVW9pejHpyIggYtvZm+NUiE9UVsZ2qrgvvkkjXngcGEAnMGjW 3 X-Google-Smtp-Source: AGHT+IFzWZBGZftFOWyrL5F4RCE5uzSTQrWk0vWZ5ly8Ds6AQmLr0wxsyAouBwF5cLw80yg3+0RO6g== X-Received: by 2002:adf:eac7:0:b0:374:cbe8:6f43 with SMTP id ffacd0b85a97d-374cbe8703bmr4119624f8f.33.1725368604675; Tue, 03 Sep 2024 06:03:24 -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 v3 3/7] x86/time: split CMOS read and probe logic into function Date: Tue, 3 Sep 2024 15:02:59 +0200 Message-ID: <20240903130303.71334-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240903130303.71334-1-roger.pau@citrix.com> References: <20240903130303.71334-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: 1725368631339116600 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. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 --- 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 2a64687bf45b..10840757b22c 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1292,45 +1292,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(); @@ -1338,7 +1325,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:33:17 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=1725368628; cv=none; d=zohomail.com; s=zohoarc; b=KDkuS8ZaluYB5OSEoomyBleY+wwEJqaiaVfEyxexVz+x+bXCaLb9epxqKR1YliL5zQcKsgpPjG7T4Gvo1RtoVmCIEuswe5hkQDfFH6uw6/PCs3lbJ1IzGOdLoTwZEr8PCTCYgPRh7lBOI0OLToKXDKzuAuDSzoPnYOTYjhpNYK4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725368628; 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=GYHgwNobacqZEEFEfRPcZZVej2rQvaVSJz+xtblHyy0=; b=D8TEV8IX+r+BPERhIvhnlJNJjK0FurfUg1CkmyyNZ+Qk8E9lIqqwDKh2O0eHJNFm3U7bnANJp9K9sMeOG7WPOkSPKXJ/vDmBS719QF71jQm9mFUKHNfgZ5zx3T3PrRfMX6fgUhaizJ7I64vIQF79Tblz1Pszt5fQxr7vRrkGglY= 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 172536862802410.249522820759012; Tue, 3 Sep 2024 06:03:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.789152.1198706 (Exim 4.92) (envelope-from ) id 1slTBy-0008CZ-9o; Tue, 03 Sep 2024 13:03:30 +0000 Received: by outflank-mailman (output) from mailman id 789152.1198706; Tue, 03 Sep 2024 13:03:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1slTBy-0008CP-6k; Tue, 03 Sep 2024 13:03:30 +0000 Received: by outflank-mailman (input) for mailman id 789152; Tue, 03 Sep 2024 13:03:29 +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 1slTBx-0006aM-3H for xen-devel@lists.xenproject.org; Tue, 03 Sep 2024 13:03:29 +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 e8e5a12c-69f4-11ef-99a1-01e77a169b0f; Tue, 03 Sep 2024 15:03:27 +0200 (CEST) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-42c5347b2f7so29258975e9.0 for ; Tue, 03 Sep 2024 06:03:27 -0700 (PDT) Received: from localhost ([213.195.124.163]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42bb6deb27fsm170548455e9.10.2024.09.03.06.03.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 06:03:25 -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: e8e5a12c-69f4-11ef-99a1-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725368606; x=1725973406; 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=GYHgwNobacqZEEFEfRPcZZVej2rQvaVSJz+xtblHyy0=; b=ZSIwY4jreM0sA11hcb3EEBDcR5EbUv0scM2J+KGmN9iTBkjVD8mXnFHMAD8e+D4PWT V8lYJfp1olhEvVDdUkElhmnxksfDwdp7mHK+nEfvmpVT90FwNHvyyTiYFNZgW29NPOHF MW5e5rY3lESowRT8YE3w2Z+1YNkTJO15QaYz8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725368606; x=1725973406; 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=GYHgwNobacqZEEFEfRPcZZVej2rQvaVSJz+xtblHyy0=; b=G2b9MNiRBtMSPVZdvfaWLHnvI9DH5zN+OicrzZ8Ke9cSB8kph1cJxT1XvLOcopclby jQIpNNOxBGPZ6DGVyhdfxjD4Bbqi/N4YlADStr/2t3GQ4VIHqvrfszmdoSIQ8iqD6u2Y LmIwZwplVTw8GOLUzO+cDQ6nyUrEW3lne1LxzrvzOqRduCCBmJLw54nsG1Eo9bbmKJx6 /A9V0DZ0R1T2ymB7mlfT+uwayVqp9cHrTfhO+491LBAIJufLNo6u7rMjUmFH+ROgLd4i fViSNgPSuhp0VKzvCCnUd0VKzTxKeZsUveRu12rttWdPHnrScp5NUonjnbIBPcz/DyrQ 5j1A== X-Gm-Message-State: AOJu0YxB2YRfXMkP3sCP3bO934BW25TEkkczN+bSZ9kLGD2OP0dGy700 QIO+lkAkpTwAYLVrPN7zxwSLhCtBmHLy3ZVRhaXZNbAmJMEYYo9ShJsFkaGJ+sRhZiB5PUS0AOh V X-Google-Smtp-Source: AGHT+IHEaPSP4/6SwxNG7VslKvx6IVaH+TNN7/+zQWQ3nl5upfg1dKtLEqkFPOcBzsURkDvR92GVLw== X-Received: by 2002:a05:600c:1389:b0:426:6326:4cec with SMTP id 5b1f17b1804b1-42bb01e6befmr120507635e9.29.1725368605780; Tue, 03 Sep 2024 06:03:25 -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 v3 4/7] x86/time: introduce probing logic for the wallclock Date: Tue, 3 Sep 2024 15:03:00 +0200 Message-ID: <20240903130303.71334-5-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240903130303.71334-1-roger.pau@citrix.com> References: <20240903130303.71334-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: 1725368629415116600 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 v2: - New in this version. --- xen/arch/x86/time.c | 116 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 92 insertions(+), 24 deletions(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 10840757b22c..8402131d7b6a 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1292,14 +1292,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; @@ -1329,28 +1338,13 @@ 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); + bool success =3D __get_cmos_time(&rtc); =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"); + ASSERT(success); =20 return mktime(rtc.year, rtc.mon, rtc.day, rtc.hour, rtc.min, rtc.sec); } @@ -1533,12 +1527,82 @@ 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 *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 /*************************************************************************= ** @@ -2463,6 +2527,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:33:17 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=1725368625; cv=none; d=zohomail.com; s=zohoarc; b=BHeh/fTb7+28+Eo5Fq3LNk0lsnpsPIfPUJodyspjtRyXj4QQNkNmfcY75WWGJXHJPWmzBof8ZqCITJKsDLpvai0QKMSZpgcIKArhXYhzKXB0T8HVxu2Aivi5uPDXHw7IT207c/lpsU6rSTNMbhQq4l1OGk0Gq9gvYzoDAHV3JPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725368625; 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=jceNvRc/CuXKw5rQwzG8yXCY7o696EqY1ix9gGzcyRM=; b=ApSpjOD7D042OOVhv2dp/bnktrXN16AfHhFThXr6wWr9mOwd+PLt5b4caYPI5YqVEQIxtaJnWcezbwXxGEBoIM7X9UBQjJU+jQ/uGxjw9cVGK8mEjEhc95a5S4FnSxOXtzgNwHzvkfSqJy14nbOnP2oZN2oGYuu0t1B28n5fUEY= 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 1725368625866406.8652063455314; Tue, 3 Sep 2024 06:03:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.789153.1198712 (Exim 4.92) (envelope-from ) id 1slTBy-0008FX-L1; Tue, 03 Sep 2024 13:03:30 +0000 Received: by outflank-mailman (output) from mailman id 789153.1198712; Tue, 03 Sep 2024 13:03:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1slTBy-0008Em-FH; Tue, 03 Sep 2024 13:03:30 +0000 Received: by outflank-mailman (input) for mailman id 789153; Tue, 03 Sep 2024 13:03:29 +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 1slTBx-00075o-E3 for xen-devel@lists.xenproject.org; Tue, 03 Sep 2024 13:03:29 +0000 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [2a00:1450:4864:20::231]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e9df047b-69f4-11ef-a0b2-8be0dac302b0; Tue, 03 Sep 2024 15:03:28 +0200 (CEST) Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2f51b67e16dso60990161fa.3 for ; Tue, 03 Sep 2024 06:03:28 -0700 (PDT) Received: from localhost ([213.195.124.163]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42c800554d6sm88155245e9.43.2024.09.03.06.03.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 06:03:26 -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: e9df047b-69f4-11ef-a0b2-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725368608; x=1725973408; 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=jceNvRc/CuXKw5rQwzG8yXCY7o696EqY1ix9gGzcyRM=; b=rZ34bLXN4P+MY9vB+yikXTrTZeXq7yVNVveljk+SN6qZAGyaCLLosOwqo3Ovfr0qUA HNYAXpLcXXh/Gj9DWwLUBpvgSd2FiHXaA6nZT6g1Xf/o6rOokw5I2LvZZI0T9Zb+v/tY W+fLMAm1Jj/uB7CXS3xxJUyr+1S/gnhEjCDmQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725368608; x=1725973408; 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=jceNvRc/CuXKw5rQwzG8yXCY7o696EqY1ix9gGzcyRM=; b=vavzfEu98yyV5HlRP/Ftf87gaz06mkvnrotDRFea43NVv3fH6889fdNWi2/1HMufDE HJ+/86k5QmEcEaX1UkbW6YJchbxdxl60iE0q4LE12eka+Eboh9F9GLj+cgKbzhGhTpHp l54FhJQy89QnO/FJUq33IxbyyCT9Qgvf7HNfkcahP79M2OH+is8QbOkhq/UB753xjqSk vGm5dkeJCI0HcLrJvSEvVchdBcI+8+N1cWvsdIIiNHysrZ90pstrZWoHwZp8bAe1Kj5O Z0Sc2vLIVOKozn+lv1Gx4ODwa6UznKzC6CqT0xe8mxE9VHlckZPM/3yx3myxFES5RDYV PuKQ== X-Gm-Message-State: AOJu0Yyo1DUdB1huHyV9TsAOx+/mDeukL/jwWoUuthkGhBaGdH9wTx+u 8KDj+96AlCAOq23Rn9wM8UP2Lv/Nf3h57jqo4t/sKHQzkfUOh8QCRRsAtz0X4b9k/7oEKL+fLoP u X-Google-Smtp-Source: AGHT+IEDWCPrJWORvsJ13y/C7todzJDIqiW3XEZeizyR6oZMsdTVnezZK68W3iNYQHJoc5ZlvRvoOQ== X-Received: by 2002:a2e:be84:0:b0:2f3:b078:84bc with SMTP id 38308e7fff4ca-2f64d472191mr6632101fa.4.1725368606925; Tue, 03 Sep 2024 06:03:26 -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 v3 5/7] x86/time: prefer CMOS over EFI_GET_TIME Date: Tue, 3 Sep 2024 15:03:01 +0200 Message-ID: <20240903130303.71334-6-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240903130303.71334-1-roger.pau@citrix.com> References: <20240903130303.71334-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: 1725368627339116600 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 8402131d7b6a..da3fd1555041 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1564,14 +1564,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 From nobody Wed Dec 4 08:33:17 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=1725368635; cv=none; d=zohomail.com; s=zohoarc; b=Ro+NA+acPiig5jtK0YK8HLFelfdq9qN4lo67N2rELxWkrO3O/P1pWzkQHbtWZi0+2oWQCl2Vomuz+zd3k5dYoIT+HM1t3hM4U0n9+1Ui0rxDUO1nqhY8Yqv3D5BvDaDVuKic8xgJfgusNYij3B6u+6LXYYDC6m40zjeea+YFRDI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725368635; 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=wlZbFmrpXgN45+AwQZrxSvY5k9Jof+k8TfRDS2/g8Jk=; b=mq8tqjHkGjawH5FbfwEjPMmVUx5uHevKgL8/9AY6Fj/0U+g/3XUXEEZX+APnikAdRGnlJYwfbCwJTRyDb04Va/F+ZXkbXm9q+ZafXzff8K6ByKsjLCFxp8V8aax5lzs8+xIn77qIEqmRY1zXaUJ/cLJFjy6uw+se07VRcDgLoFY= 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 1725368635811492.41797966926947; Tue, 3 Sep 2024 06:03:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.789154.1198726 (Exim 4.92) (envelope-from ) id 1slTC1-0000N1-Vc; Tue, 03 Sep 2024 13:03:33 +0000 Received: by outflank-mailman (output) from mailman id 789154.1198726; Tue, 03 Sep 2024 13:03:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1slTC1-0000Mj-S9; Tue, 03 Sep 2024 13:03:33 +0000 Received: by outflank-mailman (input) for mailman id 789154; Tue, 03 Sep 2024 13:03:32 +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 1slTC0-0006aM-6o for xen-devel@lists.xenproject.org; Tue, 03 Sep 2024 13:03:32 +0000 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [2a00:1450:4864:20::429]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id eac49aed-69f4-11ef-99a1-01e77a169b0f; Tue, 03 Sep 2024 15:03:30 +0200 (CEST) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-374c3400367so2022676f8f.2 for ; Tue, 03 Sep 2024 06:03:30 -0700 (PDT) Received: from localhost ([213.195.124.163]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42c88c624f7sm29018635e9.39.2024.09.03.06.03.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 06:03:28 -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: eac49aed-69f4-11ef-99a1-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725368609; x=1725973409; 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=wlZbFmrpXgN45+AwQZrxSvY5k9Jof+k8TfRDS2/g8Jk=; b=YZdDFskrdpci6NJY8E+zzQBhJxRogIg1egGtmtrHCSQk1mnSaHfq4GOp3kJuqA9VNT NoZESqRwZpX264TkXc6iSY0BsE9pktilj/BGr1hFed1I80U5bkXJma00eZ4n3HD5zl5z 9PFJTEFZgGoGuc3SL+7IvLL9W8zw36149RQW0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725368609; x=1725973409; 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=wlZbFmrpXgN45+AwQZrxSvY5k9Jof+k8TfRDS2/g8Jk=; b=ETBSf9BQDv5OREtJbkphWCpYfhH/Dm/8nyxryrq+5pw/SjyXzARTahOw9IpohlraL/ ylJdG0u/Q3t8uH4AIaZTaVlvFQqqFXlvuQD02gQtvnhNG6GfdFupi6dSMHaDqxrf/a6l T9waZsQMdP5wTxRUCFCJpluApngSaupHYL6sJ5qTlT+dEXHpbzFq05PFzBWD5cLN/bR/ F9hFiu9rGFE8OsWiydzu1MNjqdQsq1GkqtJ7g0iXuJJfdxuX7e+cNwqfTPnZfK443mBb OaVOHN2vuIBq3t6MDtt4pAQQ6VRrWhSj4TZutyY6BnlKPHFLx/vbMhT7+M+ohzaqPg38 oyaA== X-Gm-Message-State: AOJu0YyoflWBHNqC9Qc+QO/L4UJfXYP/OtJEIC4ZbR6TGI8Z9UAa6Lgq wQoyLykkO5P0b0HvcYIa61lNDBGf0Gp+lw9tg4BdmaYxGAO9QoBb7PTZdTKqRdxtC4My/Qf58C1 S X-Google-Smtp-Source: AGHT+IE8qegNxXDlJK1PFWwHLcnJqhDb4R6QI089xcWKPngT9LyUKz+TVPUn4HkmSxtmlDjANTWxQA== X-Received: by 2002:a5d:64e4:0:b0:374:c3e4:d6b1 with SMTP id ffacd0b85a97d-374c3e4d794mr8638205f8f.44.1725368609090; Tue, 03 Sep 2024 06:03:29 -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 v3 6/7] x86/time: introduce command line option to select wallclock Date: Tue, 3 Sep 2024 15:03:02 +0200 Message-ID: <20240903130303.71334-7-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240903130303.71334-1-roger.pau@citrix.com> References: <20240903130303.71334-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: 1725368637372116600 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 --- docs/misc/xen-command-line.pandoc | 18 +++++++++++++++++ xen/arch/x86/time.c | 33 ++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line= .pandoc index 0a66e1ee2d7e..23de922b9705 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -2821,6 +2821,24 @@ 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. + + * `cmos` force usage of the CMOS RTC wallclock. + + * `efi` force usage of the EFI_GFET_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 da3fd1555041..6e19c666d13f 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1555,6 +1555,36 @@ static const char *wallclock_type_to_string(void) 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); @@ -2527,7 +2557,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:33:17 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=1725368636; cv=none; d=zohomail.com; s=zohoarc; b=PtMAYE+bmW5PmNhb6PN5hRwxOfvUCDTtzZIPB4jC4Oov8cZLHuEni2bOP4kiB0SQYZs3TdJXBTFEA2xN45IfzsKPZn5sZ+ycrbdVQ6dgPU13IyCuQL9YNttfNswwqQ0Ng8fvN8VZMYwVhiiCxvXM11P1tZqn8RpRWc9OX1Ms9yY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725368636; 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=a1JudryMrIq+tOf/N0m9wlfd8xvBvSyUHDLaba1S/18=; b=NDMuHnyEfVcY9pkzXT/B8+/ftcUlnB844OyWaPxYgs+Xt8t6Fw4qGZTxNudx6DdYV05QX93CuFl7pAC3tkGFck5qEYLN4QD7fFxIpqUQ2VLYxXSoDSbDswEomrVBWnL9BQ275TMLJn8uvcXWm7DTWkFwb6Edyzt008koADDbVoY= 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 1725368636478957.3428490310308; Tue, 3 Sep 2024 06:03:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.789155.1198731 (Exim 4.92) (envelope-from ) id 1slTC2-0000QQ-BZ; Tue, 03 Sep 2024 13:03:34 +0000 Received: by outflank-mailman (output) from mailman id 789155.1198731; Tue, 03 Sep 2024 13:03:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1slTC2-0000PX-58; Tue, 03 Sep 2024 13:03:34 +0000 Received: by outflank-mailman (input) for mailman id 789155; Tue, 03 Sep 2024 13:03:32 +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 1slTC0-00075o-KU for xen-devel@lists.xenproject.org; Tue, 03 Sep 2024 13:03:32 +0000 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [2a00:1450:4864:20::330]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id eb9c1a24-69f4-11ef-a0b2-8be0dac302b0; Tue, 03 Sep 2024 15:03:31 +0200 (CEST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-42bbbff40bbso35490575e9.2 for ; Tue, 03 Sep 2024 06:03:31 -0700 (PDT) Received: from localhost ([213.195.124.163]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374c90c6c06sm6450395f8f.84.2024.09.03.06.03.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 06:03:29 -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: eb9c1a24-69f4-11ef-a0b2-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725368611; x=1725973411; 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=a1JudryMrIq+tOf/N0m9wlfd8xvBvSyUHDLaba1S/18=; b=jvjEpyQ3vLauobmFJuB+DQ6NSq92bjPMOvzNcHlfa0nt6lgiJ/q+42MXNRCXt5hZGX QOVGpT2YWxFByxs/ywomlblD3Tw0bG+Eyg48Dw3W8H0ti3EJepSSyrdaof41K3CwoqPG 8GQDQpAKrgHN60XV0LzNawfqjJ6yOPltQnw7A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725368611; x=1725973411; 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=a1JudryMrIq+tOf/N0m9wlfd8xvBvSyUHDLaba1S/18=; b=iJgQrD6nPSSguOuKvk/1AZgzO9U0D7k8DRdUg0D4ldXaMWISI+eBu8M7oDJTmEJMGi fHjmw1mGdB2gspHZG15STKjqexb45ctRod91kbhA2817GsGc1WUCg3sVzXR3yIUDgfkM VVuqpExKR8Zi/f9PsQlZA2M3PVmNhdISTXf0iwu+th5+7BY+nuCQmH/z1UTKHFKC7cud 5RPoJWgLnn4eVNf2yZuGINjE2RRwTByxkeBAaURVqOqTHt3++WMY4hHo0UvRXaMC7VWK 02iJnIIZK9ExQpScElXiGVrD7keoH0eflYARScWuXzJo/3sTDb1f8JhgbfwkhSgUV0C2 3H9w== X-Gm-Message-State: AOJu0YyXO8caKuFtAqTggE6hBR7h9rodSI/yodP3Az9BXZW0PGeXV9Zm KzxZgLXuHOLULYZfzlbX2xp0vKT6xlg+ixdHQ/o8ffQkuq5/Ueo7hJi6zxgSbARZGsX30IwebDn 5 X-Google-Smtp-Source: AGHT+IH7I2bKXiaNswiZ7b1msSyL3gc2WaSwaOBkVhc0qiu5vT6iJ4YIoeTIGXn8Gs38oih2orxHKg== X-Received: by 2002:a05:600c:997:b0:42b:ac3f:f5c with SMTP id 5b1f17b1804b1-42bbb436de5mr84973365e9.26.1725368610668; Tue, 03 Sep 2024 06:03:30 -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 v3 7/7] x86/time: probe the CMOS RTC by default Date: Tue, 3 Sep 2024 15:03:03 +0200 Message-ID: <20240903130303.71334-8-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240903130303.71334-1-roger.pau@citrix.com> References: <20240903130303.71334-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: 1725368637389116600 Probing for the CMOS RTC registers consist in reading IO ports, and we expe= ct those reads to have no side effects even when the CMOS RTC is not present. = Xen already does a similar probing (reading of IO ports) by default when search= ing for possible CMOS aliased locations. Switch the default to probe for the CMOS RTC by default when ACPI FADT cont= ains the ACPI_FADT_NO_CMOS_RTC flag. At the same time introduce a new option th= at can be used to turn off the probing: `wallclock=3Dno-cmos-probe`. Deprecat= e the previous `cmos-rtc-probe` option. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v2: - New in this version. --- docs/misc/xen-command-line.pandoc | 12 ++++++++++-- xen/arch/x86/time.c | 9 ++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line= .pandoc index 23de922b9705..0d603b9521ae 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -326,11 +326,14 @@ Interrupts. Specifying zero disables CMCI handling. ### cmos-rtc-probe (x86) > `=3D ` =20 -> Default: `false` +> Default: `true` =20 Flag to indicate whether to probe for a CMOS Real Time Clock irrespective = of ACPI indicating none to be there. =20 +**WARNING: The `cmos-rtc-probe` option is deprecated and superseded by +_wallclock=3Dno-cmos-probe_ using both options in combination is undefined= .** + ### com1 (x86) ### com2 (x86) > `=3D [/][,[DPS][,[|pci|amt][,[|msi][,[][,[]]]]]]` @@ -2822,7 +2825,7 @@ suboptimal scheduling decisions, but only when the sy= stem is oversubscribed (i.e., in total there are more vCPUs than pCPUs). =20 ### wallclock (x86) -> `=3D auto |=C2=A0xen | cmos | efi` +> `=3D auto |=C2=A0xen | cmos | no-cmos-probe |=C2=A0efi` =20 > Default: `auto` =20 @@ -2836,6 +2839,11 @@ Allow forcing the usage of a specific wallclock sour= ce. =20 * `cmos` force usage of the CMOS RTC wallclock. =20 + * `no-cmos-probe` do not probe for the CMOS RTC presence if the ACPI FADT + table signals there's no CMOS RTC. Implies using the same heuristics as + the `auto` option. By default Xen will probe for the CMOS RTC presence + even when ACPI FADT signals no CMOS RTC available. + * `efi` force usage of the EFI_GFET_TIME run-time method when booted from= EFI firmware. =20 diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 6e19c666d13f..8e6ecbe5e964 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1292,7 +1292,7 @@ static bool __get_cmos_time(struct rtc_time *rtc) return t1 <=3D SECONDS(1) && t2 < MILLISECS(3); } =20 -static bool __initdata cmos_rtc_probe; +static bool __initdata cmos_rtc_probe =3D true; boolean_param("cmos-rtc-probe", cmos_rtc_probe); =20 static bool __init cmos_probe(void) @@ -1560,6 +1560,8 @@ static int __init cf_check parse_wallclock(const char= *arg) if ( !arg ) return -EINVAL; =20 + cmos_rtc_probe =3D true; + if ( !strcmp("auto", arg) ) wallclock_source =3D WALLCLOCK_UNSET; else if ( !strcmp("xen", arg) ) @@ -1571,6 +1573,8 @@ static int __init cf_check parse_wallclock(const char= *arg) } else if ( !strcmp("cmos", arg) ) wallclock_source =3D WALLCLOCK_CMOS; + else if ( !strcmp("no-cmos-probe", arg) ) + cmos_rtc_probe =3D false; else if ( !strcmp("efi", arg) ) { if ( !efi_enabled(EFI_RS) ) @@ -1609,8 +1613,7 @@ static void __init probe_wallclock(void) !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" : "= "); + !efi_enabled(EFI_RS) ? "System must be booted from EFI\n" : ""); } =20 static unsigned long get_wallclock_time(void) --=20 2.46.0