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

[xen stable-4.14] x86: restore pv_rtc_handler() invocation



commit d820391d2fba67566c52d5e0a047e70483265b6e
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Jul 15 15:48:43 2020 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Jul 15 15:48:43 2020 +0200

    x86: restore pv_rtc_handler() invocation
    
    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@xxxxxxxx>
    Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Release-acked-by: Paul Durrant <paul@xxxxxxx>
    master commit: f8fe3c07363d11fc81d8e7382dbcaa357c861569
    master date: 2020-07-15 15:46:30 +0200
---
 xen/arch/x86/hpet.c | 2 +-
 xen/arch/x86/time.c | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hpet.c b/xen/arch/x86/hpet.c
index c46e7cf4ee..154c67423b 100644
--- a/xen/arch/x86/hpet.c
+++ b/xen/arch/x86/hpet.c
@@ -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;
     }
 }
 
diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index cf97dde9d6..505e54ebd7 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -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));
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.14



 


Rackspace

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