aboutsummaryrefslogtreecommitdiffstats
path: root/main/grub/0006-xen-Rearrange-xen-init.c-to-prepare-it-for-Xen-PVH-m.patch
diff options
context:
space:
mode:
Diffstat (limited to 'main/grub/0006-xen-Rearrange-xen-init.c-to-prepare-it-for-Xen-PVH-m.patch')
-rw-r--r--main/grub/0006-xen-Rearrange-xen-init.c-to-prepare-it-for-Xen-PVH-m.patch135
1 files changed, 135 insertions, 0 deletions
diff --git a/main/grub/0006-xen-Rearrange-xen-init.c-to-prepare-it-for-Xen-PVH-m.patch b/main/grub/0006-xen-Rearrange-xen-init.c-to-prepare-it-for-Xen-PVH-m.patch
new file mode 100644
index 0000000000..35673cc065
--- /dev/null
+++ b/main/grub/0006-xen-Rearrange-xen-init.c-to-prepare-it-for-Xen-PVH-m.patch
@@ -0,0 +1,135 @@
+From 56eb459603e458316d93cf5bdf16e4539dbb6a9d Mon Sep 17 00:00:00 2001
+From: Juergen Gross <jgross@suse.com>
+Date: Fri, 7 Dec 2018 13:11:34 +0100
+Subject: [PATCH 06/20] xen: Rearrange xen/init.c to prepare it for Xen PVH
+ mode
+
+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 <jgross@suse.com>
+Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
+Tested-by: Hans van Kranenburg <hans@knorrie.org>
+(cherry picked from commit bec9edf53f4d0b629a52a7d1145f38f88df8dd1d)
+---
+ 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.21.0
+