Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1039120pxb; Thu, 28 Jan 2021 06:44:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+KRcd3Ji4Uf3ybcwqqPfBPf91mr1j4HGYrFq/znZfLcQYWj85sz+feljiBch3RxMgEsed X-Received: by 2002:aa7:cf8d:: with SMTP id z13mr14131442edx.119.1611845098719; Thu, 28 Jan 2021 06:44:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611845098; cv=none; d=google.com; s=arc-20160816; b=Nu+BJVT1KIpN9ntP9TqIJysqLLuBVVSNfkbOmZqg5wcN0vZ5lxknNUeObEYiFl4EBM rnvAQ1BA3nMzXKuThQDwyoF4f+jeBm/x5rYJJ8N6e5PlFHQLlI91vCs5GLxec9+QM/Lq UmSAgSHMkmLEojKWsGvAWOTCt64LFrRlUhXxvW2TpmA7XNOrAl6PGDhJ2b+9sineqXVa La4X5nXFZHQfW2OwkeBO97lulK7GK0bCiY+fGgSAjpCLsH+p2gNp7O1J33xW9Jir3+lz hcTZs/m4mQBscWNXf5N7RSUfasKuT5NizpdpThVyM8u94Hk523ENbY1q6Q2XZ3zkxK/l le+g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Vra/8R9BJFPpbB1vr+cBu428jEwk9zi9qo7gpPVDYWY=; b=P0/vjcFKwqR/YmTmvmNTsG01YpgWe5KzLDKmt+JWOYHROno++dn3ChWhUo3faNJh2T 2491tIYkMsMM6uynWrwNSuEasNNB/5LtMWHDrpIEMSyR9VcyOexc4B58uPbyf7Xe3SDk Yh1CntznQIfufQQxd6o77kBUo74qVNvHT60sPATgtQWZWaBDCnfnB2d/ESAyP4UiyGtp QSsrY/XlM+bCvKJ1j4qaM77Ghp7c85hVT6N1+0dpKrp3kSwHVXC7t1gL/iakmFSDjhUg SIJG78ehwyc+8Jl/6o227JV+xoavxPdQjakfXmCmkDY0zz2JvLKjqIiXDGvmUIa1IVJN RcnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N+sKNSyF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id b8si2517043eja.22.2021.01.28.06.44.32; Thu, 28 Jan 2021 06:44:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=N+sKNSyF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S229627AbhA1Onp (ORCPT + 99 others); Thu, 28 Jan 2021 09:43:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:42944 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231520AbhA1OnN (ORCPT ); Thu, 28 Jan 2021 09:43:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611844907; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Vra/8R9BJFPpbB1vr+cBu428jEwk9zi9qo7gpPVDYWY=; b=N+sKNSyFt6kjNLZ8S3xALs1G/ztpELyI34RkVsADtwTY9LyIOiLwisqpdhFPJ1m55OMOGa xBk4kS4CBjvSCU1v7bUgUi3Nd17FVYZEyBWigrh6VXEBG/En5U3tXAmVC0emzszf0V3+C2 bh10ZUu0O08W4vF73mThwrKj3J3aIJs= 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-207-91Ui66JCMViZtffPQ_YwDg-1; Thu, 28 Jan 2021 09:41:45 -0500 X-MC-Unique: 91Ui66JCMViZtffPQ_YwDg-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 7606410054FF; Thu, 28 Jan 2021 14:41:44 +0000 (UTC) Received: from steredhat.redhat.com (ovpn-113-219.ams2.redhat.com [10.36.113.219]) by smtp.corp.redhat.com (Postfix) with ESMTP id F39F060CF1; Thu, 28 Jan 2021 14:41:41 +0000 (UTC) From: Stefano Garzarella To: virtualization@lists.linux-foundation.org Cc: Xie Yongji , "Michael S. Tsirkin" , Stefano Garzarella , Laurent Vivier , Stefan Hajnoczi , linux-kernel@vger.kernel.org, Max Gurtovoy , Jason Wang , kvm@vger.kernel.org Subject: [PATCH RFC v2 03/10] vringh: reset kiov 'consumed' field in __vringh_iov() Date: Thu, 28 Jan 2021 15:41:20 +0100 Message-Id: <20210128144127.113245-4-sgarzare@redhat.com> In-Reply-To: <20210128144127.113245-1-sgarzare@redhat.com> References: <20210128144127.113245-1-sgarzare@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __vringh_iov() overwrites the contents of riov and wiov, in fact it resets the 'i' and 'used' fields, but also the consumed field should be reset to avoid an inconsistent state. Signed-off-by: Stefano Garzarella --- drivers/vhost/vringh.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c index f68122705719..bee63d68201a 100644 --- a/drivers/vhost/vringh.c +++ b/drivers/vhost/vringh.c @@ -290,9 +290,9 @@ __vringh_iov(struct vringh *vrh, u16 i, return -EINVAL; if (riov) - riov->i = riov->used = 0; + riov->i = riov->used = riov->consumed = 0; if (wiov) - wiov->i = wiov->used = 0; + wiov->i = wiov->used = wiov->consumed = 0; for (;;) { void *addr; -- 2.29.2