From: Stefano Stabellini <sstabellini@kernel.org> To: xen-devel@lists.xenproject.org Cc: sstabellini@kernel.org, jgross@suse.com, Bertrand.Marquis@arm.com, julien@xen.org, Volodymyr_Babchuk@epam.com, Stefano Stabellini <stefano.stabellini@xilinx.com>, Luca Fancellu <luca.fancellu@arm.com>, Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>, Julien Grall <jgrall@amazon.com> Subject: [PATCH v7 2/7] xen/arm: implement domU extended regions Date: Fri, 13 May 2022 14:07:25 -0700 [thread overview] Message-ID: <20220513210730.679871-2-sstabellini@kernel.org> (raw) In-Reply-To: <alpine.DEB.2.22.394.2205131405550.3842@ubuntu-linux-20-04-desktop> From: Stefano Stabellini <stefano.stabellini@xilinx.com> Implement extended regions for dom0less domUs. The implementation is based on the libxl implementation. Also update docs for the ext_regions command line option. Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com> Reviewed-by: Luca Fancellu <luca.fancellu@arm.com> Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> Acked-by: Julien Grall <jgrall@amazon.com> --- Changes in v6: - add reviewed-by - address 2 NITs - update docs Changes in v5: - print the domain - coding style - simplify the code in find_domU_holes - return error if no regions allocated in find_domU_holes - use ROUNDUP - uint64_t/paddr_t --- docs/misc/xen-command-line.pandoc | 9 ++--- xen/arch/arm/domain_build.c | 60 ++++++++++++++++++++++++++----- 2 files changed, 56 insertions(+), 13 deletions(-) --- docs/misc/xen-command-line.pandoc | 9 ++--- xen/arch/arm/domain_build.c | 60 ++++++++++++++++++++++++++----- 2 files changed, 56 insertions(+), 13 deletions(-) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc index 1dc7e1ca07..881fe409ac 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -1110,11 +1110,12 @@ to use the default. > Default : `true` -Flag to enable or disable support for extended regions for Dom0. +Flag to enable or disable support for extended regions for Dom0 and +Dom0less DomUs. -Extended regions are ranges of unused address space exposed to Dom0 as -"safe to use" for special memory mappings. Disable if your board device -tree is incomplete. +Extended regions are ranges of unused address space exposed to the guest +as "safe to use" for special memory mappings. Disable if your board +device tree is incomplete. ### flask > `= permissive | enforcing | late | disabled` diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index aa777741bd..c4dd211b91 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -35,7 +35,10 @@ static unsigned int __initdata opt_dom0_max_vcpus; integer_param("dom0_max_vcpus", opt_dom0_max_vcpus); -/* If true, the extended regions support is enabled for dom0 */ +/* + * If true, the extended regions support is enabled for dom0 and + * dom0less domUs. + */ static bool __initdata opt_ext_regions = true; boolean_param("ext_regions", opt_ext_regions); @@ -1327,6 +1330,36 @@ out: return res; } +static int __init find_domU_holes(const struct kernel_info *kinfo, + struct meminfo *ext_regions) +{ + unsigned int i; + paddr_t bankend; + const paddr_t bankbase[] = GUEST_RAM_BANK_BASES; + const paddr_t banksize[] = GUEST_RAM_BANK_SIZES; + int res = -ENOENT; + + for ( i = 0; i < GUEST_RAM_BANKS; i++ ) + { + struct membank *ext_bank = &(ext_regions->bank[ext_regions->nr_banks]); + + ext_bank->start = ROUNDUP(bankbase[i] + kinfo->mem.bank[i].size, SZ_2M); + + bankend = ~0ULL >> (64 - p2m_ipa_bits); + bankend = min(bankend, bankbase[i] + banksize[i] - 1); + if ( bankend > ext_bank->start ) + ext_bank->size = bankend - ext_bank->start + 1; + + /* 64MB is the minimum size of an extended region */ + if ( ext_bank->size < MB(64) ) + continue; + ext_regions->nr_banks++; + res = 0; + } + + return res; +} + static int __init make_hypervisor_node(struct domain *d, const struct kernel_info *kinfo, int addrcells, int sizecells) @@ -1363,12 +1396,13 @@ static int __init make_hypervisor_node(struct domain *d, if ( !opt_ext_regions ) { - printk(XENLOG_INFO "The extended regions support is disabled\n"); + printk(XENLOG_INFO "%pd: extended regions support is disabled\n", d); nr_ext_regions = 0; } else if ( is_32bit_domain(d) ) { - printk(XENLOG_WARNING "The extended regions are only supported for 64-bit guest currently\n"); + printk(XENLOG_WARNING + "%pd: extended regions not supported for 32-bit guests\n", d); nr_ext_regions = 0; } else @@ -1377,13 +1411,21 @@ static int __init make_hypervisor_node(struct domain *d, if ( !ext_regions ) return -ENOMEM; - if ( !is_iommu_enabled(d) ) - res = find_unallocated_memory(kinfo, ext_regions); + if ( is_domain_direct_mapped(d) ) + { + if ( !is_iommu_enabled(d) ) + res = find_unallocated_memory(kinfo, ext_regions); + else + res = find_memory_holes(kinfo, ext_regions); + } else - res = find_memory_holes(kinfo, ext_regions); + { + res = find_domU_holes(kinfo, ext_regions); + } if ( res ) - printk(XENLOG_WARNING "Failed to allocate extended regions\n"); + printk(XENLOG_WARNING "%pd: failed to allocate extended regions\n", + d); nr_ext_regions = ext_regions->nr_banks; } @@ -1404,8 +1446,8 @@ static int __init make_hypervisor_node(struct domain *d, u64 start = ext_regions->bank[i].start; u64 size = ext_regions->bank[i].size; - printk("Extended region %d: %#"PRIx64"->%#"PRIx64"\n", - i, start, start + size); + printk("%pd: extended region %d: %#"PRIx64"->%#"PRIx64"\n", + d, i, start, start + size); dt_child_set_range(&cells, addrcells, sizecells, start, size); } -- 2.25.1
next prev parent reply other threads:[~2022-05-13 21:07 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-05-13 21:07 [PATCH v7 0/7] dom0less PV drivers Stefano Stabellini 2022-05-13 21:07 ` [PATCH v7 1/7] xen/dt: of_property_read_string return -ENODATA when !length Stefano Stabellini 2022-05-13 21:07 ` Stefano Stabellini [this message] 2022-05-13 21:07 ` [PATCH v7 3/7] xen: introduce xen,enhanced dom0less property Stefano Stabellini 2022-05-14 13:23 ` Julien Grall 2022-05-13 21:07 ` [PATCH v7 4/7] xen/arm: configure dom0less domain for enabling xenstore after boot Stefano Stabellini 2022-05-13 21:07 ` [PATCH v7 5/7] xenstored: send an evtchn notification on introduce_domain Stefano Stabellini 2022-05-23 6:06 ` Juergen Gross 2022-05-13 21:07 ` [PATCH v7 6/7] tools: add example application to initialize dom0less PV drivers Stefano Stabellini 2022-05-14 16:19 ` Julien Grall 2022-05-24 23:34 ` Stefano Stabellini 2022-05-13 21:07 ` [PATCH v7 7/7] docs: document dom0less + " Stefano Stabellini
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220513210730.679871-2-sstabellini@kernel.org \ --to=sstabellini@kernel.org \ --cc=Bertrand.Marquis@arm.com \ --cc=Volodymyr_Babchuk@epam.com \ --cc=jgrall@amazon.com \ --cc=jgross@suse.com \ --cc=julien@xen.org \ --cc=luca.fancellu@arm.com \ --cc=oleksandr_tyshchenko@epam.com \ --cc=stefano.stabellini@xilinx.com \ --cc=xen-devel@lists.xenproject.org \ --subject='Re: [PATCH v7 2/7] xen/arm: implement domU extended regions' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.