OSDN Git Service

KVM: arm64: Fix-up hyp stage-1 refcounts for all pages mapped at EL2
authorQuentin Perret <qperret@google.com>
Thu, 10 Nov 2022 19:02:37 +0000 (19:02 +0000)
committerMarc Zyngier <maz@kernel.org>
Fri, 11 Nov 2022 16:40:54 +0000 (16:40 +0000)
commit0d16d12eb26ef85602ef8a678d94825a66772774
tree941972f99871b62465e5b2d8b069358ac7b6e20d
parent8e6bcc3a4502a0d8d065466efd888b6b59b85789
KVM: arm64: Fix-up hyp stage-1 refcounts for all pages mapped at EL2

In order to allow unmapping arbitrary memory pages from the hypervisor
stage-1 page-table, fix-up the initial refcount for pages that have been
mapped before the 'vmemmap' array was up and running so that it
accurately accounts for all existing hypervisor mappings.

This is achieved by traversing the entire hypervisor stage-1 page-table
during initialisation of EL2 and updating the corresponding
'struct hyp_page' for each valid mapping.

Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Tested-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Quentin Perret <qperret@google.com>
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20221110190259.26861-5-will@kernel.org
arch/arm64/kvm/hyp/nvhe/setup.c