diff mbox

[v2,02/24] xen/mm: Use typesafe MFN for alloc_boot_pages return

Message ID 20170912100330.2168-3-julien.grall@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Julien Grall Sept. 12, 2017, 10:03 a.m. UTC
At the moment, most of the callers will have to use mfn_x. However
follow-up patches will remove some of them by propagating the typesafe a
bit further.

Signed-off-by: Julien Grall <julien.grall@arm.com>
---

Changes in v2:
    - Push down a bit some mfn_t to convert some unsigned long local
    variables to mfn_t.

Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>
---
 xen/arch/arm/mm.c       | 26 ++++++++++++++------------
 xen/arch/arm/setup.c    |  4 ++--
 xen/arch/x86/mm.c       |  7 ++++---
 xen/arch/x86/numa.c     |  2 +-
 xen/arch/x86/srat.c     |  5 +++--
 xen/common/page_alloc.c |  7 +++----
 xen/drivers/acpi/osl.c  |  2 +-
 xen/include/xen/mm.h    |  3 +--
 8 files changed, 29 insertions(+), 27 deletions(-)

Comments

Jan Beulich Sept. 12, 2017, 10:27 a.m. UTC | #1
>>> On 12.09.17 at 12:03, <julien.grall@arm.com> wrote:
> At the moment, most of the callers will have to use mfn_x. However
> follow-up patches will remove some of them by propagating the typesafe a
> bit further.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Non-ARM pieces
Acked-by: Jan Beulich <jbeulich@suse.com>
Wei Liu Sept. 12, 2017, 10:29 a.m. UTC | #2
On Tue, Sep 12, 2017 at 11:03:08AM +0100, Julien Grall wrote:
> At the moment, most of the callers will have to use mfn_x. However
> follow-up patches will remove some of them by propagating the typesafe a
> bit further.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Reviewed-by: Wei Liu <wei.liu2@citrix.com>
George Dunlap Sept. 12, 2017, 2:19 p.m. UTC | #3
On 09/12/2017 11:03 AM, Julien Grall wrote:
> At the moment, most of the callers will have to use mfn_x. However
> follow-up patches will remove some of them by propagating the typesafe a
> bit further.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>

mm bits:

