Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp892204ybb; Wed, 1 Apr 2020 11:33:36 -0700 (PDT) X-Google-Smtp-Source: APiQypIrIMiv8z/fUeMrsbbkQY3qddinavy7mOUXvn86rY9SjoRi+rOLxgIqkSJhbM+cPDvkIsth X-Received: by 2002:a05:6808:8db:: with SMTP id k27mr3886216oij.175.1585766016053; Wed, 01 Apr 2020 11:33:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585766016; cv=none; d=google.com; s=arc-20160816; b=L8KBHBe4ROKPZ/bUKE1BwzMvr94IKRwQQ8F+sUyqs1cc0N2fiyLtwHaV94/n9jxmnW hllVgRWNWIF0ZFTPm7tXc+SbKhtKK7C5502ccCduOTl6dCTzHQ4NcvzqQxGx9uoJk1N+ iVWrP3k6giwfoPJjRfO2qUVwV/tqWAJeviQSlyY8qprV7MfEixScWwb52dSGLfOS5TIX irRxhntCR/LqPhSFyJL00HJzbc8fhPUUEe0w4xILzOlqSMmhHRdJLKFnoiOyIBfLFs7T WpkcLrjUABk3MmEQgoRxiuCFmrBtc2i+qoIkxnakaU7gaTNQjnP4+/j4Plur2zwJdTc8 5sdA== 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=XFWPG187HUhkSGxk00FG9TA0iVCphDpDrVtIpYx7KzE=; b=GaqcEl3sNVOOy/aT+e+kxmQ9YW2yW2BrGw4GCRW2S8FkpuCZn7/5v88m+shQTt+Gb4 IaVmlG6s6khoFtYnOoKbkMG/uLEs6uOHjyrhhQ/nucTN7E6s4A3eQ2P+AOfgIS2FVctz qhreIwYRIH1IodG0jWgAIRDzpG2PNq80GbUPXKLV/306WzmQa17QUdSLj2u90DpzoLch pNLkEoBrEEws+JMaDM2r1wUyQ6MOE3F7pOxl1KuDtZ/m6WOMvPYPMk7tW+jssHSTL23k 4MxVxuOJWCS3dS8hhZ4lhN1+5NVRP8fojAQSXfRcbKV9bv9ldDa4KeZ12Hn5LYnaki4x tPng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="GGemJhZ/"; 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 x9si1163280oia.194.2020.04.01.11.33.22; Wed, 01 Apr 2020 11:33:36 -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="GGemJhZ/"; 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 S1733008AbgDASbe (ORCPT + 99 others); Wed, 1 Apr 2020 14:31:34 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:50025 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732864AbgDASbd (ORCPT ); Wed, 1 Apr 2020 14:31:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585765892; 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=XFWPG187HUhkSGxk00FG9TA0iVCphDpDrVtIpYx7KzE=; b=GGemJhZ/6PQUlz9m/ZAOmIZjrgjUPXJNQwZvmJKZvkev7f+kz8C6aRXhf3So11FgezWrzp XaOmcO5lTVa+Je0Ynq/RQjGzPrxoYiGO9cjDpez1fTLjh0KdXxm/ax9Ay5s6DNW5qsnGmu YXHW0E75YXwBYdRpxQVJmXrIb9DlB4U= 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-200-o8ufVN_IPVGhpVSDAjVHrw-1; Wed, 01 Apr 2020 14:31:29 -0400 X-MC-Unique: o8ufVN_IPVGhpVSDAjVHrw-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 9962918C8C19; Wed, 1 Apr 2020 18:31:27 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-73.ams2.redhat.com [10.36.113.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0887196F83; Wed, 1 Apr 2020 18:31:22 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: "virtualization@lists.linux-foundation.org" , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Linux Next Mailing List , Stephen Rothwell , kvm list , Halil Pasic , "linux-kernel@vger.kernel.org" , Cornelia Huck , Christian Borntraeger Subject: [PATCH v4 0/7] vhost: Reset batched descriptors on SET_VRING_BASE call Date: Wed, 1 Apr 2020 20:31:11 +0200 Message-Id: <20200401183118.8334-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. v4: * Rebase with vhost_iotlb changes. v3: * Rename accesors functions. * Make scsi and test use the accesors too. v2: * Squashed commits. * Create vq private_data accesors (mst). This serie is meant to be applied on top of 38dd2ba72ece18ec8398c8ddd13cfb02870b0309 in git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git. Eugenio P=C3=A9rez (4): 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/test.c | 59 +++++++- drivers/vhost/test.h | 1 + drivers/vhost/vhost.c | 271 +++++++++++++++++++++++------------ drivers/vhost/vhost.h | 17 ++- drivers/virtio/virtio_ring.c | 29 ++++ tools/virtio/linux/virtio.h | 2 + tools/virtio/virtio_test.c | 123 ++++++++++++++-- 7 files changed, 395 insertions(+), 107 deletions(-) --=20 2.18.1