Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1438403ybb; Sun, 29 Mar 2020 04:49:32 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv/PJK/kqXwS6MpHqqwIYrLpRHUsWo7zBqSpBTnqFvTANULtmI0VkOzDlty1HvTFm5C9MQ8 X-Received: by 2002:a9d:469d:: with SMTP id z29mr5557620ote.320.1585482572482; Sun, 29 Mar 2020 04:49:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585482572; cv=none; d=google.com; s=arc-20160816; b=zJD7Qsf38ZC/tdLcFMgGC9iQxQVSV/iDXQzxDsAQZkzX+T0NwyUdJ77h8KV0R7ApyW zab+pOS2/VKbEOK/hp1sKdjx3YV5/KpPqE6AfWZJC5U1X9LUMXz+l216arp6aegOGJlo 6k4R6A3kGxGklAxVG1DYmEPyCxMH+RSvDUMpn2RLWUQPh2S6PfClVamgnEJ0Su2fvPUY 58jTMatc4R3YghF/zerDZOcXWlDo6CobU7hAIK598+XZT4qdcvXQLpBa9MhyJT9EjJVi BRbOHjWboorRmEwx3risVpt2sC9fcr1tyJH0yMO3wN/tERQ/j8m2J4B5uGSt15uwsC/X G3kg== 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=ViPGPqwEgspRtJgmZ4rE2OqFoX1oHWclqobpFUgHsnM=; b=nLZThu3hJThisngshNb5VC8alyCp1UNv+u5vmT8XJ3tkT1x0E3ooMmljUg49l6l/7h ln/J/cPbiHGdD8R7ODHRkB6KrQgm4DRER6/KlbU7VrFBm1+V7mKN9tqo0gNb0Lb63/zW V/4GwdQjJrzdW5lOEhfPkxhLLN7nUP7FIAZcO15kXERm+ftmY4ecxcjzt7KZKrRU/RSf C+VGogEg6+M7EU4QVSXPaFEc/SMTMzi9hu0U0bjeJuebkdFnBgemUlgpLEQQ2YKpwFWb PX1SYecRr4ZEea1iHkM5DjY9OpiqT5IxEVPoXBlr7jrcWhtk3S5Wu8y12rLITh1wF+dO pekQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="He/no2RA"; 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 p21si1864362ota.291.2020.03.29.04.49.06; Sun, 29 Mar 2020 04:49:32 -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="He/no2RA"; 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 S1728056AbgC2LeQ (ORCPT + 99 others); Sun, 29 Mar 2020 07:34:16 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:55113 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727875AbgC2LeQ (ORCPT ); Sun, 29 Mar 2020 07:34:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585481655; 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=ViPGPqwEgspRtJgmZ4rE2OqFoX1oHWclqobpFUgHsnM=; b=He/no2RAPkfymhV+3KbcSW24BNsO8sYmihMdWTVOIwLmI7MHQowgaFCJeI492JWjDGaJgY E/IB8www1NV0Gac9ERd3sZwBosPtBsTXwlsbdtv1fsSl2KiKIQs6vnvmV4WcO3i3Zy4HpG XnKKEplZo7LfetEPxAeUtNAFwn3AJIw= 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-224-gzzDmRD2MRCIB1hML660mw-1; Sun, 29 Mar 2020 07:34:11 -0400 X-MC-Unique: gzzDmRD2MRCIB1hML660mw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA33118B5F69; Sun, 29 Mar 2020 11:34:09 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-95.ams2.redhat.com [10.36.112.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 393DB5C1BE; Sun, 29 Mar 2020 11:34:03 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: "virtualization@lists.linux-foundation.org" , Halil Pasic , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Stephen Rothwell , Linux Next Mailing List , kvm list , Cornelia Huck , Christian Borntraeger , "linux-kernel@vger.kernel.org" Subject: [PATCH 0/6] vhost: Reset batched descriptors on SET_VRING_BASE call Date: Sun, 29 Mar 2020 13:33:53 +0200 Message-Id: <20200329113359.30960-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.16 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 ev= ent. Because of that, is possible to return an invalid descriptor to the = guest. This series ammend this, and creates a test to assert correct behavior. T= o do that, they need to expose a new function in virtio_ring, virtqueue_r= eset_free_head. Not sure if this can be avoided. Also, change from https://lkml.org/lkml/2020/3/27/108 is not included, th= at avoids to update a variable in a loop where it can be updated once. This is meant to be applied on top of eccb852f1fe6bede630e2e4f1a121a81e34= 354ab in git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git, and some = commits should be squashed with that series. Eugenio P=C3=A9rez (6): tools/virtio: Add --batch option tools/virtio: Add --batch=3Drandom option tools/virtio: Add --reset=3Drandom tools/virtio: Make --reset reset ring idx vhost: Delete virtqueue batch_descs member fixup! vhost: batching fetches drivers/vhost/test.c | 57 ++++++++++++++++ drivers/vhost/test.h | 1 + drivers/vhost/vhost.c | 12 +++- drivers/vhost/vhost.h | 1 - drivers/virtio/virtio_ring.c | 18 +++++ include/linux/virtio.h | 2 + tools/virtio/linux/virtio.h | 2 + tools/virtio/virtio_test.c | 123 +++++++++++++++++++++++++++++++---- 8 files changed, 201 insertions(+), 15 deletions(-) --=20 2.18.1