Acked-by: George Dunlap <george.dunlap@citrix.com>
Stefano Stabellini Sept. 15, 2017, 11:33 p.m. UTC | #4
On Tue, 12 Sep 2017, Julien Grall wrote:
> At the moment, most of the callers will have to use mfn_x. However
> follow-up patches will remove some of them by propagating the typesafe a
> bit further.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
> 
> Changes in v2:
>     - Push down a bit some mfn_t to convert some unsigned long local
>     variables to mfn_t.
> 
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> Cc: George Dunlap <George.Dunlap@eu.citrix.com>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Tim Deegan <tim@xen.org>
> Cc: Wei Liu <wei.liu2@citrix.com>
> ---
>  xen/arch/arm/mm.c       | 26 ++++++++++++++------------
>  xen/arch/arm/setup.c    |  4 ++--
>  xen/arch/x86/mm.c       |  7 ++++---
>  xen/arch/x86/numa.c     |  2 +-
>  xen/arch/x86/srat.c     |  5 +++--
>  xen/common/page_alloc.c |  7 +++----
>  xen/drivers/acpi/osl.c  |  2 +-
>  xen/include/xen/mm.h    |  3 +--
>  8 files changed, 29 insertions(+), 27 deletions(-)
> 
> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index b39677eac9..965d0573a4 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -864,13 +864,13 @@ void __init setup_xenheap_mappings(unsigned long base_mfn,
>          }
>          else
>          {
> -            unsigned long first_mfn = alloc_boot_pages(1, 1);
> +            mfn_t first_mfn = alloc_boot_pages(1, 1);
>  
> -            clear_page(mfn_to_virt(first_mfn));
> -            pte = mfn_to_xen_entry(_mfn(first_mfn), WRITEALLOC);
> +            clear_page(mfn_to_virt(mfn_x(first_mfn)));
> +            pte = mfn_to_xen_entry(first_mfn, WRITEALLOC);
>              pte.pt.table = 1;
>              write_pte(p, pte);
> -            first = mfn_to_virt(first_mfn);
> +            first = mfn_to_virt(mfn_x(first_mfn));
>          }
>  
>          pte = mfn_to_xen_entry(_mfn(mfn), WRITEALLOC);
> @@ -891,11 +891,12 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe)
>      unsigned long nr_pages = (pe - ps) >> PAGE_SHIFT;
>      unsigned long nr_pdxs = pfn_to_pdx(nr_pages);
>      unsigned long frametable_size = nr_pdxs * sizeof(struct page_info);
> -    unsigned long base_mfn;
> +    mfn_t base_mfn;
>      const unsigned long mapping_size = frametable_size < MB(32) ? MB(2) : MB(32);
>  #ifdef CONFIG_ARM_64
>      lpae_t *second, pte;
> -    unsigned long nr_second, second_base;
> +    unsigned long nr_second;
> +    mfn_t second_base;
>      int i;
>  #endif
>  
> @@ -908,18 +909,19 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe)
>      /* Compute the number of second level pages. */
>      nr_second = ROUNDUP(frametable_size, FIRST_SIZE) >> FIRST_SHIFT;
>      second_base = alloc_boot_pages(nr_second, 1);
> -    second = mfn_to_virt(second_base);
> +    second = mfn_to_virt(mfn_x(second_base));
>      for ( i = 0; i < nr_second; i++ )
>      {
> -        clear_page(mfn_to_virt(second_base + i));
> -        pte = mfn_to_xen_entry(_mfn(second_base + i), WRITEALLOC);
> +        clear_page(mfn_to_virt(mfn_x(mfn_add(second_base, i))));
> +        pte = mfn_to_xen_entry(mfn_add(second_base, i), WRITEALLOC);
>          pte.pt.table = 1;
>          write_pte(&xen_first[first_table_offset(FRAMETABLE_VIRT_START)+i], pte);
>      }
> -    create_mappings(second, 0, base_mfn, frametable_size >> PAGE_SHIFT, mapping_size);
> +    create_mappings(second, 0, mfn_x(base_mfn), frametable_size >> PAGE_SHIFT,
> +                    mapping_size);
>  #else
> -    create_mappings(xen_second, FRAMETABLE_VIRT_START,
> -                    base_mfn, frametable_size >> PAGE_SHIFT, mapping_size);
> +    create_mappings(xen_second, FRAMETABLE_VIRT_START, mfn_x(base_mfn),
> +                    frametable_size >> PAGE_SHIFT, mapping_size);
>  #endif
>  
>      memset(&frame_table[0], 0, nr_pdxs * sizeof(struct page_info));
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index 92f173be0c..b00eebd96e 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -561,7 +561,7 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
>      init_boot_pages(pfn_to_paddr(boot_mfn_start), pfn_to_paddr(boot_mfn_end));
>  
>      /* Copy the DTB. */
> -    fdt = mfn_to_virt(alloc_boot_pages(dtb_pages, 1));
> +    fdt = mfn_to_virt(mfn_x(alloc_boot_pages(dtb_pages, 1)));
>      copy_from_paddr(fdt, dtb_paddr, dtb_size);
>      device_tree_flattened = fdt;
>  
> @@ -671,7 +671,7 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
>      dtb_pages = (dtb_size + PAGE_SIZE-1) >> PAGE_SHIFT;
>  
>      /* Copy the DTB. */
> -    fdt = mfn_to_virt(alloc_boot_pages(dtb_pages, 1));
> +    fdt = mfn_to_virt(mfn_x(alloc_boot_pages(dtb_pages, 1)));
>      copy_from_paddr(fdt, dtb_paddr, dtb_size);
>      device_tree_flattened = fdt;
>  
> diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
> index e5a029c9be..850e4721cd 100644
> --- a/xen/arch/x86/mm.c
> +++ b/xen/arch/x86/mm.c
> @@ -200,7 +200,8 @@ static void __init init_frametable_chunk(void *start, void *end)
>  {
>      unsigned long s = (unsigned long)start;
>      unsigned long e = (unsigned long)end;
> -    unsigned long step, mfn;
> +    unsigned long step;
> +    mfn_t mfn;
>  
>      ASSERT(!(s & ((1 << L2_PAGETABLE_SHIFT) - 1)));
>      for ( ; s < e; s += step << PAGE_SHIFT )
> @@ -216,7 +217,7 @@ static void __init init_frametable_chunk(void *start, void *end)
>          while ( step && s + (step << PAGE_SHIFT) > e + (4 << PAGE_SHIFT) )
>              step >>= PAGETABLE_ORDER;
>          mfn = alloc_boot_pages(step, step);
> -        map_pages_to_xen(s, mfn, step, PAGE_HYPERVISOR);
> +        map_pages_to_xen(s, mfn_x(mfn), step, PAGE_HYPERVISOR);
>      }
>  
>      memset(start, 0, end - start);
> @@ -5328,7 +5329,7 @@ void *alloc_xen_pagetable(void)
>          return ptr;
>      }
>  
> -    return mfn_to_virt(alloc_boot_pages(1, 1));
> +    return mfn_to_virt(mfn_x(alloc_boot_pages(1, 1)));
>  }
>  
>  void free_xen_pagetable(void *v)
> diff --git a/xen/arch/x86/numa.c b/xen/arch/x86/numa.c
> index 32914bce27..4fc967f893 100644
> --- a/xen/arch/x86/numa.c
> +++ b/xen/arch/x86/numa.c
> @@ -99,7 +99,7 @@ static int __init populate_memnodemap(const struct node *nodes,
>  static int __init allocate_cachealigned_memnodemap(void)
>  {
>      unsigned long size = PFN_UP(memnodemapsize * sizeof(*memnodemap));
> -    unsigned long mfn = alloc_boot_pages(size, 1);
> +    unsigned long mfn = mfn_x(alloc_boot_pages(size, 1));
>  
>      memnodemap = mfn_to_virt(mfn);
>      mfn <<= PAGE_SHIFT;
> diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c
> index 95660a9bbc..528ec7181a 100644
> --- a/xen/arch/x86/srat.c
> +++ b/xen/arch/x86/srat.c
> @@ -187,14 +187,15 @@ static __init int slit_valid(struct acpi_table_slit *slit)
>  /* Callback for SLIT parsing */
>  void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
>  {
> -	unsigned long mfn;
> +	mfn_t mfn;
> +
>  	if (!slit_valid(slit)) {
>  		printk(KERN_INFO "ACPI: SLIT table looks invalid. "
>  		       "Not used.\n");
>  		return;
>  	}
>  	mfn = alloc_boot_pages(PFN_UP(slit->header.length), 1);
> -	acpi_slit = mfn_to_virt(mfn);
> +	acpi_slit = mfn_to_virt(mfn_x(mfn));
>  	memcpy(acpi_slit, slit, slit->header.length);
>  }
>  
> diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
> index b5243fca3c..86bd298b44 100644
> --- a/xen/common/page_alloc.c
> +++ b/xen/common/page_alloc.c
> @@ -325,8 +325,7 @@ void __init init_boot_pages(paddr_t ps, paddr_t pe)
>      }
>  }
>  
> -unsigned long __init alloc_boot_pages(
> -    unsigned long nr_pfns, unsigned long pfn_align)
> +mfn_t __init alloc_boot_pages(unsigned long nr_pfns, unsigned long pfn_align)
>  {
>      unsigned long pg, _e;
>      unsigned int i = nr_bootmem_regions;
> @@ -355,14 +354,14 @@ unsigned long __init alloc_boot_pages(
>              if ( pg + nr_pfns > PFN_DOWN(highmem_start) )
>                  continue;
>              r->s = pg + nr_pfns;
> -            return pg;
> +            return _mfn(pg);
>          }
>  #endif
>  
>          _e = r->e;
>          r->e = pg;
>          bootmem_region_add(pg + nr_pfns, _e);
> -        return pg;
> +        return _mfn(pg);
>      }
>  
>      BUG();
> diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
> index 9881db19da..52c9b4ba9a 100644
> --- a/xen/drivers/acpi/osl.c
> +++ b/xen/drivers/acpi/osl.c
> @@ -214,7 +214,7 @@ void *__init acpi_os_alloc_memory(size_t sz)
>  	void *ptr;
>  
>  	if (system_state == SYS_STATE_early_boot)
> -		return mfn_to_virt(alloc_boot_pages(PFN_UP(sz), 1));
> +		return mfn_to_virt(mfn_x(alloc_boot_pages(PFN_UP(sz), 1)));
>  
>  	ptr = xmalloc_bytes(sz);
>  	ASSERT(!ptr || is_xmalloc_memory(ptr));
> diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h
> index c2f5a089ec..f8b6177c32 100644
> --- a/xen/include/xen/mm.h
> +++ b/xen/include/xen/mm.h
> @@ -151,8 +151,7 @@ struct domain *__must_check page_get_owner_and_reference(struct page_info *);
>  
>  /* Boot-time allocator. Turns into generic allocator after bootstrap. */
>  void init_boot_pages(paddr_t ps, paddr_t pe);
> -unsigned long alloc_boot_pages(
> -    unsigned long nr_pfns, unsigned long pfn_align);
> +mfn_t alloc_boot_pages(unsigned long nr_pfns, unsigned long pfn_align);
>  void end_boot_allocator(void);
>  
>  /* Xen suballocator. These functions are interrupt-safe. */
> -- 
> 2.11.0
>
diff mbox

