Skip to contentSkip to conversation

x86/acpi: fix unmapping of low 1MB memory in acpi_os_unmap_memory

PATCH In review Roger Pau Monne 2 participants 2 messages Feb 9, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/acpi: fix unmapping of low 1MB memory in acpi_os_unmap_memory

Current code in acpi_os_map_memory uses the direct map in order to map memory in the low 1MB, but acpi_os_unmap_memory doesn't takes that into account, and always tries to perform a vunmap, which results in the following WARN:

(XEN) Xen WARN at vmap.c:185
(XEN) ----[ Xen-4.9-unstable x86_64 debug=y Tainted: C ]----
(XEN) CPU: 0
(XEN) RIP: e008:[<ffff82d0801369d7>] vmap.c#vm_free+0xd7/0xe0
[...]
(XEN) Xen call trace:

(XEN)    [<ffff82d0801369d7>] vmap.c#vm_free+0xd7/0xe0
(XEN)    [<ffff82d0802bdeda>] acpi_find_root_pointer+0x3a/0x170
(XEN)    [<ffff82d0802bd0ee>] acpi_os_get_root_pointer+0x4e/0x60
(XEN)    [<ffff82d0802d74d0>] domain_build.c#pvh_setup_acpi_xsdt+0x90/0x240
(XEN)    [<ffff82d0802d5d1a>] domain_build.c#pvh_setup_acpi+0x18a/0x2e0
(XEN)    [<ffff82d0802d3ad2>] domain_build.c#construct_dom0_pvh+0xd2/0x120
(XEN)    [<ffff82d0802c9174>] __start_xen+0x1d14/0x2420
(XEN)    [<ffff82d080100073>] __high_start+0x53/0x60

Fix this by checking if the virtual address passed to acpi_os_unmap_memory belongs to the direct map.

---
Cc: Jan Beulich <[email protected]>

---
 xen/drivers/acpi/osl.c | 7 +++++++
 1 file changed, 7 insertions(+)
xen/drivers/acpi/osl.c +7 -0
index 7199047..930e2d9 100644
@@ -104,6 +104,13 @@ acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
 
 void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
 {
+	if (IS_ENABLED(CONFIG_X86) &&
+	    (unsigned long)virt >= DIRECTMAP_VIRT_START &&
+	    (unsigned long)virt < DIRECTMAP_VIRT_END) {
+		ASSERT(!((__pa(virt) + size - 1) >> 20));
+		return;
+	}
+
 	if (system_state >= SYS_STATE_boot)
 		vunmap((void *)((unsigned long)virt & PAGE_MASK));
 }
Signature · 7 lines
2.10.1 (Apple Git-78)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 09.02.17 at 11:37, <[email protected]> wrote:

Current code in acpi_os_map_memory uses the direct map in order to map memory in the low 1MB, but acpi_os_unmap_memory doesn't takes that into account, and
always tries to perform a vunmap, which results in the following WARN:

(XEN) Xen WARN at vmap.c:185
(XEN) ----[ Xen-4.9-unstable x86_64 debug=y Tainted: C ]----
(XEN) CPU: 0
(XEN) RIP: e008:[<ffff82d0801369d7>] vmap.c#vm_free+0xd7/0xe0
[...]
(XEN) Xen call trace:

(XEN)    [<ffff82d0801369d7>] vmap.c#vm_free+0xd7/0xe0
(XEN)    [<ffff82d0802bdeda>] acpi_find_root_pointer+0x3a/0x170
(XEN)    [<ffff82d0802bd0ee>] acpi_os_get_root_pointer+0x4e/0x60
(XEN)    [<ffff82d0802d74d0>] domain_build.c#pvh_setup_acpi_xsdt+0x90/0x240
(XEN)    [<ffff82d0802d5d1a>] domain_build.c#pvh_setup_acpi+0x18a/0x2e0
(XEN)    [<ffff82d0802d3ad2>] domain_build.c#construct_dom0_pvh+0xd2/0x120
(XEN)    [<ffff82d0802c9174>] __start_xen+0x1d14/0x2420
(XEN)    [<ffff82d080100073>] __high_start+0x53/0x60
Quoted 4 lines

Fix this by checking if the virtual address passed to acpi_os_unmap_memory belongs to the direct map.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel