[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFC PATCH] arm: dom0: allow static memory configuration
The Arm Xen allocates memory to place Dom0 following the logic described in allocate_memory_11() function which is a bit complicated with major requirement to place Dom0 within the first 128MB of RAM and below 4G. But this doesn't guarantee it will be placed at the same physical base address even between two boots with different configuration (changing the Kernel image size or Initrd size may cause Dom0 base address to change). In case of "thin Dom0" use case, when Dom0 implemented with RTOS like Zephyr, which doesn't use dynamic device-tree parsing, such behavior causes a lot of inconvenience as it is required to perform modification and recompiling of Zephyr image to adjust memory layout. It also prevents from using Initrd with Zephyr, for example, as it's expected to be placed at known, fixed address in memory. This RFC patch introduces the possibility to place Dom0 at fixed physical base address, by checking if "chosen" node contains property "xen,static-mem" and placs Dom0 exactly at the specified memory chunk. The implementation follows the same approach as for the static, direct-mapped guest domain in case of dom0less boot. Signed-off-by: Grygorii Strashko <grygorii_strashko@xxxxxxxx> --- docs/misc/arm/device-tree/booting.txt | 20 ++++++++++++++++++++ xen/arch/arm/domain_build.c | 12 +++++++++--- xen/common/device-tree/bootfdt.c | 14 ++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-tree/booting.txt index 9c881baccc19..485dcb82de8c 100644 --- a/docs/misc/arm/device-tree/booting.txt +++ b/docs/misc/arm/device-tree/booting.txt @@ -448,6 +448,26 @@ device-tree: This will reserve a 512MB region starting at the host physical address 0x30000000 to be exclusively used by DomU1. +Dom0 Static Allocation +====================== + +The Memory can be statically allocated to a Dom0 using the property +"xen,static-mem" defined under the "\chosen" node. This options allows to use +RTOS as the dom0 kernel, which support only static memory layout. + +Below is an DT example: + + / { + chosen { + #address-cells = <0x1>; + #size-cells = <0x1>; + xen,static-mem = <0x50000000 0x8000000>; + ... + }; + +This will reserve a 128MB region starting at the host physical address +0x50000000 to be exclusively used by Dom0. + Static Event Channel ==================== The event channel communication will be established statically between two diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 7b47abade196..8ee280614813 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -31,6 +31,7 @@ #include <asm/cpufeature.h> #include <asm/dom0less-build.h> #include <asm/domain_build.h> +#include <asm/static-memory.h> #include <asm/static-shmem.h> #include <xen/event.h> @@ -2272,6 +2273,7 @@ int __init construct_domain(struct domain *d, struct kernel_info *kinfo) static int __init construct_dom0(struct domain *d) { struct kernel_info kinfo = KERNEL_INFO_INIT; + const struct dt_device_node *chosen = dt_find_node_by_path("/chosen"); int rc; /* Sanity! */ @@ -2305,10 +2307,14 @@ static int __init construct_dom0(struct domain *d) d->arch.type = kinfo.type; #endif find_gnttab_region(d, &kinfo); - if ( is_domain_direct_mapped(d) ) - allocate_memory_11(d, &kinfo); - else + if ( is_domain_direct_mapped(d) ) { + if ( !dt_find_property(chosen, "xen,static-mem", NULL) ) + allocate_memory_11(d, &kinfo); + else + assign_static_memory_11(d, &kinfo, chosen); + } else { allocate_memory(d, &kinfo); + } rc = process_shm_chosen(d, &kinfo); if ( rc < 0 ) diff --git a/xen/common/device-tree/bootfdt.c b/xen/common/device-tree/bootfdt.c index 529c91e603ab..563a5436fac0 100644 --- a/xen/common/device-tree/bootfdt.c +++ b/xen/common/device-tree/bootfdt.c @@ -413,6 +413,20 @@ static int __init process_chosen_node(const void *fdt, int node, using_static_heap = true; } + if ( fdt_get_property(fdt, node, "xen,static-mem", NULL) ) + { + int rc; + + printk("Checking for static static-mem in /chosen\n"); + + rc = device_tree_get_meminfo(fdt, node, "xen,static-mem", + address_cells, size_cells, + bootinfo_get_reserved_mem(), + MEMBANK_STATIC_DOMAIN); + if ( rc ) + return rc; + } + printk("Checking for initrd in /chosen\n"); prop = fdt_get_property(fdt, node, "linux,initrd-start", &len); -- 2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |