[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 06/18] xen: rearrange xen/init.c to prepare it for Xen PVH mod
From: |
Juergen Gross |
Subject: |
[PATCH v3 06/18] xen: rearrange xen/init.c to prepare it for Xen PVH mode |
Date: |
Wed, 24 Oct 2018 16:54:15 +0200 |
Rearrange grub-core/kern/xen/init.c to prepare adding PVH mode support
to it. This includes putting some code under #ifdef GRUB_MACHINE_XEN
as it will not be used when running as PVH.
Signed-off-by: Juergen Gross <address@hidden>
Reviewed-by: Daniel Kiper <address@hidden>
---
grub-core/kern/xen/init.c | 60 +++++++++++++++++++++++++++--------------------
1 file changed, 34 insertions(+), 26 deletions(-)
diff --git a/grub-core/kern/xen/init.c b/grub-core/kern/xen/init.c
index 29f5bc23d..10007b411 100644
--- a/grub-core/kern/xen/init.c
+++ b/grub-core/kern/xen/init.c
@@ -41,9 +41,11 @@ grub_size_t grub_xen_n_allocated_shared_pages;
static grub_xen_mfn_t
grub_xen_ptr2mfn (void *ptr)
{
+#ifdef GRUB_MACHINE_XEN
grub_xen_mfn_t *mfn_list =
(grub_xen_mfn_t *) grub_xen_start_page_addr->mfn_list;
return mfn_list[(grub_addr_t) ptr >> GRUB_XEN_LOG_PAGE_SIZE];
+#endif
}
void *
@@ -104,18 +106,6 @@ grub_machine_get_bootlocation (char **device __attribute__
((unused)),
{
}
-static grub_uint8_t window[GRUB_XEN_PAGE_SIZE]
- __attribute__ ((aligned (GRUB_XEN_PAGE_SIZE)));
-
-#ifdef __x86_64__
-#define NUMBER_OF_LEVELS 4
-#else
-#define NUMBER_OF_LEVELS 3
-#endif
-
-#define LOG_POINTERS_PER_PAGE 9
-#define POINTERS_PER_PAGE (1 << LOG_POINTERS_PER_PAGE)
-
void
grub_xen_store_send (const void *buf_, grub_size_t len)
{
@@ -337,6 +327,19 @@ grub_xen_setup_gnttab (void)
grub_xen_grant_table_op (GNTTABOP_setup_table, &gnttab_setup, 1);
}
+#ifdef GRUB_MACHINE_XEN
+static grub_uint8_t window[GRUB_XEN_PAGE_SIZE]
+ __attribute__ ((aligned (GRUB_XEN_PAGE_SIZE)));
+
+#ifdef __x86_64__
+#define NUMBER_OF_LEVELS 4
+#else
+#define NUMBER_OF_LEVELS 3
+#endif
+
+#define LOG_POINTERS_PER_PAGE 9
+#define POINTERS_PER_PAGE (1 << LOG_POINTERS_PER_PAGE)
+
#define MAX_N_UNUSABLE_PAGES 4
static int
@@ -529,13 +532,30 @@ map_all_pages (void)
grub_mm_init_region ((void *) heap_start, heap_end - heap_start);
}
+grub_err_t
+grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
+{
+ grub_uint64_t total_pages = grub_xen_start_page_addr->nr_pages;
+ grub_uint64_t usable_pages = grub_xen_start_page_addr->pt_base >> 12;
+ if (hook (0, page2offset (usable_pages), GRUB_MEMORY_AVAILABLE, hook_data))
+ return GRUB_ERR_NONE;
+
+ hook (page2offset (usable_pages), page2offset (total_pages - usable_pages),
+ GRUB_MEMORY_RESERVED, hook_data);
+
+ return GRUB_ERR_NONE;
+}
+#endif
+
extern char _end[];
void
grub_machine_init (void)
{
+#ifdef GRUB_MACHINE_XEN
#ifdef __i386__
grub_xen_vm_assist (VMASST_CMD_enable, VMASST_TYPE_pae_extended_cr3);
+#endif
#endif
grub_modbase = ALIGN_UP ((grub_addr_t) _end
@@ -544,7 +564,9 @@ grub_machine_init (void)
grub_xen_setup_gnttab ();
+#ifdef GRUB_MACHINE_XEN
map_all_pages ();
+#endif
grub_console_init ();
@@ -571,17 +593,3 @@ grub_machine_fini (int flags __attribute__ ((unused)))
grub_xendisk_fini ();
grub_boot_fini ();
}
-
-grub_err_t
-grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
-{
- grub_uint64_t total_pages = grub_xen_start_page_addr->nr_pages;
- grub_uint64_t usable_pages = grub_xen_start_page_addr->pt_base >> 12;
- if (hook (0, page2offset (usable_pages), GRUB_MEMORY_AVAILABLE, hook_data))
- return GRUB_ERR_NONE;
-
- hook (page2offset (usable_pages), page2offset (total_pages - usable_pages),
- GRUB_MEMORY_RESERVED, hook_data);
-
- return GRUB_ERR_NONE;
-}
--
2.16.4
- [PATCH v3 00/18] xen: add pvh guest support, Juergen Gross, 2018/10/24
- [PATCH v3 05/18] xen: add some dummy headers for PVH mode, Juergen Gross, 2018/10/24
- [PATCH v3 04/18] xen: prepare common code for Xen PVH support, Juergen Gross, 2018/10/24
- [PATCH v3 03/18] xen: carve out grant tab initialization into dedicated function, Juergen Gross, 2018/10/24
- [PATCH v3 07/18] xen: add PVH specific defines to offset.h, Juergen Gross, 2018/10/24
- [PATCH v3 10/18] xen: setup hypercall page for PVH, Juergen Gross, 2018/10/24
- [PATCH v3 06/18] xen: rearrange xen/init.c to prepare it for Xen PVH mode,
Juergen Gross <=
- [PATCH v3 08/18] xen: add basic hooks for PVH in current code, Juergen Gross, 2018/10/24
- [PATCH v3 02/18] loader/linux: support passing rsdp address via boot params, Juergen Gross, 2018/10/24
- [PATCH v3 15/18] grub-module-verifier: Ignore all_video for xenpvh, Juergen Gross, 2018/10/24
- [PATCH v3 11/18] xen: get memory map from hypervisor for PVH, Juergen Gross, 2018/10/24
- [PATCH v3 17/18] xen_pvh: support grub-install for xen_pvh, Juergen Gross, 2018/10/24
- [PATCH v3 14/18] xen_pvh: add build runes for grub-core, Juergen Gross, 2018/10/24
- [PATCH v3 13/18] xen: init memory regions for PVH, Juergen Gross, 2018/10/24
- [PATCH v3 18/18] xen_pvh: add support to configure, Juergen Gross, 2018/10/24
- [PATCH v3 09/18] xen: add PVH boot entry code, Juergen Gross, 2018/10/24
- [PATCH v3 12/18] xen: setup Xen specific data for PVH, Juergen Gross, 2018/10/24