From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF48E29A1; Tue, 17 Feb 2026 20:46:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771361200; cv=none; b=tzhzxzRi8l+cVXjPohQaxHBtWjnLfi+k0Sdo1qWbj55QRTCJuqk51e/oI1Bgn7BQ8A9L15qAfIRmkdWoQPVGiFBDVqX/8mU4dMkMsd1Wp3UiIOm2bjhutv79B8cm08ZWdQlzWBG5WgsRlnyygxCB+cR7DhHR6DgXvonT2n5CIpk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771361200; c=relaxed/simple; bh=qLZxZkYhDkewzZf94r9TSPoCCHtWegR0YB6A9CuWlJc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mofDA06yN6rNjLQD+z6sVz/9SOVMgkhPyODQEibp5y4Ouph8CV61TgT02seujOkUAcV8zJMgcxRlr870UAKJ1Kogikv+D/tc0XuX6nocHHiH2F+1Eu7uHLBwi88b1LhYSfFfePFNoEn3WIBJl/kmcxFzMvsdN4AGMFEn+XolCUo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=yTwD3RtF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="yTwD3RtF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA23BC4CEF7; Tue, 17 Feb 2026 20:46:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1771361200; bh=qLZxZkYhDkewzZf94r9TSPoCCHtWegR0YB6A9CuWlJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yTwD3RtFD5RuF/AhWKPZiNIglThhcu+iUJpBjtq1YIxkhRuSg27E6U+NbRKCUm2nt uSjGGMUOczAIImQEu9qigEqpqaoDVECuNREJFM8o9tIig8ebaW2SywEHrsOQJYXJpj 16DULRKeX2r8iU7hRVB9ga3C78W3SVdYUskt531Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bibo Mao , Jason Wang , "Michael S. Tsirkin" , Herbert Xu Subject: [PATCH 6.1 06/64] crypto: virtio - Add spinlock protection with virtqueue notification Date: Tue, 17 Feb 2026 21:31:02 +0100 Message-ID: <20260217200007.748370490@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260217200007.505931165@linuxfoundation.org> References: <20260217200007.505931165@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bibo Mao commit b505047ffc8057555900d2d3a005d033e6967382 upstream. When VM boots with one virtio-crypto PCI device and builtin backend, run openssl benchmark command with multiple processes, such as openssl speed -evp aes-128-cbc -engine afalg -seconds 10 -multi 32 openssl processes will hangup and there is error reported like this: virtio_crypto virtio0: dataq.0:id 3 is not a head! It seems that the data virtqueue need protection when it is handled for virtio done notification. If the spinlock protection is added in virtcrypto_done_task(), openssl benchmark with multiple processes works well. Fixes: fed93fb62e05 ("crypto: virtio - Handle dataq logic with tasklet") Cc: stable@vger.kernel.org Signed-off-by: Bibo Mao Acked-by: Jason Wang Acked-by: Michael S. Tsirkin Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/virtio/virtio_crypto_core.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/crypto/virtio/virtio_crypto_core.c +++ b/drivers/crypto/virtio/virtio_crypto_core.c @@ -77,15 +77,20 @@ static void virtcrypto_done_task(unsigne struct data_queue *data_vq = (struct data_queue *)data; struct virtqueue *vq = data_vq->vq; struct virtio_crypto_request *vc_req; + unsigned long flags; unsigned int len; + spin_lock_irqsave(&data_vq->lock, flags); do { virtqueue_disable_cb(vq); while ((vc_req = virtqueue_get_buf(vq, &len)) != NULL) { + spin_unlock_irqrestore(&data_vq->lock, flags); if (vc_req->alg_cb) vc_req->alg_cb(vc_req, len); + spin_lock_irqsave(&data_vq->lock, flags); } } while (!virtqueue_enable_cb(vq)); + spin_unlock_irqrestore(&data_vq->lock, flags); } static void virtcrypto_dataq_callback(struct virtqueue *vq)