Patch

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index b39677eac9..965d0573a4 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -864,13 +864,13 @@  void __init setup_xenheap_mappings(unsigned long base_mfn,
         }
         else
         {
-            unsigned long first_mfn = alloc_boot_pages(1, 1);
+            mfn_t first_mfn = alloc_boot_pages(1, 1);
 
-            clear_page(mfn_to_virt(first_mfn));
-            pte = mfn_to_xen_entry(_mfn(first_mfn), WRITEALLOC);
+            clear_page(mfn_to_virt(mfn_x(first_mfn)));
+            pte = mfn_to_xen_entry(first_mfn, WRITEALLOC);
             pte.pt.table = 1;
             write_pte(p, pte);
-            first = mfn_to_virt(first_mfn);
+            first = mfn_to_virt(mfn_x(first_mfn));
         }
 
         pte = mfn_to_xen_entry(_mfn(mfn), WRITEALLOC);
@@ -891,11 +891,12 @@  void __init setup_frametable_mappings(paddr_t ps, paddr_t pe)
     unsigned long nr_pages = (pe - ps) >> PAGE_SHIFT;
     unsigned long nr_pdxs = pfn_to_pdx(nr_pages);
     unsigned long frametable_size = nr_pdxs * sizeof(struct page_info);
-    unsigned long base_mfn;
+    mfn_t base_mfn;
     const unsigned long mapping_size = frametable_size < MB(32) ? MB(2) : MB(32);
 #ifdef CONFIG_ARM_64
     lpae_t *second, pte;
