grub-devel
[Top][All Lists]
Advanced

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

[RFC PATCH v3 2/2] mm: Separate different types of allocations into diff


From: Zhang Boyang
Subject: [RFC PATCH v3 2/2] mm: Separate different types of allocations into different regions
Date: Thu, 13 Oct 2022 09:29:19 +0800

This patch add type infomation to heap regions. Currently there are four
types: GRUB_MM_SIZE_SMALL, GRUB_MM_SIZE_LARGE, GRUB_MM_CLASS_DATA,
GRUB_MM_CLASS_MODULE. Each heap region can have its own mask of
acceptable memory allocation types.

The GRUB_MM_SIZE_* types denotes the relative size of an allocation.
Allocations lesser than GRUB_MM_GROW_SMALL belong to GRUB_MM_SIZE_SMALL,
otherwise they belong to GRUB_MM_SIZE_LARGE. Thus small and large chunks
can be separated into different heaps. This might help reduce heap
fragmentation.

The GRUB_MM_CLASS_* types denotes whether an allocation is a module
segment. Module segments are allocated with GRUB_MM_CLASS_MODULE flag
set. Plain data chunks (and module metadata) are allocated with
GRUB_MM_CLASS_DATA flag set. Thus module segments and plain data chunks
can be separated into different heaps.

On platforms with dynamic heap growth support, when heap space is
exhausted, a new region will be allocated from firmware. The new region
has same type flags as the allocation request itself. The size of new
region will be (size + align + GRUB_MM_MAX_COST) for GRUB_MM_SIZE_LARGE
requests, and (GRUB_MM_GROW_SMALL + GRUB_MM_MAX_COST) for
GRUB_MM_SIZE_SMALL requests, with GRUB_MM_MAX_COST denotes the extra
region management cost.

On platforms without dynamic heap growth support, default heap will be
created with GRUB_MM_TYPE_ALL, so any type of allocation can be
fulfilled by default heap.

Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
---
 docs/grub-dev.texi                   |  3 +-
 grub-core/kern/arm/coreboot/init.c   |  4 +--
 grub-core/kern/dl.c                  |  2 +-
 grub-core/kern/efi/mm.c              | 12 ++++---
 grub-core/kern/i386/coreboot/init.c  |  2 +-
 grub-core/kern/i386/pc/init.c        |  2 +-
 grub-core/kern/i386/qemu/init.c      |  2 +-
 grub-core/kern/i386/xen/pvh.c        |  2 +-
 grub-core/kern/ieee1275/init.c       |  4 +--
 grub-core/kern/main.c                |  2 +-
 grub-core/kern/mips/arc/init.c       |  2 +-
 grub-core/kern/mips/loongson/init.c  |  2 +-
 grub-core/kern/mips/qemu_mips/init.c |  2 +-
 grub-core/kern/mm.c                  | 52 ++++++++++++++++++++++++----
 grub-core/kern/uboot/hw.c            |  2 +-
 grub-core/kern/xen/init.c            |  2 +-
 include/grub/mm.h                    | 23 ++++++++++--
 include/grub/mm_private.h            |  5 ++-
 util/misc.c                          |  3 +-
 19 files changed, 95 insertions(+), 33 deletions(-)

diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi
index f76fc658b..2c27fad98 100644
--- a/docs/grub-dev.texi
+++ b/docs/grub-dev.texi
@@ -818,7 +818,8 @@ If it works next stage is to have heap, console and timer.
 
 To have the heap working you need to determine which regions are suitable for
 heap usage, allocate them from firmware and map (if applicable). Then call
-grub_mm_init_region (void *start, grub_size_t s) for every of this region.
+grub_mm_init_region (void *addr, grub_size_t size, unsigned int types) for
+every of this region.
 As a shortcut for early port you can allocate right after _end or have
 a big static array for heap. If you do you'll probably need to come back to
 this later. As for output console you should distinguish between an array of
