@@ -54,6 +54,8 @@ static grub_uint64_t modules_target_start;
static grub_size_t n_modules;
static struct grub_relocator_xen_state state;
static grub_xen_mfn_t *virt_mfn_list;
+static struct start_info *virt_start_info;
+static grub_xen_mfn_t console_pfn;
#define PAGE_SIZE 4096
#define MAX_MODULES (PAGE_SIZE / sizeof (struct xen_multiboot_mod_list))
@@ -232,43 +234,51 @@ grub_xen_p2m_alloc (void)
}
static grub_err_t
-grub_xen_boot (void)
+grub_xen_special_alloc (void)
{
grub_relocator_chunk_t ch;
grub_err_t err;
- struct start_info *nst;
- grub_uint64_t nr_info_pages;
- grub_uint64_t nr_pages, nr_pt_pages, nr_need_pages;
- struct gnttab_set_version gnttab_setver;
- grub_size_t i;
-
- if (grub_xen_n_allocated_shared_pages)
- return grub_error (GRUB_ERR_BUG, "active grants");
-
- err = grub_xen_p2m_alloc ();
- if (err)
- return err;
err = grub_relocator_alloc_chunk_addr (relocator, &ch,
max_addr, sizeof (next_start));
if (err)
return err;
state.start_info = max_addr + xen_inf.virt_base;
- nst = get_virtual_current_address (ch);
+ virt_start_info = get_virtual_current_address (ch);
max_addr = ALIGN_UP (max_addr + sizeof (next_start), PAGE_SIZE);
+ console_pfn = max_addr >> PAGE_SHIFT;
+ max_addr += 2 * PAGE_SIZE;
next_start.nr_pages = grub_xen_start_page_addr->nr_pages;
grub_memcpy (next_start.magic, grub_xen_start_page_addr->magic,
sizeof (next_start.magic));
+ next_start.shared_info = grub_xen_start_page_addr->shared_info;
next_start.store_mfn = grub_xen_start_page_addr->store_mfn;
next_start.store_evtchn = grub_xen_start_page_addr->store_evtchn;
next_start.console.domU = grub_xen_start_page_addr->console.domU;
- next_start.shared_info = grub_xen_start_page_addr->shared_info;
- err = set_mfns (max_addr >> PAGE_SHIFT);
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_xen_boot (void)
+{
+ grub_relocator_chunk_t ch;
+ grub_err_t err;
+ grub_uint64_t nr_info_pages;
+ grub_uint64_t nr_pages, nr_pt_pages, nr_need_pages;
+ struct gnttab_set_version gnttab_setver;
+ grub_size_t i;
+
+ if (grub_xen_n_allocated_shared_pages)
+ return grub_error (GRUB_ERR_BUG, "active grants");
+
+ err = grub_xen_p2m_alloc ();
+ if (err)
+ return err;
+ err = grub_xen_special_alloc ();
if (err)
return err;
- max_addr += 2 * PAGE_SIZE;
next_start.pt_base = max_addr + xen_inf.virt_base;
state.paging_start = max_addr >> PAGE_SHIFT;
@@ -297,6 +307,10 @@ grub_xen_boot (void)
if (err)
return err;
+ err = set_mfns (console_pfn);
+ if (err)
+ return err;
+
generate_page_table (get_virtual_current_address (ch),
max_addr >> PAGE_SHIFT, nr_pages,
xen_inf.virt_base, virt_mfn_list);
@@ -308,7 +322,7 @@ grub_xen_boot (void)
next_start.nr_pt_frames = nr_pt_pages;
state.paging_size = nr_pt_pages;
- *nst = next_start;
+ *virt_start_info = next_start;
grub_memset (&gnttab_setver, 0, sizeof (gnttab_setver));
Do the allocation of special pages (start info, console and xenbus ring buffers) in a separate function. This will allow to do the allocation at different times of the boot preparations depending on the features the kernel is supporting. Signed-off-by: Juergen Gross <jgross@suse.com> --- grub-core/loader/i386/xen.c | 50 +++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 18 deletions(-)