Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1410289pxb; Thu, 28 Oct 2021 03:12:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8weBcNQqJzTNB2EWWJiciO0yygcqW4jU1C2tAFKioAKDYAfKk60agR/IVgLDkJmBYPAQ7 X-Received: by 2002:a17:907:16a1:: with SMTP id hc33mr4097998ejc.137.1635415958795; Thu, 28 Oct 2021 03:12:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635415958; cv=none; d=google.com; s=arc-20160816; b=GXZpROZ7NUDFseOd3n5NQYSG0dfYhZq2sV9WfzWONDLIVXfHblSZGaQN7hoxAfxrwE 69+sunvdsS9aWPENdEShBhGrETnGNAD4RQ7abqCHPL4+kVLWlQICDirO4vacD8lr/oIf MfawdWqDpvLaA+JX//6EzKIcren3RGuPzrgzSpyLF4BBUjUfkVFxPB9N55t+eakQwScJ jtwJ/m+JxMGOzrkFt4Zok7Oees4n89z2sbY1GUDsdhIhJylqjuMOFP+EH7RLKD27xHPT +8xGMxNmGepOTDKD/E2bpDB6KaUlvloB000IoSI/gexfauXhIvgV/0ECjnBDo78Ncuys y7Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Lf5038czWxD5TVdb3xzJS31yq5LDU7rgKUOZR2ujX9Y=; b=TGko1oB/26n5ny9EL4CrW5Bq/WMe/Rb/gujOE5p5QKe+VyAUPy/itoFj18bWD/xtMO 3s80tHP0uieXZ0onU6envxgYb0tdIGZcI03TtWawOJ0HJ2E8wAUAE3guX5uLLfBL0PUM kHpBcAcRmcREpWR9nrHBi27rxIs5CXXxNq89o1UqZlHKlXX/eLhdpMOvc6p0zhJYuZWS erYynFDINb6vx3bTgQz6qyGmmC5U3G4mdoROi0buxjuNu4KcQ9La3slqn7pfMBLuhB3t mwIh5LNaoDSmNwGwG8NsUTvAOlVTnMRWkKRD4fr/QyC6XSiuNp5IVCZrhhO8bbit4tlm qF/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="ScE/ShA+"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n11si4485453edx.410.2021.10.28.03.12.04; Thu, 28 Oct 2021 03:12:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="ScE/ShA+"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230077AbhJ1KOI (ORCPT + 99 others); Thu, 28 Oct 2021 06:14:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58333 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbhJ1KOG (ORCPT ); Thu, 28 Oct 2021 06:14:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635415899; 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; bh=Lf5038czWxD5TVdb3xzJS31yq5LDU7rgKUOZR2ujX9Y=; b=ScE/ShA+qF1HzfNI3oqvvxiZAD2q7zPDEWBC2fxPTXNh2wm5L+N7W5jpSbWPEiNJgVs0OZ LzFXLaeybsu8q6REGAJHqfTZKFKQEsuYLl49o6+M9S5JyhR3qjYG9Wu3I+94MKhScl+j7u O4eMwQ3F2qc/j1pssZ6QN1HPbPJuqGI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-507-CeVCjHmJNmOCLy6xJIUSjw-1; Thu, 28 Oct 2021 06:11:33 -0400 X-MC-Unique: CeVCjHmJNmOCLy6xJIUSjw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 67BAD10A8E02; Thu, 28 Oct 2021 10:11:31 +0000 (UTC) Received: from thinkpad.redhat.com (unknown [10.39.194.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id E635D60C04; Thu, 28 Oct 2021 10:11:12 +0000 (UTC) From: Laurent Vivier To: linux-kernel@vger.kernel.org Cc: amit@kernel.org, Herbert Xu , Matt Mackall , virtualization@lists.linux-foundation.org, Dmitriy Vyukov , rusty@rustcorp.com.au, akong@redhat.com, Alexander Potapenko , "Michael S . Tsirkin" , linux-crypto@vger.kernel.org, Laurent Vivier Subject: [PATCH v2 0/4] hwrng: virtio - add an internal buffer Date: Thu, 28 Oct 2021 12:11:07 +0200 Message-Id: <20211028101111.128049-1-lvivier@redhat.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org hwrng core uses two buffers that can be mixed in the virtio-rng queue.=0D =0D This series fixes the problem by adding an internal buffer in virtio-rng.=0D =0D Once the internal buffer is added, we can fix two other problems:=0D =0D - to be able to release the driver without waiting the device releases the= =0D buffer=0D =0D - actually returns some data when wait=3D0 as we can have some already=0D available data=0D =0D It also tries to improve the performance by always having a buffer in=0D the queue of the device.=0D =0D v2:=0D fixes issue reported by syzbot+b86736b5935e0d25b446@syzkaller.appspotmail.c= om=0D by reseting data_idx to 0 when the buffer is submitted not when it is=0D received as the consumer checks for data_avail, not only for the completion= .=0D =0D Laurent Vivier (4):=0D hwrng: virtio - add an internal buffer=0D hwrng: virtio - don't wait on cleanup=0D hwrng: virtio - don't waste entropy=0D hwrng: virtio - always add a pending request=0D =0D drivers/char/hw_random/virtio-rng.c | 86 ++++++++++++++++++++++-------=0D 1 file changed, 65 insertions(+), 21 deletions(-)=0D =0D -- =0D 2.31.1=0D =0D