Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1041325pxb; Thu, 28 Jan 2021 06:48:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFVqjL9mJkAUFpJlXtIef+xdzkqtCj+yib7wWDnxMPiJAFwezPfp9jkc27nb/9mX5mbkmd X-Received: by 2002:aa7:d2d4:: with SMTP id k20mr14207377edr.361.1611845285134; Thu, 28 Jan 2021 06:48:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611845285; cv=none; d=google.com; s=arc-20160816; b=GlPeinDO2RBHkruc64Td3+FbhnjHiFf7IzOQPeCMH520nOFp3qZlgbLnGsR8m3CLN9 jR8fMUd/uWUmd67hFq9a58KxWbCdPNT5tUhLC8GuCgqQwLRZU6JoGNfzCgOOSzLE39I1 1m8XRCiuzyiLjxHxmWUS53O81/PnEyUzJQVZ7sxtcWJP1t1KsORgjY7xc14fdj0xNFTh C1uWwC105wrE2wfbNsjm6hpop/3bmfDBuaSHs2lwQp/ty4tuol5gUkIxGPqScBLg3hDG r7VbnVMZe3JiQFbo8wzeDlgekb79iUkX8yBgcRaLVYyhKHRVueIWdF2PqjT+ZfqsRYyn VgNw== 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=JEbif7/ADZLMGVwqcPthCfeKHX7VDIqnCprYX3mORNQ=; b=a1SPQALSKl8pEARSMEmYY8a6WWhH5hoWaXE0tnXSrgQKi44wbo78+4PBW91VjXneRr Y6W8qhQwaBgiP04TRk25DThz1xPNkd7F2WZdMwsg+BTGeG6lNEgjv0kYKiix+Oi4Zkjx c8ZV6gvhySur0JsvwbcqQ3HMzxfOOOWrnMvjX5cRxQIjiFKaLMfg7URPAbF2mSX+geXA 2X97Se60j0eJJGuD6rHxq7o8MU42lfCSedGIi7LARziMnK007eDZKQu5gZO1FHB+aDFN Aas922dxIbtrLpWRyAgHDtD44FI6AEq3Eq9zcSKd1nPPAhGsoI9kN6TQLrt+JUWB+UT1 SzHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gSYH48oL; 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 dk14si3182591edb.128.2021.01.28.06.47.40; Thu, 28 Jan 2021 06:48:05 -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=gSYH48oL; 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 S231451AbhA1Ool (ORCPT + 99 others); Thu, 28 Jan 2021 09:44:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26073 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231915AbhA1OoL (ORCPT ); Thu, 28 Jan 2021 09:44:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611844965; 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=JEbif7/ADZLMGVwqcPthCfeKHX7VDIqnCprYX3mORNQ=; b=gSYH48oLwZ3XgaIAXfGFoLfREsH7KtBvQLbL8WeDVkTg4S/FSI1yENnt/ZONdS5NI2QB03 E0ZlgKho6/w4RblC+VOKyV2QEKm9j1/K3kB5y4qy0bpZRBcJ+l/vx9QkHQCpS3G1dj2AFE yZPzQAqstdx6LeSLtX+nCsusO3uixSY= 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-541-DNeStv0DNkC0ZZFM2w-a-Q-1; Thu, 28 Jan 2021 09:42:41 -0500 X-MC-Unique: DNeStv0DNkC0ZZFM2w-a-Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B10EE1800D41; Thu, 28 Jan 2021 14:42:39 +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 9746D62686; Thu, 28 Jan 2021 14:42:35 +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 07/10] vdpa: Remove the restriction that only supports virtio-net devices Date: Thu, 28 Jan 2021 15:41:24 +0100 Message-Id: <20210128144127.113245-8-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.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xie Yongji With VDUSE, we should be able to support all kinds of virtio devices. Signed-off-by: Xie Yongji --- drivers/vhost/vdpa.c | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index ef688c8c0e0e..28624cbfe6dd 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -185,26 +185,6 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp) return 0; } -static int vhost_vdpa_config_validate(struct vhost_vdpa *v, - struct vhost_vdpa_config *c) -{ - long size = 0; - - switch (v->virtio_id) { - case VIRTIO_ID_NET: - size = sizeof(struct virtio_net_config); - break; - } - - if (c->len == 0) - return -EINVAL; - - if (c->len > size - c->off) - return -E2BIG; - - return 0; -} - static long vhost_vdpa_get_config(struct vhost_vdpa *v, struct vhost_vdpa_config __user *c) { @@ -215,7 +195,7 @@ static long vhost_vdpa_get_config(struct vhost_vdpa *v, if (copy_from_user(&config, c, size)) return -EFAULT; - if (vhost_vdpa_config_validate(v, &config)) + if (config.len == 0) return -EINVAL; buf = kvzalloc(config.len, GFP_KERNEL); if (!buf) @@ -243,7 +223,7 @@ static long vhost_vdpa_set_config(struct vhost_vdpa *v, if (copy_from_user(&config, c, size)) return -EFAULT; - if (vhost_vdpa_config_validate(v, &config)) + if (config.len == 0) return -EINVAL; buf = vmemdup_user(c->buf, config.len); @@ -1021,10 +1001,6 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa) int minor; int r; - /* Currently, we only accept the network devices. */ - if (ops->get_device_id(vdpa) != VIRTIO_ID_NET) - return -ENOTSUPP; - v = kzalloc(sizeof(*v), GFP_KERNEL | __GFP_RETRY_MAYFAIL); if (!v) return -ENOMEM; -- 2.29.2