Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp769081pxv; Fri, 9 Jul 2021 08:34:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3oxfasXXvY9eW2dCc05whVhA66jEVxawwg2EJKrS61LdqaeksERV3XdV1zVXLvosKs0d1 X-Received: by 2002:aa7:db93:: with SMTP id u19mr47432519edt.227.1625844892034; Fri, 09 Jul 2021 08:34:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625844892; cv=none; d=google.com; s=arc-20160816; b=ti1fF55Nk91FfaDui0yZ7X0Ndl5Kt4agpbqExNUk8CiOlAEcWqWsGOI8wIedJ5qCJ5 BOtInpH0FzFqxjTv4rci5h1sZruUpJF+4ZVPuKkf4CsCt/1ViGQcBP2YqC3QQOxfeWjh kRGDj52EK0It1vQshHveDH5D6BNf/q44K6Q3pv63Tww3ODl7cS83bY/rfEGYlUbmU6xy V7uIRpfEM3OpHqmRXcgprEMTT5tQA75lxTiHFrakPLWSuNLPq5dOJFmyFcf1RmJxa+5L /UZ6vxuiVrOutd8QreBq5KonO3pB5+/VM5yWQ08N/LwzfLjKQQUKr7BkV5MWq290E2sR RSsA== 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:dkim-signature; bh=y7YLHiF0t+l7CAiXRoEvkaZFeIRtHz06yPRep3Kg/LM=; b=x+GIzIxQFCR3utEqEmHVyd8GpKNql5klD2TxnfJbpVUr/iQgKnkoCmr1ZtB/NJMtog MH/YrH2sj2Qz7PreowI4ZXAoHzIWwqsMONVvKh5Bh60BiTlfGU+Pj3pYTOxyn7D3M5hc uUox/hPGtjNA2wkf88BV7JZHJXX4D8LRv6R1pLo+u8HqBgFyBgGI1THj1TTSOshviXIw TxHbOFdfcVqWd1TafTcAOd4cAlOAUfhNsk9RCpqhRS6/+gZ08K/DQ6ohjG9BTQGsvDui a+Mw7wP6CWlMiyAWplY5XXy4hINnVvgGi6zzN/sUQPt0+6uUj1kwmADKENS1Tykp/6zH PRkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cBaSGviw; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 23si8189507ejg.238.2021.07.09.08.34.05; Fri, 09 Jul 2021 08:34:52 -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=@infradead.org header.s=casper.20170209 header.b=cBaSGviw; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232328AbhGIPfn (ORCPT + 99 others); Fri, 9 Jul 2021 11:35:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231976AbhGIPfn (ORCPT ); Fri, 9 Jul 2021 11:35:43 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C23C6C0613DD; Fri, 9 Jul 2021 08:32:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=y7YLHiF0t+l7CAiXRoEvkaZFeIRtHz06yPRep3Kg/LM=; b=cBaSGviwrp/QKpIQbEzA+mZFQt gwNGWcl04gu8kPnL199xu/bBhXuhbNZRbCFyLnnY6WTYlGlXWVhJu0+MXdkdYFiI/6yYbV3bl32s0 JWG9A0CdPvNcpYS1YUnAv8QgA/UymEqfFn8bzWbKCHXwaWKUDNvPXQ16pM55my0DJt0ntdPFILt4E uN2RM+XpsviEXdDjdC1SiPe1jN9t9R/U9mYpIViX4Ug97nhwdepiGqHj5+kYfhd7C7tMCdpr1/Ae2 JmCWzLhVPcTns+75Q1+sGe6vZFgLsSZR8BPvVXWz3N6IghXCyUFWCizmSgFMHhPnolCcE43NaSgk5 Rn3Q10SQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m1sUi-00EdZV-PT; Fri, 09 Jul 2021 15:32:50 +0000 Date: Fri, 9 Jul 2021 16:32:48 +0100 From: Matthew Wilcox To: Wei Liu Cc: 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: References: <20210709114339.3467637-1-wei.liu@kernel.org> <20210709114339.3467637-8-wei.liu@kernel.org> <20210709135013.t5axinjmufotpylf@liuwe-devbox-debian-v2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210709135013.t5axinjmufotpylf@liuwe-devbox-debian-v2> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 09, 2021 at 01:50:13PM +0000, Wei Liu wrote: > 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. Then don't define your own structure. Use theirs.