Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4943607pxb; Wed, 19 Jan 2022 07:59:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJywrw9Iz3+w2vsSXUC1iQUFST2TgHgSrwd9GNqyECHKqMt7aJKC+rliaeIwyNcZ1GAiLZ0f X-Received: by 2002:a63:6f4d:: with SMTP id k74mr28434484pgc.208.1642607993302; Wed, 19 Jan 2022 07:59:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642607993; cv=none; d=google.com; s=arc-20160816; b=Y3l42aHRKiwI/+Okzhf6Q9hjqLymF50QOrfq7jcLOrlHQuZCkIeCear3uRLJ06mAaF oNkkrNzYJr5vTeGcahnntwTMoYnOMq/XDl2D2BKZIVdkRFgEaNB/6usn6GagHjy4qz50 MS+gDNOlEhYv15FJv7SLptlR1ST945++408K9+Ny/VD5C92D8gZ1AXfR3MKCUIDP4cz5 VOCOsuPQb60BR1Nkw4g4JeIQhFgrHpKX01JQ3K2cFPBZu3jxmQvrQ6rSu/JGJogI/tuC r/lITE2CJ3EP89fswfDskKkCq006JjqZ5zac0dZRCrl2ZYPrBjnXs8q4mxsNhZESLI7A cUhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=m/T+xqeUAypi/EBSYpJv9W0hZEqvgrZKwX4x1rH2s4Q=; b=rXUPjBrJNEsRbBKFjcLUbcbWNbbotMsNOBu1a+azX7SXzJ2V9M387lNQ74aJMtg/36 2hz55TY+baaU2jpaMvvoIZTal0ljkjHVMqDCQel525STm/il2V/AYkGedt8b0ozBwf9a nJ3tWMNFxvMuoq1sJ5sLz0eAHTYR1wn9neSFIswCZBZ6BmcR8t8oaS+UXJB6LoiihBfL /mwPTybKCv4GB5v+A0xrKH18ExMFrBmrQKtQNvzE3YlTYqefeNy1/NttmpnzyyZkz7o8 sqX93wQOfVduCE1JgBFKGLvQZjeueXOH4X231Q5uEZaDpdtaZEkYJywDJHUUE7WED7Wv GZ6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XUPA0c9D; 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 u22si64466pjx.70.2022.01.19.07.59.40; Wed, 19 Jan 2022 07:59:53 -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=XUPA0c9D; 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 S243374AbiARDfc (ORCPT + 99 others); Mon, 17 Jan 2022 22:35:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50662 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354554AbiARDGy (ORCPT ); Mon, 17 Jan 2022 22:06:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642475213; 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=m/T+xqeUAypi/EBSYpJv9W0hZEqvgrZKwX4x1rH2s4Q=; b=XUPA0c9D1oZmlMbfU411dL7GElI8BEZ+GCMtCL3hilyuo1ESjaLyLB0D5n3LhuzJzhmkqK hB7VXBRF7aYs3k8FGuP+Jh7NkT9OK8IrP4o9W2RG0yPxZXnKaF1rtKAz+xa2DKKAzIrH5Q Ms/ddpcOn2JRPtQGhz5pFYIrjvtT1jE= Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-156-HVhlt4s7NnSHygj2GsuG8w-1; Mon, 17 Jan 2022 22:06:52 -0500 X-MC-Unique: HVhlt4s7NnSHygj2GsuG8w-1 Received: by mail-pg1-f197.google.com with SMTP id u6-20020a63ef06000000b00341c8aa06d8so8695578pgh.2 for ; Mon, 17 Jan 2022 19:06:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=m/T+xqeUAypi/EBSYpJv9W0hZEqvgrZKwX4x1rH2s4Q=; b=iR9U1Ln2Nuxvt/nuNTOFaf62aJ877naGsp5Dkf0nFFfNQhqd8W1/UN7DFqUBi2ROcx bEK1Ta8ABO6aeXI2XVBV+fzSPGFC7DxfC4fz48kCMLiE2dWCJWXDueJ0RIyzrVNqLz1y VBmaTjEHFyPKzIR35wGmxiau/gh+MtQR4EfPg710fK/seaY+uA3NUw4SvZyGKvvYg41l 3Glc2I6fsaFKRrlYS3ihipvU+noATT9hzQpetPs3S7b0PLsFxCU8k6o/kuZaZGcyMIhi qZuXb9/5V3ITL0cHAqxjqvJ9pemZCO9xoPio+P+VioeUt1FSpIbzFY5gCwuIvPFdaNXR jNDg== X-Gm-Message-State: AOAM533yI238QZtPGJuAD2GK0Bn+1LJWtJahlK39V56yJShs2XNv0kk5 S2ZtGRTo3vJ49xMzA0r8i3NjFYjPFo0FEZnRsABCkOFUmqMk3ePX514TRcTrcyUsWxDkkeMx+4d Abm1F4/qlcwBdjL7KmRFRLMBR X-Received: by 2002:a17:902:d505:b0:14a:77ac:1e8b with SMTP id b5-20020a170902d50500b0014a77ac1e8bmr25111376plg.1.1642475211594; Mon, 17 Jan 2022 19:06:51 -0800 (PST) X-Received: by 2002:a17:902:d505:b0:14a:77ac:1e8b with SMTP id b5-20020a170902d50500b0014a77ac1e8bmr25111367plg.1.1642475211348; Mon, 17 Jan 2022 19:06:51 -0800 (PST) Received: from [10.72.13.83] ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id c19sm15280757pfo.91.2022.01.17.19.06.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Jan 2022 19:06:50 -0800 (PST) Message-ID: Date: Tue, 18 Jan 2022 11:06:42 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [RFC 1/3] vdpa: support exposing the config size to userspace Content-Language: en-US To: "Longpeng(Mike)" , mst@redhat.com, sgarzare@redhat.com, stefanha@redhat.com Cc: virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, arei.gonglei@huawei.com, yechuan@huawei.com, huangzhichao@huawei.com References: <20220117092921.1573-1-longpeng2@huawei.com> <20220117092921.1573-2-longpeng2@huawei.com> From: Jason Wang In-Reply-To: <20220117092921.1573-2-longpeng2@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2022/1/17 下午5:29, Longpeng(Mike) 写道: > From: Longpeng > > - GET_CONFIG_SIZE: the size of the virtio config space I think we need to be verbose here. And it would be better to quote what spec said: " The device MUST allow reading of any device-specific configuration field before FEATURES_OK is set by the driver. This includes fields which are conditional on feature bits, as long as those feature bits are offered by the device. " I guess the size should contain the conditional on features bits. (Or maybe we need to tweak the comment for get_config_size as well). Other looks good. Thanks > > Signed-off-by: Longpeng > --- > drivers/vhost/vdpa.c | 17 +++++++++++++++++ > include/uapi/linux/vhost.h | 4 ++++ > 2 files changed, 21 insertions(+) > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > index 29cced1cd277..1eea14a4ea56 100644 > --- a/drivers/vhost/vdpa.c > +++ b/drivers/vhost/vdpa.c > @@ -355,6 +355,20 @@ static long vhost_vdpa_get_iova_range(struct vhost_vdpa *v, u32 __user *argp) > return 0; > } > > +static long vhost_vdpa_get_config_size(struct vhost_vdpa *v, u32 __user *argp) > +{ > + struct vdpa_device *vdpa = v->vdpa; > + const struct vdpa_config_ops *ops = vdpa->config; > + u32 size; > + > + size = ops->get_config_size(vdpa); > + > + if (copy_to_user(argp, &size, sizeof(size))) > + return -EFAULT; > + > + return 0; > +} > + > static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, > void __user *argp) > { > @@ -492,6 +506,9 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, > case VHOST_VDPA_GET_IOVA_RANGE: > r = vhost_vdpa_get_iova_range(v, argp); > break; > + case VHOST_VDPA_GET_CONFIG_SIZE: > + r = vhost_vdpa_get_config_size(v, argp); > + break; > default: > r = vhost_dev_ioctl(&v->vdev, cmd, argp); > if (r == -ENOIOCTLCMD) > diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h > index c998860d7bbc..bc74e95a273a 100644 > --- a/include/uapi/linux/vhost.h > +++ b/include/uapi/linux/vhost.h > @@ -150,4 +150,8 @@ > /* Get the valid iova range */ > #define VHOST_VDPA_GET_IOVA_RANGE _IOR(VHOST_VIRTIO, 0x78, \ > struct vhost_vdpa_iova_range) > + > +/* Get the config size */ > +#define VHOST_VDPA_GET_CONFIG_SIZE _IOR(VHOST_VIRTIO, 0x79, __u32) > + > #endif