Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp3640061rwi; Wed, 2 Nov 2022 01:05:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4va54U05svzP2d3Y4nGTQOND3cwr+rzyGL3iMRW4rgc2PaZ4ibgI0upkfL+REfhQhsgPrx X-Received: by 2002:a05:6402:5483:b0:45c:1336:6d9b with SMTP id fg3-20020a056402548300b0045c13366d9bmr23667640edb.100.1667376352578; Wed, 02 Nov 2022 01:05:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667376352; cv=none; d=google.com; s=arc-20160816; b=mwsJiMbZDU6PPZGrAeGTYxjP5w0eIh5rKplKxQ1YpcfNyiQZpME/VdLGvJ6IM3cBcv EE41CnIvut0JDRBl8OBbOnzA3GLSoOUCujv11uV5zIN+Kr3SWFcfBxjGziqZ0lTW3igX Zj93Pe+ndScJWv3q5mDqTKk2MjZHXuLkMpOo83UqcP9tf92kZ/DQ1vfL4B+p76ZLdKBi G7PYXwolnMKhGbbd9l/NH0Dem8apuxfMR5wDIrBPPRCGqPlIQDEZyhDtHXBZ2Oqxk6UB wIe0vW8biG0znUotLF9eEqNY+c77zqF3OwOBISEgCjHMHCXVYQESTukGIuFw3b8PzW75 Wirg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature :dkim-signature; bh=tjNciGfsgSgUkI6AndysubaRT3eHHI12Uie04qhAmh0=; b=qXUJIDA7uGR1Vcehbe1pEqFbJeSdUEoDggNA0/Lw4S2mBrB4a3LSrWxlPaYm0dOgom pxmKDihH0VkiGEicktfwmlBRDDnSpkZpm9GudXjZwjFeXtR+H3iNA2ZpX7XAX7odHyP1 pfeaXHsDPnjyti0Alat5FgA0cT6WioWsb6jnHzSA3WbhF2xtaKONFTqcMzN+6bUOjm+j h86rtQBiHcIrf5aVV56uz+a8T6kbzgZpKv56nl8Uf90NA3zwM1eXepBjAsxdM92aILoL m+FDypcxO/dxSowRhYsSwcA81TDrt6QQaLHr9giTEIAsP55Hs18Fg2vP0+HRGQYlHPEZ 756g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm3 header.b=UShU2c4U; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=abzirlul; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o3-20020a170906288300b0078dc3cb8b41si11146397ejd.507.2022.11.02.01.05.28; Wed, 02 Nov 2022 01:05:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@arndb.de header.s=fm3 header.b=UShU2c4U; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=abzirlul; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230381AbiKBHcF (ORCPT + 97 others); Wed, 2 Nov 2022 03:32:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229548AbiKBHcD (ORCPT ); Wed, 2 Nov 2022 03:32:03 -0400 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46A132528F; Wed, 2 Nov 2022 00:32:02 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id CE4F85C0082; Wed, 2 Nov 2022 03:31:59 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute3.internal (MEProxy); Wed, 02 Nov 2022 03:31:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; t=1667374319; x=1667460719; bh=tjNciGfsgS gUkI6AndysubaRT3eHHI12Uie04qhAmh0=; b=UShU2c4UuH9O0ddC5fHgnXw+P1 LHLgIobxEaT9eMmnEO2f+SZFwa4aOPnv6ZosuolyHg+EXWb7n4ZCSoL8Y/2iG2Pm SwcYhtqLWDuq5LM4htLEImoS13NKm4Gx8lKCBUp0567Hji4GFe6GHhtTTqx9Rgvt 5zskIIoLoSGnU7fg46WkAYB4gmIt+y1LEwvrY2pVxw0u60S+VQNrct94Do24T4ft xgR225H2HjFaCIHURz142zpaNZ+3rU+ifa3Q3T72vUcj2WfJIHSXj8NSCVXMYK25 EZg+CmKFZLDb2zQ+oFte3ivhlOB6riG91dVELjzOqNiPpcNwIQn7IGx7fyEw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1667374319; x=1667460719; bh=tjNciGfsgSgUkI6AndysubaRT3eH HI12Uie04qhAmh0=; b=abzirlulPfkSCDmgHgvxI5Q70zVdESHnHjiptECBSIT0 AfO+p7ct9hd6p/pzCJ7xfoFFYDKlJwzq5el0Uh2MNBRMSPa3+mvY0VjZx5l6uKd9 617YAa6kRy5oYhxIj3v4bhq4fEp/LDORNPqL4pDAkQZPN2xLfTiciOMGwy8f/0hl mePnKhSyHHmpz3MwUfEbVuxGNIq+7baEp2azz+RjOwTb/fRKjLJ5EhHf+vJltbny y42DCVTVJzjLSEUuwzBbMP20GS/HXFk+loFeKByaVXAWS+YpBCZ0HRUOQLPYdXAJ Rl1t4aTZgIwgNwhZRUUAE74sz0N2rmBIZPKddA3QYA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrudeigddutdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderredtnecuhfhrohhmpedftehr nhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrdguvgeqnecuggftrfgrth htvghrnhepffehueegteeihfegtefhjefgtdeugfegjeelheejueethfefgeeghfektdek teffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hrnhgusegrrhhnuggsrdguvg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 164CEB603D5; Wed, 2 Nov 2022 03:31:59 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-1087-g968661d8e1-fm-20221021.001-g968661d8 Mime-Version: 1.0 Message-Id: In-Reply-To: <20221026185846.3983888-14-quic_eberman@quicinc.com> References: <20221026185846.3983888-1-quic_eberman@quicinc.com> <20221026185846.3983888-14-quic_eberman@quicinc.com> Date: Wed, 02 Nov 2022 08:31:39 +0100 From: "Arnd Bergmann" To: "Elliot Berman" , "Bjorn Andersson" Cc: "Murali Nalajala" , "Trilok Soni" , "Srivatsa Vaddagiri" , "Carl van Schaik" , "Prakruthi Deepak Heragu" , "Andy Gross" , "Dmitry Baryshkov" , "Jassi Brar" , linux-arm-kernel@lists.infradead.org, "Mark Rutland" , "Lorenzo Pieralisi" , "Sudeep Holla" , "Marc Zyngier" , "Rob Herring" , "Krzysztof Kozlowski" , "Jonathan Corbet" , "Will Deacon" , "Catalin Marinas" , "Greg Kroah-Hartman" , "Srinivas Kandagatla" , "Amol Maheshwari" , "Kalle Valo" , devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 13/21] gunyah: vm_mgr: Introduce basic VM Manager Content-Type: text/plain X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 26, 2022, at 20:58, Elliot Berman wrote: > +static const struct file_operations gh_vm_fops = { > + .unlocked_ioctl = gh_vm_ioctl, > + .release = gh_vm_release, > + .llseek = noop_llseek, > +}; There should be a .compat_ioctl entry here, otherwise it is impossible to use from 32-bit tasks. If all commands have arguments passed through a pointer to a properly defined structure, you can just set it to compat_ptr_ioctl. > +static long gh_dev_ioctl_create_vm(unsigned long arg) > +{ > + struct gunyah_vm *ghvm; > + struct file *file; > + int fd, err; > + > + /* arg reserved for future use. */ > + if (arg) > + return -EINVAL; Do you have something specific in mind here? If 'create' is the only command you support, and it has no arguments, it would be easier to do it implicitly during open() and have each fd opened from /dev/gunyah represent a new VM. > + ghvm = gunyah_vm_alloc(); > + if (IS_ERR_OR_NULL(ghvm)) > + return PTR_ERR(ghvm) ? : -ENOMEM; If you find yourself using IS_ERR_OR_NULL(), you have usually made a mistake. In this case, the gunyah_vm_alloc() function is badly defined and should just return -ENOMEM for an allocation failure. > +static struct gunyah_rsc_mgr_device_id vm_mgr_ids[] = { > + { .name = GH_RM_DEVICE_VM_MGR }, > + {} > +}; > +MODULE_DEVICE_TABLE(gunyah_rsc_mgr, vm_mgr_ids); > + > +static struct gh_rm_driver vm_mgr_drv = { > + .drv = { > + .name = KBUILD_MODNAME, > + .probe = vm_mgr_probe, > + .remove = vm_mgr_remove, > + }, > + .id_table = vm_mgr_ids, > +}; > +module_gh_rm_driver(vm_mgr_drv); It looks like the gunyah_rsc_mgr_device_id in this case is purely internal to the kernel, so you are adding abstraction layers to something that does not need to be abstracted because the host side has no corresponding concept of devices. I'm correct, you can just turn the entire bus/device/driver structure within your code into simple function calls, where the main code calls vm_mgr_probe() as an exported function instead of creating a device. Arnd