Author: royger
Date: Tue Mar  7 09:17:48 2017
New Revision: 314841
URL: https://svnweb.freebsd.org/changeset/base/314841

Log:
  xenstore: fix suspension when using the xenstore device
  
  Lock the xenstore request mutex when suspending user-space processes, in order
  to prevent any process from holding this lock when going into suspension, or
  else the xenstore suspend process is going to deadlock.
  
  Submitted by:         Liuyingdong <[email protected]>
  Reviewed by:          royger
  MFC after:            2 weeks
  Differential revision:        https://reviews.freebsd.org/D9638

Modified:
  head/sys/dev/xen/control/control.c
  head/sys/dev/xen/xenstore/xenstore.c
  head/sys/xen/xenstore/xenstorevar.h

Modified: head/sys/dev/xen/control/control.c
==============================================================================
--- head/sys/dev/xen/control/control.c  Tue Mar  7 09:16:51 2017        
(r314840)
+++ head/sys/dev/xen/control/control.c  Tue Mar  7 09:17:48 2017        
(r314841)
@@ -199,7 +199,9 @@ xctrl_suspend()
 #endif
 
        EVENTHANDLER_INVOKE(power_suspend_early);
+       xs_lock();
        stop_all_proc();
+       xs_unlock();
        EVENTHANDLER_INVOKE(power_suspend);
 
 #ifdef EARLY_AP_STARTUP

Modified: head/sys/dev/xen/xenstore/xenstore.c
==============================================================================
--- head/sys/dev/xen/xenstore/xenstore.c        Tue Mar  7 09:16:51 2017        
(r314840)
+++ head/sys/dev/xen/xenstore/xenstore.c        Tue Mar  7 09:17:48 2017        
(r314841)
@@ -1699,3 +1699,20 @@ xs_unregister_watch(struct xs_watch *wat
                sx_xunlock(&xs.xenwatch_mutex);
        }
 }
+
+void
+xs_lock(void)
+{
+
+       sx_xlock(&xs.request_mutex);
+       return;
+}
+
+void
+xs_unlock(void)
+{
+
+       sx_xunlock(&xs.request_mutex);
+       return;
+}
+

Modified: head/sys/xen/xenstore/xenstorevar.h
==============================================================================
--- head/sys/xen/xenstore/xenstorevar.h Tue Mar  7 09:16:51 2017        
(r314840)
+++ head/sys/xen/xenstore/xenstorevar.h Tue Mar  7 09:17:48 2017        
(r314841)
@@ -338,4 +338,15 @@ void xs_unregister_watch(struct xs_watch
  */
 struct sbuf *xs_join(const char *, const char *);
 
+/**
+ * Lock the xenstore request mutex.
+ */
+void xs_lock(void);
+
+/**
+ * Unlock the xenstore request mutex.
+ */
+void xs_unlock(void);
+
 #endif /* _XEN_XENSTORE_XENSTOREVAR_H */
+
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to