diff --git a/grub-core/kern/arm/coreboot/init.c 
b/grub-core/kern/arm/coreboot/init.c
index 8d8c5b829..95bd45afd 100644
--- a/grub-core/kern/arm/coreboot/init.c
+++ b/grub-core/kern/arm/coreboot/init.c
@@ -77,7 +77,7 @@ heap_init (grub_uint64_t addr, grub_uint64_t size, 
grub_memory_type_t type,
     {
       if (begin < (grub_addr_t)_start)
        {
-         grub_mm_init_region ((void *) (grub_addr_t) begin, (grub_size_t) 
((grub_addr_t)_start - begin));
+         grub_mm_init_region ((void *) (grub_addr_t) begin, (grub_size_t) 
((grub_addr_t)_start - begin), GRUB_MM_TYPE_ALL);
          have_memory = 1;
        }
       begin = modend;
@@ -90,7 +90,7 @@ heap_init (grub_uint64_t addr, grub_uint64_t size, 
grub_memory_type_t type,
   if (end <= begin)
     return 0;
 
-  grub_mm_init_region ((void *) (grub_addr_t) begin, (grub_size_t) (end - 
begin));
+  grub_mm_init_region ((void *) (grub_addr_t) begin, (grub_size_t) (end - 
begin), GRUB_MM_TYPE_ALL);
 
   have_memory = 1;
 
diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
index e447fd0fa..f11a23cc6 100644
--- a/grub-core/kern/dl.c
+++ b/grub-core/kern/dl.c
@@ -256,7 +256,7 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
 #ifdef GRUB_MACHINE_EMU
   mod->base = grub_osdep_dl_memalign (talign, tsize);
 #else
-  mod->base = grub_memalign (talign, tsize);
+  mod->base = grub_module_memalign (talign, tsize);
 #endif
   if (!mod->base)
     return grub_errno;
diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
index 3705b8b1b..8218d721a 100644
--- a/grub-core/kern/efi/mm.c
+++ b/grub-core/kern/efi/mm.c
@@ -483,7 +483,7 @@ add_memory_regions (grub_efi_memory_descriptor_t 
*memory_map,
                    grub_efi_uintn_t desc_size,
                    grub_efi_memory_descriptor_t *memory_map_end,
                    grub_efi_uint64_t required_pages,
-                   unsigned int flags)
+                   unsigned int flags, unsigned int types)
 {
   grub_efi_memory_descriptor_t *desc;
 
@@ -515,7 +515,7 @@ add_memory_regions (grub_efi_memory_descriptor_t 
*memory_map,
                            "Memory starting at %p (%u pages) marked as free, 
but EFI would not allocate",
                            (void *) ((grub_addr_t) start), (unsigned) pages);
 
-      grub_mm_init_region (addr, PAGES_TO_BYTES (pages));
+      grub_mm_init_region (addr, PAGES_TO_BYTES (pages), types);
 
       required_pages -= pages;
       if (required_pages == 0)
@@ -566,7 +566,7 @@ print_memory_map (grub_efi_memory_descriptor_t *memory_map,
 #endif
 
 static grub_err_t
-grub_efi_mm_add_regions (grub_size_t required_bytes, unsigned int flags)
+grub_efi_mm_add_regions (grub_size_t required_bytes, unsigned int flags, 
unsigned int types)
 {
   grub_efi_memory_descriptor_t *memory_map;
   grub_efi_memory_descriptor_t *memory_map_end;
@@ -622,7 +622,7 @@ grub_efi_mm_add_regions (grub_size_t required_bytes, 
unsigned int flags)
   err = add_memory_regions (filtered_memory_map, desc_size,
                            filtered_memory_map_end,
                            BYTES_TO_PAGES (required_bytes),
-                           flags);
+                           flags, types);
   if (err != GRUB_ERR_NONE)
     return err;
 
@@ -649,7 +649,9 @@ grub_efi_mm_add_regions (grub_size_t required_bytes, 
unsigned int flags)
 void
 grub_efi_mm_init (void)
 {
-  if (grub_efi_mm_add_regions (DEFAULT_HEAP_SIZE, GRUB_MM_ADD_REGION_NONE) != 
GRUB_ERR_NONE)
+  if (grub_efi_mm_add_regions (DEFAULT_HEAP_SIZE,
+                              GRUB_MM_ADD_REGION_NONE,
+                              GRUB_MM_SIZE_ALL | GRUB_MM_CLASS_DATA) != 
GRUB_ERR_NONE)
     grub_fatal ("%s", grub_errmsg);
   grub_mm_add_region_fn = grub_efi_mm_add_regions;
 }
diff --git a/grub-core/kern/i386/coreboot/init.c 
b/grub-core/kern/i386/coreboot/init.c
index 4fae8b571..90b688304 100644
--- a/grub-core/kern/i386/coreboot/init.c
+++ b/grub-core/kern/i386/coreboot/init.c
@@ -81,7 +81,7 @@ heap_init (grub_uint64_t addr, grub_uint64_t size, 
grub_memory_type_t type,
   if (end <= begin)
     return 0;
 
-  grub_mm_init_region ((void *) (grub_addr_t) begin, (grub_size_t) (end - 
begin));
+  grub_mm_init_region ((void *) (grub_addr_t) begin, (grub_size_t) (end - 
begin), GRUB_MM_TYPE_ALL);
 
   have_memory = 1;
 
diff --git a/grub-core/kern/i386/pc/init.c b/grub-core/kern/i386/pc/init.c
index 27bc68b8a..4ec26dcf1 100644
--- a/grub-core/kern/i386/pc/init.c
+++ b/grub-core/kern/i386/pc/init.c
@@ -256,7 +256,7 @@ grub_machine_init (void)
        beg = modend;
       if (beg >= fin)
        continue;
-      grub_mm_init_region ((void *) beg, fin - beg);
+      grub_mm_init_region ((void *) beg, fin - beg, GRUB_MM_TYPE_ALL);
     }
 
   grub_tsc_init ();
diff --git a/grub-core/kern/i386/qemu/init.c b/grub-core/kern/i386/qemu/init.c
index 4e84d3ba1..c1d0f6aa3 100644
--- a/grub-core/kern/i386/qemu/init.c
+++ b/grub-core/kern/i386/qemu/init.c
@@ -77,7 +77,7 @@ heap_init (grub_uint64_t addr, grub_uint64_t size, 
grub_memory_type_t type,
   if (end <= begin)
     return 0;
 
-  grub_mm_init_region ((void *) (grub_addr_t) begin, (grub_size_t) (end - 
begin));
+  grub_mm_init_region ((void *) (grub_addr_t) begin, (grub_size_t) (end - 
begin), GRUB_MM_TYPE_ALL);
 
   return 0;
 }
diff --git a/grub-core/kern/i386/xen/pvh.c b/grub-core/kern/i386/xen/pvh.c
index 91fbca859..01f11200e 100644
--- a/grub-core/kern/i386/xen/pvh.c
+++ b/grub-core/kern/i386/xen/pvh.c
@@ -261,7 +261,7 @@ grub_xen_mm_init_regions (void)
         continue;
       if (to > (1ULL << 32))
         to = 1ULL << 32;
-      grub_mm_init_region ((void *) (grub_addr_t) from, to - from);
+      grub_mm_init_region ((void *) (grub_addr_t) from, to - from, 
GRUB_MM_TYPE_ALL);
     }
 }
 
diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
index 2adf4fdfc..cd8377f7f 100644
--- a/grub-core/kern/ieee1275/init.c
+++ b/grub-core/kern/ieee1275/init.c
@@ -142,7 +142,7 @@ static void
 grub_claim_heap (void)
 {
   grub_mm_init_region ((void *) (grub_modules_get_end ()
-                                + GRUB_KERNEL_MACHINE_STACK_SIZE), 0x200000);
+                                + GRUB_KERNEL_MACHINE_STACK_SIZE), 0x200000, 
GRUB_MM_TYPE_ALL);
 }
 #else
 /* Helper for grub_claim_heap.  */