-    unsigned long nr_second, second_base;
+    unsigned long nr_second;
+    mfn_t second_base;
     int i;
 #endif
 
@@ -908,18 +909,19 @@  void __init setup_frametable_mappings(paddr_t ps, paddr_t pe)
     /* Compute the number of second level pages. */
     nr_second = ROUNDUP(frametable_size, FIRST_SIZE) >> FIRST_SHIFT;
     second_base = alloc_boot_pages(nr_second, 1);
-    second = mfn_to_virt(second_base);
+    second = mfn_to_virt(mfn_x(second_base));
     for ( i = 0; i < nr_second; i++ )
     {
-        clear_page(mfn_to_virt(second_base + i));
-        pte = mfn_to_xen_entry(_mfn(second_base + i), WRITEALLOC);
+        clear_page(mfn_to_virt(mfn_x(mfn_add(second_base, i))));
+        pte = mfn_to_xen_entry(mfn_add(second_base, i), WRITEALLOC);
         pte.pt.table = 1;
         write_pte(&xen_first[first_table_offset(FRAMETABLE_VIRT_START)+i], pte);
     }
-    create_mappings(second, 0, base_mfn, frametable_size >> PAGE_SHIFT, mapping_size);
+    create_mappings(second, 0, mfn_x(base_mfn), frametable_size >> PAGE_SHIFT,
+                    mapping_size);
 #else
