Skip to content

Commit 3d3fe7c

Browse files
Ard BiesheuvelAlex Shi
authored andcommitted
arm64: mm: check at build time that PAGE_OFFSET divides the VA space evenly
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> (cherry picked from commit 6d2aa549de1fc998581d216de3853aa131aa4446) Signed-off-by: Alex Shi <alex.shi@linaro.org>
1 parent 9ca2991 commit 3d3fe7c

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

arch/arm64/mm/init.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ void __init arm64_memblock_init(void)
170170
{
171171
const s64 linear_region_size = -(s64)PAGE_OFFSET;
172172

173+
/*
174+
* Ensure that the linear region takes up exactly half of the kernel
175+
* virtual address space. This way, we can distinguish a linear address
176+
* from a kernel/module/vmalloc address by testing a single bit.
177+
*/
178+
BUILD_BUG_ON(linear_region_size != BIT(VA_BITS - 1));
179+
173180
/*
174181
* Select a suitable value for the base of physical memory.
175182
*/

0 commit comments

Comments
 (0)