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

Re: [PATCH v2 2/2] xen/arm: skip holes in physical address space when setting up frametable


  • To: Michal Orzel <michal.orzel@xxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Fri, 1 May 2026 15:00:00 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=amd.com smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; 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=1QeZMlERVZEBLSBXUlnnwQ5D1Zpa7DcRdDVOqv/XFQw=; b=psNualF/1reMgDe7+C7OXB6za4ORRQQOz5evT0rAI7Lx3AbNlw/HGtQht9aasHtxEcgiVpa55o//oK2zg1peqBb336sW+WV9wOMXCF5pX7a+mdXOmE2KPtFZ2EezWbV1uVj1TqIdfa45ROh3kXhKI/ZncnGM34g7gWLv55d5pNpeljnHivyek0DQTsrpzFKPThpg4Y5EepFj1rVPkmdpVqtSmqNtx1kCLjd1Ys6rm+FZCTWK+rYebOAnrVQc7Qv2rh0ualmmG2ggZF37NszdS16JGJ4/CA2qnnVL4MIr+Y9AEsSAalDt/cDr35jhS1vieEr2gd/9NLdwKDwKVF3M2A==
  • 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=1QeZMlERVZEBLSBXUlnnwQ5D1Zpa7DcRdDVOqv/XFQw=; b=roxTJdWuvIP5LpJ9VaXs7Cpc+EP/F3cSuoZ05rUCAUbuH5TfpU8GN1MxabYPGl8tDxp1qTB6t/4q5urFcf4sRQkhK38UGcJMDSwpOnsuhqvFjp5Q6R0abPxyQX1mYjMIeC7aCM4xPvG9xHfVGcCM1FDq715Lx1v18NQufnaV9WprdeTxvuPbuu/zcM5XtlnirD+4mntjWtl7oPgMWrShSGraJlShnycl9lYKUqkdBhLrBDelZ1P+ITqnxB7SR2oJYGTgSBOPkxk1aUdgnW0e/XyNYj1H16zaLbIZvCZJRCw3w2IbpOO0xA9XykcXh2VTVU4yqnYb0er9fHQgj4n1ww==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=dACI7pCUSe/QBgSqu/vxLR6wAY5Vl7D29BTqpKJA9SQ+8EUXaOywcjhnNLOXRuo+xAblLPJfFOXWfqTwUzvdOsFqrN4DMY6ZYuwPkeNfsH9mgt2fII2If1fb2056sJNop5G4JuUNnrkui91mgCfcjsqmpfx6EoxQmrtPocsQ/xxBsSvMkqx8PAv9JE1GPhZSYCsZb9rFvx16ejTjIpXbQKG1UnfYnZwAcZKUjhvHxN13ETMsN5zP1V+Q/hrX9rWvlyKGy3nRM42Xz6f3H1cz3QmCZNycPgzHxPovJX0PxRSphliNxKiaG7dAzcSimp4355pEUNIPwBF0DewF2/ATeQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d69OLrlVoc2r5hCkcYmCmVUInZfR60jNF47GbPw22+IK/0CBgIFn8FPyhUnn0Q4Fg30hvQ46qMZhoS8TeeJV0xYuqpS9D1lCv/Kb8R6EPG2kRbG5FY/Q197MeNEzN8x4csVO1w5QfGOqp5tZ+LcFQQnl69/9LTJ0KMYfBgxKqxAzVhTHuG1ju5Z7D1z0ubuPRridNpD9qpoWKc42hQq6W4ix1dbiYmSE/0xwZ6FP+P/juWTcytI1RpCVOa3Ru0Bh7WRJ6RmA1NsYXuAne0gX1VLyCu58pSFCgC7QcUcP85G/rh2Kkw3Ry8Q2wpMPJjaNZWp0ZV1Gvz83ImMfA0xmaw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Fri, 01 May 2026 15:01:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHc2KCxQvKgH2FypkCKt5lrj84l4LX5RPgA
  • Thread-topic: [PATCH v2 2/2] xen/arm: skip holes in physical address space when setting up frametable

Hi Michal,

> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index faef0efb327c..7297cca01551 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -63,7 +63,7 @@ void __init setup_mm(void)
> 
>     setup_mm_helper();
> 
> -    setup_frametable_mappings(ram_start, ram_end);
> +    init_frametable(ram_start);

I think that now ram_end and bank_end can be removed

> 
>     init_staticmem_pages();
>     init_sharedmem_pages();
> diff --git a/xen/arch/arm/mmu/mm.c b/xen/arch/arm/mmu/mm.c
> index 6604f3bf4e6a..dfc888c8ee0e 100644
> --- a/xen/arch/arm/mmu/mm.c
> +++ b/xen/arch/arm/mmu/mm.c
> @@ -6,18 +6,45 @@
> #include <xen/mm.h>
> #include <xen/mm-frame.h>
> #include <xen/pdx.h>
> +#include <xen/sizes.h>
> #include <xen/string.h>
> 
> -/* Map a frame table to cover physical addresses ps through pe */
> -void __init setup_frametable_mappings(paddr_t ps, paddr_t pe)
> +static void __init init_frametable_chunk(unsigned long pdx_s,
> +                                         unsigned long pdx_e)
> {
> -    unsigned long nr_pdxs = mfn_to_pdx(mfn_add(maddr_to_mfn(pe), -1)) -
> -                            mfn_to_pdx(maddr_to_mfn(ps)) + 1;
> -    unsigned long frametable_size = nr_pdxs * sizeof(struct page_info);
> -    mfn_t base_mfn;
> -    const unsigned long mapping_size = frametable_size < MB(32) ? MB(2)
> -                                                                : MB(32);
> +    unsigned long nr_pdxs = pdx_e - pdx_s;
> +    unsigned long chunk_size = nr_pdxs * sizeof(struct page_info);
> +    unsigned long virt;
>     int rc;
> +    mfn_t base_mfn;
> +
> +    /*
> +     * In-loop chunks span whole PDX groups, which are always page-size
> +     * aligned. The last chunk ending at max_pdx may not be, so round up.
> +     */
> +    chunk_size = ROUNDUP(chunk_size, PAGE_SIZE);
> +
> +    /*
> +     * Align the allocation to the contiguous mapping size so that
> +     * map_pages_to_xen() can use the contiguous bit.
> +     */
> +    base_mfn = alloc_boot_pages(chunk_size >> PAGE_SHIFT,
> +                                MB(32) >> PAGE_SHIFT);

This fixed 32Mb alignment feels a bit more than we need, If for example the
chunk is less than 32Mb? If we had some variable alignment for chunks less
than 32MB we would maybe help alloc_boot_pages job, in the end if the chunk
is less than 32Mb it won’t get the contiguous bit anyway.

But I’m fine also if you leave it as it is.

With the above fixed:

Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx>
Tested-by: Luca Fancellu <luca.fancellu@xxxxxxx>

I’ve also tested on Arm64 MMU, Arm32 MMU, Arm64 MPU virtual platforms.

Cheers,
Luca


 


Rackspace

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