arm64: mm: use bit ops rather than arithmetic in pa/va translations
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 22 Feb 2016 17:46:04 +0000 (18:46 +0100)
committerAlex Shi <alex.shi@linaro.org>
Wed, 11 May 2016 14:52:49 +0000 (22:52 +0800)
commitd3bb0180b3ecbcff076ca7e41d4ad4fa0ee4c9d7
treee69d3ae80b9984bcedcde8fd9e8c2032cae347f5
parentbf7cb966b2f5ef5a456a25d84d2b64c79730a07a
arm64: mm: use bit ops rather than arithmetic in pa/va translations

Since PAGE_OFFSET is chosen such that it cuts the kernel VA space right
in half, and since the size of the kernel VA space itself is always a
power of 2, we can treat PAGE_OFFSET as a bitmask and replace the
additions/subtractions with 'or' and 'and-not' operations.

For the comparison against PAGE_OFFSET, a mov/cmp/branch sequence ends
up getting replaced with a single tbz instruction. For the additions and
subtractions, we save a mov instruction since the mask is folded into the
instruction's immediate field.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
(cherry picked from commit 8439e62a15614e8fcd43835d57b7245cd9870dc5)
Signed-off-by: Alex Shi <alex.shi@linaro.org>
arch/arm64/include/asm/memory.h