]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
rcu: fix rcu_lock_domain()
authorJuergen Gross <jgross@suse.com>
Wed, 11 Mar 2020 12:18:49 +0000 (13:18 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 11 Mar 2020 12:18:49 +0000 (13:18 +0100)
rcu_lock_domain() misuses the domain structure as rcu lock, which is
working only as long as rcu_read_lock() isn't evaluating the lock.

Fix that by adding a rcu lock to struct domain and use that for
rcu_lock_domain().

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/common/domain.c
xen/include/xen/rcupdate.h
xen/include/xen/sched.h

index 6ad458fa6be13ad6127cda6e751429c0ffc4979e..b4eb476a9cc33dd80d19e9bf8a51c2839c7e5650 100644 (file)
@@ -398,6 +398,7 @@ struct domain *domain_create(domid_t domid,
         goto fail;
 
     atomic_set(&d->refcnt, 1);
+    RCU_READ_LOCK_INIT(&d->rcu_lock);
     spin_lock_init_prof(d, domain_lock);
     spin_lock_init_prof(d, page_alloc_lock);
     spin_lock_init(&d->hypercall_deadlock_mutex);
index 174d058113c14f4327e1ef39cd9c6745b55b6de6..eb9b60df07e2bd61600f0199248135c2a5071b67 100644 (file)
@@ -65,6 +65,7 @@ int rcu_needs_cpu(int cpu);
 struct _rcu_read_lock {};
 typedef struct _rcu_read_lock rcu_read_lock_t;
 #define DEFINE_RCU_READ_LOCK(x) rcu_read_lock_t x
+#define RCU_READ_LOCK_INIT(x)
 
 /**
  * rcu_read_lock - mark the beginning of an RCU read-side critical section.
index 739fa6854109b64aee1d0463f4b1351a880ef2b7..e6813288abbbc8feacc444b8c63d14bb99d317fe 100644 (file)
@@ -323,6 +323,8 @@ struct domain
 
     shared_info_t   *shared_info;     /* shared data area */
 
+    rcu_read_lock_t  rcu_lock;
+
     spinlock_t       domain_lock;
 
     spinlock_t       page_alloc_lock; /* protects all the following fields  */
@@ -609,13 +611,13 @@ int rcu_lock_live_remote_domain_by_id(domid_t dom, struct domain **d);
 static inline void rcu_unlock_domain(struct domain *d)
 {
     if ( d != current->domain )
-        rcu_read_unlock(d);
+        rcu_read_unlock(&d->rcu_lock);
 }
 
 static inline struct domain *rcu_lock_domain(struct domain *d)
 {
     if ( d != current->domain )
-        rcu_read_lock(d);
+        rcu_read_lock(&d->rcu_lock);
     return d;
 }