From patchwork Mon Sep 13 22:41:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 12490905 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-22.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE87EC433F5 for ; Mon, 13 Sep 2021 22:42:24 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 92D26610D2 for ; Mon, 13 Sep 2021 22:42:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 92D26610D2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.185979.334722 (Exim 4.92) (envelope-from ) id 1mPueG-0005dn-9V; Mon, 13 Sep 2021 22:42:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 185979.334722; Mon, 13 Sep 2021 22:42:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mPueG-0005dg-5O; Mon, 13 Sep 2021 22:42:00 +0000 Received: by outflank-mailman (input) for mailman id 185979; Mon, 13 Sep 2021 22:41:59 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mPueF-0005da-JS for xen-devel@lists.xenproject.org; Mon, 13 Sep 2021 22:41:59 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a117f107-84ac-475c-b895-4fad6ab2bda8; Mon, 13 Sep 2021 22:41:58 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 6BC8560EE5; Mon, 13 Sep 2021 22:41:57 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a117f107-84ac-475c-b895-4fad6ab2bda8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631572917; bh=i4LeucUZLkdN7pXKmEjyTssQ6r/JJQqxLWYz7r6pC3k=; h=Date:From:To:cc:Subject:From; b=JsNe0fliB/whyFslve9Un8WbgWFs0Wm2ZlE/vynYnDzdvoEm6Mtx82r65EFEtGs94 k6f/Hd79mdwZDDALsTtoj0SHwPlYXM6/9QWc2w6EuMeoQmm4ZE1I7kJRVhwcRPRxdw 7HkVH5ffMuu8MVL+oyoK9FFkoZAZ2PD3+26ljnGqQYxpNnbOcgh8edcsNdNjqZ6JXi KGnclL7NLMRtz8M9qMOm1ArQudtRghefiD3lcroIJ65DiduS1RmyoveOkUeCPM4LZC c06gE+EvtrcpHFGRpetEoFGFa+uwqN0Qyna5q1yG+AsRm1oL/LWBpXpsrP74VWZ0oA 8e3d+1NsgOtfA== Date: Mon, 13 Sep 2021 15:41:56 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-T480s To: xen-devel@lists.xenproject.org cc: sstabellini@kernel.org, Bertrand.Marquis@arm.com, Alec.Kwapis@dornerworks.com, christopher.w.clark@gmail.com Subject: Dom0less + Argo enablement Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-ID: Hi all, This email is for anybody interested in using Argo with Dom0less setups for domain-to-domain communications. Argo is a secure VM-to-VM communication mechanism based on hypercalls [1]. It is a good fit for Dom0less setups because Argo is lightweight and doesn't make use of PV frontends, backends, and xenstore. Thus, it is easier to enable in simple Dom0less setups where VMs are booting in parallel, backends cannot be assumed to be already up and running, and the goal is just to get two VMs to talk to each others. Argo makes use of event channels for notifications. Dom0less VMs don't have event channels support yet, although it is work-in-progress. The attached patch for Linux (not ready for upstreaming) enables the necessary event channels initialization. In addition, you also need to add the following to the DomU device tree (see xen/arch/arm/domain_build.c:prepare_dtb_domU): event-channel { compatible = "xen,xen-4.15", "xen,xen"; interrupts = <0x01 0x0f 0xf08>; interrupt-parent = <0xfde8>; }; The final pieces to enable Argo are: - CONFIG_ARGO in the Xen build - the Argo Linux kernel module https://github.com/OpenXT/linux-xen-argo - the Yocto recipe was based on https://github.com/dozylynx/meta-argo-linux - pass dom0less_domU to the domU kernel command line Then you are good to go for using Argo in your Dom0less VMs, e.g.: From receiver domain: streamTest -domid 5 -port 8022 -file test.txt -receive From sender domain: streamTest -domid 4 -port 8022 -file test.txt -send -connect Many thanks to Alec Kwapis from DornerWorks for all the information and the patch! Cheers, Stefano [1] https://wiki.xenproject.org/wiki/Argo:_Hypervisor-Mediated_Exchange_(HMX)_for_Xen From 6486a0d73d3d422f54f8b579a3550160098fcc93 Mon Sep 17 00:00:00 2001 From: Alec Kwapis Date: Wed, 8 Sep 2021 09:01:46 -0400 Subject: [PATCH] Perform Xen Initialization in Dom0less This patch allows some Xen initialization to occur during the boot process of the Linux kernel. This already occurs for guests in a Dom0-managed configuration, however, the xen_domain() API will evaluate to false for guests in a Dom0less configuration. Therefore, a Linux kernel command line argument was added ("dom0less_domU") which signifies that Linux is being booted as a guest in Dom0less. This allows certain initialization to occur, such as event channels and the shared info page. This does not include grant table initialization. This patch is necessary in getting Argo to work in Dom0less, which requires both Xen event channels for the Argo virtual interrupt, and the shared info page. Signed-off-by: Alec Kwapis --- arch/arm/xen/enlighten.c | 25 +++++++++++++++---------- init/main.c | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index dd6804a64f1a..0c216b1ff279 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -36,6 +36,8 @@ #include +extern bool dom0less_domU; + struct start_info _xen_start_info; struct start_info *xen_start_info = &_xen_start_info; EXPORT_SYMBOL(xen_start_info); @@ -311,7 +313,7 @@ static int __init xen_guest_init(void) struct shared_info *shared_info_page = NULL; int cpu; - if (!xen_domain()) + if (!xen_domain() && !dom0less_domU) return 0; if (!acpi_disabled) @@ -362,16 +364,19 @@ static int __init xen_guest_init(void) for_each_possible_cpu(cpu) per_cpu(xen_vcpu_id, cpu) = cpu; - xen_auto_xlat_grant_frames.count = gnttab_max_grant_frames(); - if (xen_xlate_map_ballooned_pages(&xen_auto_xlat_grant_frames.pfn, - &xen_auto_xlat_grant_frames.vaddr, - xen_auto_xlat_grant_frames.count)) { - free_percpu(xen_vcpu_info); - return -ENOMEM; + if (xen_domain() && !dom0less_domU) + { + xen_auto_xlat_grant_frames.count = gnttab_max_grant_frames(); + if (xen_xlate_map_ballooned_pages(&xen_auto_xlat_grant_frames.pfn, + &xen_auto_xlat_grant_frames.vaddr, + xen_auto_xlat_grant_frames.count)) { + free_percpu(xen_vcpu_info); + return -ENOMEM; + } + gnttab_init(); + if (!xen_initial_domain()) + xenbus_probe(NULL); } - gnttab_init(); - if (!xen_initial_domain()) - xenbus_probe(NULL); /* * Making sure board specific code will not set up ops for diff --git a/init/main.c b/init/main.c index 91f6ebb30ef0..917cd60a8997 100644 --- a/init/main.c +++ b/init/main.c @@ -149,6 +149,24 @@ static char *ramdisk_execute_command; bool static_key_initialized __read_mostly; EXPORT_SYMBOL_GPL(static_key_initialized); +/* + * If set, this is an indication that Linux will be booted in a Xen dom0less + * configuration. This is necessary because the current xen_domain() API evaluates + * to false for dom0less domains on ARM, but the Linux kernel still needs to know + * that it is being booted in Xen to setup Xen features such as event channels and + * the shared info page. + */ +bool dom0less_domU = false; +EXPORT_SYMBOL(dom0less_domU); + +static int __init set_dom0less_domU(char *str) +{ + dom0less_domU = true; + return 1; +} + +__setup("dom0less_domU", set_dom0less_domU); + /* * If set, this is an indication to the drivers that reset the underlying * device before going ahead with the initialization otherwise driver might -- 2.25.1