From: Grygorii Strashko <grygorii_stras...@epam.com>

It is possible to have 32/64bit guests not only on Arm64 arch, so
add generic is_32bit_type flag to the struct kernel_info instead of Arm64
specific enum domain_type type.

Signed-off-by: Grygorii Strashko <grygorii_stras...@epam.com>
---
 xen/arch/arm/dom0less-build.c     |  2 +-
 xen/arch/arm/domain_build.c       |  6 +++---
 xen/arch/arm/include/asm/kernel.h |  7 +------
 xen/arch/arm/kernel.c             | 10 +++++-----
 xen/include/xen/fdt-kernel.h      |  3 +++
 5 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c
index c8d07213e247..3ac2da0b3576 100644
--- a/xen/arch/arm/dom0less-build.c
+++ b/xen/arch/arm/dom0less-build.c
@@ -241,7 +241,7 @@ int __init make_arch_nodes(struct kernel_info *kinfo)
 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;
+    d->arch.type = kinfo->is_32bit_type ? DOMAIN_32BIT : DOMAIN_64BIT;
 }
 #else
 void __init set_domain_type(struct domain *d, struct kernel_info *kinfo)
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 463ae4474d30..fc9bcc6fbbd5 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1874,13 +1874,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->arch.type == DOMAIN_32BIT )
+    if ( !(cpu_has_el1_32) && kinfo->is_32bit_type )
     {
         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->is_32bit_type )
     {
         printk("SVE is not available for 32-bit domain\n");
         return -EINVAL;
@@ -1996,7 +1996,7 @@ int __init construct_hwdom(struct kernel_info *kinfo,
 
 #ifdef CONFIG_ARM_64
     /* type must be set before allocate_memory */
-    d->arch.type = kinfo->arch.type;
+    d->arch.type = kinfo->is_32bit_type ? DOMAIN_32BIT : DOMAIN_64BIT;
 #endif
     find_gnttab_region(d, kinfo);
     if ( is_domain_direct_mapped(d) )
diff --git a/xen/arch/arm/include/asm/kernel.h 
b/xen/arch/arm/include/asm/kernel.h
index 7c3b7fde5b64..150cd9e30944 100644
--- a/xen/arch/arm/include/asm/kernel.h
+++ b/xen/arch/arm/include/asm/kernel.h
@@ -8,12 +8,7 @@
 
 #include <asm/domain.h>
 
-struct arch_kernel_info
-{
-#ifdef CONFIG_ARM_64
-    enum domain_type type;
-#endif
-
+struct arch_kernel_info {
     /* Enable pl011 emulation */
     bool vpl011;
 };
diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c
index 48f4b56d0ccc..607758bedb22 100644
--- a/xen/arch/arm/kernel.c
+++ b/xen/arch/arm/kernel.c
@@ -103,7 +103,7 @@ static paddr_t __init kernel_zimage_place(struct 
kernel_info *info)
     paddr_t load_addr;
 
 #ifdef CONFIG_ARM_64
-    if ( (info->arch.type == DOMAIN_64BIT) && (info->zimage.start == 0) )
+    if ( (!info->is_32bit_type) && (info->zimage.start == 0) )
         return mem->bank[0].start + info->zimage.text_offset;
 #endif
 
@@ -274,10 +274,10 @@ int __init kernel_uimage_probe(struct kernel_info *info,
     switch ( uimage.arch )
     {
     case IH_ARCH_ARM:
-        info->arch.type = DOMAIN_32BIT;
+        info->is_32bit_type = true;
         break;
     case IH_ARCH_ARM64:
-        info->arch.type = DOMAIN_64BIT;
+        info->is_32bit_type = false;
         break;
     default:
         printk(XENLOG_ERR "Unsupported uImage arch type %d\n", uimage.arch);
@@ -347,7 +347,7 @@ static int __init kernel_zimage64_probe(struct kernel_info 
*info,
 
     info->load = kernel_zimage_load;
 
-    info->arch.type = DOMAIN_64BIT;
+    info->is_32bit_type = false;
 
     return 0;
 }
@@ -399,7 +399,7 @@ static int __init kernel_zimage32_probe(struct kernel_info 
*info,
     info->load = kernel_zimage_load;
 
 #ifdef CONFIG_ARM_64
-    info->arch.type = DOMAIN_32BIT;
+    info->is_32bit_type = true;
 #endif
 
     return 0;
diff --git a/xen/include/xen/fdt-kernel.h b/xen/include/xen/fdt-kernel.h
index 33a60597bb4d..c862ff6c17ca 100644
--- a/xen/include/xen/fdt-kernel.h
+++ b/xen/include/xen/fdt-kernel.h
@@ -41,6 +41,9 @@ struct kernel_info {
     /* Enable/Disable PV drivers interfaces */
     uint16_t dom0less_feature;
 
+    /* Is 32bits guest detected? */
+    bool is_32bit_type;
+
     /* Interrupt controller phandle */
     uint32_t phandle_intc;
 
-- 
2.34.1

Reply via email to