From nobody Mon May 6 21:17:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1559136576; cv=none; d=zoho.com; s=zohoarc; b=XxYNE9V7VH4X9oOoXLfiAOQMS0Wi3ypyusTLg/ZuqwkpnCruT0A2913d5CZwKLmFDHZNMI+3gAJd1ocLvQr01HQ/n+JVbnwrj9bnRM+so/+JoF4aYAf4/vuZ0cIHoLDVCLVAwvFZggb6hGZjG/V1CcNkPwne6+mK7xxcxd96G+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559136576; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=6S+9LLdDh5ReF/kyZ4mh1Ymou+juI26d4it8Wfo6R4I=; b=mnLyvAdzC+2hJEbMCjp5wt+xGUkS8q+38dv+ygwpDf4gCJ4vYlD8+iqr36Zv/5rT2ODIRImwL4i+jE8aWaK2MXBY29knvLwTwLd850dpwrdfSEyATWjGWz6HTxtIZ5JcaSphu+SaZPITkpHVJvEo/xW640YWmaJziKkHGJfmTns= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1559136576690533.740326709941; Wed, 29 May 2019 06:29:36 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hVyct-0003Vn-3B; Wed, 29 May 2019 13:28:19 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hVycr-0003VY-Et for xen-devel@lists.xenproject.org; Wed, 29 May 2019 13:28:17 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 9bf26f52-8215-11e9-8231-5f2c921ddbfd; Wed, 29 May 2019 13:28:14 +0000 (UTC) X-Inumbo-ID: 9bf26f52-8215-11e9-8231-5f2c921ddbfd Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=paul.durrant@citrix.com; spf=Pass smtp.mailfrom=Paul.Durrant@citrix.com; spf=None smtp.helo=postmaster@MIAPEX02MSOL01.citrite.net Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of paul.durrant@citrix.com) identity=pra; client-ip=23.29.105.83; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="paul.durrant@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of Paul.Durrant@citrix.com designates 23.29.105.83 as permitted sender) identity=mailfrom; client-ip=23.29.105.83; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="Paul.Durrant@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:23.29.105.83 ip4:162.221.156.50 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@MIAPEX02MSOL01.citrite.net) identity=helo; client-ip=23.29.105.83; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="postmaster@MIAPEX02MSOL01.citrite.net"; x-conformance=sidf_compatible IronPort-SDR: m0gPzjEozlfonxNoS4B83qsD+86xkmc9HKnPgZnZmHf2ZwJiWLPM+UOt7ip06GhIuiQVJ8ScFS K1SdO87gyIx8CBtM27snfVkq2q57ppvqPzeh8wkncQffF02nCBkDPOnhp3SLn98U0JMcU22Bpo nGem2tiQMGjcxzNGQqaieORudYmmlMUMNsuCIGBrpXZpJmnY0WHQKPt56xv3kkDsLixp25Ytlw xzbjrBPf5yM4WXCwg6GBZ8HN7aOJEW7XsH4BUwr5pCss5ALDGxTss2tYQKg3Tsk9FrobKKwg2Q W0w= X-SBRS: 2.7 X-MesageID: 1042745 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 23.29.105.83 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.60,527,1549947600"; d="scan'208";a="1042745" From: Paul Durrant To: Date: Wed, 29 May 2019 14:28:08 +0100 Message-ID: <20190529132808.5419-1-paul.durrant@citrix.com> X-Mailer: git-send-email 2.20.1.2.gb21ebb671 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2] x86/hvm/hpet: avoid 'small' time diff test on resume X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Paul Durrant , Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" It appears that even 64-bit versions of Windows 10, when not using syth- etic timers, will use 32-bit HPET non-periodic timers. There is a test in hpet_set_timer(), specific to 32-bit timers, that tries to disambiguate between a comparator value that is in the past and one that is sufficiently far in the future that it wraps. This is done by assuming that the delta between the main counter and comparator will be 'small' [1], if the comparator value is in the past. Unfortunately, more often than not, this is not the case if the timer is being re-started after a migrate and so the timer is set to fire far in the future (in excess of a minute in several observed cases) rather then set to fire immediately. This has a rather odd symptom where the guest console is alive enough to be able to deal with mouse pointer re-rendering, but any keyboard activity or mouse clicks yield no response. This patch simply adds a boolean argument to hpet_set_timer() so that the 'small' time test is omitted when the function is called to restart timers on resume, and thus any negative delta causes a timer to fire immediately. [1] The number of ticks that equate to 0.9765625 milliseconds Signed-off-by: Paul Durrant --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monn=C3=A9" I notice that we seemingly don't handle main counter wrap in the HPET code. The spec. says that timers should fire at the point the counter wraps at the timer's width. I think the need for the 'small' time test would go away if this was implemented, but that's for another day. --- xen/arch/x86/hvm/hpet.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/hvm/hpet.c b/xen/arch/x86/hvm/hpet.c index a916758106..49257986b5 100644 --- a/xen/arch/x86/hvm/hpet.c +++ b/xen/arch/x86/hvm/hpet.c @@ -233,7 +233,7 @@ static void hpet_timer_fired(struct vcpu *v, void *data) #define HPET_TINY_TIME_SPAN ((h->stime_freq >> 10) / STIME_PER_HPET_TICK) =20 static void hpet_set_timer(HPETState *h, unsigned int tn, - uint64_t guest_time) + uint64_t guest_time, bool resume) { uint64_t tn_cmp, cur_tick, diff; unsigned int irq; @@ -273,10 +273,13 @@ static void hpet_set_timer(HPETState *h, unsigned int= tn, * Detect time values set in the past. This is hard to do for 32-bit * comparators as the timer does not have to be set that far in the fu= ture * for the counter difference to wrap a 32-bit signed integer. We fudge - * by looking for a 'small' time value in the past. + * by looking for a 'small' time value in the past. However, if we + * are resuming from suspend, 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) && (-diff > HPET_TINY_TIME_SPAN)) + diff =3D (timer_is_32bit(h, tn) && (-diff > HPET_TINY_TIME_SPAN) && + !resume) ? (uint32_t)diff : 0; =20 destroy_periodic_time(&h->pt[tn]); @@ -547,7 +550,7 @@ static int hpet_write( { i =3D find_first_set_bit(start_timers); __clear_bit(i, &start_timers); - hpet_set_timer(h, i, guest_time); + hpet_set_timer(h, i, guest_time, false); } =20 #undef set_stop_timer @@ -692,7 +695,7 @@ static int hpet_load(struct domain *d, hvm_domain_conte= xt_t *h) if ( hpet_enabled(hp) ) for ( i =3D 0; i < HPET_TIMER_NUM; i++ ) if ( timer_enabled(hp, i) ) - hpet_set_timer(hp, i, guest_time); + hpet_set_timer(hp, i, guest_time, true); =20 write_unlock(&hp->lock); =20 --=20 2.20.1.2.gb21ebb671 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel