From nobody Tue May 21 04:56:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1601719401; cv=none; d=zohomail.com; s=zohoarc; b=IWG76d+c0S1U3TrCiLUB51QaWJfpWQq6VQ13VFKMLS3m9pd3EEklFcPHir6kM6OM4g1HXscJGbH1LDOZHGnWJWjTrrzjEEzPkkwqWbeT04gUtX4+FP3vOQ/BYn0y/e/kuJgsT61K9fP3sV/J5LDkvWiznS7wYLXuU9FKMviRJ5s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601719401; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4T5z5gk4olpGWCgVFpxNtiY96pwhjy3W7L0rGbvLwk8=; b=aTzyCVa4DIsd0uicZmPfGOAddL+cTMbs54z8KDuR34yqiKZfZH6dY3JDJJvPzplZegN8hnl4vN2wsrS+ZJ2HRZvhnsoDHiv5W3D5JZHkjZQtoD2dXISd8JD1HdGmvDJ2PhmCsyLLLdhLcIPlsptBXWfkppTgCQJJr6OD9ndbCOg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160171940179713.339258022470744; Sat, 3 Oct 2020 03:03:21 -0700 (PDT) Received: from localhost ([::1]:50840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOeNs-0005dg-CY for importer@patchew.org; Sat, 03 Oct 2020 06:03:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOeMf-0004Ub-AO for qemu-devel@nongnu.org; Sat, 03 Oct 2020 06:02:05 -0400 Received: from us-smtp-delivery-44.mimecast.com ([205.139.111.44]:38554) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kOeMd-0002x3-Ml for qemu-devel@nongnu.org; Sat, 03 Oct 2020 06:02:05 -0400 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-374-o1tP11ugOfO_vsKHpUl3HA-1; Sat, 03 Oct 2020 06:01:59 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BCE86802B75; Sat, 3 Oct 2020 10:01:57 +0000 (UTC) Received: from bahia.lan (ovpn-112-192.ams2.redhat.com [10.36.112.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 148CB60C15; Sat, 3 Oct 2020 10:01:52 +0000 (UTC) X-MC-Unique: o1tP11ugOfO_vsKHpUl3HA-1 Subject: [PATCH v3 1/3] vhost: Don't call access_ok() when using IOTLB From: Greg Kurz To: "Michael S. Tsirkin" , Jason Wang Date: Sat, 03 Oct 2020 12:01:52 +0200 Message-ID: <160171931213.284610.2052489816407219136.stgit@bahia.lan> In-Reply-To: <160171888144.284610.4628526949393013039.stgit@bahia.lan> References: <160171888144.284610.4628526949393013039.stgit@bahia.lan> User-Agent: StGit/0.21 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=groug@kaod.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: softfail client-ip=205.139.111.44; envelope-from=groug@kaod.org; helo=us-smtp-delivery-44.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/03 06:01:51 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, netdev@vger.kernel.org, qemu-devel@nongnu.org, Laurent Vivier , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" When the IOTLB device is enabled, the vring addresses we get from userspace are GIOVAs. It is thus wrong to pass them down to access_ok() which only takes HVAs. Access validation is done at prefetch time with IOTLB. Teach vq_access_ok() about that by moving the (vq->iotlb) check from vhost_vq_access_ok() to vq_access_ok(). This prevents vhost_vring_set_addr() to fail when verifying the accesses. No behavior change for vhost_vq_access_ok(). BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=3D1883084 Fixes: 6b1e6cc7855b ("vhost: new device IOTLB API") Cc: jasowang@redhat.com CC: stable@vger.kernel.org # 4.14+ Signed-off-by: Greg Kurz Acked-by: Jason Wang --- drivers/vhost/vhost.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index b45519ca66a7..c3b49975dc28 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -1290,6 +1290,11 @@ static bool vq_access_ok(struct vhost_virtqueue *vq,= unsigned int num, vring_used_t __user *used) =20 { + /* If an IOTLB device is present, the vring addresses are + * GIOVAs. Access validation occurs at prefetch time. */ + if (vq->iotlb) + return true; + return access_ok(desc, vhost_get_desc_size(vq, num)) && access_ok(avail, vhost_get_avail_size(vq, num)) && access_ok(used, vhost_get_used_size(vq, num)); @@ -1383,10 +1388,6 @@ bool vhost_vq_access_ok(struct vhost_virtqueue *vq) if (!vq_log_access_ok(vq, vq->log_base)) return false; =20 - /* Access validation occurs at prefetch time with IOTLB */ - if (vq->iotlb) - return true; - return vq_access_ok(vq, vq->num, vq->desc, vq->avail, vq->used); } EXPORT_SYMBOL_GPL(vhost_vq_access_ok); From nobody Tue May 21 04:56:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1601719431; cv=none; d=zohomail.com; s=zohoarc; b=STVvZ5WrHkwlaTlI0V6RAY7mVKEiidOrETktvhC9VlvG9uwAPlUZVxhdzyEYUAdh8/ydSCJG9YqY6fOC3leCQSaSSzWzvnasOdFMS47/wz0ytgNgiUIqHQMGonxxQEFKDTpKy3h+4BnC6Dv9+giwSBFrtQsocV+Q0Nj0Y/G8cQE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601719431; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gn3wu8Jn8jHGwpTTgTMJq/04MmncDYt8zKNASp4W2F4=; b=RwiLqA92iK4dK01UBcj4vqvWfSTomT+DHqdRTDmgy5f0ECFlLS8xaCqMdJ8QPEPmROR9GLorXWrEg+C/K3gHID9difX8KpO1irXq4UuWm5PCeMGWH7KOkkWEHXvkuxPe1Vycj6JcX1B69ySiz6F9FkwYDMQ/zmIA0wzEXvhRcGc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1601719431871720.6626703338254; Sat, 3 Oct 2020 03:03:51 -0700 (PDT) Received: from localhost ([::1]:52032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOeOM-00067E-I0 for importer@patchew.org; Sat, 03 Oct 2020 06:03:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOeMq-0004mz-Pu for qemu-devel@nongnu.org; Sat, 03 Oct 2020 06:02:16 -0400 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:30470) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kOeMp-0002xP-1v for qemu-devel@nongnu.org; Sat, 03 Oct 2020 06:02:16 -0400 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-203-fajacoYON_SSdHYDcB0WXA-1; Sat, 03 Oct 2020 06:02:10 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9A6171005E5A; Sat, 3 Oct 2020 10:02:08 +0000 (UTC) Received: from bahia.lan (ovpn-112-192.ams2.redhat.com [10.36.112.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1BBC10027AB; Sat, 3 Oct 2020 10:02:03 +0000 (UTC) X-MC-Unique: fajacoYON_SSdHYDcB0WXA-1 Subject: [PATCH v3 2/3] vhost: Use vhost_get_used_size() in vhost_vring_set_addr() From: Greg Kurz To: "Michael S. Tsirkin" , Jason Wang Date: Sat, 03 Oct 2020 12:02:03 +0200 Message-ID: <160171932300.284610.11846106312938909461.stgit@bahia.lan> In-Reply-To: <160171888144.284610.4628526949393013039.stgit@bahia.lan> References: <160171888144.284610.4628526949393013039.stgit@bahia.lan> User-Agent: StGit/0.21 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: softfail client-ip=207.211.30.44; envelope-from=groug@kaod.org; helo=us-smtp-delivery-44.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/03 06:02:14 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, netdev@vger.kernel.org, qemu-devel@nongnu.org, Laurent Vivier , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The open-coded computation of the used size doesn't take the event into account when the VIRTIO_RING_F_EVENT_IDX feature is present. Fix that by using vhost_get_used_size(). Signed-off-by: Greg Kurz Acked-by: Jason Wang --- drivers/vhost/vhost.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index c3b49975dc28..9d2c225fb518 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -1519,8 +1519,7 @@ static long vhost_vring_set_addr(struct vhost_dev *d, /* Also validate log access for used ring if enabled. */ if ((a.flags & (0x1 << VHOST_VRING_F_LOG)) && !log_access_ok(vq->log_base, a.log_guest_addr, - sizeof *vq->used + - vq->num * sizeof *vq->used->ring)) + vhost_get_used_size(vq, vq->num))) return -EINVAL; } =20 From nobody Tue May 21 04:56:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1601719540; cv=none; d=zohomail.com; s=zohoarc; b=kfqPIE6d2m2PFCNN7MDdobckUD+/7QrGmRjqca4MalbwsuXQloG5e2avcUS9T7TTiIOTN2wxoxZtLFUQIpBx4APNdpbP7WyRHpfPbFtk3csETqXron8kQ256k9ktrHCqJ6d9d9q0igL4dx/i2qIanruT04s0YN4m8qQKJxuv3xg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601719540; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9ytqhy9+E+lzVyFBUTQPaj3VYHiSMWR6vAe0SDgp1c4=; b=MOS4PUMujPvE+yTl898/nZZ2/5fSdniPsDPwt4ctVSxn6rCldewHK3CTLMGL8AbscsjeXkb3pki6pD/ul8sy082iKhPdqizI9/lpaYWvVBOnkTD6r0ydhZkwfReL4K9CMsRjl6WOF8iWMburwm8HSU45rVnJLgVDYPgc+QAxPjc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1601719540836391.6138987486087; Sat, 3 Oct 2020 03:05:40 -0700 (PDT) Received: from localhost ([::1]:55830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOeQ7-0007gA-II for importer@patchew.org; Sat, 03 Oct 2020 06:05:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOeMy-00053z-Pm for qemu-devel@nongnu.org; Sat, 03 Oct 2020 06:02:24 -0400 Received: from us-smtp-delivery-44.mimecast.com ([205.139.111.44]:48596) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kOeMx-0002xr-9s for qemu-devel@nongnu.org; Sat, 03 Oct 2020 06:02:24 -0400 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-378-tgmJOLFBPUuJiiTYcs74xg-1; Sat, 03 Oct 2020 06:02:18 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E5F43185A0C1; Sat, 3 Oct 2020 10:02:16 +0000 (UTC) Received: from bahia.lan (ovpn-112-192.ams2.redhat.com [10.36.112.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id C57B110013C4; Sat, 3 Oct 2020 10:02:14 +0000 (UTC) X-MC-Unique: tgmJOLFBPUuJiiTYcs74xg-1 Subject: [PATCH v3 3/3] vhost: Don't call log_access_ok() when using IOTLB From: Greg Kurz To: "Michael S. Tsirkin" , Jason Wang Date: Sat, 03 Oct 2020 12:02:13 +0200 Message-ID: <160171933385.284610.10189082586063280867.stgit@bahia.lan> In-Reply-To: <160171888144.284610.4628526949393013039.stgit@bahia.lan> References: <160171888144.284610.4628526949393013039.stgit@bahia.lan> User-Agent: StGit/0.21 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=groug@kaod.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: softfail client-ip=205.139.111.44; envelope-from=groug@kaod.org; helo=us-smtp-delivery-44.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/03 06:01:51 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, netdev@vger.kernel.org, qemu-devel@nongnu.org, Laurent Vivier , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" When the IOTLB device is enabled, the log_guest_addr that is passed by userspace to the VHOST_SET_VRING_ADDR ioctl, and which is then written to vq->log_addr, is a GIOVA. All writes to this address are translated by log_user() to writes to an HVA, and then ultimately logged through the corresponding GPAs in log_write_hva(). No logging will ever occur with vq->log_addr in this case. It is thus wrong to pass vq->log_addr and log_guest_addr to log_access_vq() which assumes they are actual GPAs. Introduce a new vq_log_used_access_ok() helper that only checks accesses to the log for the used structure when there isn't an IOTLB device around. Signed-off-by: Greg Kurz Acked-by: Jason Wang --- drivers/vhost/vhost.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 9d2c225fb518..9ad45e1d27f0 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -1370,6 +1370,20 @@ bool vhost_log_access_ok(struct vhost_dev *dev) } EXPORT_SYMBOL_GPL(vhost_log_access_ok); =20 +static bool vq_log_used_access_ok(struct vhost_virtqueue *vq, + void __user *log_base, + bool log_used, + u64 log_addr) +{ + /* If an IOTLB device is present, log_addr is a GIOVA that + * will never be logged by log_used(). */ + if (vq->iotlb) + return true; + + return !log_used || log_access_ok(log_base, log_addr, + vhost_get_used_size(vq, vq->num)); +} + /* Verify access for write logging. */ /* Caller should have vq mutex and device mutex */ static bool vq_log_access_ok(struct vhost_virtqueue *vq, @@ -1377,8 +1391,7 @@ static bool vq_log_access_ok(struct vhost_virtqueue *= vq, { return vq_memory_access_ok(log_base, vq->umem, vhost_has_feature(vq, VHOST_F_LOG_ALL)) && - (!vq->log_used || log_access_ok(log_base, vq->log_addr, - vhost_get_used_size(vq, vq->num))); + vq_log_used_access_ok(vq, log_base, vq->log_used, vq->log_addr); } =20 /* Can we start vq? */ @@ -1517,9 +1530,9 @@ static long vhost_vring_set_addr(struct vhost_dev *d, return -EINVAL; =20 /* Also validate log access for used ring if enabled. */ - if ((a.flags & (0x1 << VHOST_VRING_F_LOG)) && - !log_access_ok(vq->log_base, a.log_guest_addr, - vhost_get_used_size(vq, vq->num))) + if (!vq_log_used_access_ok(vq, vq->log_base, + a.flags & (0x1 << VHOST_VRING_F_LOG), + a.log_guest_addr)) return -EINVAL; } =20