Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3814778ybb; Tue, 31 Mar 2020 12:31:19 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsB1c1rUbswIJ6VuhmJseywzjV4qGwZx6FfLY3FWOmIFRslg+AGJkiBngH8NZWaOWrhGG4D X-Received: by 2002:a4a:4505:: with SMTP id y5mr14431196ooa.29.1585683079492; Tue, 31 Mar 2020 12:31:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585683079; cv=none; d=google.com; s=arc-20160816; b=rdNhyRJPGf7iJT05ovKA3L72TsLVUToKDPxRa4vI++K4HYQzFck+qZqsgg8mO9y6mE 6Pn0uw+xu1sc/QF27SmvCNm/KTnVhqflbRkIh5glDJV9mVtkN3LEKBa3yBmf8plLU6OP S3vrPetS9pubXy5ziD0ytY1YSNG3++Z0zLGRoajIEJFvy/xg427iKOe7BCVNZEfAWaWl POdHpUBeepjTxtp1N0mg4IRh3ZaqRAWhmPLegcdS1Ip6nDec3f8yuDEiW6AFTujQT2Rl ownuo3DERC6/Fg8dkeEznTTSXfOpaAs3wjIuTIcrH3iqWwLZ1dt+uDaB1DIZCQnLrkOf VJdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=bZBZ2PvIvDxfPAe1u1A6kkjjW8ODyemq7LucCatSJOc=; b=TSMJsGRWIz5bwbJJRAQv/6v5dLBoAhxEDOuXMqSOmltc5d9B27L1np6Hx0z0+kA27o PCTxnY+bm8QTdDsvz8LIRYiLMXdmrSc4KJ/SxrgLCeRpE/xnx1RmwkMBnspJxW8UdgKu XHKefL92GLMrz1Iadg4VJwNBWDzSRter+FdJ9y1tHtRGfBfEnE0qFOXIeF+QpeUoF3OI O9HtUfVnQd/CABRSrcEtZ9kWgyUA5lvFIru62tV96LtL+o6L8wf6F1nikuW0mVLL//sR y6TZFcTouJpiRN1Pg6edn5MXbZKvGHqdtXsVpUFyRoCkT3V1A/Wnx1IKMyea0sLdEZZu FE0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="RwsMC/4n"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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. [209.132.180.67]) by mx.google.com with ESMTP id x14si7846238ooc.26.2020.03.31.12.31.06; Tue, 31 Mar 2020 12:31:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="RwsMC/4n"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1727509AbgCaT2T (ORCPT + 99 others); Tue, 31 Mar 2020 15:28:19 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:30885 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726290AbgCaT2T (ORCPT ); Tue, 31 Mar 2020 15:28:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585682897; 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=bZBZ2PvIvDxfPAe1u1A6kkjjW8ODyemq7LucCatSJOc=; b=RwsMC/4nz845t6j+oEJjQvD8Tbt93sCqs3XKPYFJ+Y62mfgDEIJsmjDP47cLrJ+DG4eNCB p4dmatsEDBASFs9UvaDEE/QUc5TJ87P0AuAq2YfrtVd8lRxPro1IYlmkjAhtb8ExAw34IU M85spl5PTHYbrossDyeeTv9LxDeoe4Q= 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-25-PaRuMewrOIaDewXx01564w-1; Tue, 31 Mar 2020 15:28:14 -0400 X-MC-Unique: PaRuMewrOIaDewXx01564w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F07C418A6EC1; Tue, 31 Mar 2020 19:28:12 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-92.ams2.redhat.com [10.36.112.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BE2898A57; Tue, 31 Mar 2020 19:28:07 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: "linux-kernel@vger.kernel.org" , Stephen Rothwell , kvm list , Linux Next Mailing List , "virtualization@lists.linux-foundation.org" , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Christian Borntraeger , Halil Pasic , Cornelia Huck Subject: [PATCH v3 0/8] vhost: Reset batched descriptors on SET_VRING_BASE call Date: Tue, 31 Mar 2020 21:27:56 +0200 Message-Id: <20200331192804.6019-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Vhost did not reset properly the batched descriptors on SET_VRING_BASE event. Because of that, is possible to return an invalid descriptor to the guest. This series ammend this, resetting them every time backend changes, and creates a test to assert correct behavior. To do that, they need to expose a new function in virtio_ring, virtqueue_reset_free_head, only on test code. Another useful thing would be to check if mutex is properly get in vq private_data accessors. Not sure if mutex debug code allow that, similar to C++ unique lock::owns_lock. Not acquiring in the function because caller code holds the mutex in order to perform more actions. v3: * Rename accesors functions. * Make scsi and test use the accesors too. v2: * Squashed commits. * Create vq private_data accesors (mst). This is meant to be applied on top of c4f1c41a6094582903c75c0dcfacb453c959d457 in git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git. Eugenio P=C3=A9rez (5): vhost: Create accessors for virtqueues private_data tools/virtio: Add --batch option tools/virtio: Add --batch=3Drandom option tools/virtio: Add --reset=3Drandom tools/virtio: Make --reset reset ring idx Michael S. Tsirkin (3): vhost: option to fetch descriptors through an independent struct vhost: use batched version by default vhost: batching fetches drivers/vhost/net.c | 28 ++-- drivers/vhost/scsi.c | 14 +- drivers/vhost/test.c | 69 ++++++++- drivers/vhost/test.h | 1 + drivers/vhost/vhost.c | 271 +++++++++++++++++++++++------------ drivers/vhost/vhost.h | 44 +++++- drivers/vhost/vsock.c | 14 +- drivers/virtio/virtio_ring.c | 29 ++++ tools/virtio/linux/virtio.h | 2 + tools/virtio/virtio_test.c | 123 ++++++++++++++-- 10 files changed, 456 insertions(+), 139 deletions(-) --=20 2.18.1