From nobody Mon Feb 9 16:20:16 2026 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 header.i=@amazon.com; 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=quarantine dis=none) header.from=amazon.com ARC-Seal: i=1; a=rsa-sha256; t=1598049063; cv=none; d=zohomail.com; s=zohoarc; b=NbyWuQHWPmcdHpo5YNGa0PUUSPBJk8Y6yCIntC/kzFxp5lsTEYLKf+BdEYM3PtrbyjxR8FcRWIvmIIDyhSJ5z6kAP2VWat2TWkB8oZHspFN2syMRWpYfcIyGcvzy8ZLMFPAY+gtBH+Sp8UivsMHyVD13GZOIzJBPrlFKrU7J3lc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598049063; h=Content-Type:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fYlNM/Ki+IOGvkGZqz//RrR1UMvb0Rd2rCL0FP2g5T0=; b=Fs4B+aTSiLa5M7qExYnKlSBuD2iuVtD6ulAqyNRaF85HR+tRsprFxSi2W8owVbs2R/Da4exNInPZZ7h6bXedYQuMQpcsGyTvXR25/wx/LVgPN+0r6CKOL3pkilSzBdqkQGSUbdzCjqLuqFRR35XbKCTBMkVQlE6EBLsEex7kLAY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.com; 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=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1598049063790601.2527595399279; Fri, 21 Aug 2020 15:31:03 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k9FYg-0005ek-Q2; Fri, 21 Aug 2020 22:30:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k9FYf-0005eR-Jt for xen-devel@lists.xenproject.org; Fri, 21 Aug 2020 22:30:49 +0000 Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 9dfdf4ac-0b3a-4138-9ea8-e5897a1496e8; Fri, 21 Aug 2020 22:30:49 +0000 (UTC) Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1a-821c648d.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 21 Aug 2020 22:30:46 +0000 Received: from EX13MTAUWC001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-821c648d.us-east-1.amazon.com (Postfix) with ESMTPS id C2DE2A1FA1; Fri, 21 Aug 2020 22:30:39 +0000 (UTC) Received: from EX13D05UWC002.ant.amazon.com (10.43.162.92) by EX13MTAUWC001.ant.amazon.com (10.43.162.135) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 21 Aug 2020 22:30:11 +0000 Received: from EX13MTAUWC001.ant.amazon.com (10.43.162.135) by EX13D05UWC002.ant.amazon.com (10.43.162.92) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 21 Aug 2020 22:30:11 +0000 Received: from dev-dsk-anchalag-2a-9c2d1d96.us-west-2.amazon.com (172.22.96.68) by mail-relay.amazon.com (10.43.162.232) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 21 Aug 2020 22:30:11 +0000 Received: by dev-dsk-anchalag-2a-9c2d1d96.us-west-2.amazon.com (Postfix, from userid 4335130) id 59A8A40362; Fri, 21 Aug 2020 22:30:11 +0000 (UTC) X-Inumbo-ID: 9dfdf4ac-0b3a-4138-9ea8-e5897a1496e8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1598049049; x=1629585049; h=date:from:to:subject:message-id:references:mime-version: in-reply-to; bh=fYlNM/Ki+IOGvkGZqz//RrR1UMvb0Rd2rCL0FP2g5T0=; b=pn/9JOBeWYnevmFKb35F9JN1FDS14Fldm6UpDiEdFFOGxsEkSVMjnhhK ZE2lqZPwMMsadGJo2IqOC+YbCvcABrrr19HqGSUrl9oFTPHM6Lf5sQjTT sHbLUSbRXzMH81LocOyw+aPK/FbUuL9hK+Qdqq9nE31G0T5emgmffQl6E 0=; X-IronPort-AV: E=Sophos;i="5.76,338,1592870400"; d="scan'208";a="69983166" Date: Fri, 21 Aug 2020 22:30:11 +0000 From: Anchal Agarwal To: , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 09/11] xen: Introduce wrapper for save/restore sched clock offset Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: Bulk X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: pass (identity @amazon.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce wrappers for save/restore xen_sched_clock_offset to be used by PM hibernation code to avoid system instability during resume. Signed-off-by: Anchal Agarwal --- arch/x86/xen/time.c | 15 +++++++++++++-- arch/x86/xen/xen-ops.h | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c index 91f5b330dcc6..e45349178ffc 100644 --- a/arch/x86/xen/time.c +++ b/arch/x86/xen/time.c @@ -387,12 +387,23 @@ static const struct pv_time_ops xen_time_ops __initco= nst =3D { static struct pvclock_vsyscall_time_info *xen_clock __read_mostly; static u64 xen_clock_value_saved; =20 +/*This is needed to maintain a monotonic clock value during PM hibernation= */ +void xen_save_sched_clock_offset(void) +{ + xen_clock_value_saved =3D xen_clocksource_read() - xen_sched_clock_offset; +} + +void xen_restore_sched_clock_offset(void) +{ + xen_sched_clock_offset =3D xen_clocksource_read() - xen_clock_value_saved; +} + void xen_save_time_memory_area(void) { struct vcpu_register_time_memory_area t; int ret; =20 - xen_clock_value_saved =3D xen_clocksource_read() - xen_sched_clock_offset; + xen_save_sched_clock_offset(); =20 if (!xen_clock) return; @@ -435,7 +446,7 @@ void xen_restore_time_memory_area(void) out: /* Need pvclock_resume() before using xen_clocksource_read(). */ pvclock_resume(); - xen_sched_clock_offset =3D xen_clocksource_read() - xen_clock_value_saved; + xen_restore_sched_clock_offset(); } =20 static void xen_setup_vsyscall_time_info(void) diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h index 9f0a4345220e..9a79e210119c 100644 --- a/arch/x86/xen/xen-ops.h +++ b/arch/x86/xen/xen-ops.h @@ -69,6 +69,8 @@ void xen_save_time_memory_area(void); void xen_restore_time_memory_area(void); void xen_init_time_ops(void); void xen_hvm_init_time_ops(void); +void xen_save_sched_clock_offset(void); +void xen_restore_sched_clock_offset(void); =20 irqreturn_t xen_debug_interrupt(int irq, void *dev_id); =20 --=20 2.16.6