Skip to content

Commit

Permalink
arm64: mm: check at build time that PAGE_OFFSET divides the VA space …
Browse files Browse the repository at this point in the history
…evenly

Commit 8439e62 ("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>
  • Loading branch information
Ard Biesheuvel authored and Catalin Marinas committed Mar 2, 2016
1 parent 22b39ca commit 6d2aa54
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions arch/arm64/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 6d2aa54

Please sign in to comment.