Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp28826368rwd; Wed, 5 Jul 2023 03:21:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlEj4mCxcLuAuFWj9qXl/YWs+AIX2+L546agCtABtaGZRYfkTe/ipweFdiSFOi2R/vWToH8H X-Received: by 2002:a17:90a:3d0d:b0:25b:ea12:a2f5 with SMTP id h13-20020a17090a3d0d00b0025bea12a2f5mr14113788pjc.35.1688552513406; Wed, 05 Jul 2023 03:21:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688552513; cv=none; d=google.com; s=arc-20160816; b=y9EdFHACnGyoxHwWV8+zDFnBcwg560u/cV5+/CXV87WKHytzhRn8EyaDoLro0pd5OR eFkAjCz4OPAT67v1eYeCKP40HevsuPER1Q6C+IvO14Qsz+aBVJYqTjZ+FZU/kxfDrYAs OB/WOO38qVGIS/1tcYViyxmUAj4qMkwiJTaNhtOIpvr/nbqY2XT9itlK3U3hrt5WIWYB Ev7kkPq/2Vmu02YPNgmcYjV9qujeV1xliQ/PDGOQUI6YTFw8tnzqVhAb9TVuP7ehUJfA WO1etygeS0nP1Ei4RjNkM5O0lyvmzuJDxGbCXnDKoCRJFpQbF86lHk/YbQ1l3e9A52CR Kx6A== 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=ZEEgjTVF9ob0iUf+PbGSGnuQoV1ZTJ330EoiYkZKizQ=; fh=S1rZK6DPg0mAED4KjNm0cP4EEY87q6FXHFEeosELg0E=; b=PMIGwHnvBusWEQbNWzePxT5vZ5olrymiOTtoAb1dHQt6gTCfGpFK9gbJsI+CxNkR/H 3OWYzvXASlF/EFpNFhhgoFzlsuRXF0S+bew942+TXcnsMBU1mzh4zY/P8S8t+0DyJi8w f32V8PDb1AV9x92tpR3X307HUKbFKwyQUBEP5V1AtfMzvtMCznt4/BEkMIT1/8OFHSVZ yOXAGIzaA2oCGzQf0CWbqC0xx9I8llkKckrLv7WgrTluJnlGM4jsXt6x9vCSEo8vyGue TQje4CwwbAgv7ljbh5fxNu4IJqw+phevkPwztwxzxqn145de7V8ym66uUcXjdxuKJBG9 51Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OaLw9Ceg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p38-20020a634f66000000b0053fd39c7f6csi22342223pgl.646.2023.07.05.03.21.36; Wed, 05 Jul 2023 03:21:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OaLw9Ceg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231552AbjGEKF2 (ORCPT + 99 others); Wed, 5 Jul 2023 06:05:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231213AbjGEKFX (ORCPT ); Wed, 5 Jul 2023 06:05:23 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6AB11721 for ; Wed, 5 Jul 2023 03:04:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688551482; 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=ZEEgjTVF9ob0iUf+PbGSGnuQoV1ZTJ330EoiYkZKizQ=; b=OaLw9Cegd27WGSdL4tcv3Q5sD+RI6Oq9Biakzapibmbe4rA65zlaM0SLRViddcYO+1EjXX roBFx/IKeX7dUl47tWn5Y1oKH3TtwQc6FOh0DwIY/e/Fhu0R0IuJBKQC4GuNRHvonCFYRF fHrGOwgAa0Fd21gHbDiDySMEc838bH0= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-547-6G-zWxspOc2F045WvzciDg-1; Wed, 05 Jul 2023 06:04:38 -0400 X-MC-Unique: 6G-zWxspOc2F045WvzciDg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B73D3380671D; Wed, 5 Jul 2023 10:04:37 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.39.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8994F4021523; Wed, 5 Jul 2023 10:04:35 +0000 (UTC) From: Maxime Coquelin To: xieyongji@bytedance.com, jasowang@redhat.com, mst@redhat.com, david.marchand@redhat.com, lulu@redhat.com Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, Maxime Coquelin Subject: [PATCH v3 1/3] vduse: validate block features only with block devices Date: Wed, 5 Jul 2023 12:04:28 +0200 Message-ID: <20230705100430.61927-2-maxime.coquelin@redhat.com> In-Reply-To: <20230705100430.61927-1-maxime.coquelin@redhat.com> References: <20230705100430.61927-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch is preliminary work to enable network device type support to VDUSE. As VIRTIO_BLK_F_CONFIG_WCE shares the same value as VIRTIO_NET_F_HOST_TSO4, we need to restrict its check to Virtio-blk device type. Acked-by: Jason Wang Reviewed-by: Xie Yongji Signed-off-by: Maxime Coquelin --- drivers/vdpa/vdpa_user/vduse_dev.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index dc38ed21319d..ff9fdd6783fe 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1662,13 +1662,14 @@ static bool device_is_allowed(u32 device_id) return false; } -static bool features_is_valid(u64 features) +static bool features_is_valid(struct vduse_dev_config *config) { - if (!(features & (1ULL << VIRTIO_F_ACCESS_PLATFORM))) + if (!(config->features & (1ULL << VIRTIO_F_ACCESS_PLATFORM))) return false; /* Now we only support read-only configuration space */ - if (features & (1ULL << VIRTIO_BLK_F_CONFIG_WCE)) + if ((config->device_id == VIRTIO_ID_BLOCK) && + (config->features & (1ULL << VIRTIO_BLK_F_CONFIG_WCE))) return false; return true; @@ -1695,7 +1696,7 @@ static bool vduse_validate_config(struct vduse_dev_config *config) if (!device_is_allowed(config->device_id)) return false; - if (!features_is_valid(config->features)) + if (!features_is_valid(config)) return false; return true; -- 2.41.0