xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-4.10] libxc: load acpi RSDP table at correct address
@ 2017-11-20  8:34 Juergen Gross
       [not found] ` <CAPLaKK5OH3Fj=9EgVZ19=8kiRuHwftWnYduoV7+rkFU_bkWBgQ@mail.gmail.com>
  0 siblings, 1 reply; 37+ messages in thread
From: Juergen Gross @ 2017-11-20  8:34 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, wei.liu2, julien.grall, ian.jackson

For PVH domains loading of the ACPI RSDP table is done via allocating
a domain loader segment after having loaded the kernel. This leads to
the RSDP table being loaded at an arbitrary guest address instead of
the architectural correct address just below 1MB.

When using the Linux kernel this is currently no problem as the
bzImage loader is being used, which is loading ACPI tables via an
alternative method.

Using grub2 however exposes this problem leading to the selected
kernel no longer being able to find the RSDP table.

To solve this issue allow to load the RSDP table below the already
loaded kernel if this space hasn't been used before.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
Not sure if this is acceptable for 4.10, but I think PVH guest support
should include the possibility to use grub2 as a boot loader.

So please consider this patch for 4.10.
---
 tools/libxc/xc_dom_hvmloader.c | 39 +++++++++++++++++++++++++++++++--------
 1 file changed, 31 insertions(+), 8 deletions(-)

diff --git a/tools/libxc/xc_dom_hvmloader.c b/tools/libxc/xc_dom_hvmloader.c
index 59f94e51e5..2284c7f9df 100644
--- a/tools/libxc/xc_dom_hvmloader.c
+++ b/tools/libxc/xc_dom_hvmloader.c
@@ -135,20 +135,43 @@ static int module_init_one(struct xc_dom_image *dom,
 {
     struct xc_dom_seg seg;
     void *dest;
+    xen_pfn_t start, end;
+    unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
 
     if ( module->length )
     {
-        if ( xc_dom_alloc_segment(dom, &seg, name, 0, module->length) )
-            goto err;
-        dest = xc_dom_seg_to_ptr(dom, &seg);
-        if ( dest == NULL )
+        /*
+         * Check for module located below kernel.
+         * Make sure not to be fooled by a kernel based on virtual address.
+         */
+        if ( module->guest_addr_out && !(dom->kernel_seg.vstart >> 32) &&
+             module->guest_addr_out + module->length <= dom->kernel_seg.vstart )
         {
-            DOMPRINTF("%s: xc_dom_seg_to_ptr(dom, &seg) => NULL",
-                      __FUNCTION__);
-            goto err;
+            start = module->guest_addr_out / page_size;
+            end = (module->guest_addr_out + module->length + page_size - 1) /
+                  page_size;
+            dest = xc_dom_pfn_to_ptr(dom, start, end - start);
+            if ( dest == NULL )
+            {
+                DOMPRINTF("%s: xc_dom_pfn_to_ptr() => NULL", __FUNCTION__);
+                goto err;
+            }
+            dest += module->guest_addr_out - start * page_size;
+        }
+        else
+        {
+            if ( xc_dom_alloc_segment(dom, &seg, name, 0, module->length) )
+                goto err;
+            dest = xc_dom_seg_to_ptr(dom, &seg);
+            if ( dest == NULL )
+            {
+                DOMPRINTF("%s: xc_dom_seg_to_ptr(dom, &seg) => NULL",
+                          __FUNCTION__);
+                goto err;
+            }
+            module->guest_addr_out = seg.vstart;
         }
         memcpy(dest, module->data, module->length);
-        module->guest_addr_out = seg.vstart;
 
         assert(dom->mmio_start > 0 && dom->mmio_start < UINT32_MAX);
         if ( module->guest_addr_out > dom->mmio_start ||
-- 
2.12.3


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2017-11-22 10:26 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-20  8:34 [PATCH for-4.10] libxc: load acpi RSDP table at correct address Juergen Gross
     [not found] ` <CAPLaKK5OH3Fj=9EgVZ19=8kiRuHwftWnYduoV7+rkFU_bkWBgQ@mail.gmail.com>
2017-11-20  9:51   ` Roger Pau Monné
2017-11-20  9:55     ` Juergen Gross
2017-11-20  9:58       ` Andrew Cooper
2017-11-20 10:04         ` Juergen Gross
2017-11-20 10:21           ` Andrew Cooper
2017-11-20 10:43             ` Juergen Gross
2017-11-20 10:57               ` Andrew Cooper
2017-11-20 11:20                 ` Juergen Gross
2017-11-20 11:50                   ` Jan Beulich
2017-11-20 13:56                     ` Boris Ostrovsky
2017-11-20 14:11                       ` Jan Beulich
2017-11-20 14:14                       ` Juergen Gross
2017-11-20 14:20                         ` Jan Beulich
2017-11-20 14:25                         ` Boris Ostrovsky
2017-11-20 14:36                           ` Andrew Cooper
2017-11-20 14:52                             ` Boris Ostrovsky
2017-11-20 15:27                           ` Juergen Gross
2017-11-20 16:14                             ` Boris Ostrovsky
2017-11-20 16:26                               ` Jan Beulich
2017-11-20 16:28                                 ` Boris Ostrovsky
2017-11-20 16:43                                   ` Jan Beulich
2017-11-20 16:59                                     ` Boris Ostrovsky
2017-11-21  7:44                                       ` Jan Beulich
2017-11-21 10:42                                         ` Andrew Cooper
2017-11-21 11:13                                           ` Juergen Gross
2017-11-22 10:26                                             ` Roger Pau Monné
2017-11-20 18:29                               ` Juergen Gross
     [not found]                         ` <5A12F2BA02000078001901F3@suse.com>
2017-11-20 15:24                           ` Juergen Gross
2017-11-20 16:14                             ` Jan Beulich
     [not found]                             ` <5A130D68020000780019032E@suse.com>
2017-11-20 18:28                               ` Juergen Gross
2017-11-21  7:50                                 ` Jan Beulich
     [not found]                                 ` <5A13E8DB0200007800190512@suse.com>
2017-11-21  8:13                                   ` Juergen Gross
2017-11-21  8:46                                     ` Jan Beulich
     [not found]                                     ` <5A13F5DD02000078001905AC@suse.com>
2017-11-21  9:37                                       ` Juergen Gross
2017-11-21 10:44                                         ` Andrew Cooper
2017-11-20 13:51                   ` Boris Ostrovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).