-    create_mappings(xen_second, FRAMETABLE_VIRT_START,
-                    base_mfn, frametable_size >> PAGE_SHIFT, mapping_size);
+    create_mappings(xen_second, FRAMETABLE_VIRT_START, mfn_x(base_mfn),
+                    frametable_size >> PAGE_SHIFT, mapping_size);
 #endif
 
     memset(&frame_table[0], 0, nr_pdxs * sizeof(struct page_info));
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 92f173be0c..b00eebd96e 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -561,7 +561,7 @@  static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
     init_boot_pages(pfn_to_paddr(boot_mfn_start), pfn_to_paddr(boot_mfn_end));
 
     /* Copy the DTB. */
-    fdt = mfn_to_virt(alloc_boot_pages(dtb_pages, 1));
+    fdt = mfn_to_virt(mfn_x(alloc_boot_pages(dtb_pages, 1)));
     copy_from_paddr(fdt, dtb_paddr, dtb_size);
     device_tree_flattened = fdt;
 
@@ -671,7 +671,7 @@  static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
     dtb_pages = (dtb_size + PAGE_SIZE-1) >> PAGE_SHIFT;
 
     /* Copy the DTB. */
-    fdt = mfn_to_virt(alloc_boot_pages(dtb_pages, 1));
+    fdt = mfn_to_virt(mfn_x(alloc_boot_pages(dtb_pages, 1)));
     copy_from_paddr(fdt, dtb_paddr, dtb_size);
     device_tree_flattened = fdt;
 
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index e5a029c9be..850e4721cd 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -200,7 +200,8 @@  static void __init init_frametable_chunk(void *start, void *end)
 {
     unsigned long s = (unsigned long)start;
     unsigned long e = (unsigned long)end;
-    unsigned long step, mfn;
+    unsigned long step;
+    mfn_t mfn;
 
     ASSERT(!(s & ((1 << L2_PAGETABLE_SHIFT) - 1)));
     for ( ; s < e; s += step << PAGE_SHIFT )
@@ -216,7 +217,7 @@  static void __init init_frametable_chunk(void *start, void *end)
         while ( step && s + (step << PAGE_SHIFT) > e + (4 << PAGE_SHIFT) )
             step >>= PAGETABLE_ORDER;
         mfn = alloc_boot_pages(step, step);
-        map_pages_to_xen(s, mfn, step, PAGE_HYPERVISOR);
+        map_pages_to_xen(s, mfn_x(mfn), step, PAGE_HYPERVISOR);
     }
 
     memset(start, 0, end - start);
@@ -5328,7 +5329,7 @@  void *alloc_xen_pagetable(void)
         return ptr;
     }
 
-    return mfn_to_virt(alloc_boot_pages(1, 1));
+    return mfn_to_virt(mfn_x(alloc_boot_pages(1, 1)));
 }
 
 void free_xen_pagetable(void *v)
