From patchwork Fri Oct 20 15:58:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 156203 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp1155993vqb; Fri, 20 Oct 2023 09:00:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwekB1Uy9z/TYHKvSTpdZCJjDRX58vGrHhyi21R3b9RpJjtrBv4O8Bin0qk5jaQ+DKbvli X-Received: by 2002:a05:6a20:6a1f:b0:15e:7323:5bf3 with SMTP id p31-20020a056a206a1f00b0015e73235bf3mr7757873pzk.26.1697817638357; Fri, 20 Oct 2023 09:00:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697817638; cv=none; d=google.com; s=arc-20160816; b=VRizY5XPAtBCCrBCxY6DwXUU8XyYPIgXU0pGR+eTOMchaQQ3KSpQq3Q25/w0JeXjML LY0/HCoeFqh50yGBgDU3ihhTvwwG/cktncExbdCKqY1efYvRhBgqL6sajXpROtDN+bmu poIsdbil/vYXvU1ptBUxguMMAfZl4RB4Dkrf8rmOcdOKwBXB/0r2VEYSImy2DTTOW+wi jTQmTnfdoChFYGBtu54i7Oi1+CBRrDdX15xH1Y3qGLwmnMxkiMY2Wm2vIiPxF5VIVj96 jZ7CDQJp/rfMXKib5LYBIvVQYFT9DUIypN3T+wezso0evOh6HsgzTSrqDlyukVeoRCsl BaYg== 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=PrVd5hNLS1wjnMKJG4uMD0VRG9l+SsuhqjwmjWwDMM4=; fh=DW2mHD/f0kRN+01V+Z9as8p7OnC0swQlfBH91pgf6/A=; b=aDOv2MgbVOH4oZAbZopBmbm4le3gcNtRCh5NhWZdG1jyhlfKg2hzeW0emkjDSJ1B04 bQsg6MUosDSOEfO/L6iTFgrFtKyWwPzcmItnzCkNFlHFsk/aUUH7xAjq5rkHM9JBTKCl oaImCn0uI7BcXJ/DHohMcs8Rrpk6JSuTEapc44vJL1PSg5IWwwBowOhEdYYp7JAC98p9 rxizdrm1IEJzxpQ0Jl208pv310kk/u+iEPOy4k99n85QYQst4iRjfMDZzPJVl1wW0qB9 70Mhl+fQrx4tcWQr/fJB9ajon/JSHPn9mY34xNsMFmtV0IvJdGOSCAqy0XvDzI/DjwAz nFqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Gde7rFo1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id c7-20020a633507000000b0057744d09d1bsi2209844pga.251.2023.10.20.09.00.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 09:00:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Gde7rFo1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 32BB0833F8FE; Fri, 20 Oct 2023 09:00:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377852AbjJTQAM (ORCPT + 26 others); Fri, 20 Oct 2023 12:00:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377835AbjJTQAK (ORCPT ); Fri, 20 Oct 2023 12:00:10 -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 170DED73 for ; Fri, 20 Oct 2023 08:58:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697817529; 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=PrVd5hNLS1wjnMKJG4uMD0VRG9l+SsuhqjwmjWwDMM4=; b=Gde7rFo1I77vKSXaaT6sCNbmBUeBnF5lf95Jkywj5jC6D1SlATsHPnTjL4lp+0sMSR5Tml qdLn/I8vvxMrnuaVAkDfHSy4Oi/BZIB3m3ffB8iinLglApo/cyylBG5sn1LteW62naksYL H/geAOVcthe7iHqEEZc5InodH8V8V/0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-609-oJ_RXLPwNCCswWlW3aS1YA-1; Fri, 20 Oct 2023 11:58:33 -0400 X-MC-Unique: oJ_RXLPwNCCswWlW3aS1YA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6CED2857D07; Fri, 20 Oct 2023 15:58:32 +0000 (UTC) Received: from max-p1.redhat.com (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 61637503B; Fri, 20 Oct 2023 15:58:29 +0000 (UTC) From: Maxime Coquelin To: mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, stephen.smalley.work@gmail.com, eparis@parisplace.org, xieyongji@bytedance.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, david.marchand@redhat.com, lulu@redhat.com Cc: Maxime Coquelin Subject: [PATCH v4 1/4] vduse: validate block features only with block devices Date: Fri, 20 Oct 2023 17:58:16 +0200 Message-ID: <20231020155819.24000-2-maxime.coquelin@redhat.com> In-Reply-To: <20231020155819.24000-1-maxime.coquelin@redhat.com> References: <20231020155819.24000-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 20 Oct 2023 09:00:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780290827742759763 X-GMAIL-MSGID: 1780290827742759763 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 df7869537ef1..5b3879976b3d 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;