mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
libxc: properly account for the page offset when copying ACPI data
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> Reviewed-and-Tested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Wei Liu <wei.liu2@citrix.com> Release-acked-by: Wei Liu <wei.liu2@citrix.com>
This commit is contained in:
1 parent
712db0f301
commit
fac7f77b69
1 file changed
+6
-2
@@ -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);
|
||||
|
||||
|
||||