From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgross@suse.com>,
wei.liu2@citrix.com, julien.grall@arm.com,
ian.jackson@eu.citrix.com
Subject: [PATCH for-4.10] libxc: load acpi RSDP table at correct address
Date: Mon, 20 Nov 2017 09:34:27 +0100 [thread overview]
Message-ID: <20171120083427.3434-1-jgross@suse.com> (raw)
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
next reply other threads:[~2017-11-20 8:34 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-20 8:34 Juergen Gross [this message]
[not found] ` <CAPLaKK5OH3Fj=9EgVZ19=8kiRuHwftWnYduoV7+rkFU_bkWBgQ@mail.gmail.com>
2017-11-20 9:51 ` [PATCH for-4.10] libxc: load acpi RSDP table at correct address 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171120083427.3434-1-jgross@suse.com \
--to=jgross@suse.com \
--cc=ian.jackson@eu.citrix.com \
--cc=julien.grall@arm.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.