From nobody Tue Feb 10 03:39:48 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1583303589; cv=none; d=zohomail.com; s=zohoarc; b=Ih3rMgwQLYILKatJfXH6/nIWEz4qlr8R5bAM0Ne8ve/8r1wQhb6qmKjO8f6rolFPasLby1VakSwa/mYZQ+XXSkZhyqR9jEnWkwbIP5En9NJuG/2FAh0Cm89EKK6Y/qIYHkQjmFgLPKIZuvrmDbnDCw1GgmlYgQksVhGD0tdgqag= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583303589; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+wjMI4oFpq3a9pTzRUqOvEH/AD4AWAQ1rSMuUUuW0tQ=; b=Wi04R+N4OqaxJKDngIogojBW2aE35haP817ps2D53Ix05CJ+mgg0UJkPEBJElt8ZPBJ9bOK3h5j3g6G9Z3WgwJUTfN/ngD1Fm/i+82hybOqAVWAk+mOssN+BCStOKqK3S9fgA2iNIhYrXcKrHscPOSWJGAYbT/e4pMDc/PEEc00= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 158330358932350.83011542889085; Tue, 3 Mar 2020 22:33:09 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j9NZv-0001tQ-QO; Wed, 04 Mar 2020 06:32:23 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j9NZu-0001t5-6Y for xen-devel@lists.xenproject.org; Wed, 04 Mar 2020 06:32:22 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e4190b30-5de1-11ea-b52f-bc764e2007e4; Wed, 04 Mar 2020 06:32:16 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A5064AFFC; Wed, 4 Mar 2020 06:32:15 +0000 (UTC) X-Inumbo-ID: e4190b30-5de1-11ea-b52f-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Wed, 4 Mar 2020 07:32:10 +0100 Message-Id: <20200304063212.20843-5-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200304063212.20843-1-jgross@suse.com> References: <20200304063212.20843-1-jgross@suse.com> Subject: [Xen-devel] [PATCH v3 4/6] xen/rcu: fix rcu_lock_domain() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Julien Grall , Wei Liu , Andrew Cooper , Ian Jackson , George Dunlap , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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 --- xen/common/domain.c | 1 + xen/include/xen/rcupdate.h | 1 + xen/include/xen/sched.h | 6 ++++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 6ad458fa6b..b4eb476a9c 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -398,6 +398,7 @@ struct domain *domain_create(domid_t domid, goto fail; =20 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); diff --git a/xen/include/xen/rcupdate.h b/xen/include/xen/rcupdate.h index 87f35b7704..31c8b86d13 100644 --- a/xen/include/xen/rcupdate.h +++ b/xen/include/xen/rcupdate.h @@ -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) =20 /** * rcu_read_lock - mark the beginning of an RCU read-side critical section. diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 3a4f43098c..647e4d31fb 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -348,6 +348,8 @@ struct domain =20 shared_info_t *shared_info; /* shared data area */ =20 + rcu_read_lock_t rcu_lock; + spinlock_t domain_lock; =20 spinlock_t page_alloc_lock; /* protects all the following fields= */ @@ -634,13 +636,13 @@ int rcu_lock_live_remote_domain_by_id(domid_t dom, st= ruct domain **d); static inline void rcu_unlock_domain(struct domain *d) { if ( d !=3D current->domain ) - rcu_read_unlock(d); + rcu_read_unlock(&d->rcu_lock); } =20 static inline struct domain *rcu_lock_domain(struct domain *d) { if ( d !=3D current->domain ) - rcu_read_lock(d); + rcu_read_lock(&d->rcu_lock); return d; } =20 --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel