Skip to content
Snippets Groups Projects
Commit f102fe0a authored by Nadav Har'El's avatar Nadav Har'El Committed by Avi Kivity
Browse files

acpi: Fix early-ACPI partial linear map


When running on a KVM host without EPT, OSv used to crash if ran 1GB
or less memory. The crash was in early acpi initialization, which called
AcpiOsMapMemory, which called linear_map() on the small chunk of physical
memory requested by ACPI.

It turns out that the chunk requested was just 4096 bytes, which caused
our linear_map() implementation to break down a huge-page into small-pages.
This didn't work - I'm don't know yet what exactly is the bug or why it
only shows up when the host doesn't use EPT, or if the memory is smaller
than 1GB...

But in any case, since we know our complete linear map always uses huge
pages, I think it makes no sense to map a single small page, and we can
just map a whole huge page. This will cause linear_map() not to try to
break up any huge pages, and this bug goes away.

Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
parent 9045f06d
No related branches found
No related tags found
No related merge requests found
...@@ -163,8 +163,8 @@ void AcpiOsFree(void *Memory) ...@@ -163,8 +163,8 @@ void AcpiOsFree(void *Memory)
void *AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS Where, ACPI_SIZE Length) void *AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS Where, ACPI_SIZE Length)
{ {
uint64_t _where = align_down(Where, mmu::page_size); uint64_t _where = align_down(Where, mmu::huge_page_size);
size_t map_size = align_up(Length + Where - _where, mmu::page_size); size_t map_size = align_up(Length + Where - _where, mmu::huge_page_size);
mmu::linear_map(mmu::phys_to_virt(_where), _where, map_size); mmu::linear_map(mmu::phys_to_virt(_where), _where, map_size);
return mmu::phys_to_virt(Where); return mmu::phys_to_virt(Where);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment