From nobody Tue May 7 21:37:21 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=1559135483; cv=none; d=zoho.com; s=zohoarc; b=fnMOlhCajZGAAd4uT5ZwhBdn3/TUoH/2sOrSIpwVpN6rHPnWVR47OEwxCsFHH446Zv2XCuUmnFPpYLHwQT7Vuc92NXCQ3rJjzndiuJBaEkQ4S7MgEuYDrMXxv22WOLjb9jmQf2aHy1SLvFgcoE2NXE263GgrRPcvAZXD/Xic6aM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559135483; 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=iEmUxWNGbght06GbWYboOiNZZQVL0MdKI+Qt8DPzl2Y=; b=jBwFUUemQCAwMKmIqwh/J+tkNm91K0cLtK2B5ZWkzAlecUf5QPR4KTq4LIYAqYA5N8dFan64A7sn6Bv2uQyOD0MapsDA+peJZKJBSu78GkRabNcVCbqGZQekO7vvKH6+dgbsPDu+J2xuFSjW6mW21itE0pFD6K0KWNMwyP8OUrc= 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 1559135483465481.06476974386385; Wed, 29 May 2019 06:11:23 -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 1hVyL6-0001qc-2T; Wed, 29 May 2019 13:09:56 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hVyL4-0001qX-KM for xen-devel@lists.xenproject.org; Wed, 29 May 2019 13:09:54 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 0bb0e6b6-8213-11e9-8980-bc764e045a96; Wed, 29 May 2019 13:09:52 +0000 (UTC) X-Inumbo-ID: 0bb0e6b6-8213-11e9-8980-bc764e045a96 Authentication-Results: esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="paul.durrant@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.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=esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="postmaster@MIAPEX02MSOL01.citrite.net"; x-conformance=sidf_compatible IronPort-SDR: FFRV6PyCtDzDrOWqzUY/djVtu5VpZeoTbHahbfS7TGUuXs9Hf2vmOXlGEmokhq76t94PtjmZL8 Dbm5RpHr/7kyu7YXafgmzwqqe2P8z2PuM/4NE5C5IWEE7tsbDteU0IKRTXcsFZZAoEpFxj/2ZA UPwmybdqVDEh+QNnzHpOSgv2jo0TeI7P4wrqR9hecbSjDn0wA1OGg6PWabHgM6dgYkizJXorc9 N3eXRY2bJuRII5x71ymkqy3BNrb33CO6cayoG0dzfQXmVoqFEGXMNjUroZaTodbdY5eBNA02Fa Pxo= X-SBRS: 2.7 X-MesageID: 1040998 X-Ironport-Server: esa2.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="1040998" From: Paul Durrant To: Date: Wed, 29 May 2019 14:09:48 +0100 Message-ID: <20190529130948.5314-1-paul.durrant@citrix.com> X-Mailer: git-send-email 2.20.1.2.gb21ebb671 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] 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. 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