Now that the size of struct vcpu is smaller than PAGE_SIZE,
MAX_PAGES_PER_VCPU is no longer needed and is removed.
This change also updates {alloc,free}_vcpu_struct().
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
---
Changes in v2:
- New patch.
---
xen/arch/arm/domain.c | 25 +++++--------------------
1 file changed, 5 insertions(+), 20 deletions(-)
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 47973f99d9..e566023340 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -473,36 +473,21 @@ void dump_pageframe_info(struct domain *d)
}
-/*
- * The new VGIC has a bigger per-IRQ structure, so we need more than one
- * page on ARM64. Cowardly increase the limit in this case.
- */
-#if defined(CONFIG_NEW_VGIC) && defined(CONFIG_ARM_64)
-#define MAX_PAGES_PER_VCPU 2
-#else
-#define MAX_PAGES_PER_VCPU 1
-#endif
-
struct vcpu *alloc_vcpu_struct(const struct domain *d)
{
struct vcpu *v;
- BUILD_BUG_ON(sizeof(*v) > MAX_PAGES_PER_VCPU * PAGE_SIZE);
- v = alloc_xenheap_pages(get_order_from_bytes(sizeof(*v)), 0);
- if ( v != NULL )
- {
- unsigned int i;
-
- for ( i = 0; i < DIV_ROUND_UP(sizeof(*v), PAGE_SIZE); i++ )
- clear_page((void *)v + i * PAGE_SIZE);
- }
+ BUILD_BUG_ON(sizeof(*v) > PAGE_SIZE);
+ v = alloc_xenheap_pages(0, 0);
+ if ( v )
+ clear_page(v);
return v;
}
void free_vcpu_struct(struct vcpu *v)
{
- free_xenheap_pages(v, get_order_from_bytes(sizeof(*v)));
+ free_xenheap_page(v);
}
int arch_vcpu_create(struct vcpu *v)
--
2.52.0
On 18/12/2025 5:28 pm, Oleksii Kurochko wrote:
> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> index 47973f99d9..e566023340 100644
> --- a/xen/arch/arm/domain.c
> +++ b/xen/arch/arm/domain.c
> @@ -473,36 +473,21 @@ void dump_pageframe_info(struct domain *d)
>
> }
>
> -/*
> - * The new VGIC has a bigger per-IRQ structure, so we need more than one
> - * page on ARM64. Cowardly increase the limit in this case.
> - */
> -#if defined(CONFIG_NEW_VGIC) && defined(CONFIG_ARM_64)
> -#define MAX_PAGES_PER_VCPU 2
> -#else
> -#define MAX_PAGES_PER_VCPU 1
> -#endif
> -
> struct vcpu *alloc_vcpu_struct(const struct domain *d)
> {
> struct vcpu *v;
>
> - BUILD_BUG_ON(sizeof(*v) > MAX_PAGES_PER_VCPU * PAGE_SIZE);
> - v = alloc_xenheap_pages(get_order_from_bytes(sizeof(*v)), 0);
> - if ( v != NULL )
> - {
> - unsigned int i;
> -
> - for ( i = 0; i < DIV_ROUND_UP(sizeof(*v), PAGE_SIZE); i++ )
> - clear_page((void *)v + i * PAGE_SIZE);
> - }
> + BUILD_BUG_ON(sizeof(*v) > PAGE_SIZE);
> + v = alloc_xenheap_pages(0, 0);
I know this is only interim until the next patch, but
alloc_xenheap_page() to match the free function used.
Personally, I'd merge patches 2 and 3 together, because everything you
touch in this patch is deleted by the next one.
But, whatever the ARM maintainers prefer.
~Andrew
On 18/12/2025 19:19, Andrew Cooper wrote:
> On 18/12/2025 5:28 pm, Oleksii Kurochko wrote:
>> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
>> index 47973f99d9..e566023340 100644
>> --- a/xen/arch/arm/domain.c
>> +++ b/xen/arch/arm/domain.c
>> @@ -473,36 +473,21 @@ void dump_pageframe_info(struct domain *d)
>>
>> }
>>
>> -/*
>> - * The new VGIC has a bigger per-IRQ structure, so we need more than one
>> - * page on ARM64. Cowardly increase the limit in this case.
>> - */
>> -#if defined(CONFIG_NEW_VGIC) && defined(CONFIG_ARM_64)
>> -#define MAX_PAGES_PER_VCPU 2
>> -#else
>> -#define MAX_PAGES_PER_VCPU 1
>> -#endif
>> -
>> struct vcpu *alloc_vcpu_struct(const struct domain *d)
>> {
>> struct vcpu *v;
>>
>> - BUILD_BUG_ON(sizeof(*v) > MAX_PAGES_PER_VCPU * PAGE_SIZE);
>> - v = alloc_xenheap_pages(get_order_from_bytes(sizeof(*v)), 0);
>> - if ( v != NULL )
>> - {
>> - unsigned int i;
>> -
>> - for ( i = 0; i < DIV_ROUND_UP(sizeof(*v), PAGE_SIZE); i++ )
>> - clear_page((void *)v + i * PAGE_SIZE);
>> - }
>> + BUILD_BUG_ON(sizeof(*v) > PAGE_SIZE);
>> + v = alloc_xenheap_pages(0, 0);
>
> I know this is only interim until the next patch, but
> alloc_xenheap_page() to match the free function used.
>
> Personally, I'd merge patches 2 and 3 together, because everything you
> touch in this patch is deleted by the next one.
>
> But, whatever the ARM maintainers prefer.
I'm in favor of Andrew's suggestion. There's no point in introducing something
in one patch and dropping it in the very next one.
~Michal
On 12/19/25 9:22 AM, Orzel, Michal wrote:
>
> On 18/12/2025 19:19, Andrew Cooper wrote:
>> On 18/12/2025 5:28 pm, Oleksii Kurochko wrote:
>>> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
>>> index 47973f99d9..e566023340 100644
>>> --- a/xen/arch/arm/domain.c
>>> +++ b/xen/arch/arm/domain.c
>>> @@ -473,36 +473,21 @@ void dump_pageframe_info(struct domain *d)
>>>
>>> }
>>>
>>> -/*
>>> - * The new VGIC has a bigger per-IRQ structure, so we need more than one
>>> - * page on ARM64. Cowardly increase the limit in this case.
>>> - */
>>> -#if defined(CONFIG_NEW_VGIC) && defined(CONFIG_ARM_64)
>>> -#define MAX_PAGES_PER_VCPU 2
>>> -#else
>>> -#define MAX_PAGES_PER_VCPU 1
>>> -#endif
>>> -
>>> struct vcpu *alloc_vcpu_struct(const struct domain *d)
>>> {
>>> struct vcpu *v;
>>>
>>> - BUILD_BUG_ON(sizeof(*v) > MAX_PAGES_PER_VCPU * PAGE_SIZE);
>>> - v = alloc_xenheap_pages(get_order_from_bytes(sizeof(*v)), 0);
>>> - if ( v != NULL )
>>> - {
>>> - unsigned int i;
>>> -
>>> - for ( i = 0; i < DIV_ROUND_UP(sizeof(*v), PAGE_SIZE); i++ )
>>> - clear_page((void *)v + i * PAGE_SIZE);
>>> - }
>>> + BUILD_BUG_ON(sizeof(*v) > PAGE_SIZE);
>>> + v = alloc_xenheap_pages(0, 0);
>> I know this is only interim until the next patch, but
>> alloc_xenheap_page() to match the free function used.
>>
>> Personally, I'd merge patches 2 and 3 together, because everything you
>> touch in this patch is deleted by the next one.
>>
>> But, whatever the ARM maintainers prefer.
> I'm in favor of Andrew's suggestion. There's no point in introducing something
> in one patch and dropping it in the very next one.
Then I will merge patch 2 and 3.
~ Oleksii
© 2016 - 2026 Red Hat, Inc.