@@ -190,7 +190,7 @@ heap_init (grub_uint64_t addr, grub_uint64_t len, 
grub_memory_type_t type,
       err = grub_claimmap (addr, len);
       if (err)
        return err;
-      grub_mm_init_region ((void *) (grub_addr_t) addr, len);
+      grub_mm_init_region ((void *) (grub_addr_t) addr, len, GRUB_MM_TYPE_ALL);
     }
 
   *total += len;
diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c
index 731c07c29..068e48571 100644
--- a/grub-core/kern/main.c
+++ b/grub-core/kern/main.c
@@ -254,7 +254,7 @@ reclaim_module_space (void)
   grub_modbase = 0;
 
 #if GRUB_KERNEL_PRELOAD_SPACE_REUSABLE
-  grub_mm_init_region ((void *) modstart, modend - modstart);
+  grub_mm_init_region ((void *) modstart, modend - modstart, GRUB_MM_TYPE_ALL);
 #else
   (void) modstart;
   (void) modend;
diff --git a/grub-core/kern/mips/arc/init.c b/grub-core/kern/mips/arc/init.c
index 2ed3ff319..82b1012ce 100644
--- a/grub-core/kern/mips/arc/init.c
+++ b/grub-core/kern/mips/arc/init.c
@@ -250,7 +250,7 @@ grub_machine_init (void)
        end = 0x20000000;
       if (end > start)
        grub_mm_init_region ((void *) (grub_addr_t) (start | 0x80000000),
-                            end - start);
+                            end - start, GRUB_MM_TYPE_ALL);
     }
 
   grub_console_init_lately ();
