Skip to content

Commit 8ff2906

Browse files
vitkabelerafaeljw
authored andcommitted
ACPICA: Do not touch VGA memory when EBDA < 1ki_b
ACPICA commit a36eda9631e84f271319c41288889dd5b1329369 The ACPICA code assumes that EBDA region must be at least 1ki_b in size. Because this is not guaranteed, it might happen that while scanning the memory for RSDP pointer, the kernel touches memory above 640ki_b. This is unwanted as the VGA memory range may not be decoded or even present when running under virtualization. Link: acpica/acpica@a36eda96 Signed-off-by: Vit Kabele <[email protected]> Signed-off-by: Bob Moore <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 4fe54f5 commit 8ff2906

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

drivers/acpi/acpica/tbxfroot.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ acpi_find_root_pointer(acpi_physical_address *table_address)
114114
u8 *table_ptr;
115115
u8 *mem_rover;
116116
u32 physical_address;
117+
u32 ebda_window_size;
117118

118119
ACPI_FUNCTION_TRACE(acpi_find_root_pointer);
119120

@@ -145,24 +146,31 @@ acpi_find_root_pointer(acpi_physical_address *table_address)
145146
*/
146147
if (physical_address > 0x400 && physical_address < 0xA0000) {
147148
/*
148-
* 1b) Search EBDA paragraphs (EBDA is required to be a
149-
* minimum of 1K length)
149+
* Calculate the scan window size
150+
* The EBDA is not guaranteed to be larger than a ki_b and in case
151+
* that it is smaller, the scanning function would leave the low
152+
* memory and continue to the VGA range.
153+
*/
154+
ebda_window_size = ACPI_MIN(ACPI_EBDA_WINDOW_SIZE,
155+
0xA0000 - physical_address);
156+
157+
/*
158+
* 1b) Search EBDA paragraphs
150159
*/
151160
table_ptr = acpi_os_map_memory((acpi_physical_address)
152161
physical_address,
153-
ACPI_EBDA_WINDOW_SIZE);
162+
ebda_window_size);
154163
if (!table_ptr) {
155164
ACPI_ERROR((AE_INFO,
156165
"Could not map memory at 0x%8.8X for length %u",
157-
physical_address, ACPI_EBDA_WINDOW_SIZE));
166+
physical_address, ebda_window_size));
158167

159168
return_ACPI_STATUS(AE_NO_MEMORY);
160169
}
161170

162171
mem_rover =
163-
acpi_tb_scan_memory_for_rsdp(table_ptr,
164-
ACPI_EBDA_WINDOW_SIZE);
165-
acpi_os_unmap_memory(table_ptr, ACPI_EBDA_WINDOW_SIZE);
172+
acpi_tb_scan_memory_for_rsdp(table_ptr, ebda_window_size);
173+
acpi_os_unmap_memory(table_ptr, ebda_window_size);
166174

167175
if (mem_rover) {
168176

0 commit comments

Comments
 (0)