[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 14/20] xen: init memory regions for PVH
From: |
Juergen Gross |
Subject: |
[PATCH v6 14/20] xen: init memory regions for PVH |
Date: |
Wed, 28 Nov 2018 14:55:24 +0100 |
Add all usable memory regions to grub memory management and add the
needed mmap iterate code, which will be used by grub core (e.g.
grub-core/lib/relocator.c or grub-core/mmap/mmap.c).
As we are running in 32-bit mode don't add memory above 4GB.
Signed-off-by: Juergen Gross <address@hidden>
Reviewed-by: Daniel Kiper <address@hidden>
---
V5: 0x100000000ULL -> 1ULL << 32 (Roger Pau Monné)
---
grub-core/kern/i386/xen/pvh.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/grub-core/kern/i386/xen/pvh.c b/grub-core/kern/i386/xen/pvh.c
index 472085ed1..91fbca859 100644
--- a/grub-core/kern/i386/xen/pvh.c
+++ b/grub-core/kern/i386/xen/pvh.c
@@ -241,6 +241,30 @@ grub_xen_set_mmap (void)
(grub_uint32_t) (&memmap), 0, 0, 0, 0);
}
+static void
+grub_xen_mm_init_regions (void)
+{
+ grub_uint64_t modend, from, to;
+ unsigned int i;
+
+ modend = grub_modules_get_end ();
+
+ for (i = 0; i < nr_map_entries; i++)
+ {
+ if (map[i].type != GRUB_MEMORY_AVAILABLE)
+ continue;
+ from = map[i].addr;
+ to = from + map[i].len;
+ if (from < modend)
+ from = modend;
+ if (from >= to || from >= (1ULL << 32))
+ continue;
+ if (to > (1ULL << 32))
+ to = 1ULL << 32;
+ grub_mm_init_region ((void *) (grub_addr_t) from, to - from);
+ }
+}
+
static grub_uint64_t
grub_xen_find_page (grub_uint64_t start)
{
@@ -325,10 +349,21 @@ grub_xen_setup_pvh (void)
(void *) par);
grub_xen_set_mmap ();
+ grub_xen_mm_init_regions ();
+
grub_rsdp_addr = pvh_start_info->rsdp_paddr;
}
grub_err_t
grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
{
+ unsigned int i;
+
+ for (i = 0; i < nr_map_entries; i++)
+ {
+ if (map[i].len && hook (map[i].addr, map[i].len, map[i].type, hook_data))
+ break;
+ }
+
+ return GRUB_ERR_NONE;
}
--
2.16.4
- [PATCH v6 19/20] xen_pvh: support grub-install for xen_pvh, (continued)
- [PATCH v6 19/20] xen_pvh: support grub-install for xen_pvh, Juergen Gross, 2018/11/28
- [PATCH v6 16/20] grub-module-verifier: Ignore all_video for xenpvh, Juergen Gross, 2018/11/28
- [PATCH v6 09/20] xen: add basic hooks for PVH in current code, Juergen Gross, 2018/11/28
- [PATCH v6 18/20] xen_pvh: support building a standalone image, Juergen Gross, 2018/11/28
- [PATCH v6 06/20] xen: rearrange xen/init.c to prepare it for Xen PVH mode, Juergen Gross, 2018/11/28
- [PATCH v6 17/20] xen: use elfnote defines instead of plain numbers, Juergen Gross, 2018/11/28
- [PATCH v6 20/20] xen_pvh: add support to configure, Juergen Gross, 2018/11/28
- [PATCH v6 01/20] xen: add some xen headers, Juergen Gross, 2018/11/28
- [PATCH v6 14/20] xen: init memory regions for PVH,
Juergen Gross <=
- [PATCH v6 15/20] xen_pvh: add build runes for grub-core, Juergen Gross, 2018/11/28
- Re: [PATCH v6 00/20] xen: add pvh guest support, Daniel Kiper, 2018/11/29