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 1AE2E2C0F79; Tue, 17 Feb 2026 20:42:22 +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=1771360943; cv=none; b=JZf9xqpEGUiFfpLxAVa/U5mPb4Nm7n8DP4SK4dfW1l+CCrkWnwNa6El8hRzxj/V+pMJpvw588Fq+vF3bemQmkt+npcv0Vot6Lztr/iB+w0lC1OXIwUfBnuwt3QGnm79F6Q1aR03scZJGUKgSnljCZrFXP34evLwZjy4Ua5Pqh6c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771360943; c=relaxed/simple; bh=jsKk63vwje27+aaV/neTE7hlqnHRe2+v9st5ojzAjBI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ItZPFiD3rZbbPwx6ufUK2MAy45OqY4rxMR/j3NpgM7AkVgn0TpEu7nw2ip2UQCJV/ZRaX9MOmqxJgGSxruVVtxNEzUqhiMibyLZoovpZFGE0hBRNq3V6VhYQQ8uJA5LvSdT30QTQpZ5E46aaptBWQNWmN+rKP8BiiN6jpGQl2sU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=s7FmSkYB; 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="s7FmSkYB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48C0FC4CEF7; Tue, 17 Feb 2026 20:42:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1771360942; bh=jsKk63vwje27+aaV/neTE7hlqnHRe2+v9st5ojzAjBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s7FmSkYBFcjBjdAtNQsLXEWzk1rA16Mp9Z56FNe/QRktt9x48tfrCMbaseJj6bnI0 78BKvkoXLX42qe54bcdsN1uYEcyf7nsoc8zUzEHU3SvMbLuC7Xsysp4RwCRmSSkzOr 0fZcNUJE4y8ZZkJ8Bnbs63nO1LI9g+kNrPDSniPg= 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 5.10 03/24] crypto: virtio - Add spinlock protection with virtqueue notification Date: Tue, 17 Feb 2026 21:31:16 +0100 Message-ID: <20260217200000.842308027@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260217200000.708219618@linuxfoundation.org> References: <20260217200000.708219618@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 5.10-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)