Re: [Xen-devel] [PATCH] x86/acpi: fix unmapping of low 1MB memory in acpi_os_unmap_memory

2017-02-09 Thread Jan Beulich
>>> On 09.02.17 at 11:37,  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:[] vmap.c#vm_free+0xd7/0xe0
> [...]
> (XEN) Xen call trace:
> (XEN)[] vmap.c#vm_free+0xd7/0xe0
> (XEN)[] acpi_find_root_pointer+0x3a/0x170
> (XEN)[] acpi_os_get_root_pointer+0x4e/0x60
> (XEN)[] domain_build.c#pvh_setup_acpi_xsdt+0x90/0x240
> (XEN)[] domain_build.c#pvh_setup_acpi+0x18a/0x2e0
> (XEN)[] domain_build.c#construct_dom0_pvh+0xd2/0x120
> (XEN)[] __start_xen+0x1d14/0x2420
> (XEN)[] __high_start+0x53/0x60
> 
> Fix this by checking if the virtual address passed to acpi_os_unmap_memory
> belongs to the direct map.
> 
> Signed-off-by: Roger Pau Monné 

Reviewed-by: Jan Beulich 


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH] x86/acpi: fix unmapping of low 1MB memory in acpi_os_unmap_memory

2017-02-09 Thread Roger Pau Monne
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:[] vmap.c#vm_free+0xd7/0xe0
[...]
(XEN) Xen call trace:
(XEN)[] vmap.c#vm_free+0xd7/0xe0
(XEN)[] acpi_find_root_pointer+0x3a/0x170
(XEN)[] acpi_os_get_root_pointer+0x4e/0x60
(XEN)[] domain_build.c#pvh_setup_acpi_xsdt+0x90/0x240
(XEN)[] domain_build.c#pvh_setup_acpi+0x18a/0x2e0
(XEN)[] domain_build.c#construct_dom0_pvh+0xd2/0x120
(XEN)[] __start_xen+0x1d14/0x2420
(XEN)[] __high_start+0x53/0x60

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

Signed-off-by: Roger Pau Monné 
---
Cc: Jan Beulich 
---
 xen/drivers/acpi/osl.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
index 7199047..930e2d9 100644
--- a/xen/drivers/acpi/osl.c
+++ b/xen/drivers/acpi/osl.c
@@ -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));
 }
-- 
2.10.1 (Apple Git-78)


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel