Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp685449pxv; Fri, 9 Jul 2021 06:51:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkkLy6FvQxs66QN3t2VfKyyw88XVO9EsEqGPU5XyQz4fm7ahXSeIfSVbfiTFrlsrfeZPCt X-Received: by 2002:a05:6638:328e:: with SMTP id f14mr1678668jav.41.1625838682225; Fri, 09 Jul 2021 06:51:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625838682; cv=none; d=google.com; s=arc-20160816; b=Ul+vp8j7BIdfwaOrnHMuu7xTCQI6SFGqSCcxqd+TVedZppHTdoMS2KlPt/MoN6RB3w jD7xMs9D2xzkMKnTkZuEL/2kZMBYdKidm0fzfw7CjPTb2wF0ON1LO+gF9Q0Mv/2W+2Fu EN98rrYu1zmy+/MXGFwNEnX1i3/BAR3quf+5OQbGWlYR0oUDqPTHBgIFprZzM7Wa2xuE jiA3GhAs46GY0wqIQd7Q+4tYIy4Q/bb+hxXsUmekEBDEfZev1+UoreLm9bOaye4Be4eJ EPfZfcux2H8AIns8gDTQFZXGqRVo60z7J+Zfn5sA2uiqr6pZq5w5aPbRLSoGmBoXtnI1 MRag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=GoDqQzDQbxqFmqbu69TknlhRgwp/b+vsLpDJzZkaLpI=; b=GSQmw8j0P3vLIrKGbEurksSJ8GvXg+bWHAC8lYHQEU9Uqj2IlW7WHcUbcPx96KDULP /RD+z05JyIsc9KEJu78F45mnJMAx1YGYzDZCf68oyJNisP0DaWJlgBl0+h+JwTvi1BvU +nPgGYoB54lpJWq/XvsLBVEfvONvcr7+mtsjKngkJ0uZG38/k2TamBWdt0x3sUAJevS/ /D7hpzDfC4xXEKqeWLY/udrdHz+rwgcA1rDuPg9NghK/7bZRkdpdtfFukeWnDG2SYS99 Tjp9zh/Xu3huIg9hQHNHBWjPMSzx9hVtSP2PmTmLrnbx5OQxAgYp9LP8MJD8xuMfktvn h39A== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g9si6361683ilb.126.2021.07.09.06.51.08; Fri, 09 Jul 2021 06:51:22 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232051AbhGINxA (ORCPT + 99 others); Fri, 9 Jul 2021 09:53:00 -0400 Received: from mail-wr1-f44.google.com ([209.85.221.44]:34636 "EHLO mail-wr1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231454AbhGINxA (ORCPT ); Fri, 9 Jul 2021 09:53:00 -0400 Received: by mail-wr1-f44.google.com with SMTP id p8so12288720wrr.1; Fri, 09 Jul 2021 06:50:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GoDqQzDQbxqFmqbu69TknlhRgwp/b+vsLpDJzZkaLpI=; b=A7u/m/LMbrIXNThlyol64Vsn/TgD/P73G3UBPGZ981KTBK+fNByDp/tre4HLU1cBla T6zjLLyZLuB5OuFVcOxs/14QJF2ezPzoFI8t0r478NSkgsuaVuqZ9CT7lJmySowoxM9x yyf7ur2tjxFQAaeeINmXfqJtL4x61i42rCQFFRW/ogy+jRXW2HGcj6gE0gA8Uc8c2rws Dx03anX0kXN5E9E32Oo20AqM+eRm0L9r5uaN0ZRFrnJV0o5YAdifIF2snIokxM/2p76J lKNHh5TCVso4XhyegPY/TxSv25r7Swmphd1M4bY/0eqi2K3m3e5dSX1flv/0L0E/Yq9c tO6w== X-Gm-Message-State: AOAM532L45xRDRn1I4LAUIOJ7bCp825ayw43ZNFAQmJnS52RLAUi7VGe x6A2hEHXjJSIdCGqr2ZEPbU= X-Received: by 2002:a5d:6652:: with SMTP id f18mr16659403wrw.235.1625838615682; Fri, 09 Jul 2021 06:50:15 -0700 (PDT) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id g3sm5416303wrv.64.2021.07.09.06.50.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 06:50:15 -0700 (PDT) Date: Fri, 9 Jul 2021 13:50:13 +0000 From: Wei Liu To: Matthew Wilcox Cc: Wei Liu , Linux on Hyper-V List , virtualization@lists.linux-foundation.org, Linux Kernel List , Michael Kelley , Vineeth Pillai , Sunil Muthuswamy , Nuno Das Neves , kumarpraveen@linux.microsoft.com, pasha.tatashin@soleen.com, Jonathan Corbet , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Dexuan Cui , Lillian Grassin-Drake , Muminul Islam , "open list:DOCUMENTATION" Subject: Re: [RFC v1 7/8] mshv: implement in-kernel device framework Message-ID: <20210709135013.t5axinjmufotpylf@liuwe-devbox-debian-v2> References: <20210709114339.3467637-1-wei.liu@kernel.org> <20210709114339.3467637-8-wei.liu@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 09, 2021 at 02:02:04PM +0100, Matthew Wilcox wrote: > On Fri, Jul 09, 2021 at 11:43:38AM +0000, Wei Liu wrote: > > +static long > > +mshv_partition_ioctl_create_device(struct mshv_partition *partition, > > + void __user *user_args) > > +{ > [...] > > + mshv_partition_get(partition); > > + r = anon_inode_getfd(ops->name, &mshv_device_fops, dev, O_RDWR | O_CLOEXEC); > > + if (r < 0) { > > + mshv_partition_put_no_destroy(partition); > > + list_del(&dev->partition_node); > > + ops->destroy(dev); > > + goto out; > > + } > > + > > + cd->fd = r; > > + r = 0; > > Why return the fd in memory instead of returning the fd as the return > value from the ioctl? > > > + if (copy_to_user(user_args, &tmp, sizeof(tmp))) { > > + r = -EFAULT; > > + goto out; > > + } > > ... this could then disappear. Thanks for your comment, Matthew. This is intentionally because I didn't want to deviate from KVM's API. The fewer differences the better. Wei. >