From patchwork Mon Mar 28 12:17:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 108930 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B338EA0501; Mon, 28 Mar 2022 14:18:25 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A657D42871; Mon, 28 Mar 2022 14:18:25 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id DA1DF4286B for ; Mon, 28 Mar 2022 14:18:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648469904; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lkJkvPaJYAV9qFfSvXhPBD+zekg3wpjSt6cj2KPpQDI=; b=OmJJy/yvmbOnwY7A0AxfZyTJnDKwwclMNd98Hh8yAqRF95sLI4cITEqLzCJLcPfBpDj1oX /5QMsOL1arBXZwklAAWN8mKw5JLavOOeNzvKPsMnD58+G0GCNv6GJppGm4ZomMnjWoCKGv sF0PqV8ji77hQXHadXJYtyozPo8YARQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-193-yal6jOXjMwqTF8dqeVOR3g-1; Mon, 28 Mar 2022 08:18:21 -0400 X-MC-Unique: yal6jOXjMwqTF8dqeVOR3g-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A7DD1805F0E; Mon, 28 Mar 2022 12:18:20 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.195.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A74FC15D58; Mon, 28 Mar 2022 12:18:16 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, chenbo.xia@intel.com, stable@dpdk.org, Yuanhan Liu , Stefan Hajnoczi Subject: [RFC PATCH 1/5] vhost: fix missing virtqueue lock protection Date: Mon, 28 Mar 2022 14:17:54 +0200 Message-Id: <20220328121758.26632-2-david.marchand@redhat.com> In-Reply-To: <20220328121758.26632-1-david.marchand@redhat.com> References: <20220328121758.26632-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Maxime Coquelin This patch ensures virtqueue metadata are not being modified while rte_vhost_vring_call() is executed. Fixes: 6c299bb7322f ("vhost: introduce vring call API") Cc: stable@dpdk.org Signed-off-by: Maxime Coquelin Reviewed-by: David Marchand --- This is the same as: https://patchwork.dpdk.org/project/dpdk/patch/20220324124638.32672-2-maxime.coquelin@redhat.com/ --- lib/vhost/vhost.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index bc88148347..2f96a28dac 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -1291,11 +1291,15 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx) if (!vq) return -1; + rte_spinlock_lock(&vq->access_lock); + if (vq_is_packed(dev)) vhost_vring_call_packed(dev, vq); else vhost_vring_call_split(dev, vq); + rte_spinlock_unlock(&vq->access_lock); + return 0; }