xen: introduce CONFIG_HAS_DOMAIN_TYPE
PATCH v5 1/1 xen: introduce CONFIG_HAS_DOMAIN_TYPE
As domain type is part of common code now there is no any reason to have architecture-specific set_domain_type() functions so it is dropped.
Change the guard around access of kinfo->type to CONFIG_HAS_DOMAIN_TYPE for consistency. Also, drop and add some parentheses to be aligned with the similar if() below.
x86 with CONFIG_64BIT=y shouldn't use is_{32,64}bit_domain() as x86 doesn't have support of CONFIG_HAS_DOMAIN_TYPE. Since x86_32 Xen no longer builds, the fallback is currently only relevant for arm32.
---
CI tests: https://gitlab.com/xen-project/people/olkur/xen/-/pipelines/2506583130
---
Changes in v5:
- Drop excess parentheses from definion of is_{32,64}bit_domain for 32-bit case.
- Add const for 2-nd argument of set_domain_type().
- Add ASSERT(!domain_tot_pages(d)); inside set_domain_type() to guarantee what is written in the comment above it.
- Add Acked-by: Jan Beulich <[email protected]>.
---
Changes in v4:
- Drop enum domain_type type; from Arm's struct arch_domain.
- Add Reviewed-by: Michal Orzel <[email protected]>.
---
Changes in v3:
- Sort properly HAS_DOMAIN_TYPE in xen/common/Kconfig.
- Update the comment above is_*bit_domain() macros.
---
Changes in v2:
- Update the commit message.
- Move HAS_DOMAIN_TYPE to xen/common/Kconfig.
- Return set_domain_type(), move it to xen/fdt-domain-build.h and make it static inline.
- s/CONFIG_ARM_64/CONFIG_HAS_DOMAIN for the places where kinfo->type is used.
- Drop parantethes around cpu_has_el1_32 in if() and add around (kinfo->type == DOMAIN_32BIT) to be consistent with the similar check below.
- Fix comment code style.
- Add __packed to definition of enum domain_type
---
--- xen/arch/arm/Kconfig | 1 + xen/arch/arm/arm64/domctl.c | 4 ++-- xen/arch/arm/dom0less-build.c | 14 -------------- xen/arch/arm/domain_build.c | 12 +++++------- xen/arch/arm/include/asm/domain.h | 16 ---------------- xen/arch/arm/include/asm/kernel.h | 4 ---- xen/arch/arm/kernel.c | 16 ++++++++-------- xen/common/Kconfig | 3 +++ xen/include/xen/dom0less-build.h | 2 -- xen/include/xen/domain.h | 13 +++++++++++++ xen/include/xen/fdt-domain-build.h | 10 ++++++++++ xen/include/xen/fdt-kernel.h | 5 +++++ xen/include/xen/sched.h | 4 ++++ 13 files changed, 51 insertions(+), 53 deletions(-)
xen/arch/arm/Kconfig +1 -0
@@ -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
xen/arch/arm/arm64/domctl.c +2 -2
@@ -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)
xen/arch/arm/dom0less-build.c +0 -14
@@ -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) {
xen/arch/arm/domain_build.c +5 -7
@@ -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);
xen/arch/arm/include/asm/domain.h +0 -16
@@ -18,18 +18,6 @@ struct hvm_domainuint64_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;
xen/arch/arm/include/asm/kernel.h +0 -4
@@ -10,10 +10,6 @@struct arch_kernel_info { -#ifdef CONFIG_ARM_64 -enum domain_type type; -#endif -/* Enable pl011 emulation */ bool vpl011; };
xen/arch/arm/kernel.c +8 -8
@@ -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 ;
xen/common/Kconfig +3 -0
@@ -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
xen/include/xen/dom0less-build.h +0 -2
@@ -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);
xen/include/xen/domain.h +13 -0
@@ -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 <asm/domain.h> typedef union {
xen/include/xen/fdt-domain-build.h +10 -0
@@ -7,6 +7,7 @@#include <xen/device_tree.h> #include <xen/fdt-kernel.h> #include <xen/mm.h> +#include <xen/sched.h> #include <xen/types.h> 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__ */ /*
xen/include/xen/fdt-kernel.h +5 -0
@@ -9,6 +9,7 @@#include <xen/bootinfo.h> #include <xen/device_tree.h> +#include <xen/domain.h> #include <xen/types.h> #if __has_include(<asm/kernel.h>)
@@ -65,6 +66,10 @@ struct kernel_info { } zimage; }; +#ifdef CONFIG_HAS_DOMAIN_TYPE +enum domain_type type; +#endif + #if __has_include(<asm/kernel.h>)struct arch_kernel_info arch;#endif
xen/include/xen/sched.h +4 -0
@@ -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 */
Signature · 1 line
2.54.0