[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[XEN][PATCH 2/8] xen/arm: move vcpu_switch_to_aarch64_mode() in arch_vcpu_create()


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Date: Wed, 23 Jul 2025 07:58:37 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NnkgHZDA95iuw2TlQ4kHkXqSKfJLLFnu6aLF1WOiSpA=; b=cSKyYL0ZawfkpqK8JF3iOjA+7ss9cMdRPEcI7p/xTMLlpBhTL8owYZwRbupfX3zTdRqjKCKLQOJetuI+mVUcY3+tMg8tc58Mhx6FzppzKssctzVxHYn2t1FCIRMB9YUQ8sU2hU3/RiZOE3thdSUkH4bTAX8wK6+gBz42nXufOkXt0TNqG3mUd6izkm+b/xcoxpF12cjJkwP66ZUaHH/sSpvBxmipz2g54MGBkr3EwobaqS++r4PwrpS9uVFyQ2Lw13xUs9Ty5Kjz2DN+aT8uxftLqU1JMMnwDz54kIQvvOoHxYP+T9pho6CFD9HunJPq9ayLPteN0Bw4SDeIEYL8zQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fVOyRCHozoHEv1JDTo2J5g7liTNA1Jhp4sp8l2yqrB4pMmgxLJ1fuqnp/3GRgPsgL7qQAjMYTDUfRWoV7rG89FCgkuKnSvcOZYevcR7UWn+RP3O0Qhq3KUGeCMXmesIDLb6CC4POlxdd4ILUaju0NuDBYlJthUv2U4kT7mf+Dk2lSxTve8m8xYo/koj7LeolkLK0SB6NEAloN2DeYoVpOKV5QBCPk2oT6cweYUGe8O4b1IaHrSmnH1p2UDJ642dIrZZFW7J+jK9Vcp98zG33nftxkZ2E5COjPVlMwOcsXy3pZz/EzmczIzTd3xRUGvvcsE2IM3NJoke9H7j+BB/uAg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Delivery-date: Wed, 23 Jul 2025 07:58:46 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHb+6eY7tK778r4fEOnvsrV6Tw39Q==
  • Thread-topic: [XEN][PATCH 2/8] xen/arm: move vcpu_switch_to_aarch64_mode() in arch_vcpu_create()

From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>

Move vcpu_switch_to_aarch64_mode() in arch_vcpu_create() callback instead
of calling it manually from few different places after vcpu_create().

Before doing above ensure vcpu0 is created after kernel_probe() is done and
domain's guest execution mode (32-bit/64-bit) is set for dom0 and dom0less
domains.

Signed-off-by: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
---
 xen/arch/arm/domain.c                    |  3 +++
 xen/arch/arm/domain_build.c              | 13 +++++--------
 xen/common/device-tree/dom0less-build.c  |  6 +++---
 xen/include/asm-generic/dom0less-build.h |  2 +-
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 79a144e61be9..bbd4a764c696 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -586,6 +586,9 @@ int arch_vcpu_create(struct vcpu *v)
     if ( get_ssbd_state() == ARM_SSBD_RUNTIME )
         v->arch.cpu_info->flags |= CPUINFO_WORKAROUND_2_FLAG;
 
+    if ( is_64bit_domain(v->domain) )
+        vcpu_switch_to_aarch64_mode(v);
+
     return rc;
 
 fail:
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index d91a71acfd3b..af7e9d830ae1 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1885,10 +1885,6 @@ int __init construct_domain(struct domain *d, struct 
kernel_info *kinfo)
         printk("SVE is not available for 32-bit domain\n");
         return -EINVAL;
     }
-
-    if ( is_64bit_domain(d) )
-        vcpu_switch_to_aarch64_mode(v);
-
 #endif
 
     /*
@@ -1941,9 +1937,6 @@ int __init construct_domain(struct domain *d, struct 
kernel_info *kinfo)
             printk("Failed to allocate d%dv%d\n", d->domain_id, i);
             break;
         }
-
-        if ( is_64bit_domain(d) )
-            vcpu_switch_to_aarch64_mode(d->vcpu[i]);
     }
 
     domain_update_node_affinity(d);
@@ -1995,9 +1988,13 @@ int __init construct_hwdom(struct kernel_info *kinfo,
     iommu_hwdom_init(d);
 
 #ifdef CONFIG_ARM_64
-    /* type must be set before allocate_memory */
+    /* type must be set before allocate_memory or create cpu */
     d->arch.type = kinfo->arch.type;
 #endif
+
+    if ( vcpu_create(d, 0) == NULL )
+        panic("Error creating domain 0 vcpu0\n");
+
     find_gnttab_region(d, kinfo);
     if ( is_domain_direct_mapped(d) )
         allocate_memory_11(d, kinfo);
diff --git a/xen/common/device-tree/dom0less-build.c 
b/xen/common/device-tree/dom0less-build.c
index efa846da2a55..f02ce6c776de 100644
--- a/xen/common/device-tree/dom0less-build.c
+++ b/xen/common/device-tree/dom0less-build.c
@@ -771,9 +771,6 @@ static int __init construct_domU(struct domain *d,
     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.bd.d = d;
@@ -792,6 +789,9 @@ static int __init construct_domU(struct domain *d,
     }
     else
     {
+        if ( vcpu_create(d, 0) == NULL )
+            return -ENOMEM;
+
         if ( !dt_find_property(node, "xen,static-mem", NULL) )
             allocate_memory(d, &kinfo);
         else if ( !is_domain_direct_mapped(d) )
diff --git a/xen/include/asm-generic/dom0less-build.h 
b/xen/include/asm-generic/dom0less-build.h
index 6b80ffbd8679..13616975b3ca 100644
--- a/xen/include/asm-generic/dom0less-build.h
+++ b/xen/include/asm-generic/dom0less-build.h
@@ -59,7 +59,7 @@ int make_arch_nodes(struct kernel_info *kinfo);
 /*
  * Set domain type from struct kernel_info which defines guest Execution
  * State 32-bit/64-bit (for Arm AArch32/AArch64).
- * The domain type must be set before allocate_memory.
+ * The domain type must be set before allocate_memory or create vcpus.
  *
  * @d: pointer to the domain structure.
  * @kinfo: pointer to the kinfo structure.
-- 
2.34.1



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.