From nobody Fri Oct 31 03:57:58 2025 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=none dis=none) header.from=yandex.ru ARC-Seal: i=1; a=rsa-sha256; t=1756274575; cv=none; d=zohomail.com; s=zohoarc; b=UeLJucXLbtCINaWFLn3y3OfwLAyzdg0h06PVWp06wTDJTgHUA8IaBAgpZ4GrBpfzzrEIqk1EIqxPo7gdz5sPhJ29XvqSZNkLQ3+qwFOmcCJi4dr6WHL6U7ova1RchtEHUAmGVTDbl6oMvd4GTsaAvOiPCeRI4FzdcU7IyYKx8FI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756274575; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0Rlob4aSxa0xqrzYkKAjTuRxH36ZPzw+XMsNDdBabeM=; b=na7HcQ6zhi73byiW5maHeftsJvOCiRHRDKeBZiU+SFNCKhw1Gouo/wnUB4e/mEiUFtuTAAv7TldxxUmflXQDTfa1IhnH/wilgtc4ggpJFND7hshggxr6+5Tr37Xg5dWgHvEL97iQRkO51pehj6tFk/VDpr2BQYvc1xNYlviTlk8= 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=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1756274575292791.7408830579648; Tue, 26 Aug 2025 23:02:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1095533.1450494 (Exim 4.92) (envelope-from ) id 1ur9F2-0007gr-9v; Wed, 27 Aug 2025 06:02:40 +0000 Received: by outflank-mailman (output) from mailman id 1095533.1450494; Wed, 27 Aug 2025 06:02:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ur9F2-0007gk-5u; Wed, 27 Aug 2025 06:02:40 +0000 Received: by outflank-mailman (input) for mailman id 1095533; Wed, 27 Aug 2025 06:02:39 +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 1ur9F0-0007ge-Nx for xen-devel@lists.xenproject.org; Wed, 27 Aug 2025 06:02:39 +0000 Received: from forward103b.mail.yandex.net (forward103b.mail.yandex.net [2a02:6b8:c02:900:1:45:d181:d103]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 6e5370e2-830b-11f0-a32c-13f23c93f187; Wed, 27 Aug 2025 08:02:37 +0200 (CEST) Received: from mail-nwsmtp-smtp-production-main-89.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-89.sas.yp-c.yandex.net [IPv6:2a02:6b8:c24:1aa8:0:640:56c3:0]) by forward103b.mail.yandex.net (Yandex) with ESMTPS id 65AE0C012A; Wed, 27 Aug 2025 09:02:35 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-89.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id 72SplHDMM8c0-t9dNJ3i3; Wed, 27 Aug 2025 09:02:34 +0300 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: 6e5370e2-830b-11f0-a32c-13f23c93f187 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1756274554; bh=0Rlob4aSxa0xqrzYkKAjTuRxH36ZPzw+XMsNDdBabeM=; h=Message-ID:Date:Cc:Subject:To:From; b=X9HOMNUMHOAb6XEZ4bEXzdZBhz2eGpk50dM6cvaXJQho9IsLMB4hfQ2kh7Hx2MXi8 ckMDIrvG8lSCmA422xVqRo3qp0U0bXWdCsRAtEwfJ3McdaloSBC88c8LWaCaHGv1uc BRp/L5B2T0gpgKGVcShRLtNWsI9G+doux1CuhiDg= Authentication-Results: mail-nwsmtp-smtp-production-main-89.sas.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Vyacheslav Legoshin To: xen-devel@lists.xenproject.org Cc: Vyacheslav Legoshin , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [XEN PATCH] x86/vhpet: Add option to always fire hpet timer on resume Date: Wed, 27 Aug 2025 09:01:08 +0300 Message-ID: X-Mailer: git-send-email 2.42.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @yandex.ru) X-ZM-MESSAGEID: 1756274578092124100 Content-Type: text/plain; charset="utf-8" The following issue was observed on Windows 10 21H2 x64+: when the domain s= tate is saved while all cores are executing the 'halt' instruction, and the memo= ry save takes a relatively long time (tens of seconds), the HPET counter may overflow as follows: counter =3D 11243f3e4a comparator =3D 910cb70f In such cases, the fix implemented in commit b144cf45d50b603c2909fc32c6abf7359f86f1aa does not work (because the 'diff' = is not negative), resulting in the guest VM becoming unresponsive for approximately 30 seconds. This patch adds an option to always adjust the HPET timer to fire immediate= ly after restore. --- docs/misc/xen-command-line.pandoc | 9 +++++++++ xen/arch/x86/hvm/hpet.c | 21 ++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line= .pandoc index a75b6c9301..b28610918f 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -1461,6 +1461,15 @@ HPET can be disabled by specifying `hpet=3D0`. =20 Deprecated alternative of `hpet=3Dbroadcast`. =20 +### hpet_drift_fix (x86) +> `=3D ` + +> Default: `false` + +Always set HPET timer to fire immediately after domain restore. +This option can be used to fix unresponsive snapshots with modern x64 Wind= ows +systems (21H2+) which use non-periodic timers. + ### hvm_debug (x86) > `=3D ` =20 diff --git a/xen/arch/x86/hvm/hpet.c b/xen/arch/x86/hvm/hpet.c index f0e5f877f4..5b9e38bd9b 100644 --- a/xen/arch/x86/hvm/hpet.c +++ b/xen/arch/x86/hvm/hpet.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -222,6 +223,9 @@ static void cf_check hpet_timer_fired(struct vcpu *v, v= oid *data) * 1/(2^10) second, namely, 0.9765625 milliseconds */ #define HPET_TINY_TIME_SPAN ((h->stime_freq >> 10) / STIME_PER_HPET_TICK) =20 +bool hpet_drift_fix; +boolean_param("hpet_drift_fix", hpet_drift_fix); + static void hpet_set_timer(HPETState *h, unsigned int tn, uint64_t guest_time) { @@ -268,11 +272,18 @@ static void hpet_set_timer(HPETState *h, unsigned int= tn, * are restoring after migrate, treat any wrap as past since the value * is unlikely to be 'small'. */ - if ( (int64_t)diff < 0 ) - diff =3D (timer_is_32bit(h, tn) && - vhpet_domain(h)->creation_finished && - (-diff > HPET_TINY_TIME_SPAN)) - ? (uint32_t)diff : 0; + if (hpet_drift_fix && !vhpet_domain(h)->creation_finished) + { + diff =3D 0; + } + else + { + if ( (int64_t)diff < 0 ) + diff =3D (timer_is_32bit(h, tn) && + vhpet_domain(h)->creation_finished && + (-diff > HPET_TINY_TIME_SPAN)) + ? (uint32_t)diff : 0; + } =20 destroy_periodic_time(&h->pt[tn]); if ( (tn <=3D 1) && (h->hpet.config & HPET_CFG_LEGACY) ) --=20 2.42.1