@@ -245,6 +245,11 @@ void *vmap(const mfn_t *mfn, unsigned int nr)
return __vmap(mfn, 1, nr, 1, PAGE_HYPERVISOR, VMAP_DEFAULT);
}
+void *vmap_contig(mfn_t mfn, unsigned int nr)
+{
+ return __vmap(&mfn, nr, 1, 1, PAGE_HYPERVISOR, VMAP_DEFAULT);
+}
+
unsigned int vmap_size(const void *va)
{
unsigned int pages = vm_size(va, VMAP_DEFAULT);
@@ -221,7 +221,11 @@ void *__init acpi_os_alloc_memory(size_t sz)
void *ptr;
if (system_state == SYS_STATE_early_boot)
- return mfn_to_virt(mfn_x(alloc_boot_pages(PFN_UP(sz), 1)));
+ {
+ mfn_t mfn = alloc_boot_pages(PFN_UP(sz), 1);
+
+ return vmap_contig(mfn, PFN_UP(sz));
+ }
ptr = xmalloc_bytes(sz);
ASSERT(!ptr || is_xmalloc_memory(ptr));
@@ -246,5 +250,11 @@ void __init acpi_os_free_memory(void *ptr)
if (is_xmalloc_memory(ptr))
xfree(ptr);
else if (ptr && system_state == SYS_STATE_early_boot)
- init_boot_pages(__pa(ptr), __pa(ptr) + PAGE_SIZE);
+ {
+ paddr_t addr = mfn_to_maddr(vmap_to_mfn(ptr));
+ unsigned int nr = vmap_size(ptr);
+
+ vunmap(ptr);
+ init_boot_pages(addr, addr + nr * PAGE_SIZE);
+ }
}
@@ -15,6 +15,7 @@ void vm_init_type(enum vmap_region type, void *start, void *end);
void *__vmap(const mfn_t *mfn, unsigned int granularity, unsigned int nr,
unsigned int align, unsigned int flags, enum vmap_region type);
void *vmap(const mfn_t *mfn, unsigned int nr);
+void *vmap_contig(mfn_t mfn, unsigned int nr);
void vunmap(const void *va);
void *vmalloc(size_t size);