From nobody Wed Dec 4 19:17:50 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