From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org,
Andrew Cooper <andrew.cooper3@citrix.com>,
Jan Beulich <JBeulich@suse.com>
Cc: Wei Liu <wei.liu2@citrix.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v2 for-4.8 1/2] libxc: properly account for the page offset when copying ACPI data
Date: Mon, 7 Nov 2016 16:32:00 +0100 [thread overview]
Message-ID: <1478532721-20160-2-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <1478532721-20160-1-git-send-email-roger.pau@citrix.com>
Or else ACPI data is always copied at the start of the page pointed by
guest_addr_out, ignoring the page offset.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
Changes since v1:
- Also fix the calculation of the required number of pages so that the
offset is taken into account.
---
tools/libxc/xc_dom_core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c
index e177667..ad819dd 100644
--- a/tools/libxc/xc_dom_core.c
+++ b/tools/libxc/xc_dom_core.c
@@ -1090,8 +1090,9 @@ static int xc_dom_load_acpi(struct xc_dom_image *dom)
dom->acpi_modules[i].length,
dom->acpi_modules[i].guest_addr_out);
- num_pages = (dom->acpi_modules[i].length + (XC_PAGE_SIZE - 1)) >>
- XC_PAGE_SHIFT;
+ num_pages = (dom->acpi_modules[i].length +
+ (dom->acpi_modules[i].guest_addr_out & ~XC_PAGE_MASK) +
+ (XC_PAGE_SIZE - 1)) >> XC_PAGE_SHIFT;
extents = malloc(num_pages * sizeof(*extents));
if ( !extents )
{
@@ -1118,6 +1119,9 @@ static int xc_dom_load_acpi(struct xc_dom_image *dom)
goto err;
}
+ ptr = (uint8_t *)ptr +
+ (dom->acpi_modules[i].guest_addr_out & ~XC_PAGE_MASK);
+
memcpy(ptr, dom->acpi_modules[i].data, dom->acpi_modules[i].length);
munmap(ptr, XC_PAGE_SIZE * num_pages);
--
2.7.4 (Apple Git-66)
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-11-07 15:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-07 15:31 [PATCH v2 for-4.8 0/2] Minor ACPI fixes for PVHv2 DomU Roger Pau Monne
2016-11-07 15:32 ` Roger Pau Monne [this message]
2016-11-07 15:43 ` [PATCH v2 for-4.8 1/2] libxc: properly account for the page offset when copying ACPI data Boris Ostrovsky
2016-11-07 15:59 ` Andrew Cooper
2016-11-07 15:32 ` [PATCH v2 for-4.8 2/2] libxc: set rsdp pointer for PVHv2 guests Roger Pau Monne
2016-11-07 15:46 ` Boris Ostrovsky
2016-11-07 15:59 ` Andrew Cooper
2016-11-08 1:59 ` [PATCH v2 for-4.8 0/2] Minor ACPI fixes for PVHv2 DomU Wei Liu
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=1478532721-20160-2-git-send-email-roger.pau@citrix.com \
--to=roger.pau@citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=ian.jackson@eu.citrix.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 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).