From nobody Fri May 3 12:09:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1615203399; cv=none; d=zohomail.com; s=zohoarc; b=RjqQVXWjyM+R5TRJLPJ6//D4I0exrKSs7Y6MezbbzJFlS71ACWfbF5ETDOZqWf/h7it/QZFpAHBwxQedTVQVUh20KczXf/g9U8ZY++NLZZVQfCJsmvLTv0oafoxkRVWdI9eLSjNK1h1hvMLHRwgp9O4bC7dQ28dg/S/PtF0yEqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615203399; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=w+fK6aRWLCW9tMnIyAs9a+UrZRLFc3fZFZbMF4XW7eg=; b=fa5/13uOZVxAMJ4QmUhHPT4NkChFX3IoazmzKGdBPZiHeG4JmVNTKpOvUjU9YFWev07Y4Mj5zrRJ0TQRV7N34RVOZMX+qdVk5Nm7VaNkHbDnPddRrN/xXWWNLgjY6+v9mLWD5e4WRAQqfxT7RQot1WScKR+CZhG8qR2mketGBic= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1615203399424260.93887178943874; Mon, 8 Mar 2021 03:36:39 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.94805.178545 (Exim 4.92) (envelope-from ) id 1lJEBW-0007Rq-0s; Mon, 08 Mar 2021 11:36:26 +0000 Received: by outflank-mailman (output) from mailman id 94805.178545; Mon, 08 Mar 2021 11:36:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lJEBV-0007Rj-U7; Mon, 08 Mar 2021 11:36:25 +0000 Received: by outflank-mailman (input) for mailman id 94805; Mon, 08 Mar 2021 11:36:25 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lJEBV-0007Rb-AZ for xen-devel@lists.xenproject.org; Mon, 08 Mar 2021 11:36:25 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 43f93126-dfc4-4871-ac97-580dbff9d0bb; Mon, 08 Mar 2021 11:36:23 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 71A6ED6E; Mon, 8 Mar 2021 03:36:23 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.197.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7AE0D3F73C; Mon, 8 Mar 2021 03:36:22 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 43f93126-dfc4-4871-ac97-580dbff9d0bb From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, wei.chen@arm.com, Stefano Stabellini , Julien Grall , Volodymyr Babchuk Subject: [PATCH] xen/arm: Prevent Dom0 to be loaded when using dom0less Date: Mon, 8 Mar 2021 11:36:04 +0000 Message-Id: <20210308113604.12961-1-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch prevents the dom0 to be loaded skipping its building and going forward to build domUs when the dom0 kernel is not found and at least one domU is present. Signed-off-by: Luca Fancellu Change-Id: Ieb9630b80cc7be7688d7d5fff3f839958f142ac0 --- xen/arch/arm/setup.c | 83 +++++++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 24 deletions(-) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 2532ec9739..6d169ff6ce 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -794,6 +794,35 @@ static void __init setup_mm(void) } #endif =20 +static bool __init is_dom0less_mode(void) +{ + struct bootmodules *mods =3D &bootinfo.modules; + struct bootmodule *mod; + unsigned int i; + bool dom0found =3D false; + bool domUfound =3D false; + + /* Look into the bootmodules */ + for ( i =3D 0 ; i < mods->nr_mods ; i++ ) + { + mod =3D &mods->module[i]; + /* Find if dom0 and domU kernels are present */ + if ( mod->kind =3D=3D BOOTMOD_KERNEL ) + { + if ( mod->domU =3D=3D false ) + dom0found =3D true; + else + domUfound =3D true; + } + } + + /* + * If there is no dom0 kernel but at least one domU, then we are in + * dom0less mode + */ + return ( !dom0found && domUfound ); +} + size_t __read_mostly dcache_line_bytes; =20 /* C entry point for boot CPU */ @@ -804,7 +833,7 @@ void __init start_xen(unsigned long boot_phys_offset, int cpus, i; const char *cmdline; struct bootmodule *xen_bootmodule; - struct domain *dom0; + struct domain *dom0 =3D NULL; struct xen_domctl_createdomain dom0_cfg =3D { .flags =3D XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap, .max_evtchn_port =3D -1, @@ -964,28 +993,33 @@ void __init start_xen(unsigned long boot_phys_offset, apply_alternatives_all(); enable_errata_workarounds(); =20 - /* Create initial domain 0. */ - /* The vGIC for DOM0 is exactly emulating the hardware GIC */ - dom0_cfg.arch.gic_version =3D XEN_DOMCTL_CONFIG_GIC_NATIVE; - /* - * Xen vGIC supports a maximum of 992 interrupt lines. - * 32 are substracted to cover local IRQs. - */ - dom0_cfg.arch.nr_spis =3D min(gic_number_lines(), (unsigned int) 992) = - 32; - if ( gic_number_lines() > 992 ) - printk(XENLOG_WARNING "Maximum number of vGIC IRQs exceeded.\n"); - dom0_cfg.arch.tee_type =3D tee_get_type(); - dom0_cfg.max_vcpus =3D dom0_max_vcpus(); - - if ( iommu_enabled ) - dom0_cfg.flags |=3D XEN_DOMCTL_CDF_iommu; - - dom0 =3D domain_create(0, &dom0_cfg, true); - if ( IS_ERR(dom0) || (alloc_dom0_vcpu0(dom0) =3D=3D NULL) ) - panic("Error creating domain 0\n"); - - if ( construct_dom0(dom0) !=3D 0) - panic("Could not set up DOM0 guest OS\n"); + if ( !is_dom0less_mode() ) + { + /* Create initial domain 0. */ + /* The vGIC for DOM0 is exactly emulating the hardware GIC */ + dom0_cfg.arch.gic_version =3D XEN_DOMCTL_CONFIG_GIC_NATIVE; + /* + * Xen vGIC supports a maximum of 992 interrupt lines. + * 32 are substracted to cover local IRQs. + */ + dom0_cfg.arch.nr_spis =3D min(gic_number_lines(), (unsigned int) 9= 92) - 32; + if ( gic_number_lines() > 992 ) + printk(XENLOG_WARNING "Maximum number of vGIC IRQs exceeded.\n= "); + dom0_cfg.arch.tee_type =3D tee_get_type(); + dom0_cfg.max_vcpus =3D dom0_max_vcpus(); + + if ( iommu_enabled ) + dom0_cfg.flags |=3D XEN_DOMCTL_CDF_iommu; + + dom0 =3D domain_create(0, &dom0_cfg, true); + if ( IS_ERR(dom0) || (alloc_dom0_vcpu0(dom0) =3D=3D NULL) ) + panic("Error creating domain 0\n"); + + if ( construct_dom0(dom0) !=3D 0) + panic("Could not set up DOM0 guest OS\n"); + } + else + printk(XENLOG_INFO "Xen dom0less mode detected\n"); =20 heap_init_late(); =20 @@ -1003,7 +1037,8 @@ void __init start_xen(unsigned long boot_phys_offset, if ( acpi_disabled ) create_domUs(); =20 - domain_unpause_by_systemcontroller(dom0); + if ( dom0 ) + domain_unpause_by_systemcontroller(dom0); =20 /* Switch on to the dynamically allocated stack for the idle vcpu * since the static one we're running on is about to be freed. */ --=20 2.17.1