arm64: mm: check at build time that PAGE_OFFSET divides the VA space evenly
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 2 Mar 2016 08:47:13 +0000 (09:47 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Wed, 2 Mar 2016 09:45:52 +0000 (09:45 +0000)
Commit 8439e62a1561 ("arm64: mm: use bit ops rather than arithmetic in
pa/va translations") changed the boundary check against PAGE_OFFSET from
an arithmetic comparison to a bit test. This means we now silently assume
that PAGE_OFFSET is a power of 2 that divides the kernel virtual address
space into two equal halves. So make that assumption explicit.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/mm/init.c

index 22c6758b01aa690b5027b1ed378a9c0c33bdec86..8c3d7dd91c25c237a5b8fc400bf1f6294adeec1e 100644 (file)
@@ -170,6 +170,13 @@ void __init arm64_memblock_init(void)
 {
        const s64 linear_region_size = -(s64)PAGE_OFFSET;
 
+       /*
+        * Ensure that the linear region takes up exactly half of the kernel
+        * virtual address space. This way, we can distinguish a linear address
+        * from a kernel/module/vmalloc address by testing a single bit.
+        */
+       BUILD_BUG_ON(linear_region_size != BIT(VA_BITS - 1));
+
        /*
         * Select a suitable value for the base of physical memory.
         */