Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3738707ybb; Tue, 31 Mar 2020 11:02:33 -0700 (PDT) X-Google-Smtp-Source: APiQypJykRpoJfThgZ1wnoe9X28/UybiF9CmV/y8P8FGEEy9zmNp7iy2snTBbrmnht9D4aW5xXgc X-Received: by 2002:a54:4197:: with SMTP id 23mr42987oiy.87.1585677753178; Tue, 31 Mar 2020 11:02:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585677753; cv=none; d=google.com; s=arc-20160816; b=D+RTu/hKaZU7gLkKdFsM1YMP4rxKtMVa3bzLjFVQrDgifw/W884PmFU0HceXLHzjgg WiS0bQ7scukucVzD8RvUlE38L1nDpGbu6SGk0wqJhYbM09cIYsHPIyu//AGD61kIyTvf 2vXWs8Qv04gv+npP81aYWBKHyP90bIj8SlUN3V3aHYwL1MbMFfGy3wuNGJzHjfQ21kf3 Hst2vFehcwqgcQ3B8OI129qE9R3a1gjaHilhhe5sycqqUHugn/f7s/WPVWVG+/aFQ2bZ TfBBteVnFeSi7TixuGjD1EHo9d81b2zTOzv5pQneUYvPaF/90bDL40YtWko0vW9vmt5i vHmg== 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=cFoxPzLg3hdCD0+oBUzFhDTOM1NMJFZ5aeMIjUALD/M=; b=AQOf6CN9XH5+CYRrj6l1GFJJ37fHADPSNXywwtsF+FZqcVDUYGeMYs+QmoTDlsqgw4 d1Jg6RV/sCw52bx5HjD8SshYvM7G8nEploZu17332EnJinn+TXEqnqO8nq/BQPOt9z3Z j6B+BxEC2ABY4qVBU1jHtiTI0clzkAjzJRpJYr3QP6/2z5j5+x25DZq1GgL4B8hTlthq gq8DVHQfHwuwx8Z62yc/bJPvvNQkGycOBcRNlxLQxnzmxdfg9mu6FFoszg/0RZPj+4Y2 JodAf1nSMGjUU5KZaUEhqahMrlalG8DdtQ7CQRTGH2eB98LRqaqy0e/mEfa6KH8GqT1Q M56Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=d56SjWTA; 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 w15si6002139otl.260.2020.03.31.11.02.18; Tue, 31 Mar 2020 11:02:33 -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=d56SjWTA; 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 S1726974AbgCaSAW (ORCPT + 99 others); Tue, 31 Mar 2020 14:00:22 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:60109 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725988AbgCaSAV (ORCPT ); Tue, 31 Mar 2020 14:00:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585677620; 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=cFoxPzLg3hdCD0+oBUzFhDTOM1NMJFZ5aeMIjUALD/M=; b=d56SjWTAWP+qGQ5JfP6Xn9ZMqEL19UoW/3tPIqd9NEDNdvOeLZdw1vm1/WcQXAMb+7PEGr ln4LjRVu0eDrxgv0Iz1Xna1wtQYimgddwFab4Fz3Z9outPNCHtk08ex8QnGUIttbjednY6 t9eTKAV/0GpkXQY5pbrsEhoqcd7VwDk= 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-166-UG21D0t2MnuDehxvHf0PFg-1; Tue, 31 Mar 2020 14:00:17 -0400 X-MC-Unique: UG21D0t2MnuDehxvHf0PFg-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 C1FEE1084424; Tue, 31 Mar 2020 18:00:15 +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 25924608E7; Tue, 31 Mar 2020 18:00:10 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: "linux-kernel@vger.kernel.org" , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , kvm list , Halil Pasic , "virtualization@lists.linux-foundation.org" , Linux Next Mailing List , Cornelia Huck , Stephen Rothwell , Christian Borntraeger Subject: [PATCH v2 0/8] vhost: Reset batched descriptors on SET_VRING_BASE call Date: Tue, 31 Mar 2020 19:59:58 +0200 Message-Id: <20200331180006.25829-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. 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/test.c | 59 +++++++- drivers/vhost/test.h | 1 + drivers/vhost/vhost.c | 271 +++++++++++++++++++++++------------ drivers/vhost/vhost.h | 45 +++++- drivers/vhost/vsock.c | 14 +- drivers/virtio/virtio_ring.c | 29 ++++ tools/virtio/linux/virtio.h | 2 + tools/virtio/virtio_test.c | 123 ++++++++++++++-- 9 files changed, 445 insertions(+), 127 deletions(-) --=20 2.18.1