diff --git a/grub-core/kern/mips/loongson/init.c 
b/grub-core/kern/mips/loongson/init.c
index 5bd721260..269fa30f1 100644
--- a/grub-core/kern/mips/loongson/init.c
+++ b/grub-core/kern/mips/loongson/init.c
@@ -202,7 +202,7 @@ grub_machine_init (void)
 
   modend = grub_modules_get_end ();
   grub_mm_init_region ((void *) modend, (grub_arch_memsize << 20)
-                      - (modend - GRUB_ARCH_LOWMEMVSTART));
+                      - (modend - GRUB_ARCH_LOWMEMVSTART), GRUB_MM_TYPE_ALL);
   /* FIXME: use upper memory as well.  */
 
   /* Initialize output terminal (can't be done earlier, as gfxterm
diff --git a/grub-core/kern/mips/qemu_mips/init.c 
b/grub-core/kern/mips/qemu_mips/init.c
index b5477b87f..5ed51f87e 100644
--- a/grub-core/kern/mips/qemu_mips/init.c
+++ b/grub-core/kern/mips/qemu_mips/init.c
@@ -53,7 +53,7 @@ grub_machine_init (void)
 
   modend = grub_modules_get_end ();
   grub_mm_init_region ((void *) modend, grub_arch_memsize
-                      - (modend - GRUB_ARCH_LOWMEMVSTART));
+                      - (modend - GRUB_ARCH_LOWMEMVSTART), GRUB_MM_TYPE_ALL);
 
   grub_install_get_time_ms (grub_rtc_get_time_ms);
 
diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c
index ae2279133..602838ae1 100644
--- a/grub-core/kern/mm.c
+++ b/grub-core/kern/mm.c
@@ -114,13 +114,13 @@ get_header_from_pointer (void *ptr, grub_mm_header_t *p, 
grub_mm_region_t *r)
 /* Initialize a region starting from ADDR and whose size is SIZE,
    to use it as free space.  */
 void
-grub_mm_init_region (void *addr, grub_size_t size)
+grub_mm_init_region (void *addr, grub_size_t size, unsigned int types)
 {
   grub_mm_header_t h;
   grub_mm_region_t r, *p, q;
 
-  grub_dprintf ("regions", "Using memory for heap: start=%p, end=%p\n",
-                addr, (char *) addr + (unsigned int) size);
+  grub_dprintf ("regions", "Using memory for heap: start=%p, end=%p, 
types=0x%x\n",
+                addr, (char *) addr + (unsigned int) size, types);
 
   /* Exclude last 4K to avoid overflows. */
   /* If addr + 0x1000 overflows then whole region is in excluded zone.  */
@@ -134,6 +134,10 @@ grub_mm_init_region (void *addr, grub_size_t size)
   /* Attempt to merge this region with every existing region */
   for (p = &grub_mm_base, q = *p; q; p = &(q->next), q = *p)
     {
+      /* Don't merge regions with different allocation types */
+      if (q->types != types)
+       continue;
+
       /*
        * Is the new region immediately below an existing region? That
        * is, is the address of the memory we're adding now (addr) + size
@@ -248,6 +252,7 @@ grub_mm_init_region (void *addr, grub_size_t size)
   r->pre_size = (grub_addr_t) r - (grub_addr_t) addr;
   r->size = (h->size << GRUB_MM_ALIGN_LOG2);
   r->post_size = size - r->size;
+  r->types = types;
 
   /* Find where to insert this region. Put a smaller one before bigger ones,
      to prevent fragmentation.  */
@@ -405,12 +410,14 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, 
grub_size_t align)
 }
 
 /* Allocate SIZE bytes with the alignment ALIGN and return the pointer.  */
