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 D9C59C7EE2E for ; Mon, 5 Jun 2023 19:50:13 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:References:Cc:To:Subject:From: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uDoupHiYKPA8qjsQM+jE2u2yNllfjFx63cwCLe6/YNY=; b=2idqjLBr7/fR2k OQvcO9O2uB9oEEOf4UFv80RIDLr77mK0jLqRTOPZmApX4FvhvoMnN4Oli/crYmvPxiPqN8ED66s0H 0w2nda8yrmnAPus+tpot1vFqsqfeEGlyOXzmegHs2LnQMLv48g4QTPQjvCajeRMyhjWJe4qbxcXso Jbb3Mhchk0+LrjDLozj0CMr8zjRE+7jTig+eBjKcQbHqN4+sB63/VwS5mdnruE5YNNyB0YOUg2miP dWb82PoMaU3U84djvdshw5dYZfcknod2cQxq21bMPV7tQjWcQAIH4cAtXq8H/P+2mXaKrzeDQcMdM Z+wnbSogmVK56vaO8pkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6GDB-00Gbxe-0Z; Mon, 05 Jun 2023 19:49:53 +0000 Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6GD8-00Gbwj-39 for linux-arm-kernel@lists.infradead.org; Mon, 05 Jun 2023 19:49:52 +0000 Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-777b2af1c53so78494139f.2 for ; Mon, 05 Jun 2023 12:49:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685994590; x=1688586590; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=cPlOjdlJ+dRPlBsswQpKMNmBPkhakhRaFVQ24sk5p48=; b=JfzQ4nFnxsDVVweSWRoSCcbfNulBTZT6AhFmi+GrblhAGn6SN9IyYc1Q9647sBsTVt 5A3awQZoHTqt1RX1Wg/y+Yu5XoboQeFoAv4LZioXXGarpJ3XdGzj7V6x39toEaKe8xkx 6T3rYZJWRHRKK/zrkJiuek556swCuPgBjcUlI0Md80mOQH8krj0JjbqziCLt8/YlhiDA td0e8yBRJMDomz+I7kuMIPsDBI+l+TP50udtaxGjpIxFrQNKRoYfB5uJRSACckH6tOe0 gxcqJIritft3hxsvAafmv0YyHrlZ0xGc0lB1nGxGXYRgxFj3NFUKTSqr+2YeLNQnzR9f SdVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685994590; x=1688586590; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cPlOjdlJ+dRPlBsswQpKMNmBPkhakhRaFVQ24sk5p48=; b=IO+Ur6AoZLCqDDw2YjCjRkaPJMyPqojSzv6bwZ1KXSFi9vmDUnqEHOSUP3gBI7E8w/ KyeS/xFGPiTRbma6Y0d32yl75diLW1J9VinzQ6M/rdB67fRDW1rI74Nwc0+knqVy508P CXzQsFk7bDrhM5ba2z3q7OtYLsLIJhSnvcesLyf0PkOrdGKnJQER+0Y3oXtceT1a4pA7 jNNafCTWc2vWNPufl87yDrtZ69QO8O8tlY2NyuogjUYo/68Jvb9385aruUm9NDB8tQUV 21XUUlX4aXqqAeFeF+UhzBIeb+UvcEgP8WiAW05I3uFYYwYzu0V8a401dIXzabKN2byk 6RzQ== X-Gm-Message-State: AC+VfDxEtkbTEA7HOVN9c00/Q/m/hOlj041OxWfIPgOSdiDdw2X9X1cC YM5IdPdHvk9qxe84GDCKIi0feA== X-Google-Smtp-Source: ACHHUZ6BgjxdZJaa9/9OIGfA+S4eoi5nWLa5slc+tS1TwE8UHFlKzkebBHIbP9/q7lYMkcbpshec8g== X-Received: by 2002:a5e:d710:0:b0:774:9c64:e0a4 with SMTP id v16-20020a5ed710000000b007749c64e0a4mr287414iom.4.1685994590054; Mon, 05 Jun 2023 12:49:50 -0700 (PDT) Received: from [172.22.22.28] ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id l22-20020a6bd116000000b0076c81bf2731sm2735824iob.20.2023.06.05.12.49.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Jun 2023 12:49:49 -0700 (PDT) Message-ID: <3dd82ec0-2a9a-3401-5385-965c624f9f32@linaro.org> Date: Mon, 5 Jun 2023 14:49:48 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 From: Alex Elder Subject: Re: [PATCH v13 17/24] gunyah: vm_mgr: Add framework for VM Functions To: Elliot Berman , Srinivas Kandagatla , Prakruthi Deepak Heragu , Jonathan Corbet Cc: Murali Nalajala , Trilok Soni , Srivatsa Vaddagiri , Carl van Schaik , Dmitry Baryshkov , Bjorn Andersson , Konrad Dybcio , Arnd Bergmann , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Bagas Sanjaya , Will Deacon , Andy Gross , 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 References: <20230509204801.2824351-1-quic_eberman@quicinc.com> <20230509204801.2824351-18-quic_eberman@quicinc.com> Content-Language: en-US In-Reply-To: <20230509204801.2824351-18-quic_eberman@quicinc.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230605_124951_015720_BCE930CC X-CRM114-Status: GOOD ( 32.09 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 5/9/23 3:47 PM, Elliot Berman wrote: > Introduce a framework for Gunyah userspace to install VM functions. VM > functions are optional interfaces to the virtual machine. vCPUs, > ioeventfs, and irqfds are examples of such VM functions and are s/ioventfs/ioventfds/ Also, these aren't just examples of VM functions, they *are* the VM functions implemented. > implemented in subsequent patches. > > A generic framework is implemented instead of individual ioctls to > create vCPUs, irqfds, etc., in order to simplify the VM manager core > implementation and allow dynamic loading of VM function modules. This also allows the set of VM functions to be extended without updating the API (like it or not). > > Signed-off-by: Elliot Berman I have a few more comments, but this looks pretty good. Reviewed-by: Alex Elder > --- > Documentation/virt/gunyah/vm-manager.rst | 18 ++ > drivers/virt/gunyah/vm_mgr.c | 216 ++++++++++++++++++++++- > drivers/virt/gunyah/vm_mgr.h | 4 + > include/linux/gunyah_vm_mgr.h | 87 +++++++++ > include/uapi/linux/gunyah.h | 18 ++ > 5 files changed, 340 insertions(+), 3 deletions(-) > create mode 100644 include/linux/gunyah_vm_mgr.h > > diff --git a/Documentation/virt/gunyah/vm-manager.rst b/Documentation/virt/gunyah/vm-manager.rst > index 50d8ae7fabcd..3b51bab9d793 100644 > --- a/Documentation/virt/gunyah/vm-manager.rst > +++ b/Documentation/virt/gunyah/vm-manager.rst > @@ -17,6 +17,24 @@ sharing userspace memory with a VM is done via the `GH_VM_SET_USER_MEM_REGION`_ > ioctl. The VM itself is configured to use the memory region via the > devicetree. > > +Gunyah Functions > +================ > + > +Components of a Gunyah VM's configuration that need kernel configuration are > +called "functions" and are built on top of a framework. Functions are identified > +by a string and have some argument(s) to configure them. They are typically > +created by the `GH_VM_ADD_FUNCTION`_ ioctl. Is a function *type* (e.g., VCPU or ioeventfd) identified by a string? Or a function *instance* (e.g. four VCPUs)? Or both? > + > +Functions typically will always do at least one of these operations: Typically, or always? > + > +1. Create resource ticket(s). Resource tickets allow a function to register > + itself as the client for a Gunyah resource (e.g. doorbell or vCPU) and > + the function is given the pointer to the &struct gh_resource when the > + VM is starting. > + What I think this means is that tickets are used to allow functions to be defined *before* the VM is actually started. So once it starts, the functions get added. (I might have this slightly wrong, but in any case I'm not sure the above sentence is very clear.) > +2. Register IO handler(s). IO handlers allow a function to handle stage-2 faults > + from the virtual machine. > + > Sample Userspace VMM > ==================== > > diff --git a/drivers/virt/gunyah/vm_mgr.c b/drivers/virt/gunyah/vm_mgr.c > index a800061f56bf..56464451b262 100644 > --- a/drivers/virt/gunyah/vm_mgr.c > +++ b/drivers/virt/gunyah/vm_mgr.c > @@ -6,10 +6,13 @@ > #define pr_fmt(fmt) "gh_vm_mgr: " fmt > > #include > +#include > #include > #include > +#include > #include > #include > +#include > > #include > > @@ -17,6 +20,172 @@ > > static void gh_vm_free(struct work_struct *work); > > +static DEFINE_XARRAY(gh_vm_functions); > + > +static void gh_vm_put_function(struct gh_vm_function *fn) > +{ > + module_put(fn->mod); > +} > + > +static struct gh_vm_function *gh_vm_get_function(u32 type) > +{ > + struct gh_vm_function *fn; > + int r; > + > + fn = xa_load(&gh_vm_functions, type); > + if (!fn) { > + r = request_module("ghfunc:%d", type); > + if (r) > + return ERR_PTR(r > 0 ? -r : r); Almost all callers of request_module() simply ignore the return value. What positive values are you expecting to see here (and are you sure they're positive errno values)? > + > + fn = xa_load(&gh_vm_functions, type); > + } > + > + if (!fn || !try_module_get(fn->mod)) > + fn = ERR_PTR(-ENOENT); > + > + return fn; > +} . . . _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel