tools/libxl: Correctly align the ACPI tables
authorKevin Stefanov <kevin.stefanov@citrix.com>
Wed, 15 Sep 2021 14:30:00 +0000 (15:30 +0100)
committerIan Jackson <iwj@xenproject.org>
Fri, 24 Sep 2021 10:07:50 +0000 (11:07 +0100)
commitdd6c062a7a4abdb662c18af03d1396325969d155
treec56c0a95b92cf7a84fc3f5bf2b2f0901d9c2e3d5
parent728998f6f2b7e1420e771236efec65cbf6143b7b
tools/libxl: Correctly align the ACPI tables

The memory allocator currently calculates alignment in libxl's virtual
address space, rather than guest physical address space. This results
in the FACS being commonly misaligned.

Furthermore, the allocator has several other bugs.

The opencoded align-up calculation is currently susceptible to a bug
that occurs in the corner case that the buffer is already aligned to
begin with. In that case, an align-sized memory hole is introduced.

The while loop is dead logic because its effects are entirely and
unconditionally overwritten immediately after it.

Rework the memory allocator to align in guest physical address space
instead of libxl's virtual memory and improve the calculation, drop
errant extra page in allocated buffer for ACPI tables, and give some
of the variables better names/types.

Fixes: 14c0d328da2b ("libxl/acpi: Build ACPI tables for HVMlite guests")
Signed-off-by: Kevin Stefanov <kevin.stefanov@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Jackson <iwj@xenproject.org>
tools/libs/light/libxl_x86_acpi.c