-void *
-grub_memalign (grub_size_t align, grub_size_t size)
+static void *
+grub_real_memalign (grub_size_t align, grub_size_t size, unsigned int types)
 {
   grub_mm_region_t r;
   grub_size_t n = ((size + GRUB_MM_ALIGN - 1) >> GRUB_MM_ALIGN_LOG2) + 1;
+  grub_size_t guarantee;
   int count = 0;
+  grub_size_t grow;
 
   if (!grub_mm_base)
     goto fail;
@@ -424,6 +431,15 @@ grub_memalign (grub_size_t align, grub_size_t size)
   if ((size + align) > ~(grub_size_t) 0x100000)
     goto fail;
 
+  /* Allocation should always success if region free bytes >= guarantee. */
+  guarantee = size + align;
+
+  /* Set size flag heuristically. */
+  if (guarantee <= GRUB_MM_GROW_SMALL)
+    types |= GRUB_MM_SIZE_SMALL;
+  else
+    types |= GRUB_MM_SIZE_LARGE;
+
   align = (align >> GRUB_MM_ALIGN_LOG2);
   if (align == 0)
     align = 1;
@@ -432,6 +448,9 @@ grub_memalign (grub_size_t align, grub_size_t size)
 
   for (r = grub_mm_base; r; r = r->next)
     {
+      if ((types & ~r->types) != 0)
+       continue;
+
       void *p;
 
       p = grub_real_malloc (&(r->first), n, align);
@@ -446,8 +465,13 @@ grub_memalign (grub_size_t align, grub_size_t size)
       /* Request additional pages, contiguous */
       count++;
 
+      if ((types & GRUB_MM_SIZE_SMALL))
+       grow = GRUB_MM_GROW_SMALL + GRUB_MM_MAX_COST;
+      else
+       grow = guarantee + GRUB_MM_MAX_COST;
+
       if (grub_mm_add_region_fn != NULL &&
-          grub_mm_add_region_fn (size, GRUB_MM_ADD_REGION_CONSECUTIVE) == 
GRUB_ERR_NONE)
+          grub_mm_add_region_fn (grow, GRUB_MM_ADD_REGION_CONSECUTIVE, types) 
== GRUB_ERR_NONE)
        goto again;
 
       /* fallthrough  */
@@ -462,7 +486,7 @@ grub_memalign (grub_size_t align, grub_size_t size)
            * Try again even if this fails, in case it was able to partially
            * satisfy the request
            */
-          grub_mm_add_region_fn (size, GRUB_MM_ADD_REGION_NONE);
+          grub_mm_add_region_fn (grow, GRUB_MM_ADD_REGION_NONE, types);
           goto again;
         }
 
@@ -483,6 +507,20 @@ grub_memalign (grub_size_t align, grub_size_t size)
   return 0;
 }
 
+/* Allocate memory for plain data. */
+void *
+grub_memalign (grub_size_t align, grub_size_t size)
+{
+  return grub_real_memalign (align, size, GRUB_MM_CLASS_DATA);
+}
+
+/* Allocate memory for modules. */
+void *
+grub_module_memalign (grub_size_t align, grub_size_t size)
+{
+  return grub_real_memalign (align, size, GRUB_MM_CLASS_MODULE);
+}
+
 /*
  * Allocate NMEMB instances of SIZE bytes and return the pointer, or error on
  * integer overflow.
diff --git a/grub-core/kern/uboot/hw.c b/grub-core/kern/uboot/hw.c
index 272b83bd7..e76302ba9 100644
--- a/grub-core/kern/uboot/hw.c
+++ b/grub-core/kern/uboot/hw.c
@@ -41,7 +41,7 @@ grub_uboot_mm_init (void)
   struct sys_info *si = grub_uboot_get_sys_info ();
 
   grub_mm_init_region ((void *) grub_modules_get_end (),
-                      GRUB_KERNEL_MACHINE_HEAP_SIZE);
+                      GRUB_KERNEL_MACHINE_HEAP_SIZE, GRUB_MM_TYPE_ALL);
 
   if (si && (si->mr_no != 0))
     {
diff --git a/grub-core/kern/xen/init.c b/grub-core/kern/xen/init.c
index 782ca7295..038a31a9f 100644
--- a/grub-core/kern/xen/init.c
+++ b/grub-core/kern/xen/init.c
@@ -531,7 +531,7 @@ map_all_pages (void)
   grub_addr_t heap_start = grub_modules_get_end ();
   grub_addr_t heap_end = (grub_addr_t) new_mfn_list;
 
-  grub_mm_init_region ((void *) heap_start, heap_end - heap_start);
+  grub_mm_init_region ((void *) heap_start, heap_end - heap_start, 
GRUB_MM_TYPE_ALL);
 }
 
 grub_err_t
diff --git a/include/grub/mm.h b/include/grub/mm.h
index f3bf87fa0..2a7e572a5 100644
--- a/include/grub/mm.h
+++ b/include/grub/mm.h
@@ -29,14 +29,30 @@
 # define NULL  ((void *) 0)
 #endif
 
+/* An upper bound of management cost of each region, 4KB should be enough. */
+#define GRUB_MM_MAX_COST 0x1000
+
+/* Region type flags. */
+#define GRUB_MM_SIZE_SMALL (1 << 0)
+#define GRUB_MM_SIZE_LARGE (1 << 1)
+#define GRUB_MM_SIZE_ALL (GRUB_MM_SIZE_SMALL | GRUB_MM_SIZE_LARGE)
+#define GRUB_MM_CLASS_DATA   (1 << 30)
+#define GRUB_MM_CLASS_MODULE (1 << 31)
+#define GRUB_MM_CLASS_ALL (GRUB_MM_CLASS_DATA | GRUB_MM_CLASS_MODULE)
+#define GRUB_MM_TYPE_ALL (GRUB_MM_SIZE_ALL | GRUB_MM_CLASS_ALL)
+
+/* Heap grow granularity for region of small type. */
+#define GRUB_MM_GROW_SMALL 0x100000
+
 #define GRUB_MM_ADD_REGION_NONE        0
 #define GRUB_MM_ADD_REGION_CONSECUTIVE (1 << 0)
 
 /*
  * Function used to request memory regions of `grub_size_t` bytes. The second
- * parameter is a bitfield of `GRUB_MM_ADD_REGION` flags.
+ * parameter is a bitfield of `GRUB_MM_ADD_REGION` flags. The third parameter
+ * is a bitfield of `GRUB_MM_TYPE` flags.
  */
