Message ID | 1675110643-28143-4-git-send-email-si-wei.liu@oracle.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2410435wrn; Mon, 30 Jan 2023 13:43:58 -0800 (PST) X-Google-Smtp-Source: AK7set+UAYvu8lbtkcwbOyOnLFAbqIP7rPRxfv+/OXwwZOHaAiYKO49/g+JCa+oqLBaW1d7S3uOH X-Received: by 2002:a17:906:741:b0:87b:d3b3:94e9 with SMTP id z1-20020a170906074100b0087bd3b394e9mr14151878ejb.0.1675115038592; Mon, 30 Jan 2023 13:43:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675115038; cv=none; d=google.com; s=arc-20160816; b=zuxV7hqysfrd038cVO20me4jwRZZ+umGmq6cXxZsFpTeGiluP0KfEE0cJ8Dx7Qq/3b bjiLH/M3MCSI12TTUfTvWoEtC8qHQ6jEeBBb5aPoNJxyi1HgD8SzvaKlYV7131Dv8YRQ Rk0VpahhJKriub9cpRtwpQeIwKB2+gsNI9Lua16n8DrKxUDsVufmDOD9zIBZzxilc3uT J6Hs3JQljPZwLOv+RWN+/YX2lK9OEqBtTk3aU2mFYjmFqyrdm+rmsICyq/BaK4HAgPu1 KkbACXuFN74WU+kPhEnD+5x+rk73sowPlQMQ8m3EDfYTjucjDgVSR7nR5TApDqU8vOMO YL/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=fSu5LWhVuNzoustkxj8evl70EvKqh8oxSx7hEUWRRQk=; b=RN+UDy72HyBgJmHopDa7fQXA712fWArOTdIHCED6FlQ5flAckaBXHpLeRIflZxMgJD Q2snliKFNazQZNE/Wt30nEBU0JoEV8Ajlg93A0/9pOxmFrffmpBaS2qK1eAPGCJYRE1K deqHs3Z48NIxlXWmytE1zR+eOXgg7hYOcgp2knyJzMpc/SP/LroPrl/qx03wzssJvzOS wWlBRz6Uady6QS8DrCKLD4VTUa4yr7yiNNsFG/ZESuJ092SjFdlS5MuAsBd07skmX0Iq +02B7M/t3LCv2a+frhOzJiOqEJT193oiGKEd0TYHmV0K9V7I+lNFrdTuCaTsqImUMtGl MF1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=TbYhdL+i; 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=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v7-20020aa7d807000000b0049e62402a6dsi16884144edq.41.2023.01.30.13.43.35; Mon, 30 Jan 2023 13:43:58 -0800 (PST) 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=@oracle.com header.s=corp-2022-7-12 header.b=TbYhdL+i; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231283AbjA3Vhe (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Mon, 30 Jan 2023 16:37:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230120AbjA3Vh1 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 30 Jan 2023 16:37:27 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEFB835B0 for <linux-kernel@vger.kernel.org>; Mon, 30 Jan 2023 13:37:26 -0800 (PST) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30UL4N7p011380; Mon, 30 Jan 2023 21:37:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2022-7-12; bh=fSu5LWhVuNzoustkxj8evl70EvKqh8oxSx7hEUWRRQk=; b=TbYhdL+iF5svJwfI1BM4C2JvHv87iIkiCAS/DowJkZLBPwdPw7WZgjZGLu4hu0dOt9m+ TnM0UH11OX1dzI/wams8lHSsWM8gQzSPpHuekqo6sc/B+iA4J5AtKQSkbI4afLEgrpw3 KZJ9BlgKMLfnEzJt9uMmq+/je27RntxJ61R6X6Z+oNN4gtnKayvjrqV6W1jVU7mbAV7G +EPIR6iiRD548qtQyohVlmhX3cSWiwYf+MDLLhWVcEoFPhvCuv0QQ9sa6er30H+/kdvP vu5PArK9QacyyJWz4DEdzEt9/5d5MTUBamBw41e8MdgAxNVlQXMl/L3WR2h/zSuUm3b9 oA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvq9m3x2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Jan 2023 21:37:22 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30UK8hq1031798; Mon, 30 Jan 2023 21:37:21 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3nct54qa7f-4; Mon, 30 Jan 2023 21:37:21 +0000 From: Si-Wei Liu <si-wei.liu@oracle.com> To: mst@redhat.com, jasowang@redhat.com, parav@nvidia.com, elic@nvidia.com Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] vdpa: validate provisioned device features against specified attribute Date: Mon, 30 Jan 2023 12:30:40 -0800 Message-Id: <1675110643-28143-4-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1675110643-28143-1-git-send-email-si-wei.liu@oracle.com> References: <1675110643-28143-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-30_17,2023-01-30_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300200 X-Proofpoint-ORIG-GUID: gPS2wF2If1QoNG-JfcE7Ytne3-fWHdYV X-Proofpoint-GUID: gPS2wF2If1QoNG-JfcE7Ytne3-fWHdYV X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756485426745003232?= X-GMAIL-MSGID: =?utf-8?q?1756485426745003232?= |
Series |
features provisioning fixes and mlx5_vdpa support
|
|
Commit Message
Si-Wei Liu
Jan. 30, 2023, 8:30 p.m. UTC
With device feature provisioning, there's a chance for misconfiguration
that the vdpa feature attribute supplied in 'vdpa dev add' command doesn't
get selected on the device_features to be provisioned. For instance, when
a @mac attribute is specified, the corresponding feature bit _F_MAC in
device_features should be set for consistency. If there's conflict on
provisioned features against the attribute, it should be treated as an
error to fail the ambiguous command. Noted the opposite is not
necessarily true, for e.g. it's okay to have _F_MAC set in device_features
without providing a corresponding @mac attribute, in which case the vdpa
vendor driver could load certain default value for attribute that is not
explicitly specified.
Generalize this check in vdpa core so that there's no duplicate code in
each vendor driver.
Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
---
drivers/vdpa/vdpa.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
Comments
On 30/01/2023 22:30, Si-Wei Liu wrote: > With device feature provisioning, there's a chance for misconfiguration > that the vdpa feature attribute supplied in 'vdpa dev add' command doesn't > get selected on the device_features to be provisioned. For instance, when > a @mac attribute is specified, the corresponding feature bit _F_MAC in > device_features should be set for consistency. If there's conflict on > provisioned features against the attribute, it should be treated as an > error to fail the ambiguous command. Noted the opposite is not > necessarily true, for e.g. it's okay to have _F_MAC set in device_features > without providing a corresponding @mac attribute, in which case the vdpa > vendor driver could load certain default value for attribute that is not > explicitly specified. > > Generalize this check in vdpa core so that there's no duplicate code in > each vendor driver. > > Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com> Reviewed-by: Eli Cohen <elic@nvidia.com> > --- > drivers/vdpa/vdpa.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c > index 5f4883b..6d02b8c 100644 > --- a/drivers/vdpa/vdpa.c > +++ b/drivers/vdpa/vdpa.c > @@ -601,8 +601,26 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i > config.mask |= BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP); > } > if (nl_attrs[VDPA_ATTR_DEV_FEATURES]) { > + u64 missing = 0x0ULL; > + > config.device_features = > nla_get_u64(nl_attrs[VDPA_ATTR_DEV_FEATURES]); > + if (nl_attrs[VDPA_ATTR_DEV_NET_CFG_MACADDR] && > + !(config.device_features & BIT_ULL(VIRTIO_NET_F_MAC))) > + missing |= BIT_ULL(VIRTIO_NET_F_MAC); > + if (nl_attrs[VDPA_ATTR_DEV_NET_CFG_MTU] && > + !(config.device_features & BIT_ULL(VIRTIO_NET_F_MTU))) > + missing |= BIT_ULL(VIRTIO_NET_F_MTU); > + if (nl_attrs[VDPA_ATTR_DEV_NET_CFG_MAX_VQP] && > + config.net.max_vq_pairs > 1 && > + !(config.device_features & BIT_ULL(VIRTIO_NET_F_MQ))) > + missing |= BIT_ULL(VIRTIO_NET_F_MQ); > + if (missing) { > + NL_SET_ERR_MSG_FMT_MOD(info->extack, > + "Missing features 0x%llx for provided attributes", > + missing); > + return -EINVAL; > + } > config.mask |= BIT_ULL(VDPA_ATTR_DEV_FEATURES); > } >
diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index 5f4883b..6d02b8c 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -601,8 +601,26 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i config.mask |= BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP); } if (nl_attrs[VDPA_ATTR_DEV_FEATURES]) { + u64 missing = 0x0ULL; + config.device_features = nla_get_u64(nl_attrs[VDPA_ATTR_DEV_FEATURES]); + if (nl_attrs[VDPA_ATTR_DEV_NET_CFG_MACADDR] && + !(config.device_features & BIT_ULL(VIRTIO_NET_F_MAC))) + missing |= BIT_ULL(VIRTIO_NET_F_MAC); + if (nl_attrs[VDPA_ATTR_DEV_NET_CFG_MTU] && + !(config.device_features & BIT_ULL(VIRTIO_NET_F_MTU))) + missing |= BIT_ULL(VIRTIO_NET_F_MTU); + if (nl_attrs[VDPA_ATTR_DEV_NET_CFG_MAX_VQP] && + config.net.max_vq_pairs > 1 && + !(config.device_features & BIT_ULL(VIRTIO_NET_F_MQ))) + missing |= BIT_ULL(VIRTIO_NET_F_MQ); + if (missing) { + NL_SET_ERR_MSG_FMT_MOD(info->extack, + "Missing features 0x%llx for provided attributes", + missing); + return -EINVAL; + } config.mask |= BIT_ULL(VDPA_ATTR_DEV_FEATURES); }