]> xenbits.xensource.com Git - people/jgross/xen.git/commitdiff
x86: restore pv_rtc_handler() invocation
authorJan Beulich <jbeulich@suse.com>
Wed, 15 Jul 2020 13:46:30 +0000 (15:46 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 15 Jul 2020 13:46:30 +0000 (15:46 +0200)
This was lost when making the logic accessible to PVH Dom0.

While doing so make the access to the global function pointer safe
against races (as noticed by Roger): The only current user wants to be
invoked just once (but can tolerate to be invoked multiple times),
zapping the pointer at that point.

Fixes: 835d8d69d96a ("x86/rtc: provide mediated access to RTC for PVH dom0")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Release-acked-by: Paul Durrant <paul@xen.org>
xen/arch/x86/hpet.c
xen/arch/x86/time.c

index c46e7cf4ee3e5acb2d7172f02fd5a486bcbb3260..154c67423b4c3a67579f44ebfac40e7b60f51dd5 100644 (file)
@@ -543,7 +543,7 @@ static void handle_rtc_once(uint8_t index, uint8_t value)
     if ( value & (RTC_PIE | RTC_AIE | RTC_UIE ) )
     {
         cpuidle_disable_deep_cstate();
-        pv_rtc_handler = NULL;
+        ACCESS_ONCE(pv_rtc_handler) = NULL;
     }
 }
 
index cf97dde9d6894a21d8011a518ba69d6c8e3ff6b3..505e54ebd7c34c67309d11e7273a66647743b01c 100644 (file)
@@ -1148,6 +1148,8 @@ void rtc_guest_write(unsigned int port, unsigned int data)
 
     switch ( port )
     {
+        typeof(pv_rtc_handler) hook;
+
     case RTC_PORT(0):
         /*
          * All PV domains (and PVH dom0) are allowed to write to the latched
@@ -1160,6 +1162,11 @@ void rtc_guest_write(unsigned int port, unsigned int data)
     case RTC_PORT(1):
         if ( !ioports_access_permitted(currd, RTC_PORT(0), RTC_PORT(1)) )
             break;
+
+        hook = ACCESS_ONCE(pv_rtc_handler);
+        if ( hook )
+            hook(currd->arch.cmos_idx & 0x7f, data);
+
         spin_lock_irqsave(&rtc_lock, flags);
         outb(currd->arch.cmos_idx & 0x7f, RTC_PORT(0));
         outb(data, RTC_PORT(1));