-typedef grub_err_t (*grub_mm_add_region_func_t) (grub_size_t, unsigned int);
+typedef grub_err_t (*grub_mm_add_region_func_t) (grub_size_t, unsigned int, 
unsigned int);
 
 /*
  * Set this function pointer to enable adding memory-regions at runtime in case
@@ -46,7 +62,7 @@ typedef grub_err_t (*grub_mm_add_region_func_t) (grub_size_t, 
unsigned int);
 extern grub_mm_add_region_func_t EXPORT_VAR(grub_mm_add_region_fn);
 #endif
 
-void grub_mm_init_region (void *addr, grub_size_t size);
+void grub_mm_init_region (void *addr, grub_size_t size, unsigned int types);
 void *EXPORT_FUNC(grub_calloc) (grub_size_t nmemb, grub_size_t size);
 void *EXPORT_FUNC(grub_malloc) (grub_size_t size);
 void *EXPORT_FUNC(grub_zalloc) (grub_size_t size);
@@ -54,6 +70,7 @@ void EXPORT_FUNC(grub_free) (void *ptr);
 void *EXPORT_FUNC(grub_realloc) (void *ptr, grub_size_t size);
 #ifndef GRUB_MACHINE_EMU
 void *EXPORT_FUNC(grub_memalign) (grub_size_t align, grub_size_t size);
+void *EXPORT_FUNC(grub_module_memalign) (grub_size_t align, grub_size_t size);
 #endif
 
 void grub_mm_check_real (const char *file, int line);
diff --git a/include/grub/mm_private.h b/include/grub/mm_private.h
index 96c2d816b..575c041d6 100644
--- a/include/grub/mm_private.h
+++ b/include/grub/mm_private.h
@@ -90,8 +90,11 @@ typedef struct grub_mm_region
   /* How many bytes are in this region? (free and allocated) */
   grub_size_t size;
 
+  /* Acceptable memory allocation types for this region. */
+  unsigned int types;
+
   /* pad to a multiple of cell size */
-  char padding[3 * GRUB_CPU_SIZEOF_VOID_P];
+  void *padding[2];
 }
 *grub_mm_region_t;
 
diff --git a/util/misc.c b/util/misc.c
index d545212d9..5315dcc35 100644
--- a/util/misc.c
+++ b/util/misc.c
@@ -207,7 +207,8 @@ grub_dl_unref (grub_dl_t mod)
 /* Some functions that we don't use.  */
 void
 grub_mm_init_region (void *addr __attribute__ ((unused)),
-                    grub_size_t size __attribute__ ((unused)))
+                    grub_size_t size __attribute__ ((unused)),
+                    unsigned int types __attribute__ ((unused)))
 {
 }
 
-- 
2.30.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]