diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 2f2b501fda..79622b46a1 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -7,6 +7,7 @@ config ARM_64 def_bool y depends on !ARM_32 select 64BIT + select HAS_DOMAIN_TYPE select HAS_FAST_MULTIPLY select HAS_VPCI_GUEST_SUPPORT if PCI_PASSTHROUGH diff --git a/xen/arch/arm/arm64/domctl.c b/xen/arch/arm/arm64/domctl.c index 8720d126c9..9e9a29eb1e 100644 --- a/xen/arch/arm/arm64/domctl.c +++ b/xen/arch/arm/arm64/domctl.c @@ -21,10 +21,10 @@ static long switch_mode(struct domain *d, enum domain_type type) return -EINVAL; if ( domain_tot_pages(d) != 0 ) return -EBUSY; - if ( d->arch.type == type ) + if ( d->type == type ) return 0; - d->arch.type = type; + d->type = type; if ( is_64bit_domain(d) ) for_each_vcpu(d, v) diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 4181c10538..6f73c65e51 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -237,20 +237,6 @@ int __init make_arch_nodes(struct kernel_info *kinfo) return 0; } -/* TODO: make arch.type generic ? */ -#ifdef CONFIG_ARM_64 -void __init set_domain_type(struct domain *d, struct kernel_info *kinfo) -{ - /* type must be set before allocate memory */ - d->arch.type = kinfo->arch.type; -} -#else -void __init set_domain_type(struct domain *d, struct kernel_info *kinfo) -{ - /* Nothing to do */ -} -#endif - int __init init_vuart(struct domain *d, struct kernel_info *kinfo, const struct dt_device_node *node) { diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index a3ff701023..ad665cd3c0 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1771,15 +1771,15 @@ int __init construct_domain(struct domain *d, struct kernel_info *kinfo) BUG_ON(d->vcpu[0] == NULL); BUG_ON(v->is_initialised); -#ifdef CONFIG_ARM_64 +#ifdef CONFIG_HAS_DOMAIN_TYPE /* if aarch32 mode is not supported at EL1 do not allow 32-bit domain */ - if ( !(cpu_has_el1_32) && kinfo->arch.type == DOMAIN_32BIT ) + if ( !cpu_has_el1_32 && (kinfo->type == DOMAIN_32BIT) ) { printk("Platform does not support 32-bit domain\n"); return -EINVAL; } - if ( is_sve_domain(d) && (kinfo->arch.type == DOMAIN_32BIT) ) + if ( is_sve_domain(d) && (kinfo->type == DOMAIN_32BIT) ) { printk("SVE is not available for 32-bit domain\n"); return -EINVAL; @@ -1893,10 +1893,8 @@ int __init construct_hwdom(struct kernel_info *kinfo, iommu_hwdom_init(d); -#ifdef CONFIG_ARM_64 - /* type must be set before allocate_memory */ - d->arch.type = kinfo->arch.type; -#endif + set_domain_type(d, kinfo); + find_gnttab_region(d, kinfo); if ( is_domain_direct_mapped(d) ) allocate_memory_11(d, kinfo); diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/domain.h index ffe5d0d9f0..b24f02d269 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -18,18 +18,6 @@ struct hvm_domain uint64_t params[HVM_NR_PARAMS]; }; -#ifdef CONFIG_ARM_64 -enum domain_type { - DOMAIN_32BIT, - DOMAIN_64BIT, -}; -#define is_32bit_domain(d) ((d)->arch.type == DOMAIN_32BIT) -#define is_64bit_domain(d) ((d)->arch.type == DOMAIN_64BIT) -#else -#define is_32bit_domain(d) (1) -#define is_64bit_domain(d) (0) -#endif - /* * Is the domain using the host memory layout? * @@ -62,10 +50,6 @@ struct paging_domain { struct arch_domain { -#ifdef CONFIG_ARM_64 - enum domain_type type; -#endif - #ifdef CONFIG_ARM64_SVE /* max SVE encoded vector length */ uint8_t sve_vl; diff --git a/xen/arch/arm/include/asm/kernel.h b/xen/arch/arm/include/asm/kernel.h index 7c3b7fde5b..21f4273fa1 100644 --- a/xen/arch/arm/include/asm/kernel.h +++ b/xen/arch/arm/include/asm/kernel.h @@ -10,10 +10,6 @@ struct arch_kernel_info { -#ifdef CONFIG_ARM_64 - enum domain_type type; -#endif - /* Enable pl011 emulation */ bool vpl011; }; diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index 7544fd50a2..9395b5af87 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -100,8 +100,8 @@ static paddr_t __init kernel_zimage_place(struct kernel_info *info) const struct membanks *mem = kernel_info_get_mem(info); paddr_t load_addr; -#ifdef CONFIG_ARM_64 - if ( (info->arch.type == DOMAIN_64BIT) && (info->zimage.start == 0) ) +#ifdef CONFIG_HAS_DOMAIN_TYPE + if ( (info->type == DOMAIN_64BIT) && (info->zimage.start == 0) ) return mem->bank[0].start + info->zimage.text_offset; #endif @@ -268,14 +268,14 @@ int __init kernel_uimage_probe(struct kernel_info *info, info->load = kernel_zimage_load; -#ifdef CONFIG_ARM_64 +#ifdef CONFIG_HAS_DOMAIN_TYPE switch ( uimage.arch ) { case IH_ARCH_ARM: - info->arch.type = DOMAIN_32BIT; + info->type = DOMAIN_32BIT; break; case IH_ARCH_ARM64: - info->arch.type = DOMAIN_64BIT; + info->type = DOMAIN_64BIT; break; default: printk(XENLOG_ERR "Unsupported uImage arch type %d\n", uimage.arch); @@ -345,7 +345,7 @@ static int __init kernel_zimage64_probe(struct kernel_info *info, info->load = kernel_zimage_load; - info->arch.type = DOMAIN_64BIT; + info->type = DOMAIN_64BIT; return 0; } @@ -396,8 +396,8 @@ static int __init kernel_zimage32_probe(struct kernel_info *info, info->load = kernel_zimage_load; -#ifdef CONFIG_ARM_64 - info->arch.type = DOMAIN_32BIT; +#ifdef CONFIG_HAS_DOMAIN_TYPE + info->type = DOMAIN_32BIT; #endif return 0; diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 0a20aa0a12..5ff71480ee 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -128,6 +128,9 @@ config HAS_DEVICE_TREE_DISCOVERY config HAS_DOM0LESS bool +config HAS_DOMAIN_TYPE + bool + config HAS_DIT # Data Independent Timing bool diff --git a/xen/include/xen/dom0less-build.h b/xen/include/xen/dom0less-build.h index faaf660424..4118dec76c 100644 --- a/xen/include/xen/dom0less-build.h +++ b/xen/include/xen/dom0less-build.h @@ -57,8 +57,6 @@ int init_vuart(struct domain *d, struct kernel_info *kinfo, 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); diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 93c0fd00c1..a095190fc7 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -13,6 +13,19 @@ struct guest_area { void *map; }; +#ifdef CONFIG_HAS_DOMAIN_TYPE +enum __packed domain_type { + DOMAIN_32BIT, + DOMAIN_64BIT, +}; +#define is_32bit_domain(d) ((d)->type == DOMAIN_32BIT) +#define is_64bit_domain(d) ((d)->type == DOMAIN_64BIT) +#elif !defined(CONFIG_64BIT) +/* At the moment on 32-bit-only platforms all domains are 32-bit. */ +#define is_32bit_domain(d) true +#define is_64bit_domain(d) false +#endif + #include typedef union { diff --git a/xen/include/xen/fdt-domain-build.h b/xen/include/xen/fdt-domain-build.h index 0d40d8cfa1..9465a1021f 100644 --- a/xen/include/xen/fdt-domain-build.h +++ b/xen/include/xen/fdt-domain-build.h @@ -7,6 +7,7 @@ #include #include #include +#include #include struct domain; @@ -69,6 +70,15 @@ static inline uint32_t alloc_phandle(struct kernel_info *kinfo) return kinfo->next_phandle >= GUEST_PHANDLE_GIC ? 0 : kinfo->next_phandle++; } +static inline void set_domain_type(struct domain *d, const struct kernel_info *kinfo) +{ +#ifdef CONFIG_HAS_DOMAIN_TYPE + /* Type must be set before allocating memory. */ + ASSERT(!domain_tot_pages(d)); + d->type = kinfo->type; +#endif +} + #endif /* __XEN_FDT_DOMAIN_BUILD_H__ */ /* diff --git a/xen/include/xen/fdt-kernel.h b/xen/include/xen/fdt-kernel.h index 4d0467bb39..86a37a1304 100644 --- a/xen/include/xen/fdt-kernel.h +++ b/xen/include/xen/fdt-kernel.h @@ -9,6 +9,7 @@ #include #include +#include #include #if __has_include() @@ -65,6 +66,10 @@ struct kernel_info { } zimage; }; +#ifdef CONFIG_HAS_DOMAIN_TYPE + enum domain_type type; +#endif + #if __has_include() struct arch_kernel_info arch; #endif diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 212c7d765c..00db1da12f 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -386,6 +386,10 @@ struct domain { domid_t domain_id; +#ifdef CONFIG_HAS_DOMAIN_TYPE + enum domain_type type; +#endif + unsigned int max_vcpus; uint64_t unique_id; /* Unique domain identifier */