Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2365598pxj; Sun, 30 May 2021 23:44:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykaV9MJujpyc0+auooImONJOJj1pl8QN348QtV1+5sNg2b7RH1hgnoRXbGqkrr8x3Ikfn7 X-Received: by 2002:a05:6602:1695:: with SMTP id s21mr15371612iow.29.1622443490833; Sun, 30 May 2021 23:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622443490; cv=none; d=google.com; s=arc-20160816; b=Uyb1A/KittkkDfbxUu1X08a3Unp4/sHkkTHW0smgtz1R9SLprC4ey1knaG5H4TcPyE u1Y3Kt6gEVkJOD5R+3D+JG0tDEbOAbj/6i1eNhSCiI+42yokx8YCoKTihXSahKsoogBV zpDqmqqWv5Y12eljjNeGxcAiwKxHDXYYnGvtwmF0dAn8cah+ENUxXrsjv2+Z0lcVuKU2 ostoBHo2Un8kJy1a8yWo78DUi/lvAgPDGRlUdo63S0cMbD0O3VWPMC+66u9+FUIXhWV+ cWTJ1wxKSrNf1klgpvakdR5nWotyIrcc7JcOia0ZlUVQqwc/QDhqW/pTZDQVhS21O6dh ABjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=TIWAUfwgcui+A5fvQ+stNJmoyeMH3B/9N1MfI1yf4jc=; b=sJn+VNJli4lNrCOmdYs7KfmvFTyFLUzGHwV4IXlXMd0LnpP3519OpmJR8L7WEwmcPr NAUBqsySzuYQP5euVoFEm+qYIAFHzCZR6lDyP15K9gMNteZBHtYvLAFCbhTj7H7QmVNv LnvFMuP3SL0w1UDJAbE4S25bNDFj0GCqKbRrukGlJqy1TghYpIxDkhYwPYAc8xc5zmqm IoJ60NnpFs6HfuV/SaQ2QF/WB2o35FQdQMMMImXY4xBxSnSGE6HmN9X/kdAAQp/MLCib PqLWVecTBxhB3CYfY2JceOMhFzXSdWT4Me9nIe1YetxoprwEef1wsLcWLNdy570dMQuz 3SfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BgelLFB2; 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 h5si11444571iol.44.2021.05.30.23.44.37; Sun, 30 May 2021 23:44:50 -0700 (PDT) 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=BgelLFB2; 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 S230111AbhEaGps (ORCPT + 99 others); Mon, 31 May 2021 02:45:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48791 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230070AbhEaGpp (ORCPT ); Mon, 31 May 2021 02:45:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622443445; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TIWAUfwgcui+A5fvQ+stNJmoyeMH3B/9N1MfI1yf4jc=; b=BgelLFB26cSrzj8ZeDqTx9M4VJan5sl1uWHdeo4iqoqkBCXgbmyF58L0KbkwkJgQ9jG0dC UCdOmngzzJi4bIyTz9YiHl2EuNYwhwetpQQqJ7rsCgSV1RlPoA46TLUDwTMk/CyocWtLxl WpCdBN3Cm9zEDauOAwP8skHzxwueo10= Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-374-EBn0KyRiPHuhOZeXeVK7DQ-1; Mon, 31 May 2021 02:44:04 -0400 X-MC-Unique: EBn0KyRiPHuhOZeXeVK7DQ-1 Received: by mail-pf1-f197.google.com with SMTP id a21-20020a62e2150000b02902e4e5d37f10so5429614pfi.11 for ; Sun, 30 May 2021 23:44:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=TIWAUfwgcui+A5fvQ+stNJmoyeMH3B/9N1MfI1yf4jc=; b=rEo3HXktIE5TYRXXasnhriFq7KOFpN/e4Yj+nZn9c8mXpEuVt3Cao/xMYF41LE09sX SNBMP2xZLJCUHY7w+0LQU+0Ex+36O1LO+HnEgHnK3LXiaA6TQFYPUEZs0nnLv6CRVUhF 5mSI9Qm+/TN3roGM070ZU9q4VByR4j6+X0BP6qFcCCWHX53SPCQJqEGsWOBHGGNISTNN jwoZbabOBhubsFhDnFyVBszrt/swtu7MJVfRgdcjvFVCsC5KXe9fe9kCFfAmmS6yF0v8 niu5l8Uwysk9MVr3qeGxCaMNh+msI93VtADtbBorPK3mQYX3D9rYSsgPRuZsj0T/rOve WKjg== X-Gm-Message-State: AOAM530q31gsJ/rTwJ5QxEGJsST+IZXm/VlI57TLDIjBXCm07jkxOgR7 L//cY0RCtkLM2THTPyrvA4e86vOJK6eqYKaqLdI2BHxdeHOgQ9uTgRu4mPBQJCipqYs4ofqnsun NiJn4pIFLypcRjfcL3BF9mxQRkd59MPgDAldOFGq6h303W2BWDNzTlMsr1gV6OCbJg2HrSWsCoQ sk X-Received: by 2002:a17:90b:1e05:: with SMTP id pg5mr17681425pjb.65.1622443443189; Sun, 30 May 2021 23:44:03 -0700 (PDT) X-Received: by 2002:a17:90b:1e05:: with SMTP id pg5mr17681403pjb.65.1622443442859; Sun, 30 May 2021 23:44:02 -0700 (PDT) Received: from wangxiaodeMacBook-Air.local ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id u1sm10771915pgh.80.2021.05.30.23.44.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 30 May 2021 23:44:02 -0700 (PDT) Subject: Re: [PATCH 1/2] vdpa/mlx5: Support creating resources with uid == 0 To: Eli Cohen Cc: mst@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org References: <20210530075415.4644-1-elic@nvidia.com> <20210530075415.4644-2-elic@nvidia.com> <7e4f741e-e595-fe19-91ef-e6faeec765d4@redhat.com> <20210531045914.GB158940@mtl-vdi-166.wap.labs.mlnx> From: Jason Wang Message-ID: <3717ebc5-66ce-2d50-1853-49442a8e71e1@redhat.com> Date: Mon, 31 May 2021 14:43:59 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: <20210531045914.GB158940@mtl-vdi-166.wap.labs.mlnx> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2021/5/31 下午12:59, Eli Cohen 写道: > On Mon, May 31, 2021 at 11:06:59AM +0800, Jason Wang wrote: >> 在 2021/5/31 上午11:02, Jason Wang 写道: >>> 在 2021/5/30 下午3:54, Eli Cohen 写道: >>>> Currently all resources must be created with uid != 0 which is essential >>>> userspace processes allocating virtquueue resources. Since this is a >>>> kernel implementation, it is perfectly legal to open resources with >>>> uid == 0. >>>> >>>> In case frimware supports, avoid allocating user context. >>> >>> Typo "frimware". >>> >>> Otherwise. >>> >>> Acked-by: Jason Wang >>> >>> (I don't see any code to check the firmware capability, is this >>> intended?) >> >> Speak too fast. I see the MLX5_CAP_GEN(), so it's fine. > And I responded too fast :-) Right and thanks for the quick response :) >> Thanks >> >> >>> Thanks >>> >>> >>>> Signed-off-by: Eli Cohen >>>> --- >>>>   drivers/vdpa/mlx5/core/resources.c | 6 ++++++ >>>>   include/linux/mlx5/mlx5_ifc.h      | 4 +++- >>>>   2 files changed, 9 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/vdpa/mlx5/core/resources.c >>>> b/drivers/vdpa/mlx5/core/resources.c >>>> index 6521cbd0f5c2..836ab9ef0fa6 100644 >>>> --- a/drivers/vdpa/mlx5/core/resources.c >>>> +++ b/drivers/vdpa/mlx5/core/resources.c >>>> @@ -54,6 +54,9 @@ static int create_uctx(struct mlx5_vdpa_dev >>>> *mvdev, u16 *uid) >>>>       void *in; >>>>       int err; >>>>   +    if (MLX5_CAP_GEN(mvdev->mdev, umem_uid_0)) >>>> +        return 0; >>>> + >>>>       /* 0 means not supported */ >>>>       if (!MLX5_CAP_GEN(mvdev->mdev, log_max_uctx)) >>>>           return -EOPNOTSUPP; >>>> @@ -79,6 +82,9 @@ static void destroy_uctx(struct mlx5_vdpa_dev >>>> *mvdev, u32 uid) >>>>       u32 out[MLX5_ST_SZ_DW(destroy_uctx_out)] = {}; >>>>       u32 in[MLX5_ST_SZ_DW(destroy_uctx_in)] = {}; >>>>   +    if (!uid) >>>> +        return; >>>> + >>>>       MLX5_SET(destroy_uctx_in, in, opcode, MLX5_CMD_OP_DESTROY_UCTX); >>>>       MLX5_SET(destroy_uctx_in, in, uid, uid); >>>>   diff --git a/include/linux/mlx5/mlx5_ifc.h >>>> b/include/linux/mlx5/mlx5_ifc.h >>>> index 9c68b2da14c6..606d2aeacad4 100644 >>>> --- a/include/linux/mlx5/mlx5_ifc.h >>>> +++ b/include/linux/mlx5/mlx5_ifc.h >>>> @@ -1487,7 +1487,9 @@ struct mlx5_ifc_cmd_hca_cap_bits { >>>>       u8         uar_4k[0x1]; >>>>       u8         reserved_at_241[0x9]; >>>>       u8         uar_sz[0x6]; >>>> -    u8         reserved_at_250[0x8]; >>>> +    u8         reserved_at_248[0x2]; >>>> +    u8         umem_uid_0[0x1]; >>>> +    u8         reserved_at_250[0x5]; >>>>       u8         log_pg_sz[0x8]; >>>>         u8         bf[0x1];