diff options
author | Vit Kabele <vit@kabele.me> | 2022-02-11 14:08:22 +0200 |
---|---|---|
committer | Vit Kabele <vit@kabele.me> | 2022-05-03 14:37:08 +0200 |
commit | a36eda9631e84f271319c41288889dd5b1329369 (patch) | |
tree | 984f052474e5bb2b2a6c503e7d8d18b4c19ce7cb | |
parent | cc9e7763ceb2e2649fe3422130416d84a3c6854a (diff) | |
download | acpica-a36eda9631e84f271319c41288889dd5b1329369.tar.gz |
Do not touch VGA memory when EBDA < 1KiB
The ACPICA code assumes that EBDA region must be at least 1KiB in size.
Because this is not guaranteed, it might happen that while scanning the
memory for RSDP pointer, the kernel touches memory above 640KiB.
This is unwanted as the VGA memory range may not be decoded or
even present when running under virtualization.
Signed-off-by: Vit Kabele <vit@kabele.me>
-rw-r--r-- | source/components/tables/tbxfroot.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/source/components/tables/tbxfroot.c b/source/components/tables/tbxfroot.c index 271c9424d..aebadac5b 100644 --- a/source/components/tables/tbxfroot.c +++ b/source/components/tables/tbxfroot.c @@ -271,6 +271,7 @@ AcpiFindRootPointer ( UINT8 *TablePtr; UINT8 *MemRover; UINT32 PhysicalAddress; + UINT32 EbdaWindowSize; ACPI_FUNCTION_TRACE (AcpiFindRootPointer); @@ -307,24 +308,32 @@ AcpiFindRootPointer ( PhysicalAddress < 0xA0000) { /* - * 1b) Search EBDA paragraphs (EBDA is required to be a - * minimum of 1K length) + * Calculate the scan window size + * The EBDA is not guaranteed to be larger than a KiB and in case + * that it is smaller, the scanning function would leave the low + * memory and continue to the VGA range. + */ + EbdaWindowSize = ACPI_MIN(ACPI_EBDA_WINDOW_SIZE, + 0xA0000 - PhysicalAddress); + + /* + * 1b) Search EBDA paragraphs */ TablePtr = AcpiOsMapMemory ( (ACPI_PHYSICAL_ADDRESS) PhysicalAddress, - ACPI_EBDA_WINDOW_SIZE); + EbdaWindowSize); if (!TablePtr) { ACPI_ERROR ((AE_INFO, "Could not map memory at 0x%8.8X for length %u", - PhysicalAddress, ACPI_EBDA_WINDOW_SIZE)); + PhysicalAddress, EbdaWindowSize)); return_ACPI_STATUS (AE_NO_MEMORY); } MemRover = AcpiTbScanMemoryForRsdp ( - TablePtr, ACPI_EBDA_WINDOW_SIZE); - AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_WINDOW_SIZE); + TablePtr, EbdaWindowSize); + AcpiOsUnmapMemory (TablePtr, EbdaWindowSize); if (MemRover) { |