arm64: Reduce add_map() complexity

The add_map() function is an interresting exercise in making something
simple way too complex. For each level it populates, it iterates from
the root of the PT tree, making it extremely ineficient if a mapping
needs to occur past level 1.

Instead, replace it with a recursive (and much simpler) algorithm
that keeps the complexity as low as possible. With this, mapping
512GB at level 2 goes from several seconds down to not measurable
on an A55 machine.

We keep the block mappings at level 1 for now though.

Bug: 217161634
Signed-off-by: Marc Zyngier <maz@kernel.org>
Change-Id: I9420f1048224650d20d14469747b512d09ecb7d4
1 file changed