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