All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grygorii Strashko <grygorii_strashko@epam.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	Michal Orzel <michal.orzel@amd.com>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Anthony PERARD <anthony.perard@vates.tech>,
	Jan Beulich <jbeulich@suse.com>,
	Roger Pau Monne <roger.pau@citrix.com>,
	Grygorii Strashko <grygorii_strashko@epam.com>
Subject: [XEN][PATCH 2/8] xen/arm: move vcpu_switch_to_aarch64_mode() in arch_vcpu_create()
Date: Wed, 23 Jul 2025 07:58:37 +0000	[thread overview]
Message-ID: <20250723075835.3993182-3-grygorii_strashko@epam.com> (raw)
In-Reply-To: <20250723075835.3993182-1-grygorii_strashko@epam.com>

From: Grygorii Strashko <grygorii_strashko@epam.com>

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@epam.com>
---
 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


  parent reply	other threads:[~2025-07-23  7:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-23  7:58 [XEN][PATCH 0/8] xen/arm64: make aarch32 support optional Grygorii Strashko
2025-07-23  7:58 ` [XEN][PATCH 1/8] xen/arm: split set_domain_type() between arm64/arm32 Grygorii Strashko
2025-07-23  7:58 ` Grygorii Strashko [this message]
2025-07-23  9:16   ` [XEN][PATCH 2/8] xen/arm: move vcpu_switch_to_aarch64_mode() in arch_vcpu_create() Julien Grall
2025-07-23 10:19     ` Grygorii Strashko
2025-07-23 11:09       ` Julien Grall
2025-07-24 13:54         ` Grygorii Strashko
2025-07-23 11:12       ` Andrew Cooper
2025-07-23  7:58 ` [XEN][PATCH 3/8] xen/arm: move vcpu_switch_to_aarch64_mode() in arm64 Grygorii Strashko
2025-07-23  9:22   ` Julien Grall
2025-07-23 10:45     ` Grygorii Strashko
2025-07-23  7:58 ` [XEN][PATCH 4/8] xen/arm: split is_32bit/64bit_domain() between arm64/arm32 Grygorii Strashko
2025-07-23  8:32   ` Andrew Cooper
2025-07-23  7:58 ` [XEN][PATCH 6/8] xen/arm64: constify is_32/64bit_domain() macro for CONFIG_ARM64_AARCH32=n Grygorii Strashko
2025-07-23  8:37   ` Andrew Cooper
2025-07-23  7:58 ` [XEN][PATCH 5/8] xen/arm64: make aarch32 support optional Grygorii Strashko
2025-07-23  7:58 ` [XEN][PATCH 7/8] xen/arm: regs.h split subarch definitions between arm64/arm32 Grygorii Strashko
2025-07-23  7:58 ` [XEN][PATCH 8/8] xen/arm64: constify regs_mode_is_32bit macro for CONFIG_ARM64_AARCH32=n Grygorii Strashko
2025-07-23  8:06 ` [XEN][PATCH 0/8] xen/arm64: make aarch32 support optional Julien Grall
2025-07-23 10:54   ` Orzel, Michal
2025-07-23 11:48     ` Grygorii Strashko
2025-07-23 12:02       ` Julien Grall
2025-07-23 12:12         ` Grygorii Strashko
2025-07-24 14:24           ` Grygorii Strashko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250723075835.3993182-3-grygorii_strashko@epam.com \
    --to=grygorii_strashko@epam.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=bertrand.marquis@arm.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.