ARM: kasan: Support discontiguous memory ranges

The Kasan code currently assumes that each memory range is
linerly mapped 1-to-1 from physical to virtual memory.
So we assume that __va() applied from the start to the end
of each memory range will return a contiguous address range.

This does not work when using for example a kernel compiled
into the vmalloc area: __va() will start to change in the
middle of a physical address range as we are now mappin the
kernel into a different place that the physical memory
below and above it.

Fix this by adding an inner loop to for_each_mem_range()
in kasan_init() so that we walk the pages and line up
those that are physically contiguos and call create_mapping()
for each contiguous range.

Add some comments and debug prints so it is clear to people
reading the code what is going on in here.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 file changed