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

Re: [PATCH v1] xen: move alloc/free_vcpu_struct() to common code


  • To: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Wed, 17 Dec 2025 11:46:25 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=6Jf7VyL54wyiLJ45oOdxGR3ZZVuP1PZZak7x1WNcM9Q=; b=kTeyrXTs905eaOW5AsZuhFPyHxhxb3MO8QkvsvRP9oEwUQCKYfaZbSWCc2Il9XAyxz+p5/NoNHYVTqlNyPouKkT/WKOKzuCeJPv+2A2S7vjY1i2aofNOdVzFcX3/KrYg0A+lMGc18SxAiqoD7b72KhYiy+8OgHN2uPL2BChYOPmtymZPS6vA7g+yRv6OGTNXat+fmEwRzSKDCPS2gO4YOteV4eLpl+KAgm0jF3ruudSS3WCQ0iSmotDIL77q7zhB8clfhXpLYBBJTZlEu3H/LjrJAnC+9tG2lvIVhpmEf0h+4B4dRzPGKI+8kd4ddIKfUTZJ6f9i+NvbkI601OFskQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VEkAoaj1xUpjNSPg5lZfVWzXhQpUvMTdh3OivkagdBtAiiUkAVK4KJ5hLbtQOUeANESGFDi/NTIZMFFdFDxBlfz68jzX8ABl7/qAkE06j5HXCndEMFoMUwghQf+R52JHd+AwV3eJkQ8sWsQ0hZsrbvh+Y+lc7ZFbEMGKCXOiL2EgDePaq0WYEPhC5age3cuf6VhYh4nLbTHZtAVzQAVY8ytv0k6aaD+aTSUu8xwXtyHJwvY6xY0E5JBZYSaHqS95WUNQ9kDvZVZYX1gODs+SDFTn208vFJwSEe+kjBBUEDBYBJehFGnt6jxSl0hErbI8V3CvorRpTkxXl+fP1Sguzg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Timothy Pearson <tpearson@xxxxxxxxxxxxxxxxxxxxx>, Alistair Francis <alistair.francis@xxxxxxx>, Bob Eshleman <bobbyeshleman@xxxxxxxxx>, Connor Davis <connojdavis@xxxxxxxxx>
  • Delivery-date: Wed, 17 Dec 2025 11:46:42 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 17/12/2025 10:53 am, Oleksii Kurochko wrote:
> alloc_vcpu_struct() and free_vcpu_struct() contain little
> architecture-specific logic and are suitable for sharing across
> architectures. Move both helpers to common code.
>
> To support the remaining architectural differences, introduce
> arch_vcpu_struct_memflags(), allowing architectures to override the
> memory flags passed to alloc_xenheap_pages(). This is currently needed
> by x86, which may require MEMF_bits(32) for HVM guests using shadow
> paging.

You lost the comment explaining the restriction.  This needs adding back.

> Move the definition of MAX_PAGES_PER_VCPU to xen/domain.h and default
> it to 1. Retain the ARM64 exception (with CONFIG_NEW_VGIC) where two
> pages are required due to larger per-IRQ structures.

CONFIG_NEW_VGIC is still off by default, unsupported, and has had no
work on it since it's introduction in 2018.

There are a lot of good reasons to enforce struct vcpu being a single
page allocation, not least because an allocation can fail due to
fragmentation despite there being enough free RAM.

I would far rather that common code enforced it being page size, and
NEW_VGIC gets deleted or adjusted to cope, than to make it this easy for
architectures to shoot themselves in the foot.

>
> The ARM implementation of alloc/free_vcpu_struct() is removed and
> replaced by the common version. Stub implementations are also dropped
> from PPC and RISC-V.
>
> Finally, make alloc_vcpu_struct() and free_vcpu_struct() static to
> common/domain.c, as they are no longer used outside common code.
>
> No functional changes.
>
> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
> ---
> CI tests: 
> https://gitlab.com/xen-project/people/olkur/xen/-/pipelines/2219693055
>
> Shouldn't we make alloc_domain_struct() and free_domain_struct() static and
> drop their declarations from xen/domain.h, since these functions are only
> used in common/domain.c?

Yes - they should become static.

~Andrew



 


Rackspace

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