From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A68B1C6379F for ; Thu, 16 Feb 2023 06:38:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229715AbjBPGiu (ORCPT ); Thu, 16 Feb 2023 01:38:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229710AbjBPGis (ORCPT ); Thu, 16 Feb 2023 01:38:48 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C98985FDA; Wed, 15 Feb 2023 22:38:27 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 639B7B8254D; Thu, 16 Feb 2023 06:38:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CEF8C433EF; Thu, 16 Feb 2023 06:38:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1676529505; bh=kNdtRxIM5pqt8Li3tt+4uiXP2y+kdvnnJ6b3JMf16Xs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uMJYwEtd+tcbfzRi+M9XL5TC9XkZRFA1w1ONhD+G3ZcY2Xe8XuMMGDhmqpSjCGIGN doHBY5sN2MOhDjZTv8S3R+4NJfdZH/JJMCG8CxsVhveug5EO3zu4aH03Pt0LT62xpw 7MjJHmk1oe4wpN8FQmXOwFqXoNU+aJTTqx3Da/ZA= Date: Thu, 16 Feb 2023 07:38:21 +0100 From: Greg Kroah-Hartman To: Elliot Berman Cc: Alex Elder , Srinivas Kandagatla , Prakruthi Deepak Heragu , Murali Nalajala , Trilok Soni , Srivatsa Vaddagiri , Carl van Schaik , Dmitry Baryshkov , Bjorn Andersson , Konrad Dybcio , Arnd Bergmann , Rob Herring , Krzysztof Kozlowski , Jonathan Corbet , Bagas Sanjaya , Catalin Marinas , Jassi Brar , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v10 12/26] gunyah: vm_mgr: Add/remove user memory regions Message-ID: References: <20230214211229.3239350-1-quic_eberman@quicinc.com> <20230214212417.3315422-1-quic_eberman@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230214212417.3315422-1-quic_eberman@quicinc.com> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On Tue, Feb 14, 2023 at 01:24:16PM -0800, Elliot Berman wrote: > > When launching a virtual machine, Gunyah userspace allocates memory for > the guest and informs Gunyah about these memory regions through > SET_USER_MEMORY_REGION ioctl. It also frees memory, see below. Why not document that? > + case GH_VM_SET_USER_MEM_REGION: { > + struct gh_userspace_memory_region region; > + > + if (copy_from_user(®ion, argp, sizeof(region))) > + return -EFAULT; > + > + /* All other flag bits are reserved for future use */ > + if (region.flags & ~(GH_MEM_ALLOW_READ | GH_MEM_ALLOW_WRITE | GH_MEM_ALLOW_EXEC | > + GH_MEM_LENT)) > + return -EINVAL; Nice, thanks for validating that. > + > + Nit, 2 blank lines are not needed :( > + if (region.memory_size) > + r = gh_vm_mem_alloc(ghvm, ®ion); > + else > + r = gh_vm_mem_free(ghvm, region.label); So if you set the size to 0 it is freed? Wouldn't a separate ioctl make more sense? Where is this logic documented to userspace? thanks, greg k-h From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0A4A9C636CC for ; Thu, 16 Feb 2023 06:39:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pNXYPbSPi9EEgatUyGT1F+NsbjOAOcb+6ggjRh4KEFQ=; b=bsd1CappnxmuQ+ hnYEoQ9oCISc8bgYBiBvgBgBpBCfYACkbL4oPIPyo2Fd1WeBJLLZErrtun1+r+pYRWdD9Ey20HQle khQ9LhfdqfWx/GxBcfZMcOfI6s8tWYYGKBmCwpl0UGjc44tt9yFK9D30GEINQ4KcWoYUkIaDAVHQd KQaWFtlHItYyRIzvuyLCU4hNo1t/YyT1j+czMlTouSv291pFRoZpLaVBLn8O2OvcCgvkGHvAEc6cT 6rZANLvMxTZgLPYqvGXaLLsbKLtKfAv5fr4IrEDTajApPA+v9TY7Zecq5WlzecO8P+gMMxvy2H6dE 9IKJJEp8t5J76K8zxCDw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSXuW-008hdn-Uy; Thu, 16 Feb 2023 06:38:29 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSXuU-008hd1-34 for linux-arm-kernel@lists.infradead.org; Thu, 16 Feb 2023 06:38:27 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 99ABE61E81; Thu, 16 Feb 2023 06:38:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CEF8C433EF; Thu, 16 Feb 2023 06:38:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1676529505; bh=kNdtRxIM5pqt8Li3tt+4uiXP2y+kdvnnJ6b3JMf16Xs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uMJYwEtd+tcbfzRi+M9XL5TC9XkZRFA1w1ONhD+G3ZcY2Xe8XuMMGDhmqpSjCGIGN doHBY5sN2MOhDjZTv8S3R+4NJfdZH/JJMCG8CxsVhveug5EO3zu4aH03Pt0LT62xpw 7MjJHmk1oe4wpN8FQmXOwFqXoNU+aJTTqx3Da/ZA= Date: Thu, 16 Feb 2023 07:38:21 +0100 From: Greg Kroah-Hartman To: Elliot Berman Cc: Alex Elder , Srinivas Kandagatla , Prakruthi Deepak Heragu , Murali Nalajala , Trilok Soni , Srivatsa Vaddagiri , Carl van Schaik , Dmitry Baryshkov , Bjorn Andersson , Konrad Dybcio , Arnd Bergmann , Rob Herring , Krzysztof Kozlowski , Jonathan Corbet , Bagas Sanjaya , Catalin Marinas , Jassi Brar , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v10 12/26] gunyah: vm_mgr: Add/remove user memory regions Message-ID: References: <20230214211229.3239350-1-quic_eberman@quicinc.com> <20230214212417.3315422-1-quic_eberman@quicinc.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230214212417.3315422-1-quic_eberman@quicinc.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230215_223826_193943_292EA5D2 X-CRM114-Status: GOOD ( 15.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Feb 14, 2023 at 01:24:16PM -0800, Elliot Berman wrote: > > When launching a virtual machine, Gunyah userspace allocates memory for > the guest and informs Gunyah about these memory regions through > SET_USER_MEMORY_REGION ioctl. It also frees memory, see below. Why not document that? > + case GH_VM_SET_USER_MEM_REGION: { > + struct gh_userspace_memory_region region; > + > + if (copy_from_user(®ion, argp, sizeof(region))) > + return -EFAULT; > + > + /* All other flag bits are reserved for future use */ > + if (region.flags & ~(GH_MEM_ALLOW_READ | GH_MEM_ALLOW_WRITE | GH_MEM_ALLOW_EXEC | > + GH_MEM_LENT)) > + return -EINVAL; Nice, thanks for validating that. > + > + Nit, 2 blank lines are not needed :( > + if (region.memory_size) > + r = gh_vm_mem_alloc(ghvm, ®ion); > + else > + r = gh_vm_mem_free(ghvm, region.label); So if you set the size to 0 it is freed? Wouldn't a separate ioctl make more sense? Where is this logic documented to userspace? thanks, greg k-h _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel