|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 3/3] 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.
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
---
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 | 12 ------------
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 | 9 +++++++++
xen/include/xen/fdt-kernel.h | 5 +++++
xen/include/xen/sched.h | 4 ++++
13 files changed, 50 insertions(+), 49 deletions(-)
diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index 2f2b501fdac4..79622b46a10d 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 8720d126c97d..9e9a29eb1e78 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 4181c105389a..6f73c65e5151 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 98f5dab35e83..1efddc60ef0a 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1772,15 +1772,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;
@@ -1894,10 +1894,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 f95ad1285e6e..2d4c1bdecb66 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
-
struct vtimer {
struct vcpu *v;
int irq;
diff --git a/xen/arch/arm/include/asm/kernel.h
b/xen/arch/arm/include/asm/kernel.h
index 7c3b7fde5b64..21f4273fa1b5 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 3c613cdb233f..a5554714cd7b 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->image.start == 0) )
+#ifdef CONFIG_HAS_DOMAIN_TYPE
+ if ( (info->type == DOMAIN_64BIT) && (info->image.start == 0) )
return mem->bank[0].start + info->image.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 0a20aa0a1249..ab62e9b07546 100644
--- a/xen/common/Kconfig
+++ b/xen/common/Kconfig
@@ -29,6 +29,9 @@ config DOM0LESS_BOOT
config DOMAIN_BUILD_HELPERS
bool
+config HAS_DOMAIN_TYPE
+ bool
+
config GRANT_TABLE
bool "Grant table support" if EXPERT
default y
diff --git a/xen/include/xen/dom0less-build.h b/xen/include/xen/dom0less-build.h
index faaf660424b2..4118dec76c0a 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 93c0fd00c1d7..fcb6dc136517 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)
+/* 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 {
diff --git a/xen/include/xen/fdt-domain-build.h
b/xen/include/xen/fdt-domain-build.h
index b7f6b1fc36a9..6ad9e8fd1642 100644
--- a/xen/include/xen/fdt-domain-build.h
+++ b/xen/include/xen/fdt-domain-build.h
@@ -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,14 @@ 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, struct kernel_info *kinfo)
+{
+#ifdef CONFIG_HAS_DOMAIN_TYPE
+ /* Type must be set before allocate memory */
+ 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 438adfe3855b..8bcc9471814b 100644
--- a/xen/include/xen/fdt-kernel.h
+++ b/xen/include/xen/fdt-kernel.h
@@ -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>)
@@ -69,6 +70,10 @@ struct kernel_info {
} image;
};
+#ifdef CONFIG_HAS_DOMAIN_TYPE
+ enum domain_type type;
+#endif
+
#if __has_include(<asm/kernel.h>)
struct arch_kernel_info arch;
#endif
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 212c7d765c3e..00db1da12f21 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 */
--
2.53.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |