[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] x86/vhpet: fix RTC special casing


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Tue, 4 May 2021 10:42:08 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gMShm7y/KTJWmReJD3OB0IPy3SLCiCtqqCgQhb7UTzU=; b=h8wCtZjxkVoXHaG3IPcUkEc87gFz4sEqSNpZxEhEHEVk94aMtwU6fSm+5IzoqCB5J4BjUSeYXnbqMsVmPJjcxME1ZlmRTOsYUFDuN3fuBGO9g8dGSac3TMc9BTHaHgdMWzb3Q///zYy3fZf4apPyD3dmOcP0Rff+kfa1KpWlRHZyAYWOCSidgFtoK4ySQca5km6ISwlBOAKU1nIJhQJJYLTmjrgRRV9gpFaOWCoKeOEP3Rmr7c7j5kSRDpDrK0vdT7aUWC/16Y3xk6d4VYmrGCmECqdzvsY+pw3uEgi6fyaZekQBhcHHTIqmMSiJ4GIbo/PIQG1bhtnIF0dDX3uV4A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fGQBlkrc4xCCl6vGAJx+HM2i0m3MFlfJAMbl6tPxM4241a1jLXP1sZIem1rL5ZM2nOTJCSbWCe+8wKeBaIUzBAaCHjL6HzdcWBubkghqT/pjhAR6xzgz6sN0+w/SgtSwZ8qkWVIZvUDiS4wnXUEqv/qqqQlohpqZYxJNyCWvgvlFAi2D+lixVVMlxRvftRmt91YoCHWAP+oMUfQ4PQAwnHr1KFidHdtmA99KAn73woN+FXfiianXqAURDKOMlYzYGzLa6CBdbSYT73l0iZAEIy+/J0o+oUQTVK1xgygzUofqbtW00EnP9jSsjx5Ym2RJQ6wUOB5C2DuhHRb33U5DCQ==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 04 May 2021 08:42:38 +0000
  • Ironport-hdrordr: A9a23:KoFOvaAc7mKNcazlHeh+sceALOonbusQ8zAX/mhsVB1YddGZnc iynPIdkST5kioVRWtIo729EYOLKEm9ybde544NMbC+GDT3oWfAFvAH0aLO4R3FXxf/+OlUyL t6f8FFYuHYIFBmga/BjzWQPM0nxLC8npyAocf74zNTQRpxa6dmhj0JbzqzNkFtXgFJCd4YOf Onl6l6jgGtc3gWcci3b0NtN4T+jubGiY78Zlo+DwMngTPksRqT9LX4HxKEty1uMQ9n/LFKyw n4uj283IqPmbWRyhjQ12jchq4m5efJ+594K+GnzuQQIjXooA60aIpmQK3qhkFInMifrGwEvf OJjxA8P9liy365RBDLnTLdnzPO/Rxry3j+xUSWiXHuyPaJOg4SOo56qq9yNj76gnBQ2+1U4e Zw8E+y86dzN1fmmh/w4tDZPisa7XackD4ZvsM4y0BEXZB2Us42kaUvuHl7Pb0nByzA5IUuAI BVfbvhzccTS1+cYnzD11MfueCEbzA2FheCdEAIptaY5ThQhGx41EsV3qUk7w89yK4=
  • Ironport-sdr: NEaZF8caH4SgaFgcySI0XH26IojI0ZZTPaG58CE2FqYoFMCPxUZU2kueyKMD91lv2+4EiBy9GE T2s3ApWKcLhIiq/h7y4E+ebifhLigb8EMOUyUTbcvRRrJEfk7r6rgQMWVNJ+KIQg/DpK4sAoCY B49CWJGbGz7cIBAEaue5kxnarxZwFICleWF2da72F8SqE8Z1UZ+0/0ahBSmne8swBykPKDm/Mm 9zldnro8qvpJKsfAmBYNMMGb75QF8Rdz1X9mtuysDasfausWlQ15uXU7IbwBk68T1sfZD/uej8 k/o=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Restore setting the virtual timer callback private data to NULL if the
timer is not level triggered. This fixes the special casing done in
pt_update_irq so that the RTC interrupt when originating from the HPET
is suspended if the interrupt source is masked.

Note the RTC special casing done in pt_update_irq should only apply to
the RTC interrupt originating from the emulated RTC device (which does
set the callback private data), as in that case the callback itself
will destroy the virtual timer if the interrupt is ignored.

While there also use RTC_IRQ instead of 8 when the HPET is configured
in LegacyReplacement Mode.

Fixes: be07023be115 ("x86/vhpet: add support for level triggered interrupts")
Reported-by: Jan Beulich <jbeulich@xxxxxxxx>
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 xen/arch/x86/hvm/hpet.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/hvm/hpet.c b/xen/arch/x86/hvm/hpet.c
index ca94e8b4538..ee756abb824 100644
--- a/xen/arch/x86/hvm/hpet.c
+++ b/xen/arch/x86/hvm/hpet.c
@@ -22,6 +22,7 @@
 #include <asm/hvm/trace.h>
 #include <asm/current.h>
 #include <asm/hpet.h>
+#include <asm/mc146818rtc.h>
 #include <xen/sched.h>
 #include <xen/event.h>
 #include <xen/trace.h>
@@ -290,7 +291,7 @@ static void hpet_set_timer(HPETState *h, unsigned int tn,
         /* if LegacyReplacementRoute bit is set, HPET specification requires
            timer0 be routed to IRQ0 in NON-APIC or IRQ2 in the I/O APIC,
            timer1 be routed to IRQ8 in NON-APIC or IRQ8 in the I/O APIC. */
-        irq = (tn == 0) ? 0 : 8;
+        irq = (tn == 0) ? 0 : RTC_IRQ;
         h->pt[tn].source = PTSRC_isa;
     }
     else
@@ -318,7 +319,8 @@ static void hpet_set_timer(HPETState *h, unsigned int tn,
                          hpet_tick_to_ns(h, diff),
                          oneshot ? 0 : hpet_tick_to_ns(h, h->hpet.period[tn]),
                          irq, timer_level(h, tn) ? hpet_timer_fired : NULL,
-                         (void *)(unsigned long)tn, timer_level(h, tn));
+                         timer_level(h, tn) ? (void *)(unsigned long)tn : NULL,
+                         timer_level(h, tn));
 }
 
 static inline uint64_t hpet_fixup_reg(
-- 
2.31.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.