KVM: arm64: Make block->table PTE changes parallel-aware
authorOliver Upton <oliver.upton@linux.dev>
Mon, 7 Nov 2022 21:58:55 +0000 (21:58 +0000)
committerMarc Zyngier <maz@kernel.org>
Thu, 10 Nov 2022 14:43:46 +0000 (14:43 +0000)
commit0ab12f3574db6cb432917a667f9392a88e8f0dfc
treec73db825b8c574644e1ddb54bdb2a21b689628e8
parent331aa3a0547d1c794587e0df374d13b16645e832
KVM: arm64: Make block->table PTE changes parallel-aware

In order to service stage-2 faults in parallel, stage-2 table walkers
must take exclusive ownership of the PTE being worked on. An additional
requirement of the architecture is that software must perform a
'break-before-make' operation when changing the block size used for
mapping memory.

Roll these two concepts together into helpers for performing a
'break-before-make' sequence. Use a special PTE value to indicate a PTE
has been locked by a software walker. Additionally, use an atomic
compare-exchange to 'break' the PTE when the stage-2 page tables are
possibly shared with another software walker. Elide the DSB + TLBI if
the evicted PTE was invalid (and thus not subject to break-before-make).

All of the atomics do nothing for now, as the stage-2 walker isn't fully
ready to perform parallel walks.

Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20221107215855.1895367-1-oliver.upton@linux.dev
arch/arm64/kvm/hyp/pgtable.c