]> xenbits.xensource.com Git - people/liuw/xen.git/commitdiff
xen/arm: Don't use _end in is_xen_fixed_mfn()
authorJulien Grall <julien.grall@arm.com>
Wed, 16 Oct 2019 10:53:03 +0000 (11:53 +0100)
committerJulien Grall <julien.grall@arm.com>
Tue, 22 Oct 2019 16:55:11 +0000 (17:55 +0100)
virt_to_maddr() is using the hardware page-table walk instructions to
translate a virtual address to physical address. The function should
only be called on virtual address mapped.

_end points past the end of Xen binary and may not be mapped when the
binary size is page-aligned. This means virt_to_maddr() will not be able
to do the translation and therefore crash Xen.

Note there is also an off-by-one issue in this code, but the panic will
trump that.

Both issues can be fixed by using _end - 1 in the check.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/include/asm-arm/mm.h

index 262d92f18d85d30d4b231bf5be50b0e561311e02..333efd3a60b1934c04dd50ac5217f6902a420f0b 100644 (file)
@@ -153,7 +153,7 @@ extern unsigned long xenheap_base_pdx;
 
 #define is_xen_fixed_mfn(mfn)                                   \
     ((mfn_to_maddr(mfn) >= virt_to_maddr(&_start)) &&           \
-     (mfn_to_maddr(mfn) <= virt_to_maddr(&_end)))
+     (mfn_to_maddr(mfn) <= virt_to_maddr((vaddr_t)_end - 1)))
 
 #define page_get_owner(_p)    (_p)->v.inuse.domain
 #define page_set_owner(_p,_d) ((_p)->v.inuse.domain = (_d))