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

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


  • To: Julien Grall <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Date: Wed, 23 Jul 2025 13:19:56 +0300
  • 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=qIGStQRv9cDlBF1dYUJXuc4zRpiQW+dkMsKVkvEbGrk=; b=ImPSg61hDYl3FgrDidgMdmTOswCmivmXXNuP1CDCYsOAE+BbB6UI6vigJiKlG5zJ+5RdjQuWFdQCn8E+0xKlYJte67ua99FrTLKrG0m9J8W5mmzb/qIrfLpMtWvYr7TvXfhX9ullpAWtCKB8RBx6RROz4yNbD4jx8JHkB4nVtLKypkxz6ZFexqHZ+anlkf0G8U6ylu83oDr9SKiwOMViIsWryn0vwPxdCjXmP9QNvbFdNztGMOQlIofn/4Ezfu2H5vAM8XMpMlf8/qiT81xy7gYWRYm7i8RCKncatwFI8jfHT4HZHcYb5YkrtiNOoGby9jCObfGOGBOHYVzbyBk3tA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aFOVCLC9bz8uKBw3Fh1wCk/0slkGsKW6O5Cx6isX9qAf+Wk94Pc1hsQkFmiP7y2pBs2WRGQLaw9pUVsAv8lx263s9m9bDo9pWXcuqqhwZUYa65C1NPLA9rYHzgn2DK8efnjzV2MWa+uoCxZU85EHGAAGjcO4qiSoEsOrLUn+H6mext33hQTorRVx5S+ykVLCuQufA19OZfJYtTrqh0FeJ9EQrE/MZRI85j66Tizomn0RYAYGtC9OYQ8p4MAGZ4Se9kvTvzLrxON87shDreSxIhLLSU32PcfBjLq4vbmasExNzRWMTfRB/1GUonyIjWwKinnrSyLSW9D5zZz2vTDs7g==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, 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>
  • Delivery-date: Wed, 23 Jul 2025 10:20:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>



On 23.07.25 12:16, Julien Grall wrote:
Hi,

On 23/07/2025 08:58, Grygorii Strashko wrote:
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.

The commit message doesn't mention anything about domains created by the 
toolstack. In this case, from my understanding, the switch to 64-bit domain 
happens *after* the vCPUs are created.

At the moment, I think this is probably ok to call...


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);

... this function here because I *think* it would be NOP. But this feels really 
fragile.

The toolstack configures domain and vcpus through XEN_DOMCTL_set_address_size 
on Arm64:
- toolstack creates domain and parses kernel binary: domain created with 
DOMAIN_32BIT mode by default
- toolstack creates vcpus (still 32 bit mode): 
libxl__build_pre()->xc_domain_max_vcpus()
- toolstack switches domain mode depending on kernel binary type: 
libxl__build_dom()->xc_dom_boot_mem_init(),
  which triggers XEN_DOMCTL_set_address_size hypercall.
  Xen: arm64: switches domain mode and re-configures vcpus: 
subarch_do_domctl()->set_address_size()

So, this patch does not affect toolstack path, only optimizes Xen boots a bit.

Also, during Xen boot or by toolstack - the domain is always created before 
it's type is even known, which, in turn,
is based on guest binary which is parsed later during domain configuration 
stage.

I can add note in commit message "This patch doesn't affect on the toolstack 
Arm64 domain creation path as toolstack always
re-configures domain mode and vcpus through XEN_DOMCTL_set_address_size hypercall 
during domain configuration stage"


If the desire is to make 32-bit domain optional on Arm64. Then I think it would 
be better to pass the domain type when the domain
is created (IOW add an extra flags to XEN_DOMCTL_createdomain). This will 
require more work, but it will be a lot more robust.



--
Best regards,
-grygorii



 


Rackspace

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