]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
core: Prevent hugepage creation if physical and virtual addresses are unaligned
authorJan Kiszka <jan.kiszka@siemens.com>
Mon, 10 Feb 2014 16:28:41 +0000 (17:28 +0100)
committerJan Kiszka <jan.kiszka@siemens.com>
Mon, 10 Feb 2014 16:28:41 +0000 (17:28 +0100)
We can only create hugepages if the there is an alignment on the page
size by both the virtual and physical address. Without this check, we
crashed, e.g., on configurations that placed the hypervisor on physical
start addresses that were not 2M-aligned.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
hypervisor/paging.c

index 779395954a6c85ed27b113716a3ec1cac891d4e0..2f6ec3cf3079e58511102cd7f39f51ed8e1849fd 100644 (file)
@@ -165,6 +165,7 @@ int page_map_create(const struct paging_structures *pg_structs,
                    unsigned long phys, unsigned long size, unsigned long virt,
                    unsigned long flags, enum page_map_coherent coherent)
 {
+       phys &= PAGE_MASK;
        virt &= PAGE_MASK;
        size = PAGE_ALIGN(size);
 
@@ -178,7 +179,7 @@ int page_map_create(const struct paging_structures *pg_structs,
                        pte = paging->get_entry(pt, virt);
                        if (paging->page_size > 0 &&
                            paging->page_size <= size &&
-                           (virt & (paging->page_size - 1)) == 0) {
+                           ((phys | virt) & (paging->page_size - 1)) == 0) {
                                /*
                                 * We might be overwriting a more fine-grained
                                 * mapping, so release it first. This cannot