All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grygorii Strashko <grygorii_strashko@epam.com>
To: Julien Grall <julien@xen.org>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Stefano Stabellini <sstabellini@kernel.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>
Subject: Re: [XEN][PATCH 2/8] xen/arm: move vcpu_switch_to_aarch64_mode() in arch_vcpu_create()
Date: Wed, 23 Jul 2025 13:19:56 +0300	[thread overview]
Message-ID: <fdf7d2b9-aca9-4392-8e4d-a7fc8ce036f2@epam.com> (raw)
In-Reply-To: <99c88af9-7f89-4d7c-9827-1ba85c803195@xen.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@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.
> 
> 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@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);
> 
> ... 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


  reply	other threads:[~2025-07-23 10:20 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 2/8] xen/arm: move vcpu_switch_to_aarch64_mode() in arch_vcpu_create() Grygorii Strashko
2025-07-23  9:16   ` Julien Grall
2025-07-23 10:19     ` Grygorii Strashko [this message]
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 1/8] xen/arm: split set_domain_type() between arm64/arm32 Grygorii Strashko
2025-07-23  7:58 ` [XEN][PATCH 4/8] xen/arm: split is_32bit/64bit_domain() " Grygorii Strashko
2025-07-23  8:32   ` 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 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 8/8] xen/arm64: constify regs_mode_is_32bit macro for CONFIG_ARM64_AARCH32=n 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  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=fdf7d2b9-aca9-4392-8e4d-a7fc8ce036f2@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.