Initialize the grant tab in a dedicated function. This will enable using it for PVH guests, too.
Call the new function from grub_machine_init() as this will later be common between Xen PV and Xen PVH mode. Signed-off-by: Juergen Gross <jgr...@suse.com> --- V2: update commit message (Daniel Kiper) --- grub-core/kern/xen/init.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/grub-core/kern/xen/init.c b/grub-core/kern/xen/init.c index 0559c033c..29f5bc23d 100644 --- a/grub-core/kern/xen/init.c +++ b/grub-core/kern/xen/init.c @@ -318,6 +318,25 @@ grub_xenstore_dir (const char *dir, unsigned long gntframe = 0; +static void +grub_xen_setup_gnttab (void) +{ + struct gnttab_set_version gnttab_setver; + struct gnttab_setup_table gnttab_setup; + + grub_memset (&gnttab_setver, 0, sizeof (gnttab_setver)); + + gnttab_setver.version = 1; + grub_xen_grant_table_op (GNTTABOP_set_version, &gnttab_setver, 1); + + grub_memset (&gnttab_setup, 0, sizeof (gnttab_setup)); + gnttab_setup.dom = DOMID_SELF; + gnttab_setup.nr_frames = 1; + gnttab_setup.frame_list.p = &gntframe; + + grub_xen_grant_table_op (GNTTABOP_setup_table, &gnttab_setup, 1); +} + #define MAX_N_UNUSABLE_PAGES 4 static int @@ -357,26 +376,12 @@ map_all_pages (void) (grub_xen_mfn_t *) grub_xen_start_page_addr->mfn_list; grub_uint64_t *pg = (grub_uint64_t *) window; grub_uint64_t oldpgstart, oldpgend; - struct gnttab_setup_table gnttab_setup; - struct gnttab_set_version gnttab_setver; grub_size_t n_unusable_pages = 0; struct mmu_update m2p_updates[2 * MAX_N_UNUSABLE_PAGES]; if (total_pages > MAX_TOTAL_PAGES - 4) total_pages = MAX_TOTAL_PAGES - 4; - grub_memset (&gnttab_setver, 0, sizeof (gnttab_setver)); - - gnttab_setver.version = 1; - grub_xen_grant_table_op (GNTTABOP_set_version, &gnttab_setver, 1); - - grub_memset (&gnttab_setup, 0, sizeof (gnttab_setup)); - gnttab_setup.dom = DOMID_SELF; - gnttab_setup.nr_frames = 1; - gnttab_setup.frame_list.p = &gntframe; - - grub_xen_grant_table_op (GNTTABOP_setup_table, &gnttab_setup, 1); - for (j = 0; j < total_pages - n_unusable_pages; j++) while (!grub_xen_is_page_usable (mfn_list[j])) { @@ -537,6 +542,8 @@ grub_machine_init (void) + GRUB_KERNEL_MACHINE_MOD_GAP, GRUB_KERNEL_MACHINE_MOD_ALIGN); + grub_xen_setup_gnttab (); + map_all_pages (); grub_console_init (); -- 2.16.4 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel