arm64: head: split __create_page_tables

Over time the creation of the idmap page tables and kernel page tables
has become increasingly complicated. The code in __create_page_tables()
performs three distinct tasks which are interleaved with one another:

* Detecting the presence of 52-bit VA support
* Creating the page tables for the idmap
* Creating the page tables for the kernel image

Due to the amount of code, and the interleaving, it can be harder than
necessary to read the code. Further, when KASLR is in use we'll recreate
the kernel image page tables using __create_page_tables(), redundantly
detecting the presence of 52-bit VA support and redundantly recreating
the idmap page tables.

To aid legibility and to avoid the redundant work, this patch splits
__create_page tables into three functions:

* __detect_vabits()
* __create_idmap_tables()
* __create_kernel_tables()

The primary boot path will call all three in order, and after KASLR
randomization we only need to call __create_kernel_tables() again. The
work is no longer interleaved, but as the only dependency between the
tasks is identifying the va bits before creating the tables, this
changes should not have any functional impact.

The new split means we can't amortize barriers required by the two page
table setup functions, but the cost of an additional DSB SY in the
primary boot path should be negligible in practice.

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
1 file changed