aboutsummaryrefslogtreecommitdiffstats
path: root/main/grub/0003-xen-Carve-out-grant-tab-initialization-into-dedicate.patch
blob: daaae83c8a8bb6ff2f5cd8b8035e12b2f774ba04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
From 7c45df9ded4ca3201cf468de899bad28e4ac8c55 Mon Sep 17 00:00:00 2001
From: Juergen Gross <jgross@suse.com>
Date: Fri, 7 Dec 2018 13:11:31 +0100
Subject: [PATCH 03/20] xen: Carve out grant tab initialization into dedicated
 function

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 <jgross@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Tested-by: Hans van Kranenburg <hans@knorrie.org>
(cherry picked from commit c84927272cea59084ad5b0705c55547e8c85b28d)
---
 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.21.0