Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2299764rwi; Thu, 3 Nov 2022 15:27:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6FpY/Oe9zDQjR4+18R/QcLyTs4Knt9S0fmYHjOGfqwVUEjuaW6ColZmJhHEI/aHBcFbp0R X-Received: by 2002:a05:6402:528a:b0:454:8613:6560 with SMTP id en10-20020a056402528a00b0045486136560mr33409089edb.252.1667514471562; Thu, 03 Nov 2022 15:27:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667514471; cv=none; d=google.com; s=arc-20160816; b=hwVQCGbXWlZbOCtmpKc5QzqM50PGrsm4SGA/bJh0+TkWO79f2621ecr37w3sCIXDmJ DMPjIpFbrA6lObW81xrfC9pOUdC630fEEm02YZ7srgY9EA+SXkvAfma1vQ37vXBjbiwO Z9XUZ2JK7p3x2+YA+6GyqEdM+48OisyaFtZ+LRb0UDjXxucZ4vAT9l7M4CDkMeNq+WhP Rpny8MvZtF4p4/m+hMtwE1fGDkgqQniYbETF2xJsH5UPPH2vIbSW1IiHmO2ndiI9gJt/ hrV8MZWFVQtZ1j4n/Xiq0GYBSeXS8kk7Md3dkmTpwVdY5sJobdnGkwtZ0Q3fiSlFtgJV FOKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=xZE61lAZEQfrRgZey91ekR4uYDbgET9M8wWEPonC8yE=; b=V24gyytRm8CAKLoIRJfK7rIIb+n8YTVJZaIKx3WyCP8ExG2HwXQDWN1/zGRyfNPfmU zJWaVkt5SmiBKd/1pJOEXuvce6alxbUDnTJd3iD5EhOaQTF5YhWKnSNvM6yyT/QNwcpW yrpxq80elu7R1vsqPOsA2nv8v8yp139uQQucVclfP+XqjZGHCNg/uhb/w0OKSGbBx6SN O53CuAsVKhWt6IqCMkVu6MTl/+rZlrqk8mTotgHynSvQH1Ryb0emVvkJgimEUXUPxKHT jodH3Oc6vD083c1jWnOoA7pSroo3OtbHyX/VsgJ3sfxy+u0vFEvPaYlQANpZhEKdbUhM TXLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=OHzcDnsQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t3-20020a1709066bc300b0078d810e16a4si2454936ejs.486.2022.11.03.15.27.28; Thu, 03 Nov 2022 15:27:51 -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=@quicinc.com header.s=qcdkim header.b=OHzcDnsQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231682AbiKCWKQ (ORCPT + 97 others); Thu, 3 Nov 2022 18:10:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231648AbiKCWKL (ORCPT ); Thu, 3 Nov 2022 18:10:11 -0400 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81FC412E; Thu, 3 Nov 2022 15:10:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1667513410; x=1699049410; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=xZE61lAZEQfrRgZey91ekR4uYDbgET9M8wWEPonC8yE=; b=OHzcDnsQr1oaIffsQHHIWhROXELVY8cAQsmuaszxRDIIEuhN0gKGvfcB /mNkKOiu8OjXpm1s1/WceIAChR+SAXcXNwX82Dfrkbn17xIVFPGBe6nRm eA2HxXY2q7s2tlkQU6LWcdMlEawnKmcX6BmGYHE2XypZMt1Gte52fDKfc M=; Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-02.qualcomm.com with ESMTP; 03 Nov 2022 15:10:10 -0700 X-QCInternal: smtphost Received: from nasanex01b.na.qualcomm.com ([10.46.141.250]) by ironmsg-SD-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2022 15:10:10 -0700 Received: from [10.110.42.219] (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Thu, 3 Nov 2022 15:10:07 -0700 Message-ID: <25174792-4b8e-9c0d-0272-8b5010406365@quicinc.com> Date: Thu, 3 Nov 2022 15:10:07 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: Re: [PATCH v6 13/21] gunyah: vm_mgr: Introduce basic VM Manager Content-Language: en-US To: Arnd Bergmann , Bjorn Andersson , Dmitry Baryshkov CC: Murali Nalajala , Trilok Soni , Srivatsa Vaddagiri , Carl van Schaik , Prakruthi Deepak Heragu , Andy Gross , Jassi Brar , , "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 , , , , References: <20221026185846.3983888-1-quic_eberman@quicinc.com> <20221026185846.3983888-14-quic_eberman@quicinc.com> <7c59a115-36c5-c954-5610-ef5ef1dbb83e@quicinc.com> From: Elliot Berman In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01b.na.qualcomm.com (10.46.141.250) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,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 11/3/2022 2:39 AM, Arnd Bergmann wrote: > On Wed, Nov 2, 2022, at 19:44, Elliot Berman wrote: >> On 11/2/2022 12:31 AM, Arnd Bergmann wrote: >>>> +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. >>> >> >> I'd like the argument here to support different types of virtual >> machines. I want to leave open what "different types" can be in case >> something new comes up in the future, but immediately "different type" >> would correspond to a few different authentication mechanisms for >> virtual machines that Gunyah supports. >> >> In this series, I'm only supporting unauthenticated virtual machines >> because they are the simplest to get up and running from a Linux >> userspace. When I introduce the other authentication mechanisms, I'll >> expand much more on how they work, but I'll give quick overview here. >> Other authentication mechanisms that are currently supported by Gunyah >> are "protected VM" and, on Qualcomm platforms, "PIL/carveout VMs". >> Protected VMs are *loosely* similar to the protected firmware design for >> KVM and intended to support Android virtualization use cases. >> PIL/carevout VMs are special virtual machines that can run on Qualcomm >> firmware which authenticate in a way similar to remoteproc firmware (MDT >> loader). > > Ok, thanks for the background. Having different types of virtual > machines does mean that you may need some complexity, but I would > still lean towards using the simpler context management of opening > the /dev/gunyah device node to get a new context, and then using > ioctls on each fd to manage that context, instead of going through > the extra indirection of having a secondary 'open context' command > that always requires opening two file descriptors. > >>> 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. >> >> Ack. I can do this, although I am nervous about this snowballing into a >> situation where I have a mega-module. >> >> > Please stop beating everything in a single module. >> >> https://lore.kernel.org/all/250945d2-3940-9830-63e5-beec5f44010b@linaro.org/ > > I see you concern, but I wasn't suggesting having everything > in one module either. There are three common ways of splitting > things into separate modules: > > - I suggested having the vm_mgr module as a library block that > exports a few symbols which get used by the core module. The > module doesn't do anything on its own, but loading the core > module forces loading the vm_mgr. > Got the idea, I'll do this. - Elliot > - Alternatively one can do the opposite, and have symbols > exported by the core module, with the vm_mgr module using > it. This would make sense if you commonly have the core > module loaded on virtual machines that do not need to manage > other VMs. > > - The method you have is to have a lower "bus" level that > abstracts device providers from consumers, with both sides > hooking into the bus. This makes sense for physical buses > like PCI or USB where both the host driver and the function > driver are unaware of implementation details of the other, > but in your case it does not seem like a good fit. > > Arnd