From nobody Sun Nov 24 03:07: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=1725011586; cv=none; d=zohomail.com; s=zohoarc; b=GyRkdmGSnLHeq7MptGAM/qCyOA+0oVkiJl7jOdeLQovswW1Vnl3tNFPo6qFTwPsHrutQocDghBuCbsJFPukdEbnkhHb7D3XDIY3TOrDFDoDMzJZ6KdwxtHExDYOsAFuOQD/O/u71bzOR8L2RE4ITNygHXVgY7jnJ4RookNPA/5g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725011586; 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=Hgy6KsLd6IVjOwpOTywTcBhClUvG6CNwo7fjv2Ub9pE=; b=VOOKzCiLgbX81ztooL1/q3htNf2/dwya7I14V/84gXxvH8D9T6VbXj81+0f4UXPm26B+j9ZJqhF3LubHIdiiIoUaHsOs7k5LhDyveXAkNQre2xvdlh1Z90zB+i4rFngb7xiLDPKSGGJ7i4MjNLO9SXHOFjlouLtWRN3hXchobA8= 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 1725011586183730.5372555680754; Fri, 30 Aug 2024 02:53:06 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.786340.1195952 (Exim 4.92) (envelope-from ) id 1sjyJI-0002PS-39; Fri, 30 Aug 2024 09:52:52 +0000 Received: by outflank-mailman (output) from mailman id 786340.1195952; Fri, 30 Aug 2024 09:52:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sjyJH-0002PL-W4; Fri, 30 Aug 2024 09:52:51 +0000 Received: by outflank-mailman (input) for mailman id 786340; Fri, 30 Aug 2024 09:52:50 +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 1sjyJG-0001wc-KF for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 09:52:50 +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 9e038f21-66b5-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 11:52:49 +0200 (CEST) Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a86c476f679so197235666b.1 for ; Fri, 30 Aug 2024 02:52:50 -0700 (PDT) Received: from localhost ([213.195.124.163]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a89891db563sm194655566b.185.2024.08.30.02.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 02:52:47 -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: 9e038f21-66b5-11ef-a0b1-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725011569; x=1725616369; 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=Hgy6KsLd6IVjOwpOTywTcBhClUvG6CNwo7fjv2Ub9pE=; b=CISCvTTikoh72V5M1EcMolC5AWIP9DqPjY8cnPV/2gGIe7/bKXPEVTbyZBW90i8/m6 QYOkJ6YVvVPOAi5AaQ4oHN8P1pdk6uUarvnBVkq5a9gSa3fT65Ee/pSf13/KnxXERR/O 8Lrq20/E5CaCVJaFxOB2xJpHh/QWxky2UcqcU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725011569; x=1725616369; 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=Hgy6KsLd6IVjOwpOTywTcBhClUvG6CNwo7fjv2Ub9pE=; b=eR3L7Di/v3wJA/CVrJFZf/IWkzordalNSbbUHaQWKxeVbSt+LddALuutT8TlxfqCIT 88Ap0SmitoYXc0ucjUyaer59PpdLb27OKJfxZzk/3+QUdx79nQ27E5GA7NKpiHQS0azu l9iUayvy9sKCgbrvT6INF3lUZcJQDiPcJmpfwfdeemAiWNcHa5YBL/d3T3x5WFRgZNI9 2xsev6Gv0W/scFyxnqHtlRqmOc74bLIKb6RV9lrv6gc7unqmlIahAkgJUZQmI+R1yrVs qN0A0EeQRKMRHWleEYdp5R+RkPwwJv33O2jOInPpcaTA9LRgXvC+e01avA86FQTyawzl x4Vg== X-Gm-Message-State: AOJu0YzXHE2MMV6Eei6U6NCpaCDVrJmu5NV9oakvPdvUNkjKot/eeQI5 A9oLJxPIkeDTrVARrWbIZG/eBKnduOQYCM8GRpwh/bbq0mlFSfmibjfJwgSAoJdwaTWeB7cklE7 r X-Google-Smtp-Source: AGHT+IFxGczVF6OVtd6iF412SmeyKSsOp7M6/YaF4GjHiZ2HTlFEHYZsy4UU3cUI+jq5qcQVC4tb1w== X-Received: by 2002:a17:907:94cb:b0:a86:8d83:542d with SMTP id a640c23a62f3a-a897fa751f3mr483777566b.45.1725011568064; Fri, 30 Aug 2024 02:52:48 -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 v2 2/2] x86/time: prefer CMOS over EFI_GET_TIME Date: Fri, 30 Aug 2024 11:52:20 +0200 Message-ID: <20240830095220.49473-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240830095220.49473-1-roger.pau@citrix.com> References: <20240830095220.49473-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: 1725011587431116600 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 --- xen/arch/x86/time.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 272ca2468ea6..0eee954809a9 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1305,24 +1305,36 @@ static unsigned long get_cmos_time(void) static bool __read_mostly cmos_rtc_probe; boolean_param("cmos-rtc-probe", cmos_rtc_probe); =20 + if ( likely(!(acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC)) ) + cmos_rtc_probe =3D false; + + if ( (!(acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) || + cmos_rtc_probe) && read_cmos_time(&rtc, cmos_rtc_probe) ) + return mktime(rtc.year, rtc.mon, rtc.day, rtc.hour, rtc.min, rtc.s= ec); + if ( efi_enabled(EFI_RS) ) { unsigned long res =3D efi_get_time(); =20 if ( res ) return res; + + panic("Broken EFI_GET_TIME %s\n", + !cmos_rtc_probe ? "try booting with \"cmos-rtc-probe\" optio= n" + : "and no CMOS RTC found"); } =20 - 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 ) + /* + * No viable clock source found. Attempt to provide some guidance to = the + * user about possible workarounds to boot Xen on the system. + */ + ASSERT(system_state < SYS_STATE_smp_boot); + + if ( !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 - if ( unlikely(!read_cmos_time(&rtc, cmos_rtc_probe)) ) - panic("No CMOS RTC found - system must be booted from EFI\n"); - - return mktime(rtc.year, rtc.mon, rtc.day, rtc.hour, rtc.min, rtc.sec); + panic("No CMOS RTC found - system must be booted from EFI\n"); } =20 static unsigned int __ro_after_init cmos_alias_mask; --=20 2.46.0