diff --git a/xen/arch/x86/numa.c b/xen/arch/x86/numa.c
index 32914bce27..4fc967f893 100644
--- a/xen/arch/x86/numa.c
+++ b/xen/arch/x86/numa.c
@@ -99,7 +99,7 @@  static int __init populate_memnodemap(const struct node *nodes,
 static int __init allocate_cachealigned_memnodemap(void)
 {
     unsigned long size = PFN_UP(memnodemapsize * sizeof(*memnodemap));
-    unsigned long mfn = alloc_boot_pages(size, 1);
+    unsigned long mfn = mfn_x(alloc_boot_pages(size, 1));
 
     memnodemap = mfn_to_virt(mfn);
     mfn <<= PAGE_SHIFT;
diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c
index 95660a9bbc..528ec7181a 100644
--- a/xen/arch/x86/srat.c
+++ b/xen/arch/x86/srat.c
@@ -187,14 +187,15 @@  static __init int slit_valid(struct acpi_table_slit *slit)
 /* Callback for SLIT parsing */
 void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
 {
-	unsigned long mfn;
+	mfn_t mfn;
+
 	if (!slit_valid(slit)) {
 		printk(KERN_INFO "ACPI: SLIT table looks invalid. "
 		       "Not used.\n");
 		return;
 	}
 	mfn = alloc_boot_pages(PFN_UP(slit->header.length), 1);
-	acpi_slit = mfn_to_virt(mfn);
+	acpi_slit = mfn_to_virt(mfn_x(mfn));
 	memcpy(acpi_slit, slit, slit->header.length);
 }
 
diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index b5243fca3c..86bd298b44 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -325,8 +325,7 @@  void __init init_boot_pages(paddr_t ps, paddr_t pe)
     }
 }
 
-unsigned long __init alloc_boot_pages(
-    unsigned long nr_pfns, unsigned long pfn_align)
+mfn_t __init alloc_boot_pages(unsigned long nr_pfns, unsigned long pfn_align)
 {
     unsigned long pg, _e;
     unsigned int i = nr_bootmem_regions;
@@ -355,14 +354,14 @@  unsigned long __init alloc_boot_pages(
             if ( pg + nr_pfns > PFN_DOWN(highmem_start) )
                 continue;
             r->s = pg + nr_pfns;
-            return pg;
+            return _mfn(pg);
         }
 #endif
 
         _e = r->e;
         r->e = pg;
         bootmem_region_add(pg + nr_pfns, _e);
-        return pg;
+        return _mfn(pg);
     }
 
     BUG();
diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
index 9881db19da..52c9b4ba9a 100644
--- a/xen/drivers/acpi/osl.c
+++ b/xen/drivers/acpi/osl.c
@@ -214,7 +214,7 @@  void *__init acpi_os_alloc_memory(size_t sz)
 	void *ptr;
 
 	if (system_state == SYS_STATE_early_boot)
-		return mfn_to_virt(alloc_boot_pages(PFN_UP(sz), 1));
+		return mfn_to_virt(mfn_x(alloc_boot_pages(PFN_UP(sz), 1)));
 
 	ptr = xmalloc_bytes(sz);
 	ASSERT(!ptr || is_xmalloc_memory(ptr));
diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h
index c2f5a089ec..f8b6177c32 100644
--- a/xen/include/xen/mm.h
+++ b/xen/include/xen/mm.h
@@ -151,8 +151,7 @@  struct domain *__must_check page_get_owner_and_reference(struct page_info *);
 
 /* Boot-time allocator. Turns into generic allocator after bootstrap. */
 void init_boot_pages(paddr_t ps, paddr_t pe);
-unsigned long alloc_boot_pages(
-    unsigned long nr_pfns, unsigned long pfn_align);
+mfn_t alloc_boot_pages(unsigned long nr_pfns, unsigned long pfn_align);
 void end_boot_allocator(void);
 
 /* Xen suballocator. These functions are interrupt-safe. */