Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2377637rdb; Mon, 11 Sep 2023 22:55:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFEqi7zKYBoKC8bQssBwm3xLO2z2Zf5Y5wMQ0wtDvcxdE21d7xoQ7yUlTQm8nylRGaB5yW8 X-Received: by 2002:a05:6870:812:b0:1d5:bda7:132d with SMTP id fw18-20020a056870081200b001d5bda7132dmr4858357oab.4.1694498119724; Mon, 11 Sep 2023 22:55:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694498119; cv=none; d=google.com; s=arc-20160816; b=VwBZW17fCm8zDgmHGCxhtSVA1RwkdNgrFtHJiK2xfrJaot6gyhRnEcyb0/M84jY6q3 ogN0SzhC2o6S7O0bhdr3MWhDhceeITbts5iih4Gb3RNSBGVSHBFQ/VG4WpvOVkkcN00/ wdlE6Y62sIZR1qbsfjJ0P7omMJN8rO6f0r35URT+EJuxAV03XVKwEQC4/Gqjn+HGrEtW iJkokQRcXi6QF4rDhwX4/zTQScS6Dy8UgehHzczcy41+5ZaTMh0QVApYxmDBfY4tTeYn Rds2OgBAYgyh2lKu1ijjpVY2b6Bt1AeIqurTNdUxuF5532Db2QY4URmngpkIdPGxA+rS l+dg== 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=WI0RMvdlyM2CoPU0JPuivhklmmTZZnT8q78FFwqlw28=; fh=E8uCy2UoKRrKjgDakfUdRLlW20LdfkTjtJs3toefLrk=; b=D6KgcMDVLmGS5vwPVeftRC6XRzZwJr0OpouVlKIEPpO5DdFS4zyWldDye2lsXDBH3i VAIGB/qMtimWmS2jIf9cwXAOPKThyCwMUk78d271k80VyS9tZB07a/JW9c05z6q5uSH2 zYgCcJnNXKvd2xnMNXdRt3I3lxvLeVXST9x6NqWQXp5U9aOulUBwgaARFFCaYPVl9cM+ ik9XOnykKpcM1NpIlWgpZ8iQkD3uwk10skt0Dn2kmZEIcVimvr66L713PFFadYtH2Q63 bObEjfOI8HkB50LKWyKExI9T9J5ANSM64+i+YP7uhebSQfWOLHOh99posZGroKZA7u5U Mg5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JfwhkaaV; 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 Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id i71-20020a63874a000000b00563de62f946si7229496pge.520.2023.09.11.22.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 22:55:19 -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=JfwhkaaV; 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 3CDCA828E876; Mon, 11 Sep 2023 21:31:43 -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 S237014AbjILDYw (ORCPT + 99 others); Mon, 11 Sep 2023 23:24:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236375AbjILDYd (ORCPT ); Mon, 11 Sep 2023 23:24:33 -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 ESMTP id D1C03296FD for ; Mon, 11 Sep 2023 20:01:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694487663; 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=WI0RMvdlyM2CoPU0JPuivhklmmTZZnT8q78FFwqlw28=; b=JfwhkaaVuDHhGVFg6tmhOJhvCGknF15HUKw/0J2yXa3In3K43e3Swptxx0l4WXLnLW226e sYyPUYo6BLLfMLnk70heg746W5cDuXIIZFs+ctLXYHNhRa5gH3euZKo+zPbOK1j5K00y3A GfCE1Lw7qqSjnnWe1WGPdn1TNyPdpec= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-281-ozpCd5wROgmlUEP7zF_bpA-1; Mon, 11 Sep 2023 23:00:59 -0400 X-MC-Unique: ozpCd5wROgmlUEP7zF_bpA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 488CB803C96; Tue, 12 Sep 2023 03:00:59 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7725110005D4; Tue, 12 Sep 2023 03:00:55 +0000 (UTC) From: Cindy Lu To: lulu@redhat.com, jasowang@redhat.com, mst@redhat.com, maxime.coquelin@redhat.com, xieyongji@bytedance.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org Cc: stable@vger.kernel.org Subject: [RFC v2 4/4] vduse: Add new ioctl VDUSE_GET_RECONNECT_INFO Date: Tue, 12 Sep 2023 11:00:08 +0800 Message-Id: <20230912030008.3599514-5-lulu@redhat.com> In-Reply-To: <20230912030008.3599514-1-lulu@redhat.com> References: <20230912030008.3599514-1-lulu@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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]); Mon, 11 Sep 2023 21:31:43 -0700 (PDT) In VDUSE_GET_RECONNECT_INFO, the Userspace App can get the map size and The number of mapping memory pages from the kernel. The userspace App can use this information to map the pages. Signed-off-by: Cindy Lu --- drivers/vdpa/vdpa_user/vduse_dev.c | 15 +++++++++++++++ include/uapi/linux/vduse.h | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index 680b23dbdde2..c99f99892b5c 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1368,6 +1368,21 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, ret = 0; break; } + case VDUSE_GET_RECONNECT_INFO: { + struct vduse_reconnect_mmap_info info; + + ret = -EFAULT; + if (copy_from_user(&info, argp, sizeof(info))) + break; + + info.size = PAGE_SIZE; + info.max_index = dev->vq_num + 1; + + if (copy_to_user(argp, &info, sizeof(info))) + break; + ret = 0; + break; + } default: ret = -ENOIOCTLCMD; break; diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h index d585425803fd..ce55e34f63d7 100644 --- a/include/uapi/linux/vduse.h +++ b/include/uapi/linux/vduse.h @@ -356,4 +356,19 @@ struct vhost_reconnect_vring { _Bool avail_wrap_counter; }; +/** + * struct vduse_reconnect_mmap_info + * @size: mapping memory size, always page_size here + * @max_index: the number of pages allocated in kernel,just + * use for check + */ + +struct vduse_reconnect_mmap_info { + __u32 size; + __u32 max_index; +}; + +#define VDUSE_GET_RECONNECT_INFO \ + _IOWR(VDUSE_BASE, 0x1b, struct vduse_reconnect_mmap_info) + #endif /* _UAPI_VDUSE_H_ */ -- 2.34.3