Move parts of Arm's Dom0less to common code
PATCH 4/9 asm-generic: move Arm's static-memory.h to asm-generic
In reply to Oleksii KurochkoExcept moving Arm's static-memory.h to asm-generic #ifdef header guard is updated: s/__ASM_STATIC_MEMORY_H_/__ASM_GENERIC_STATIC_MEMORY_H__.
Update arm/include/asm/Makefile to use asm-generic version of static-memory.h for Arm.
--- xen/arch/arm/include/asm/Makefile | 1 + xen/arch/arm/include/asm/static-memory.h | 58 ------------------------ xen/include/asm-generic/static-memory.h | 58 ++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 58 deletions(-) delete mode 100644 xen/arch/arm/include/asm/static-memory.h create mode 100644 xen/include/asm-generic/static-memory.h
xen/arch/arm/include/asm/Makefile +1 -0
@@ -8,4 +8,5 @@ generic-y += paging.h generic-y += percpu.h generic-y += random.h generic-y += softirq.h +generic-y += static-memory.h generic-y += vm_event.h
xen/arch/arm/include/asm/static-memory.h deleted +0 -58
58 lines not on this page · raw message
xen/include/asm-generic/static-memory.h new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
2.47.1
PATCH 5/9 asm-generic: move Arm's static-shmem.h to asm-generic
In reply to Oleksii KurochkoExcept moving Arm's static-shmem.h to asm-generic #ifdef header guard is updated: s/__ASM_SHMEM_MEMORY_H_/__ASM_GENERIC_SHMEM_MEMORY_H__.
Update arm/include/asm/Makefile to use asm-generic version of static-shmem.h for Arm.
--- xen/arch/arm/include/asm/Makefile | 1 + xen/arch/arm/include/asm/static-shmem.h | 117 ------------------------ xen/include/asm-generic/static-shmem.h | 117 ++++++++++++++++++++++++ 3 files changed, 118 insertions(+), 117 deletions(-) delete mode 100644 xen/arch/arm/include/asm/static-shmem.h create mode 100644 xen/include/asm-generic/static-shmem.h
xen/arch/arm/include/asm/Makefile +1 -0
@@ -9,4 +9,5 @@ generic-y += percpu.h generic-y += random.h generic-y += softirq.h generic-y += static-memory.h +generic-y += static-shmem.h generic-y += vm_event.h
xen/arch/arm/include/asm/static-shmem.h deleted +0 -117
117 lines not on this page · raw message
xen/include/asm-generic/static-shmem.h new file +117 -0
117 lines not on this page · raw message
Signature · 1 line
2.47.1
PATCH 6/9 asm-generic: move some parts of Arm's domain_build.h to asm-generic header
In reply to Oleksii KurochkoNothing changed. Only some functions declaration are moved to asm-generic header as they are expected to be used by common code of domain builing or dom0less.
--- xen/arch/arm/include/asm/domain_build.h | 19 ++---------- xen/include/asm-generic/domain-build.h | 41 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 xen/include/asm-generic/domain-build.h
xen/arch/arm/include/asm/domain_build.h +2 -17
@@ -4,28 +4,13 @@#include <xen/sched.h> #include <asm/kernel.h> +#include <asm-generic/domain-build.h> +typedef __be32 gic_interrupt_t [3 ]; -typedef bool (*alloc_domheap_mem_cb )(struct domain *d,struct page_info *pg, -unsigned int order,void *extra); -bool allocate_domheap_memory (struct domain *d,paddr_t tot_size, -alloc_domheap_mem_cb cb,void *extra); -bool allocate_bank_memory (struct kernel_info *kinfo,gfn_t sgfn, -paddr_t tot_size); -void allocate_memory (struct domain *d,struct kernel_info *kinfo); -int construct_domain (struct domain *d,struct kernel_info *kinfo);int domain_fdt_begin_node (void *fdt,const char *name,uint64_t unit); -int make_chosen_node (const struct kernel_info *kinfo); -int make_cpus_node (const struct domain *d,void *fdt); -int make_hypervisor_node (struct domain *d,const struct kernel_info *kinfo, -int addrcells,int sizecells); -int make_memory_node (const struct kernel_info *kinfo,int addrcells, -int sizecells,const struct membanks *mem);int make_psci_node (void *fdt); -int make_timer_node (const struct kernel_info *kinfo);void evtchn_allocate (struct domain *d); -unsigned int get_allocation_size (paddr_t size); -/* * handle_device_interrupts retrieves the interrupts configuration from * a device tree node and maps those interrupts to the target domain.
xen/include/asm-generic/domain-build.h new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
2.47.1
PATCH 7/9 xen/common: dom0less: introduce common kernel.c
In reply to Oleksii KurochkoThe following functions don't have arch specific things so it is moved to common:
- kernel_prboe()
- kernel_load()
- output_length()
Functions necessary for dom0less are only moved.
The following changes are done:
- Swap __init and return type of kernel_decompress() function to be consistent with defintions of functions in other files. The same for output_length().
- Wrap by "ifdef CONFIG_ARM" the call of kernel_uimage_probe() in kernel_probe() as uImage isn't really used nowadays thereby leave kernel_uimage_probe() call here just for compatability with Arm code.
- Introduce kernel_zimage_probe() to cover the case that arch can have different zimage header.
- Add ASSERT() for kernel_load() to check that it argument isn't NULL.
- Make kernel_uimage_probe() non-static in Arm's code as it is used in common/kernel.c.
Introduce CONFIG_DOMAIN_BUILD_HELPERS to not provide stubs for archs which doesn't provice enough functionality to enable it. Select CONFIG_DOMAIN_BUILD_HELPERS for CONFIG_ARM as only Arm supports it, at the moment.
--- xen/arch/arm/Kconfig | 1 + xen/arch/arm/kernel.c | 221 +--------------------------- xen/common/Kconfig | 11 +- xen/common/device-tree/Makefile | 1 + xen/common/device-tree/kernel.c | 242 +++++++++++++++++++++++++++++++ xen/include/asm-generic/kernel.h | 13 ++ 6 files changed, 272 insertions(+), 217 deletions(-) create mode 100644 xen/common/device-tree/kernel.c
xen/arch/arm/Kconfig +1 -0
@@ -12,6 +12,7 @@ config ARM_64 config ARM def_bool y + select DOMAIN_BUILD_HELPERS select FUNCTION_ALIGNMENT_4B select GENERIC_UART_INIT select HAS_ALTERNATIVE if HAS_VMAP
xen/arch/arm/kernel.c +6 -215
249 lines not on this page · raw message
xen/common/Kconfig +9 -2
@@ -14,13 +14,20 @@ config CORE_PARKING config DOM0LESS_BOOT bool "Dom0less boot support" if EXPERT - depends on ARM - default ARM + depends on DOMAIN_BUILD_HELPERS + default DOMAIN_BUILD_HELPERS help Dom0less boot support enables Xen to create and start domU guests during Xen boot without the need of a control domain (Dom0), which could be present anyway. +config DOMAIN_BUILD_HELPERS + bool + help + Introduce functions necessary for working with domain creation, kernel, + etc. As an examples, these type of functions are going to be used by + CONFIG_DOM0LESS_BOOT. + config GRANT_TABLE bool "Grant table support" if EXPERT default y
xen/common/device-tree/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-y += device-tree.o obj-$(CONFIG_DOM0LESS_BOOT) += dom0less-build.o obj-$(CONFIG_OVERLAY_DTB) += dt-overlay.o obj-y += intc.o +obj-$(CONFIG_DOMAIN_BUILD_HELPERS) += kernel.o
xen/common/device-tree/kernel.c new file +242 -0
242 lines not on this page · raw message
xen/include/asm-generic/kernel.h +13 -0
@@ -134,6 +134,19 @@ int kernel_probe(struct kernel_info *info, const struct dt_device_node *domain);*/ void kernel_load (struct kernel_info *info); +int kernel_decompress (struct bootmodule *mod,uint32_t offset); + +int kernel_zimage_probe (struct kernel_info *info,paddr_t addr,paddr_t size); + +/* +* uImage isn't really used nowadays thereby leave kernel_uimage_probe() +* call here just for compatability with Arm code. +*/ +#ifdef CONFIG_ARM +struct bootmodule ; +int kernel_uimage_probe (struct kernel_info *info,struct bootmodule *mod); +#endif +#endif /*__ASM_GENERIC_KERNEL_H__ */ /*
Signature · 1 line
2.47.1
cover Move parts of Arm's Dom0less to common code
Some parts of Arm's Dom0less solution could be moved to common code as they are not truly Arm-specific.
Most of the code is moved as is, with only minor changes introduced to provide abstractions that hide Arm-specific details, while maintaining functional equivalence with original Arm's code.
There are several open questions:
1. Probably, the introduced headers currently placed in asm-generic should instead reside in the xen/include folder.
2. Perhaps the introduced *.c files should always be placed elsewhere. They have been put in device-tree common as they somewhat depend on device tree functionality.
3. The u64 and u32 types are widely used in the code where device tree functionality is implemented because these types are used in device tree function arguments.
Should this be reworked to use uint32_t and uint64_t instead? If so, will it also be necessary to change the type of variables passed to dt-related functions, or should the argument types of device tree functions be updated too? For example:
```
u64 mem;
...
rc = dt_property_read_u64(node, "memory", &mem);
```
where dt_property_read_u64 is declared as:
bool dt_property_read_u64(... , u64 *out_value);
4. Instead of providing init_intc_phandle() (see the patch: [1]), perhaps it
would be better to add a for loop in domain_handle_dtb_bootmodule()?
Something like:
```
bool is_intc_phandle_inited = false;
for ( unsigned int i = 0; i < ARRAY_SIZE(intc_names_array); i++ )
{
if ( dt_node_cmp(name, intc_names_array[i]) == 0 )
{
uint32_t phandle_intc = fdt_get_phandle(pfdt, node_next);
if ( phandle_intc != 0 )
kinfo->phandle_intc = phandle_intc;
is_intc_phandle_inited = true;
break;
}
}
if ( is_intc_phandle_inited ) continue;
```5. If some function prototypes are moved from asm/* headers, the inclusion of arch-specific headers (asm/*.h) could potentially be dropped. For example, if we examine common/device-tree/kernel.c, the following inclusions exist:
- <asm/setup.h>: Included because of the use of copy_from_paddr(). The name copy_from_paddr() seems generic enough, so it might make sense to move it to a common header.
- <asm/page.h>: Included because of clean_dcache_va_range(). This function is already used in common code in grant_table.c, so its prototype should be placed in a common header.
- asm/kernel.h: Included because of struct kernel_info, which could also be a candidate to be moved to a common header.
[1] [PATCH v1 9/9] xen/common: dom0less: introduce common dom0less-build.c
Oleksii Kurochko (9):
xen/common: dom0less: make some parts of Arm's CONFIG_DOM0LESS common
asm-generic: move parts of Arm's asm/kernel.h to asm-generic arm/static-shmem.h: drop inclusion of asm/setup.h
asm-generic: move Arm's static-memory.h to asm-generic
asm-generic: move Arm's static-shmem.h to asm-generic
asm-generic: move some parts of Arm's domain_build.h to asm-generic
header
xen/common: dom0less: introduce common kernel.c xen/common: dom0less: introduce common domain-build.c xen/common: dom0less: introduce common dom0less-build.c
xen/arch/arm/Kconfig | 9 +- xen/arch/arm/dom0less-build.c | 842 +++------------------- xen/arch/arm/domain_build.c | 410 +---------- xen/arch/arm/include/asm/Makefile | 4 + xen/arch/arm/include/asm/dom0less-build.h | 32 - xen/arch/arm/include/asm/domain_build.h | 19 +- xen/arch/arm/include/asm/kernel.h | 115 +-- xen/arch/arm/include/asm/static-memory.h | 58 -- xen/arch/arm/include/asm/static-shmem.h | 118 --- xen/arch/arm/kernel.c | 231 +----- xen/arch/arm/static-memory.c | 1 + xen/arch/arm/static-shmem.c | 1 + xen/common/Kconfig | 16 + xen/common/device-tree/Makefile | 3 + xen/common/device-tree/dom0less-build.c | 720 ++++++++++++++++++ xen/common/device-tree/domain-build.c | 405 +++++++++++ xen/common/device-tree/dt-overlay.c | 2 + xen/common/device-tree/kernel.c | 242 +++++++ xen/include/asm-generic/dom0less-build.h | 54 ++ xen/include/asm-generic/domain-build.h | 72 ++ xen/include/asm-generic/kernel.h | 159 ++++ xen/include/asm-generic/static-memory.h | 58 ++ xen/include/asm-generic/static-shmem.h | 117 +++ 23 files changed, 1986 insertions(+), 1702 deletions(-) delete mode 100644 xen/arch/arm/include/asm/dom0less-build.h delete mode 100644 xen/arch/arm/include/asm/static-memory.h delete mode 100644 xen/arch/arm/include/asm/static-shmem.h create mode 100644 xen/common/device-tree/dom0less-build.c create mode 100644 xen/common/device-tree/domain-build.c create mode 100644 xen/common/device-tree/kernel.c create mode 100644 xen/include/asm-generic/dom0less-build.h create mode 100644 xen/include/asm-generic/domain-build.h create mode 100644 xen/include/asm-generic/kernel.h create mode 100644 xen/include/asm-generic/static-memory.h create mode 100644 xen/include/asm-generic/static-shmem.h
Signature · 1 line
2.47.1
PATCH 3/9 arm/static-shmem.h: drop inclusion of asm/setup.h
Nothing is dependent from asm/setup.h in asm/static-shmem.h so inclusion of asm/setup.h is droped.
After this drop the following compilation error related to impicit declaration of the following functions device_tree_get_reg and map_device_irqs_to_domain, device_tree_get_u32 occur during compilation of dom0less-build.c ( as they are declared in asm/setup.h ).
Add inclusion of <asm/setup.h> in dt-overlay.c as it is using handle_device() declared in <asm/setup.h>.
--- xen/arch/arm/dom0less-build.c | 1 + xen/arch/arm/include/asm/static-shmem.h | 1 - xen/common/device-tree/dt-overlay.c | 2 ++ 3 files changed, 3 insertions(+), 1 deletion(-)
xen/arch/arm/dom0less-build.c +1 -0
@@ -14,6 +14,7 @@#include <asm/arm64/sve.h> #include <asm/dom0less-build.h> #include <asm/domain_build.h> +#include <asm/setup.h> #include <asm/static-memory.h> #include <asm/static-shmem.h>
xen/arch/arm/include/asm/static-shmem.h +0 -1
@@ -5,7 +5,6 @@#include <xen/types.h> #include <asm/kernel.h> -#include <asm/setup.h> #ifdef CONFIG_STATIC_SHM
xen/common/device-tree/dt-overlay.c +2 -0
@@ -13,6 +13,8 @@#include <xen/libfdt/libfdt.h> #include <xen/xmalloc.h> +#include <asm/setup.h> +#define DT_OVERLAY_MAX_SIZE KB(500)static LIST_HEAD (overlay_tracker);
Signature · 1 line
2.47.1
PATCH 9/9 xen/common: dom0less: introduce common dom0less-build.c
In reply to Oleksii KurochkoPart of Arm's dom0less-build.c could be common between architectures which are using device tree files to create guest domains. Thereby move some parts of Arm's dom0less-build.c to common code with minor changes.
As a part of theses changes the following changes are introduced:
- Introduce make_arch_nodes() to cover arch-specific nodes. For example, in case of Arm, it is PSCI and vpl011 nodes.
- Introduce set_domain_type() to abstract a way how setting of domain type happens. For example, RISC-V won't have this member of arch_domain structure as vCPUs will always have the same bitness as hypervisor. In case of Arm, it is possible that Arm64 could create 32-bit and 64-bit domains.
- Introduce init_vuart() to cover details of virtual uart initialization.
- Introduce init_intc_phandle() to cover some details of interrupt controller phandle initialization. As an example, RISC-V could have different name for interrupt controller node ( APLIC, PLIC, IMSIC, etc ) but the code in domain_handle_dtb_bootmodule() could handle only one interrupt controller node name.
- s/make_gic_domU_node/make_intc_domU_node as GIC is Arm specific naming and add prototype of make_intc_domU_node() to dom0less-build.h
The following functions are moved to xen/common/device-tree:
- Functions which are moved as is:
- domain_p2m_pages().
- handle_passthrough_prop().
- handle_prop_pfdt().
- scan_pfdt_node().
- check_partial_fdt().
- Functions which are moved with some minor changes:
- alloc_xenstore_evtchn():
- ifdef-ing by CONFIG_HVM accesses to hvm.params.
- prepare_dtb_domU():
- ifdef-ing access to gnttab_{start,size} by CONFIG_GRANT_TABLE.
- s/make_gic_domU_node/make_intc_domU_node.
- Add call of make_arch_nodes().
- domain_handle_dtb_bootmodule():
- hide details of interrupt controller phandle initialization by calling init_intc_phandle().
- Update the comment above init_intc_phandle(): s/gic/interrupt controller.
- construct_domU():
- ifdef-ing by CONFIG_HVM accesses to hvm.params.
- Call init_vuart() to hide Arm's vpl011_init() details there.
- Add call of set_domain_type() instead of setting kinfo->arch.type explicitly.
--- xen/arch/arm/dom0less-build.c | 569 ++--------------------- xen/common/device-tree/dom0less-build.c | 559 ++++++++++++++++++++++ xen/include/asm-generic/dom0less-build.h | 14 + 3 files changed, 608 insertions(+), 534 deletions(-)
xen/arch/arm/dom0less-build.c +35 -534
@@ -143,7 +143,7 @@ static int __init make_gicv3_domU_node(struct kernel_info *kinfo) }#endif -static int __init make_gic_domU_node (struct kernel_info *kinfo) +int __init make_intc_domU_node (struct kernel_info *kinfo) {switch ( kinfo->d->arch.vgic.version ) {
@@ -209,577 +209,62 @@ static int __init make_vpl011_uart_node(struct kernel_info *kinfo) }#endif -/* -* Scan device tree properties for passthrough specific information. -* Returns < 0 on error -* 0 on success -*/ -static int __init handle_passthrough_prop (struct kernel_info *kinfo, -const struct fdt_property *xen_reg, -const struct fdt_property *xen_path, -bool xen_force, -uint32_t address_cells, -uint32_t size_cells) -{ -const __be32 *cell; -unsigned int i, len; -struct dt_device_node *node; -int res; -paddr_t mstart, size, gstart; - -/* xen,reg specifies where to map the MMIO region */ - cell = (const __be32 *)xen_reg->data; - len =fdt32_to_cpu (xen_reg->len) / ((address_cells *2 + size_cells) * -sizeof (uint32_t )); - -for ( i =0 ; i < len; i++ ) - { -device_tree_get_reg (&cell, address_cells, size_cells, - &mstart, &size); - gstart =dt_next_cell (address_cells, &cell); - -if ( gstart & ~PAGE_MASK || mstart & ~PAGE_MASK || size & ~PAGE_MASK ) - { -printk (XENLOG_ERR -"DomU passthrough config has not page aligned addresses/sizes\n" ); -return -EINVAL ; - } - - res =iomem_permit_access (kinfo->d,paddr_to_pfn (mstart), -paddr_to_pfn (PAGE_ALIGN (mstart + size -1 ))); -if ( res ) - { -printk (XENLOG_ERR "Unable to permit to dom%d access to" -" 0x%" PRIpaddr" - 0x%" PRIpaddr"\n" , - kinfo->d->domain_id, - mstart &PAGE_MASK ,PAGE_ALIGN (mstart + size) -1 ); -return res; - } - - res =map_regions_p2mt (kinfo->d, -gaddr_to_gfn (gstart), -PFN_DOWN (size), -maddr_to_mfn (mstart), - p2m_mmio_direct_dev); -if ( res <0 ) - { -printk (XENLOG_ERR -"Failed to map %" PRIpaddr" to the guest at%" PRIpaddr"\n" , - mstart, gstart); -return -EFAULT ; - } - } - -/* -* If xen_force, we let the user assign a MMIO region with no -* associated path. -*/ -if ( xen_path ==NULL ) -return xen_force ?0 : -EINVAL ; - -/* -* xen,path specifies the corresponding node in the host DT. -* Both interrupt mappings and IOMMU settings are based on it, -* as they are done based on the corresponding host DT node. -*/ - node =dt_find_node_by_path (xen_path->data); -if ( node ==NULL ) - { -printk (XENLOG_ERR "Couldn't find node %s in host_dt!\n" , - xen_path->data); -return -EINVAL ; - } - - res =map_device_irqs_to_domain (kinfo->d, node, true,NULL ); -if ( res <0 ) -return res; - - res =iommu_add_dt_device (node); -if ( res <0 ) -return res; - -/* If xen_force, we allow assignment of devices without IOMMU protection. */ -if ( xen_force && !dt_device_is_protected (node) ) -return 0 ; - -return iommu_assign_dt_device (kinfo->d, node); -} - -static int __init handle_prop_pfdt (struct kernel_info *kinfo, -const void *pfdt,int nodeoff, -uint32_t address_cells,uint32_t size_cells, -bool scan_passthrough_prop) -{ -void *fdt = kinfo->fdt; -int propoff, nameoff, res; -const struct fdt_property *prop, *xen_reg =NULL , *xen_path =NULL ; -const char *name; -bool found, xen_force = false; - -for ( propoff =fdt_first_property_offset (pfdt, nodeoff); - propoff >=0 ; - propoff =fdt_next_property_offset (pfdt, propoff) ) - { -if ( !(prop =fdt_get_property_by_offset (pfdt, propoff,NULL )) ) -return -FDT_ERR_INTERNAL ; - - found = false; - nameoff =fdt32_to_cpu (prop->nameoff); - name =fdt_string (pfdt, nameoff); - -if ( scan_passthrough_prop ) - { -if (dt_prop_cmp ("xen,reg" , name) ==0 ) - { - xen_reg = prop; - found = true; - } -else if (dt_prop_cmp ("xen,path" , name) ==0 ) - { - xen_path = prop; - found = true; - } -else if (dt_prop_cmp ("xen,force-assign-without-iommu" , - name) ==0 ) - { - xen_force = true; - found = true; - } - } - -/* -* Copy properties other than the ones above: xen,reg, xen,path, -* and xen,force-assign-without-iommu. -*/ -if ( !found ) - { - res =fdt_property (fdt, name, prop->data,fdt32_to_cpu (prop->len)); -if ( res ) -return res; - } - } - -/* -* Only handle passthrough properties if both xen,reg and xen,path -* are present, or if xen,force-assign-without-iommu is specified. -*/ -if ( xen_reg !=NULL && (xen_path !=NULL || xen_force) ) - { - res =handle_passthrough_prop (kinfo, xen_reg, xen_path, xen_force, - address_cells, size_cells); -if ( res <0 ) - { -printk (XENLOG_ERR "Failed to assign device to %pd\n" , kinfo->d); -return res; - } - } -else if ( (xen_path && !xen_reg) || (xen_reg && !xen_path && !xen_force) ) - { -printk (XENLOG_ERR "xen,reg or xen,path missing for %pd\n" , - kinfo->d); -return -EINVAL ; - } - -/* FDT_ERR_NOTFOUND => There is no more properties for this node */ -return ( propoff != -FDT_ERR_NOTFOUND ) ? propoff :0 ; -} - -static int __init scan_pfdt_node (struct kernel_info *kinfo,const void *pfdt, -int nodeoff, -uint32_t address_cells,uint32_t size_cells, -bool scan_passthrough_prop) -{ -int rc =0 ; -void *fdt = kinfo->fdt; -int node_next; - - rc =fdt_begin_node (fdt,fdt_get_name (pfdt, nodeoff,NULL )); -if ( rc ) -return rc; - - rc =handle_prop_pfdt (kinfo, pfdt, nodeoff, address_cells, size_cells, - scan_passthrough_prop); -if ( rc ) -return rc; - - address_cells =device_tree_get_u32 (pfdt, nodeoff,"#address-cells" , -DT_ROOT_NODE_ADDR_CELLS_DEFAULT ); - size_cells =device_tree_get_u32 (pfdt, nodeoff,"#size-cells" , -DT_ROOT_NODE_SIZE_CELLS_DEFAULT ); - - node_next =fdt_first_subnode (pfdt, nodeoff); -while ( node_next >0 ) - { - rc =scan_pfdt_node (kinfo, pfdt, node_next, address_cells, size_cells, - scan_passthrough_prop); -if ( rc ) -return rc; - - node_next =fdt_next_subnode (pfdt, node_next); - } - -return fdt_end_node (fdt); -} - -static int __init check_partial_fdt (void *pfdt,size_t size) -{ -int res; - -if (fdt_magic (pfdt) !=FDT_MAGIC ) - { -dprintk (XENLOG_ERR ,"Partial FDT is not a valid Flat Device Tree" ); -return -EINVAL ; - } - - res =fdt_check_header (pfdt); -if ( res ) - { -dprintk (XENLOG_ERR ,"Failed to check the partial FDT (%d)" , res); -return -EINVAL ; - } - -if (fdt_totalsize (pfdt) > size ) - { -dprintk (XENLOG_ERR ,"Partial FDT totalsize is too big" ); -return -EINVAL ; - } - -return 0 ; -} - -static int __init domain_handle_dtb_bootmodule (struct domain *d, -struct kernel_info *kinfo) +int __init make_arch_nodes (struct kernel_info *kinfo) { -void *pfdt; -int res, node_next; - - pfdt =ioremap_cache (kinfo->dtb_bootmodule->start, - kinfo->dtb_bootmodule->size); -if ( pfdt ==NULL ) -return -EFAULT ; - - res =check_partial_fdt (pfdt, kinfo->dtb_bootmodule->size); -if ( res <0 ) - goto out; - -for ( node_next =fdt_first_subnode (pfdt,0 ); - node_next >0 ; - node_next =fdt_next_subnode (pfdt, node_next) ) - { -const char *name =fdt_get_name (pfdt, node_next,NULL ); - -if ( name ==NULL ) -continue ; - -/* -* Only scan /gic /aliases /passthrough, ignore the rest. -* They don't have to be parsed in order. -* -* Take the GIC phandle value from the special /gic node in the -* DTB fragment. -*/ -if (dt_node_cmp (name,"gic" ) ==0 ) - { -uint32_t phandle_intc =fdt_get_phandle (pfdt, node_next); - -if ( phandle_intc !=0 ) - kinfo->phandle_intc = phandle_intc; -continue ; - } - -if (dt_node_cmp (name,"aliases" ) ==0 ) - { - res =scan_pfdt_node (kinfo, pfdt, node_next, -DT_ROOT_NODE_ADDR_CELLS_DEFAULT , -DT_ROOT_NODE_SIZE_CELLS_DEFAULT , - false); -if ( res ) - goto out; -continue ; - } -if (dt_node_cmp (name,"passthrough" ) ==0 ) - { - res =scan_pfdt_node (kinfo, pfdt, node_next, -DT_ROOT_NODE_ADDR_CELLS_DEFAULT , -DT_ROOT_NODE_SIZE_CELLS_DEFAULT , - true); -if ( res ) - goto out; -continue ; - } - } - - out: -iounmap (pfdt); - -return res; -} - -/* -* The max size for DT is 2MB. However, the generated DT is small (not including -* domU passthrough DT nodes whose size we account separately), 4KB are enough -* for now, but we might have to increase it in the future. -*/ -#define DOMU_DTB_SIZE 4096 -static int __init prepare_dtb_domU (struct domain *d,struct kernel_info *kinfo) -{ -int addrcells, sizecells; -int ret, fdt_size =DOMU_DTB_SIZE ; - - kinfo->phandle_intc =GUEST_PHANDLE_GIC ; - kinfo->gnttab_start =GUEST_GNTTAB_BASE ; - kinfo->gnttab_size =GUEST_GNTTAB_SIZE ; - - addrcells =GUEST_ROOT_ADDRESS_CELLS ; - sizecells =GUEST_ROOT_SIZE_CELLS ; - -/* Account for domU passthrough DT size */ -if ( kinfo->dtb_bootmodule ) - fdt_size += kinfo->dtb_bootmodule->size; - -/* Cap to max DT size if needed */ - fdt_size =min (fdt_size,SZ_2M ); - - kinfo->fdt =xmalloc_bytes (fdt_size); -if ( kinfo->fdt ==NULL ) -return -ENOMEM ; - - ret =fdt_create (kinfo->fdt, fdt_size); -if ( ret <0 ) - goto err; - - ret =fdt_finish_reservemap (kinfo->fdt); -if ( ret <0 ) - goto err; - - ret =fdt_begin_node (kinfo->fdt,"" ); -if ( ret <0 ) - goto err; - - ret =fdt_property_cell (kinfo->fdt,"#address-cells" , addrcells); -if ( ret ) - goto err; - - ret =fdt_property_cell (kinfo->fdt,"#size-cells" , sizecells); -if ( ret ) - goto err; - - ret =make_chosen_node (kinfo); -if ( ret ) - goto err; +int ret; ret =make_psci_node (kinfo->fdt);if ( ret ) - goto err; - - ret =make_cpus_node (d, kinfo->fdt); -if ( ret ) - goto err; - - ret =make_memory_node (kinfo, addrcells, sizecells, -kernel_info_get_mem (kinfo)); -if ( ret ) - goto err; - - ret =make_resv_memory_node (kinfo, addrcells, sizecells); -if ( ret ) - goto err; - -/* -* domain_handle_dtb_bootmodule has to be called before the rest of -* the device tree is generated because it depends on the value of -* the field phandle_intc. -*/ -if ( kinfo->dtb_bootmodule ) - { - ret =domain_handle_dtb_bootmodule (d, kinfo); -if ( ret ) - goto err; - } - - ret =make_gic_domU_node (kinfo); -if ( ret ) - goto err; - - ret =make_timer_node (kinfo); -if ( ret ) - goto err; +return -EINVAL ;if ( kinfo->vuart ) { - ret = -EINVAL ;#ifdef CONFIG_SBSA_VUART_CONSOLE ret =make_vpl011_uart_node (kinfo);#endif if ( ret ) - goto err; - } - -if ( kinfo->dom0less_feature &DOM0LESS_ENHANCED_NO_XS ) - { - ret =make_hypervisor_node (d, kinfo, addrcells, sizecells); -if ( ret ) - goto err; +return -EINVAL ; } - ret =fdt_end_node (kinfo->fdt); -if ( ret <0 ) - goto err; - - ret =fdt_finish (kinfo->fdt); -if ( ret <0 ) - goto err; -return 0 ; - - err: -printk ("Device tree generation failed (%d).\n" , ret); -xfree (kinfo->fdt); - -return -EINVAL ; } -static unsigned long __init domain_p2m_pages (unsigned long maxmem_kb, -unsigned int smp_cpus) +/* TODO: make arch.type generic ? */ +#ifdef CONFIG_ARM_64 +void __init set_domain_type (struct domain *d,struct kernel_info *kinfo) { -/* -* Keep in sync with libxl__get_required_paging_memory(). -* 256 pages (1MB) per vcpu, plus 1 page per MiB of RAM for the P2M map, -* plus 128 pages to cover extended regions. -*/ -unsigned long memkb =4 * (256 * smp_cpus + (maxmem_kb /1024 ) +128 ); - -BUILD_BUG_ON (PAGE_SIZE !=SZ_4K ); - -return DIV_ROUND_UP (memkb,1024 ) << (20 -PAGE_SHIFT ); +/* type must be set before allocate memory */ + d->arch.type = kinfo->arch.type; } - -static int __init alloc_xenstore_evtchn (struct domain *d) +#else +void __init set_domain_type (struct domain *d,struct kernel_info *kinfo) { -evtchn_alloc_unbound_t alloc; -int rc; - - alloc.dom = d->domain_id; - alloc.remote_dom = hardware_domain->domain_id; - rc =evtchn_alloc_unbound (&alloc,0 ); -if ( rc ) - { -printk ("Failed allocating event channel for domain\n" ); -return rc; - } - - d->arch.hvm.params[HVM_PARAM_STORE_EVTCHN ] = alloc.port; - -return 0 ; +/* Nothing to do */ } +#endif -int __init construct_domU (struct domain *d, -const struct dt_device_node *node) +int __init init_vuart (struct domain *d,struct kernel_info *kinfo, +const struct dt_device_node *node) { -struct kernel_info kinfo =KERNEL_INFO_INIT ; -const char *dom0less_enhanced; -int rc; -u64 mem; -u32 p2m_mem_mb; -unsigned long p2m_pages; - - rc =dt_property_read_u64 (node,"memory" , &mem); -if ( !rc ) - { -printk ("Error building DomU: cannot read \"memory\" property\n" ); -return -EINVAL ; - } - kinfo.unassigned_mem = (paddr_t )mem *SZ_1K ; - - rc =dt_property_read_u32 (node,"xen,domain-p2m-mem-mb" , &p2m_mem_mb); -/* If xen,domain-p2m-mem-mb is not specified, use the default value. */ - p2m_pages = rc ? - p2m_mem_mb << (20 -PAGE_SHIFT ) : -domain_p2m_pages (mem, d->max_vcpus); - -spin_lock (&d->arch.paging.lock); - rc =p2m_set_allocation (d, p2m_pages,NULL ); -spin_unlock (&d->arch.paging.lock); -if ( rc !=0 ) -return rc; - -printk ("*** LOADING DOMU cpus=%u memory=%#" PRIx64"KB ***\n" , - d->max_vcpus, mem); - - kinfo.vuart =dt_property_read_bool (node,"vpl011" ); - - rc =dt_property_read_string (node,"xen,enhanced" , &dom0less_enhanced); -if ( rc == -EILSEQ || - rc == -ENODATA || - (rc ==0 && !strcmp (dom0less_enhanced,"enabled" )) ) - { -if ( hardware_domain ) - kinfo.dom0less_feature =DOM0LESS_ENHANCED ; -else -panic ("At the moment, Xenstore support requires dom0 to be present\n" ); - } -else if ( rc ==0 && !strcmp (dom0less_enhanced,"no-xenstore" ) ) - kinfo.dom0less_feature =DOM0LESS_ENHANCED_NO_XS ; - -if (vcpu_create (d,0 ) ==NULL ) -return -ENOMEM ; - - d->max_pages = ((paddr_t )mem *SZ_1K ) >>PAGE_SHIFT ; - - kinfo.d = d; - - rc =kernel_probe (&kinfo, node); -if ( rc <0 ) -return rc; - -#ifdef CONFIG_ARM_64 -/* type must be set before allocate memory */ - d->arch.type = kinfo.arch.type; -#endif -if ( !dt_find_property (node,"xen,static-mem" ,NULL ) ) -allocate_memory (d, &kinfo); -else if ( !is_domain_direct_mapped (d) ) -allocate_static_memory (d, &kinfo, node); -else -assign_static_memory_11 (d, &kinfo, node); +int rc =0 ; - rc =process_shm (d, &kinfo, node); -if ( rc <0 ) -return rc; + kinfo->vuart =dt_property_read_bool (node,"vpl011" );/* * Base address and irq number are needed when creating vpl011 device * tree node in prepare_dtb_domU, so initialization on related variables * shall be done first. */ -if ( kinfo.vuart ) +if ( kinfo->vuart ) { rc =domain_vpl011_init (d,NULL );if ( rc <0 )return rc; } - rc =prepare_dtb_domU (d, &kinfo); -if ( rc <0 ) -return rc; - - rc =construct_domain (d, &kinfo); -if ( rc <0 ) -return rc; - -if ( kinfo.dom0less_feature &DOM0LESS_XENSTORE ) - { -ASSERT (hardware_domain); - rc =alloc_xenstore_evtchn (d); -if ( rc <0 ) -return rc; - d->arch.hvm.params[HVM_PARAM_STORE_PFN ] = ~0ULL ; - } -return rc; } -struct xen_domctl_createdomain __init arch_xen_domctl_createdomain (void ) {struct xen_domctl_createdomain d_cfg = {
@@ -868,6 +353,22 @@ void __init arch_create_domus(struct dt_device_node *node, } } +int __init init_intc_phandle (struct kernel_info *kinfo,const char *name, +const int node_next,const void *pfdt) +{ +if (dt_node_cmp (name,"gic" ) ==0 ) + { +uint32_t phandle_intc =fdt_get_phandle (pfdt, node_next); + +if ( phandle_intc !=0 ) + kinfo->phandle_intc = phandle_intc; + +return 0 ; + } + +return 1 ; +} +/* * Local variables: * mode: C
xen/common/device-tree/dom0less-build.c +559 -0
579 lines not on this page · raw message
xen/include/asm-generic/dom0less-build.h +14 -0
@@ -8,6 +8,9 @@#include <public/domctl.h> +struct kernel_info ; +struct dt_device_node ; +void create_domUs (void );bool is_dom0less_mode (void );
@@ -18,6 +21,17 @@ void arch_create_domus(struct dt_device_node *node,struct xen_domctl_createdomain *d_cfg, unsigned int flags); +int init_vuart (struct domain *d,struct kernel_info *kinfo, +const struct dt_device_node *node); + +int make_intc_domU_node (struct kernel_info *kinfo); +int make_arch_nodes (struct kernel_info *kinfo); + +void set_domain_type (struct domain *d,struct kernel_info *kinfo); + +int init_intc_phandle (struct kernel_info *kinfo,const char *name, +const int node_next,const void *pfdt); +#else /* !CONFIG_DOM0LESS_BOOT */ static inline void create_domUs (void ) {}
Signature · 1 line
2.47.1
PATCH 2/9 asm-generic: move parts of Arm's asm/kernel.h to asm-generic
In reply to Oleksii KurochkoMove the following parts to asm-generic with the following changes:
- struct kernel_info:
- Create arch_kernel_info for arch specific kernel information. At the moment, it contains domain_type for Arm.
- Rename vpl011 to vuart to have more generic name suitable for other archs.
- s/phandle_gic/phandle_intc to have more generic name suitable for other archs.
- Make text_offset of zimage structure available for RISCV_64.
- Wrap by #ifdef KERNEL_INFO_SHM_MEM_INIT definition of KERNEL_SHM_MEM_INIT and wrap by #ifndef KERNEL_INFO_INIT definition of KERNEL_INFO_INIT to have ability to override KERNEL_INFO_SHM_MEM_INIT for arch in case it doesn't want to use generic one.
- All other parts are left as is from Arm's asm/kernel.h
Because of the changes in struct kernel_info the correspondent parts of Arm's code are updated.
As part of this patch the following clean up happens:
- Drop asm/setup.h from asm/kernel.h as nothing depends from it. Add inclusion of asm/setup.h for a code which uses device_tree_get_reg() to avoid compilation issues for CONFIG_STATIC_MEMORY and CONFIG_STATIC_SHM.
--- xen/arch/arm/dom0less-build.c | 28 +++--- xen/arch/arm/domain_build.c | 10 +- xen/arch/arm/include/asm/kernel.h | 115 +---------------------- xen/arch/arm/kernel.c | 10 +- xen/arch/arm/static-memory.c | 1 + xen/arch/arm/static-shmem.c | 1 + xen/include/asm-generic/kernel.h | 146 ++++++++++++++++++++++++++++++ 7 files changed, 175 insertions(+), 136 deletions(-) create mode 100644 xen/include/asm-generic/kernel.h
xen/arch/arm/dom0less-build.c +14 -14
@@ -57,11 +57,11 @@ static int __init make_gicv2_domU_node(struct kernel_info *kinfo)if (res)return res; - res =fdt_property_cell (fdt,"linux,phandle" , kinfo->phandle_gic); + res =fdt_property_cell (fdt,"linux,phandle" , kinfo->phandle_intc);if (res)return res; - res =fdt_property_cell (fdt,"phandle" , kinfo->phandle_gic); + res =fdt_property_cell (fdt,"phandle" , kinfo->phandle_intc);if (res)return res;
@@ -128,11 +128,11 @@ static int __init make_gicv3_domU_node(struct kernel_info *kinfo)if (res)return res; - res =fdt_property_cell (fdt,"linux,phandle" , kinfo->phandle_gic); + res =fdt_property_cell (fdt,"linux,phandle" , kinfo->phandle_intc);if (res)return res; - res =fdt_property_cell (fdt,"phandle" , kinfo->phandle_gic); + res =fdt_property_cell (fdt,"phandle" , kinfo->phandle_intc);if (res)return res;
@@ -193,7 +193,7 @@ static int __init make_vpl011_uart_node(struct kernel_info *kinfo)return res; res =fdt_property_cell (fdt,"interrupt-parent" , - kinfo->phandle_gic); + kinfo->phandle_intc);if ( res )return res;
@@ -479,10 +479,10 @@ static int __init domain_handle_dtb_bootmodule(struct domain *d,*/ if (dt_node_cmp (name,"gic" ) ==0 ) { -uint32_t phandle_gic =fdt_get_phandle (pfdt, node_next); +uint32_t phandle_intc =fdt_get_phandle (pfdt, node_next); -if ( phandle_gic !=0 ) - kinfo->phandle_gic = phandle_gic; +if ( phandle_intc !=0 ) + kinfo->phandle_intc = phandle_intc;continue ; }
@@ -525,7 +525,7 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo)int addrcells, sizecells;int ret, fdt_size =DOMU_DTB_SIZE ; - kinfo->phandle_gic =GUEST_PHANDLE_GIC ; + kinfo->phandle_intc =GUEST_PHANDLE_GIC ; kinfo->gnttab_start =GUEST_GNTTAB_BASE ; kinfo->gnttab_size =GUEST_GNTTAB_SIZE ;
@@ -587,7 +587,7 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo)/* * domain_handle_dtb_bootmodule has to be called before the rest of * the device tree is generated because it depends on the value of -* the field phandle_gic. +* the field phandle_intc. */ if ( kinfo->dtb_bootmodule ) {
@@ -604,7 +604,7 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo)if ( ret ) goto err; -if ( kinfo->vpl011 ) +if ( kinfo->vuart ) { ret = -EINVAL ;#ifdef CONFIG_SBSA_VUART_CONSOLE
@@ -705,7 +705,7 @@ int __init construct_domU(struct domain *d,printk ("*** LOADING DOMU cpus=%u memory=%#" PRIx64"KB ***\n" , d->max_vcpus, mem); - kinfo.vpl011 =dt_property_read_bool (node,"vpl011" ); + kinfo.vuart =dt_property_read_bool (node,"vpl011" ); rc =dt_property_read_string (node,"xen,enhanced" , &dom0less_enhanced); if ( rc == -EILSEQ ||
@@ -733,7 +733,7 @@ int __init construct_domU(struct domain *d,#ifdef CONFIG_ARM_64 /* type must be set before allocate memory */ - d->arch.type = kinfo.type; + d->arch.type = kinfo.arch.type;#endif if ( !dt_find_property (node,"xen,static-mem" ,NULL ) )allocate_memory (d, &kinfo);
@@ -751,7 +751,7 @@ int __init construct_domU(struct domain *d,* tree node in prepare_dtb_domU, so initialization on related variables * shall be done first. */ -if ( kinfo.vpl011 ) +if ( kinfo.vuart ) { rc =domain_vpl011_init (d,NULL );if ( rc <0 )
xen/arch/arm/domain_build.c +5 -5
@@ -747,7 +747,7 @@ static int __init fdt_property_interrupts(const struct kernel_info *kinfo,return res; res =fdt_property_cell (kinfo->fdt,"interrupt-parent" , - kinfo->phandle_gic); + kinfo->phandle_intc);return res; }
@@ -2026,7 +2026,7 @@ static int __init prepare_dtb_hwdom(struct domain *d, struct kernel_info *kinfo)ASSERT (dt_host && (dt_host->sibling ==NULL )); - kinfo->phandle_gic = dt_interrupt_controller->phandle; + kinfo->phandle_intc = dt_interrupt_controller->phandle; fdt = device_tree_flattened; new_size =fdt_totalsize (fdt) +DOM0_FDT_EXTRA_SIZE ;
@@ -2194,13 +2194,13 @@ int __init construct_domain(struct domain *d, struct kernel_info *kinfo)#ifdef CONFIG_ARM_64 /* if aarch32 mode is not supported at EL1 do not allow 32-bit domain */ -if ( !(cpu_has_el1_32 ) && kinfo->type ==DOMAIN_32BIT ) +if ( !(cpu_has_el1_32 ) && kinfo->arch.type ==DOMAIN_32BIT ) {printk ("Platform does not support 32-bit domain\n" );return -EINVAL ; } -if (is_sve_domain (d) && (kinfo->type ==DOMAIN_32BIT ) ) +if (is_sve_domain (d) && (kinfo->arch.type ==DOMAIN_32BIT ) ) {printk ("SVE is not available for 32-bit domain\n" );return -EINVAL ;
@@ -2307,7 +2307,7 @@ static int __init construct_dom0(struct domain *d)#ifdef CONFIG_ARM_64 /* type must be set before allocate_memory */ - d->arch.type = kinfo.type; + d->arch.type = kinfo.arch.type;#endif find_gnttab_region (d, &kinfo);if (is_domain_direct_mapped (d) )
xen/arch/arm/include/asm/kernel.h +3 -112
128 lines not on this page · raw message
xen/arch/arm/kernel.c +5 -5
@@ -101,7 +101,7 @@ static paddr_t __init kernel_zimage_place(struct kernel_info *info)paddr_t load_addr;#ifdef CONFIG_ARM_64 -if ( (info->type ==DOMAIN_64BIT ) && (info->zimage.start ==0 ) ) +if ( (info->arch.type ==DOMAIN_64BIT ) && (info->zimage.start ==0 ) )return mem->bank[0 ].start + info->zimage.text_offset;#endif
@@ -371,10 +371,10 @@ static int __init kernel_uimage_probe(struct kernel_info *info,switch ( uimage.arch ) {case IH_ARCH_ARM : - info->type =DOMAIN_32BIT ; + info->arch.type =DOMAIN_32BIT ;break ;case IH_ARCH_ARM64 : - info->type =DOMAIN_64BIT ; + info->arch.type =DOMAIN_64BIT ;break ;default :printk (XENLOG_ERR "Unsupported uImage arch type %d\n" , uimage.arch);
@@ -444,7 +444,7 @@ static int __init kernel_zimage64_probe(struct kernel_info *info, info->load = kernel_zimage_load; - info->type =DOMAIN_64BIT ; + info->arch.type =DOMAIN_64BIT ;return 0 ; }
@@ -496,7 +496,7 @@ static int __init kernel_zimage32_probe(struct kernel_info *info, info->load = kernel_zimage_load;#ifdef CONFIG_ARM_64 - info->type =DOMAIN_32BIT ; + info->arch.type =DOMAIN_32BIT ;#endif return 0 ;
xen/arch/arm/static-memory.c +1 -0
@@ -2,6 +2,7 @@#include <xen/sched.h> +#include <asm/setup.h> #include <asm/static-memory.h> static bool __init append_static_memory_to_bank(struct domain *d,
xen/arch/arm/static-shmem.c +1 -0
@@ -6,6 +6,7 @@#include <xen/sched.h> #include <asm/domain_build.h> +#include <asm/setup.h> #include <asm/static-memory.h> #include <asm/static-shmem.h>
xen/include/asm-generic/kernel.h new file +146 -0
146 lines not on this page · raw message
Signature · 1 line
2.47.1
PATCH 1/9 xen/common: dom0less: make some parts of Arm's CONFIG_DOM0LESS common
In reply to Oleksii KurochkoUnify the API for creating DomUs and checking for Dom0less mode across architectures, including Arm and RISC-V, with potential applicability for PPC.
Move dom0less-build.h from the Arm-specific directory to asm-generic as these header is expected to be the same across acrhictectures with some updates: add the following declaration of construct_domU(), arch_xen_domctl_createdomain() and arch_create_domus() as there are some parts which are still architecture-specific.
Relocate the CONFIG_DOM0LESS configuration to the common with adding "depends on Arm" to not break builds for architectures which at the moment don't support CONFIG_DOM0LESS config, especically it would be useful to not provide stubs for construct_domU(), arch_xen_domctl_createdomain() and arch_create_domus() in case of *-randconfig which may set CONFIG_DOM0LESS=y.
Move is_dom0less_mode() function to the common code, as it depends on boot modules that are already part of the common code.
Move create_domUs() function to the common code with some updates:
- Add function arch_xen_domctl_createdomain() as structure xen_domctl_createdomain may have some arch-spicific information and initialization.
- Add arch_create_domus() to cover parsing of arch-specific features, for example, SVE (Scalar Vector Extension ) exists only in Arm.
--- xen/arch/arm/Kconfig | 8 - xen/arch/arm/dom0less-build.c | 270 ++++++---------------- xen/arch/arm/include/asm/Makefile | 1 + xen/arch/arm/include/asm/dom0less-build.h | 32 --- xen/common/Kconfig | 9 + xen/common/device-tree/Makefile | 1 + xen/common/device-tree/dom0less-build.c | 161 +++++++++++++ xen/include/asm-generic/dom0less-build.h | 40 ++++ 8 files changed, 283 insertions(+), 239 deletions(-) delete mode 100644 xen/arch/arm/include/asm/dom0less-build.h create mode 100644 xen/common/device-tree/dom0less-build.c create mode 100644 xen/include/asm-generic/dom0less-build.h
xen/arch/arm/Kconfig +0 -8
@@ -117,14 +117,6 @@ config GICV2 Driver for the ARM Generic Interrupt Controller v2. If unsure, say Y -config DOM0LESS_BOOT - bool "Dom0less boot support" if EXPERT - default y - help - Dom0less boot support enables Xen to create and start domU guests during - Xen boot without the need of a control domain (Dom0), which could be - present anyway. - config GICV3 bool "GICv3 driver" depends on !NEW_VGIC
xen/arch/arm/dom0less-build.c +71 -199
305 lines not on this page · raw message
xen/arch/arm/include/asm/Makefile +1 -0
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only generic-y += altp2m.h generic-y += device.h +generic-y += dom0less-build.h generic-y += hardirq.h generic-y += iocap.h generic-y += paging.h
xen/arch/arm/include/asm/dom0less-build.h deleted +0 -32
@@ -1,32 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#ifndef __ASM_DOM0LESS_BUILD_H_ -#define __ASM_DOM0LESS_BUILD_H_ - -#include <xen/stdbool.h> - -#ifdef CONFIG_DOM0LESS_BOOT - -void create_domUs (void ); -bool is_dom0less_mode (void ); - -#else /* !CONFIG_DOM0LESS_BOOT */ - -static inline void create_domUs (void ) {} -static inline bool is_dom0less_mode (void ) -{ -return false; -} - -#endif /* CONFIG_DOM0LESS_BOOT */ - -#endif /* __ASM_DOM0LESS_BUILD_H_ */ - -/* -* Local variables: -* mode: C -* c-file-style: "BSD" -* c-basic-offset: 4 -* indent-tabs-mode: nil -* End: -*/
xen/common/Kconfig +9 -0
@@ -12,6 +12,15 @@ config CORE_PARKING bool depends on NR_CPUS > 1 +config DOM0LESS_BOOT + bool "Dom0less boot support" if EXPERT + depends on ARM + default ARM + help + Dom0less boot support enables Xen to create and start domU guests during + Xen boot without the need of a control domain (Dom0), which could be + present anyway. + config GRANT_TABLE bool "Grant table support" if EXPERT default y
xen/common/device-tree/Makefile +1 -0
@@ -1,5 +1,6 @@ obj-y += bootfdt.init.o obj-y += bootinfo.init.o obj-y += device-tree.o +obj-$(CONFIG_DOM0LESS_BOOT) += dom0less-build.o obj-$(CONFIG_OVERLAY_DTB) += dt-overlay.o obj-y += intc.o
xen/common/device-tree/dom0less-build.c new file +161 -0
161 lines not on this page · raw message
xen/include/asm-generic/dom0less-build.h new file +40 -0
@@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_GENERIC_DOM0LESS_BUILD_H__ +#define __ASM_GENERIC_DOM0LESS_BUILD_H__ + +#include <xen/stdbool.h> + +#ifdef CONFIG_DOM0LESS_BOOT + +#include <public/domctl.h> + +void create_domUs (void ); +bool is_dom0less_mode (void ); + +int construct_domU (struct domain *d,const struct dt_device_node *node); + +struct xen_domctl_createdomain arch_xen_domctl_createdomain (void ); +void arch_create_domus (struct dt_device_node *node, +struct xen_domctl_createdomain *d_cfg, +unsigned int flags); + +#else /* !CONFIG_DOM0LESS_BOOT */ + +static inline void create_domUs (void ) {} +static inline bool is_dom0less_mode (void ) +{ +return false; +} + +#endif /* CONFIG_DOM0LESS_BOOT */ + +#endif /* __ASM_GENERIC_DOM0LESS_BUILD_H__ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
2.47.1
PATCH 8/9 xen/common: dom0less: introduce common domain-build.c
In reply to Oleksii KurochkoSome functions of Arm's domain_build.c could be reused by dom0less or other features connected to domain construction/build.
The following functions are moved to common:
- get_allocation_size().
- allocate_domheap_memory().
- guest_map_pages().
- allocate_bank_memory().
- add_hwdom_free_regions().
- find_unallocated_memory().
- allocate_memory().
- dtb_load().
- initrd_load().
Prototype of dtb_load() and initrd_load() is updated to recieve a pointer to copy_to_guest_phys() as some archs require copy_to_guest_phys_fluch_dcache().
Update arm/include/asm/Makefile to generate domain-build.h for Arm as it is used by domain-build.c.
--- xen/arch/arm/domain_build.c | 400 +----------------------- xen/arch/arm/include/asm/Makefile | 1 + xen/common/device-tree/Makefile | 1 + xen/common/device-tree/domain-build.c | 405 +++++++++++++++++++++++++ xen/include/asm-generic/domain-build.h | 33 +- 5 files changed, 441 insertions(+), 399 deletions(-) create mode 100644 xen/common/device-tree/domain-build.c
xen/arch/arm/domain_build.c +2 -398
@@ -119,18 +119,6 @@ struct vcpu *__init alloc_dom0_vcpu0(struct domain *dom0)return vcpu_create (dom0,0 ); } -unsigned int __init get_allocation_size (paddr_t size) -{ -/* -* get_order_from_bytes returns the order greater than or equal to -* the given size, but we need less than or equal. Adding one to -* the size pushes an evenly aligned size into the next order, so -* we can then unconditionally subtract 1 from the order which is -* returned. -*/ -return get_order_from_bytes (size +1 ) -1 ; -} -/* * Insert the given pages into a memory bank, banks are ordered by address. *
@@ -417,98 +405,6 @@ static void __init allocate_memory_11(struct domain *d, } } -bool __init allocate_domheap_memory (struct domain *d,paddr_t tot_size, -alloc_domheap_mem_cb cb,void *extra) -{ -unsigned int max_order =UINT_MAX ; - -while ( tot_size >0 ) - { -unsigned int order =get_allocation_size (tot_size); -struct page_info *pg; - - order =min (max_order, order); - - pg =alloc_domheap_pages (d, order,0 ); -if ( !pg ) - { -/* -* If we can't allocate one page, then it is unlikely to -* succeed in the next iteration. So bail out. -*/ -if ( !order ) -return false; - -/* -* If we can't allocate memory with order, then it is -* unlikely to succeed in the next iteration. -* Record the order - 1 to avoid re-trying. -*/ - max_order = order -1 ; -continue ; - } - -if ( !cb (d, pg, order, extra) ) -return false; - - tot_size -= (1ULL << (PAGE_SHIFT + order)); - } - -return true; -} - -static bool __init guest_map_pages (struct domain *d,struct page_info *pg, -unsigned int order,void *extra) -{ -gfn_t *sgfn = (gfn_t *)extra; -int res; - -BUG_ON (!sgfn); - res =guest_physmap_add_page (d, *sgfn,page_to_mfn (pg), order); -if ( res ) - { -dprintk (XENLOG_ERR ,"Failed map pages to DOMU: %d" , res); -return false; - } - - *sgfn =gfn_add (*sgfn,1UL << order); - -return true; -} - -bool __init allocate_bank_memory (struct kernel_info *kinfo,gfn_t sgfn, -paddr_t tot_size) -{ -struct membanks *mem =kernel_info_get_mem (kinfo); -struct domain *d = kinfo->d; -struct membank *bank; - -/* -* allocate_bank_memory can be called with a tot_size of zero for -* the second memory bank. It is not an error and we can safely -* avoid creating a zero-size memory bank. -*/ -if ( tot_size ==0 ) -return true; - - bank = &mem->bank[mem->nr_banks]; - bank->start =gfn_to_gaddr (sgfn); - bank->size = tot_size; - -/* -* Allocate pages from the heap until tot_size is zero and map them to the -* guest using guest_map_pages, passing the starting gfn as extra parameter -* for the map operation. -*/ -if ( !allocate_domheap_memory (d, tot_size, guest_map_pages, &sgfn) ) -return false; - - mem->nr_banks++; - kinfo->unassigned_mem -= bank->size; - -return true; -} -/* * When PCI passthrough is available we want to keep the * "linux,pci-domain" in sync for every host bridge.
@@ -899,229 +795,6 @@ int __init add_ext_regions(unsigned long s_gfn, unsigned long e_gfn,return 0 ; } -static int __init add_hwdom_free_regions (unsigned long s_gfn, -unsigned long e_gfn,void *data) -{ -struct membanks *free_regions = data; -paddr_t start, size; -paddr_t s =pfn_to_paddr (s_gfn); -paddr_t e =pfn_to_paddr (e_gfn); -unsigned int i, j; - -if ( free_regions->nr_banks >= free_regions->max_banks ) -return 0 ; - -/* -* Both start and size of the free region should be 2MB aligned to -* potentially allow superpage mapping. -*/ - start = (s +SZ_2M -1 ) & ~(SZ_2M -1 ); -if ( start > e ) -return 0 ; - -/* -* e is actually "end-1" because it is called by rangeset functions -* which are inclusive of the last address. -*/ - e +=1 ; - size = (e - start) & ~(SZ_2M -1 ); - -/* Find the insert position (descending order). */ -for ( i =0 ; i < free_regions->nr_banks ; i++ ) -if ( size > free_regions->bank[i].size ) -break ; - -/* Move the other banks to make space. */ -for ( j = free_regions->nr_banks; j > i ; j-- ) - { - free_regions->bank[j].start = free_regions->bank[j -1 ].start; - free_regions->bank[j].size = free_regions->bank[j -1 ].size; - } - - free_regions->bank[i].start = start; - free_regions->bank[i].size = size; - free_regions->nr_banks++; - -return 0 ; -} - -/* -* Find unused regions of Host address space which can be exposed to domain -* using the host memory layout. In order to calculate regions we exclude every -* region passed in mem_banks from the Host RAM. -*/ -static int __init find_unallocated_memory (const struct kernel_info *kinfo, -const struct membanks *mem_banks[], -unsigned int nr_mem_banks, -struct membanks *free_regions, -int (*cb)(unsigned long s_gfn, -unsigned long e_gfn, -void *data)) -{ -const struct membanks *mem =bootinfo_get_mem (); -struct rangeset *unalloc_mem; -paddr_t start, end; -unsigned int i, j; -int res; - -ASSERT (domain_use_host_layout (kinfo->d)); - - unalloc_mem =rangeset_new (NULL ,NULL ,0 ); -if ( !unalloc_mem ) -return -ENOMEM ; - -/* Start with all available RAM */ -for ( i =0 ; i < mem->nr_banks; i++ ) - { - start = mem->bank[i].start; - end = mem->bank[i].start + mem->bank[i].size; - res =rangeset_add_range (unalloc_mem,PFN_DOWN (start), -PFN_DOWN (end -1 )); -if ( res ) - { -printk (XENLOG_ERR "Failed to add: %#" PRIpaddr"->%#" PRIpaddr"\n" , - start, end); - goto out; - } - } - -/* Remove all regions listed in mem_banks */ -for ( i =0 ; i < nr_mem_banks; i++ ) -for ( j =0 ; j < mem_banks[i]->nr_banks; j++ ) - { - start = mem_banks[i]->bank[j].start; - -/* Shared memory banks can contain INVALID_PADDR as start */ -if (INVALID_PADDR == start ) -continue ; - - end = mem_banks[i]->bank[j].start + mem_banks[i]->bank[j].size; - res =rangeset_remove_range (unalloc_mem,PFN_DOWN (start), -PFN_DOWN (end -1 )); -if ( res ) - { -printk (XENLOG_ERR -"Failed to add: %#" PRIpaddr"->%#" PRIpaddr", error %d\n" , - start, end, res); - goto out; - } - } - - start =0 ; - end = (1ULL << p2m_ipa_bits) -1 ; - res =rangeset_report_ranges (unalloc_mem,PFN_DOWN (start),PFN_DOWN (end), - cb, free_regions); -if ( res ) - free_regions->nr_banks =0 ; -else if ( !free_regions->nr_banks ) - res = -ENOENT ; - -out: -rangeset_destroy (unalloc_mem); - -return res; -} - -void __init allocate_memory (struct domain *d,struct kernel_info *kinfo) -{ -struct membanks *mem =kernel_info_get_mem (kinfo); -unsigned int i, nr_banks =GUEST_RAM_BANKS ; -struct membanks *hwdom_free_mem =NULL ; - -printk (XENLOG_INFO "Allocating mappings totalling %ldMB for %pd:\n" , -/* Don't want format this as PRIpaddr (16 digit hex) */ - (unsigned long )(kinfo->unassigned_mem >>20 ), d); - - mem->nr_banks =0 ; -/* -* Use host memory layout for hwdom. Only case for this is when LLC coloring -* is enabled. -*/ -if (is_hardware_domain (d) ) - { - struct membanks *gnttab = xzalloc_flex_struct(struct membanks, bank, 1); -/* -* Exclude the following regions: -* 1) Remove reserved memory -* 2) Grant table assigned to hwdom -*/ -const struct membanks *mem_banks[] = { -bootinfo_get_reserved_mem (), - gnttab, - }; - -if ( !gnttab ) - goto fail; - - gnttab->nr_banks =1 ; - gnttab->bank[0 ].start = kinfo->gnttab_start; - gnttab->bank[0 ].size = kinfo->gnttab_size; - - hwdom_free_mem = xzalloc_flex_struct(struct membanks, bank, -NR_MEM_BANKS ); -if ( !hwdom_free_mem ) - goto fail; - - hwdom_free_mem->max_banks =NR_MEM_BANKS ; - -if (find_unallocated_memory (kinfo, mem_banks,ARRAY_SIZE (mem_banks), - hwdom_free_mem, add_hwdom_free_regions) ) - goto fail; - - nr_banks = hwdom_free_mem->nr_banks; -xfree (gnttab); - } - -for ( i =0 ; kinfo->unassigned_mem >0 && nr_banks >0 ; i++, nr_banks-- ) - { -paddr_t bank_start, bank_size; - -if (is_hardware_domain (d) ) - { - bank_start = hwdom_free_mem->bank[i].start; - bank_size = hwdom_free_mem->bank[i].size; - } -else - { -const uint64_t bankbase[] =GUEST_RAM_BANK_BASES ; -const uint64_t banksize[] =GUEST_RAM_BANK_SIZES ; - -if ( i >=GUEST_RAM_BANKS ) - goto fail; - - bank_start = bankbase[i]; - bank_size = banksize[i]; - } - - bank_size =MIN (bank_size, kinfo->unassigned_mem); -if ( !allocate_bank_memory (kinfo,gaddr_to_gfn (bank_start), bank_size) ) - goto fail; - } - -if ( kinfo->unassigned_mem ) - goto fail; - -for ( i =0 ; i < mem->nr_banks; i++ ) - { -printk (XENLOG_INFO "%pd BANK[%d] %#" PRIpaddr"-%#" PRIpaddr" (%ldMB)\n" , - d, - i, - mem->bank[i].start, - mem->bank[i].start + mem->bank[i].size, -/* Don't want format this as PRIpaddr (16 digit hex) */ - (unsigned long )(mem->bank[i].size >>20 )); - } - -xfree (hwdom_free_mem); -return ; - - fail: -panic ("Failed to allocate requested domain memory." -/* Don't want format this as PRIpaddr (16 digit hex) */ -" %ldKB unallocated. Fix the VMs configurations.\n" , - (unsigned long )kinfo->unassigned_mem >>10 ); -} -static int __init handle_pci_range (const struct dt_device_node *dev,uint64_t addr,uint64_t len,void *data) {
@@ -2056,75 +1729,6 @@ static int __init prepare_dtb_hwdom(struct domain *d, struct kernel_info *kinfo)return -EINVAL ; } -static void __init dtb_load (struct kernel_info *kinfo) -{ -unsigned long left; - -printk ("Loading %pd DTB to 0x%" PRIpaddr"-0x%" PRIpaddr"\n" , - kinfo->d, kinfo->dtb_paddr, - kinfo->dtb_paddr +fdt_totalsize (kinfo->fdt)); - - left =copy_to_guest_phys_flush_dcache (kinfo->d, kinfo->dtb_paddr, - kinfo->fdt, -fdt_totalsize (kinfo->fdt)); - -if ( left !=0 ) -panic ("Unable to copy the DTB to %pd memory (left = %lu bytes)\n" , - kinfo->d, left); -xfree (kinfo->fdt); -} - -static void __init initrd_load (struct kernel_info *kinfo) -{ -const struct bootmodule *mod = kinfo->initrd_bootmodule; -paddr_t load_addr = kinfo->initrd_paddr; -paddr_t paddr, len; -int node; -int res; -__be32 val[2 ]; -__be32 *cellp; -void __iomem *initrd; - -if ( !mod || !mod->size ) -return ; - - paddr = mod->start; - len = mod->size; - -printk ("Loading %pd initrd from %" PRIpaddr" to 0x%" PRIpaddr"-0x%" PRIpaddr"\n" , - kinfo->d, paddr, load_addr, load_addr + len); - -/* Fix up linux,initrd-start and linux,initrd-end in /chosen */ - node =fdt_path_offset (kinfo->fdt,"/chosen" ); -if ( node <0 ) -panic ("Cannot find the /chosen node\n" ); - - cellp = (__be32 *)val; -dt_set_cell (&cellp,ARRAY_SIZE (val), load_addr); - res =fdt_setprop_inplace (kinfo->fdt, node,"linux,initrd-start" , - val,sizeof (val)); -if ( res ) -panic ("Cannot fix up \"linux,initrd-start\" property\n" ); - - cellp = (__be32 *)val; -dt_set_cell (&cellp,ARRAY_SIZE (val), load_addr + len); - res =fdt_setprop_inplace (kinfo->fdt, node,"linux,initrd-end" , - val,sizeof (val)); -if ( res ) -panic ("Cannot fix up \"linux,initrd-end\" property\n" ); - - initrd =ioremap_wc (paddr, len); -if ( !initrd ) -panic ("Unable to map the hwdom initrd\n" ); - - res =copy_to_guest_phys_flush_dcache (kinfo->d, load_addr, - initrd, len); -if ( res !=0 ) -panic ("Unable to copy the initrd in the hwdom memory\n" ); - -iounmap (initrd); -} -/* * Allocate the event channel PPIs and setup the HVM_PARAM_CALLBACK_IRQ. * The allocated IRQ will be found in d->arch.evtchn_irq.
@@ -2217,8 +1821,8 @@ int __init construct_domain(struct domain *d, struct kernel_info *kinfo)*/ kernel_load (kinfo);/* initrd_load will fix up the fdt, so call it before dtb_load */ -initrd_load (kinfo); -dtb_load (kinfo); +initrd_load (kinfo, copy_to_guest_phys_flush_dcache); +dtb_load (kinfo, copy_to_guest_phys_flush_dcache);memset (regs,0 ,sizeof (*regs));
xen/arch/arm/include/asm/Makefile +1 -0
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only generic-y += altp2m.h generic-y += device.h +generic-y += domain-build.h generic-y += dom0less-build.h generic-y += hardirq.h generic-y += iocap.h
xen/common/device-tree/Makefile +1 -0
@@ -1,6 +1,7 @@ obj-y += bootfdt.init.o obj-y += bootinfo.init.o obj-y += device-tree.o +obj-$(CONFIG_DOMAIN_BUILD_HELPERS) += domain-build.o obj-$(CONFIG_DOM0LESS_BOOT) += dom0less-build.o obj-$(CONFIG_OVERLAY_DTB) += dt-overlay.o obj-y += intc.o
xen/common/device-tree/domain-build.c new file +405 -0
405 lines not on this page · raw message
xen/include/asm-generic/domain-build.h +32 -1
@@ -2,6 +2,7 @@#ifndef __ASM_GENERIC_DOMAIN_BUILD_H__#define __ASM_GENERIC_DOMAIN_BUILD_H__ +#include <xen/mm.h> #include <xen/types.h> struct domain ;
@@ -26,7 +27,37 @@ int make_memory_node(const struct kernel_info *kinfo, int addrcells, int sizecells, const struct membanks *mem);int make_timer_node (const struct kernel_info *kinfo); -unsigned int get_allocation_size (paddr_t size); + +static inline int get_allocation_size (paddr_t size) +{ +/* +* get_order_from_bytes returns the order greater than or equal to +* the given size, but we need less than or equal. Adding one to +* the size pushes an evenly aligned size into the next order, so +* we can then unconditionally subtract 1 from the order which is +* returned. +*/ +return get_order_from_bytes (size +1 ) -1 ; +} + +typedef unsigned long (*copy_to_guest_phys_cb )(struct domain *d, +paddr_t gpa, +void *buf, +unsigned int len); + +void initrd_load (struct kernel_info *kinfo, +copy_to_guest_phys_cb copy_to_guest); + +void dtb_load (struct kernel_info *kinfo, +copy_to_guest_phys_cb copy_to_guest); + +int find_unallocated_memory (const struct kernel_info *kinfo, +const struct membanks *mem_banks[], +unsigned int nr_mem_banks, +struct membanks *free_regions, +int (*cb)(unsigned long s_gfn, +unsigned long e_gfn, +void *data));#endif /* __ASM_GENERIC_DOMAIN_BUILD_H__ */
Signature · 1 line
2.47.1
Re: [PATCH v1 1/9] xen/common: dom0less: make some parts of Arm's CONFIG_DOM0LESS common
In reply to Oleksii KurochkoQuoted 3 lines · Oleksii Kurochko
Unify the API for creating DomUs and checking for Dom0less mode across architectures, including Arm and RISC-V, with potential applicability for PPC.
That is you mean to re-use it for RISC-V?
xen/common/Kconfig config CORE_PARKING · line 18
Quoted 10 lines
xen/common/Kconfig +4
-0@@ -12,6 +12,15 @@ config CORE_PARKING bool depends on NR_CPUS > 1 +config DOM0LESS_BOOT + bool "Dom0less boot support" if EXPERT + depends on ARM + default ARM
This then would better be converted to "depends on HAVE_DOM0LESS", which for now only Arm would select. With a dependency on XYZ the default also doesn't need to name XYZ again, i.e. can simply be "default y".
Jan
Re: [PATCH v1 2/9] asm-generic: move parts of Arm's asm/kernel.h to asm-generic
In reply to Oleksii KurochkoQuoted 17 lines · Oleksii Kurochko
Move the following parts to asm-generic with the following changes:
- structkernel_info:
- Createarch_kernel_infofor arch specific kernel information. At the moment, it containsdomain_typefor Arm.
- Rename vpl011 to vuart to have more generic name suitable for other archs.
- s/phandle_gic/phandle_intc to have more generic name suitable for other archs.
- Maketext_offsetof zimage structure available forRISCV_64.
- Wrap by#ifdef KERNEL_INFO_SHM_MEM_INITdefinition ofKERNEL_SHM_MEM_INITand wrap by#ifndef KERNEL_INFO_INITdefinition ofKERNEL_INFO_INITto have ability to overrideKERNEL_INFO_SHM_MEM_INITfor arch in case it doesn't want to use generic one.
- All other parts are left as is from Arm'sasm/kernel.hBecause of the changes in struct
kernel_infothe correspondent parts of Arm's code are updated.
Quoted 6 lines
As part of this patch the following clean up happens:
- Dropasm/setup.hfromasm/kernel.has nothing depends from it. Add inclusion ofasm/setup.hfor a code which usesdevice_tree_get_reg()to avoid compilation issues forCONFIG_STATIC_MEMORYandCONFIG_STATIC_SHM.Signed-off-by Oleksii Kurochko <[email protected]>
I question that what is being moved qualifies for asm-generic, an in particular for a header named kernel.h. Some of what you move may make sense to move to dom0less-build.h instead. But everything that doesn't fit there needs to find a different home, imo.
Jan
Re: [PATCH v1 4/9] asm-generic: move Arm's static-memory.h to asm-generic
In reply to Oleksii KurochkoQuoted 7 lines · Oleksii Kurochko
Except moving Arm's
static-memory.hto asm-generic #ifdef header guard is updated: s/__ASM_STATIC_MEMORY_H_/__ASM_GENERIC_STATIC_MEMORY_H__.Update arm/include/asm/Makefile to use asm-generic version of
static-memory.hfor Arm.Signed-off-by Oleksii Kurochko <[email protected]>
Here as well as in patch 5 the "why" is again missing. Moving is fine, as long as it's clear that this will actually be used by another arch (e.g. RISC-V). Whether you have such (immediate or at least near term) plans is unclear though, as both features look like relatively advanced ones, and hence more basic functionality may want to appear first in RISC-V.
Jan
Re: [PATCH v1 6/9] asm-generic: move some parts of Arm's domain_build.h to asm-generic header
In reply to Oleksii KurochkoQuoted 10 lines · Oleksii Kurochko
Nothing changed. Only some functions declaration are moved to asm-generic header as they are expected to be used by common code of domain builing or dom0less.
Signed-off-by Oleksii Kurochko <[email protected]>--- xen/arch/arm/include/asm/domain_build.h | 19 ++---------- xen/include/asm-generic/domain-build.h | 41 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 xen/include/asm-generic/domain-build.h
Again I question this movement under this name. "Domain building" is a pretty generic thing, yes, but what you move would e.g. be entirely inapplicable on x86 (as it is now). For example ...
Quoted 11 lines
xen/include/asm-generic/domain-build.h new file +8
-0@@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_GENERIC_DOMAIN_BUILD_H__ +#define __ASM_GENERIC_DOMAIN_BUILD_H__ + +#include <xen/types.h> + +struct domain ; +struct page_info ;
xen/include/asm-generic/domain-build.h line 18
Quoted 10 lines
xen/include/asm-generic/domain-build.h new file +10
-0+struct kernel_info ; +struct membanks ; + +typedef bool (*alloc_domheap_mem_cb )(struct domain *d,struct page_info *pg, +unsigned int order,void *extra); +bool allocate_domheap_memory (struct domain *d,paddr_t tot_size, +alloc_domheap_mem_cb cb,void *extra); + +bool allocate_bank_memory (struct kernel_info *kinfo,gfn_t sgfn, +paddr_t tot_size);
... the term "bank" seems pretty closely tied to DT. Other stuff ...
xen/include/asm-generic/domain-build.h line 27
Quoted 9 lines
xen/include/asm-generic/domain-build.h new file +9
-0+void allocate_memory (struct domain *d,struct kernel_info *kinfo); +int construct_domain (struct domain *d,struct kernel_info *kinfo); +int make_chosen_node (const struct kernel_info *kinfo); +int make_cpus_node (const struct domain *d,void *fdt); +int make_hypervisor_node (struct domain *d,const struct kernel_info *kinfo, +int addrcells,int sizecells); +int make_memory_node (const struct kernel_info *kinfo,int addrcells, +int sizecells,const struct membanks *mem); +int make_timer_node (const struct kernel_info *kinfo);
... here also falls in this category. Stuff like this may well live under asm-generic/, but the file name chosen then needs to reflect constraints.
xen/include/asm-generic/domain-build.h line 31
Quoted 3 lines
xen/include/asm-generic/domain-build.h new file +3
-0+unsigned int get_allocation_size (paddr_t size); + +
Nit: As before - no double blank lines please.
Jan
Re: [PATCH v1 1/9] xen/common: dom0less: make some parts of Arm's CONFIG_DOM0LESS common
In reply to Jan BeulichQuoted 5 lines · Jan Beulich
Quoted 3 lines · Oleksii Kurochko
Unify the API for creating DomUs and checking for Dom0less mode across architectures, including Arm and RISC-V, with potential applicability for PPC.
That is you mean to re-use it for RISC-V?
Yes, I will re-use it.
Quoted 7 lines
Quoted 7 lines
xen/common/Kconfig +0
-0@@ -12,6 +12,15 @@ config CORE_PARKING bool depends on NR_CPUS > 1
Quoted 7 lines
xen/common/Kconfig config CORE_PARKING · line 18
Quoted 4 lines
xen/common/Kconfig +4
-0+config DOM0LESS_BOOT + bool "Dom0less boot support" if EXPERT + depends on ARM + default ARMThis then would better be converted to "depends on
HAVE_DOM0LESS", which for now only Arm would select. With a dependency on XYZ the default also doesn't need to name XYZ again, i.e. can simply be "default y".
"depends on HAVE_DOM0LESS" would be better. I will update correspondingly.
Thanks.
~ Oleksii
Re: [PATCH v1 2/9] asm-generic: move parts of Arm's asm/kernel.h to asm-generic
In reply to Jan BeulichQuoted 23 lines · Jan Beulich
Quoted 22 lines · Oleksii Kurochko
Move the following parts to asm-generic with the following changes:
- structkernel_info:
- Createarch_kernel_infofor arch specific kernel information. At the moment, it containsdomain_typefor Arm.
- Rename vpl011 to vuart to have more generic name suitable for other archs.
- s/phandle_gic/phandle_intc to have more generic name suitable for other archs.
- Maketext_offsetof zimage structure available forRISCV_64.
- Wrap by#ifdef KERNEL_INFO_SHM_MEM_INITdefinition ofKERNEL_SHM_MEM_INITand wrap by#ifndef KERNEL_INFO_INITdefinition ofKERNEL_INFO_INITto have ability to overrideKERNEL_INFO_SHM_MEM_INITfor arch in case it doesn't want to use generic one.
- All other parts are left as is from Arm'sasm/kernel.hBecause of the changes in struct
kernel_infothe correspondent parts of Arm's code are updated.As part of this patch the following clean up happens:
- Dropasm/setup.hfromasm/kernel.has nothing depends from it. Add inclusion ofasm/setup.hfor a code which usesdevice_tree_get_reg()to avoid compilation issues forCONFIG_STATIC_MEMORYandCONFIG_STATIC_SHM.
Quoted 5 lines
Quoted 1 line
Signed-off-by Oleksii Kurochko<[email protected]>I question that what is being moved qualifies for asm-generic, an in particular for a header named
kernel.h. Some of what you move may make sense to move todom0less-build.hinstead. But everything that doesn't fit there needs to find a different home, imo.
It doesn't clear what then should be in kernel.h, I did in this way to not have a problem with header inclusion during the build of Arm.
Definitions DOM0LESSS_* could be moved to dom0less-build.h, all other doesn't really connected only to dom0less feature and could be re-used for dom0 so it seems like it should leave in a separate header ( if kernel.h isn't good for it ).
Probably kernel.h shouldn't leave in asm-generic as nothing architecture specific is in it, but on the other hand, will it be okay to have something in xen/include if it isn't supported by all architectures?
~ Oleksii
Re: [PATCH v1 4/9] asm-generic: move Arm's static-memory.h to asm-generic
In reply to Jan BeulichQuoted 7 lines · Jan Beulich
Quoted 6 lines · Oleksii Kurochko
Except moving Arm's
static-memory.hto asm-generic #ifdef header guard is updated: s/__ASM_STATIC_MEMORY_H_/__ASM_GENERIC_STATIC_MEMORY_H__.Update arm/include/asm/Makefile to use asm-generic version of
static-memory.hfor Arm.
Quoted 6 lines
Quoted 1 line
Signed-off-by Oleksii Kurochko<[email protected]>Here as well as in patch 5 the "why" is again missing. Moving is fine, as long as it's clear that this will actually be used by another arch (e.g. RISC-V). Whether you have such (immediate or at least near term) plans is unclear though, as both features look like relatively advanced ones, and hence more basic functionality may want to appear first in RISC-V.
The reason is that suggested generic dom0less solution is using allocate_static_memory() and assign_static_memory_11() so I decided that it would be better to have stubs for them in asm-generic header that wrapping by the code by "#ifdef CONFIG_STATIC_MEMORY" the places where it is used.
But considering the status of RISC-V's Xen downstream and I still don't have cases where CONFIG_STATIC_MEMORY is used for RISC-V, probably, it would be better just to use wrapping in generic code instead of stubs.
~ Oleksii
Re: [PATCH v1 6/9] asm-generic: move some parts of Arm's domain_build.h to asm-generic header
In reply to Jan BeulichQuoted 38 lines · Jan Beulich
Quoted 10 lines · Oleksii Kurochko
Nothing changed. Only some functions declaration are moved to asm-generic header as they are expected to be used by common code of domain builing or dom0less.
Signed-off-by Oleksii Kurochko<[email protected]>--- xen/arch/arm/include/asm/domain_build.h | 19 ++---------- xen/include/asm-generic/domain-build.h | 41 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 17 deletions(-)create mode 100644
xen/include/asm-generic/domain-build.hAgain I question this movement under this name. "Domain building" is a pretty generic thing, yes, but what you move would e.g. be entirely inapplicable on x86 (as it is now). For example ...
Quoted 11 lines
xen/include/asm-generic/domain-build.h new file +8
-0@@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_GENERIC_DOMAIN_BUILD_H__ +#define __ASM_GENERIC_DOMAIN_BUILD_H__ + +#include <xen/types.h> + +struct domain ; +struct page_info ;xen/include/asm-generic/domain-build.h line 18
Quoted 10 lines
xen/include/asm-generic/domain-build.h new file +10
-0+struct kernel_info ; +struct membanks ; + +typedef bool (*alloc_domheap_mem_cb )(struct domain *d,struct page_info *pg, +unsigned int order,void *extra); +bool allocate_domheap_memory (struct domain *d,paddr_t tot_size, +alloc_domheap_mem_cb cb,void *extra); + +bool allocate_bank_memory (struct kernel_info *kinfo,gfn_t sgfn, +paddr_t tot_size);... the term "bank" seems pretty closely tied to DT. Other stuff ...
Quoted 12 lines
xen/include/asm-generic/domain-build.h line 27
Quoted 9 lines
xen/include/asm-generic/domain-build.h new file +9
-0+void allocate_memory (struct domain *d,struct kernel_info *kinfo); +int construct_domain (struct domain *d,struct kernel_info *kinfo); +int make_chosen_node (const struct kernel_info *kinfo); +int make_cpus_node (const struct domain *d,void *fdt); +int make_hypervisor_node (struct domain *d,const struct kernel_info *kinfo, +int addrcells,int sizecells); +int make_memory_node (const struct kernel_info *kinfo,int addrcells, +int sizecells,const struct membanks *mem); +int make_timer_node (const struct kernel_info *kinfo);... here also falls in this category. Stuff like this may well live under asm-generic/, but the file name chosen then needs to reflect constraints.
Unfortunately, at least at the moment, this is not applicable to x86.
Partially, domain_build.h was chosen to have less changes in Arm code.
Would it be better to use domain-build-dt.h?
~ Oleksii
Re: [PATCH v1 2/9] asm-generic: move parts of Arm's asm/kernel.h to asm-generic
In reply to Oleksii KurochkoQuoted 31 lines · Oleksii Kurochko
Quoted 23 lines · Jan Beulich
Quoted 22 lines · Oleksii Kurochko
Move the following parts to asm-generic with the following changes:
- structkernel_info:
- Createarch_kernel_infofor arch specific kernel information. At the moment, it containsdomain_typefor Arm.
- Rename vpl011 to vuart to have more generic name suitable for other archs.
- s/phandle_gic/phandle_intc to have more generic name suitable for other archs.
- Maketext_offsetof zimage structure available forRISCV_64.
- Wrap by#ifdef KERNEL_INFO_SHM_MEM_INITdefinition ofKERNEL_SHM_MEM_INITand wrap by#ifndef KERNEL_INFO_INITdefinition ofKERNEL_INFO_INITto have ability to overrideKERNEL_INFO_SHM_MEM_INITfor arch in case it doesn't want to use generic one.
- All other parts are left as is from Arm'sasm/kernel.hBecause of the changes in struct
kernel_infothe correspondent parts of Arm's code are updated.As part of this patch the following clean up happens:
- Dropasm/setup.hfromasm/kernel.has nothing depends from it. Add inclusion ofasm/setup.hfor a code which usesdevice_tree_get_reg()to avoid compilation issues forCONFIG_STATIC_MEMORYandCONFIG_STATIC_SHM.Quoted 5 lines
Quoted 1 line
Signed-off-by Oleksii Kurochko<[email protected]>I question that what is being moved qualifies for asm-generic, an in particular for a header named
kernel.h. Some of what you move may make sense to move todom0less-build.hinstead. But everything that doesn't fit there needs to find a different home, imo.
Quoted 7 lines
It doesn't clear what then should be in
kernel.h, I did in this way to not have a problem with header inclusion during the build of Arm.Definitions DOM0LESSS_* could be moved to
dom0less-build.h, all other doesn't really connected only to dom0less feature and could be re-used for dom0 so it seems like it should leave in a separate header ( ifkernel.hisn't good for it ).Probably
kernel.hshouldn't leave in asm-generic as nothing architecture specific is in it,
Well, kernel.h under asm-generic/ is somewhat odd in the first place.
Quoted 2 lines
but on the other hand, will it
be okay to have something in xen/include if it isn't supported by all architectures?
It can be okay; it depends on a number of factors.
Jan
Re: [PATCH v1 6/9] asm-generic: move some parts of Arm's domain_build.h to asm-generic header
In reply to Oleksii KurochkoQuoted 52 lines · Oleksii Kurochko
Quoted 38 lines · Jan Beulich
Quoted 10 lines · Oleksii Kurochko
Nothing changed. Only some functions declaration are moved to asm-generic header as they are expected to be used by common code of domain builing or dom0less.
Signed-off-by Oleksii Kurochko<[email protected]>--- xen/arch/arm/include/asm/domain_build.h | 19 ++---------- xen/include/asm-generic/domain-build.h | 41 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 17 deletions(-)create mode 100644
xen/include/asm-generic/domain-build.hAgain I question this movement under this name. "Domain building" is a pretty generic thing, yes, but what you move would e.g. be entirely inapplicable on x86 (as it is now). For example ...
Quoted 11 lines
xen/include/asm-generic/domain-build.h new file +8
-0@@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_GENERIC_DOMAIN_BUILD_H__ +#define __ASM_GENERIC_DOMAIN_BUILD_H__ + +#include <xen/types.h> + +struct domain ; +struct page_info ;xen/include/asm-generic/domain-build.h line 18
Quoted 10 lines
xen/include/asm-generic/domain-build.h new file +10
-0+struct kernel_info ; +struct membanks ; + +typedef bool (*alloc_domheap_mem_cb )(struct domain *d,struct page_info *pg, +unsigned int order,void *extra); +bool allocate_domheap_memory (struct domain *d,paddr_t tot_size, +alloc_domheap_mem_cb cb,void *extra); + +bool allocate_bank_memory (struct kernel_info *kinfo,gfn_t sgfn, +paddr_t tot_size);... the term "bank" seems pretty closely tied to DT. Other stuff ...
Quoted 12 lines
xen/include/asm-generic/domain-build.h line 27
Quoted 9 lines
xen/include/asm-generic/domain-build.h new file +9
-0+void allocate_memory (struct domain *d,struct kernel_info *kinfo); +int construct_domain (struct domain *d,struct kernel_info *kinfo); +int make_chosen_node (const struct kernel_info *kinfo); +int make_cpus_node (const struct domain *d,void *fdt); +int make_hypervisor_node (struct domain *d,const struct kernel_info *kinfo, +int addrcells,int sizecells); +int make_memory_node (const struct kernel_info *kinfo,int addrcells, +int sizecells,const struct membanks *mem); +int make_timer_node (const struct kernel_info *kinfo);... here also falls in this category. Stuff like this may well live under asm-generic/, but the file name chosen then needs to reflect constraints.
Quoted 5 lines
Unfortunately, at least at the moment, this is not applicable to x86.
Partially,
domain_build.hwas chosen to have less changes in Arm code.Would it be better to use
domain-build-dt.h?
That would at least be a more specific name. Yet then - why put such under asm-generic/ ? This stuff isn't truly generic (as in: any arch can fall back to using this). Personally I'd rather expect such stuff to live under e.g. include/xen/device-tree/. That would make it clear that environments using DT may consider using it, but other environment shouldn't.
Jan