Skip to content

Commit db7f65d

Browse files
Quentin Perretgregkh
authored andcommitted
KVM: arm64: Fix initialisation order in __pkvm_init_finalise()
commit 5bb0aed upstream. fix_host_ownership() walks the hypervisor's stage-1 page-table to adjust the host's stage-2 accordingly. Any such adjustment that requires cache maintenance operations depends on the per-CPU hyp fixmap being present. However, fix_host_ownership() is currently called before fix_hyp_pgtable_refcnt() and hyp_create_fixmap(), so the fixmap does not yet exist when it runs. This is benign today because the host stage-2 starts empty and no CMOs are needed, but it becomes a latent crash as soon as fix_host_ownership() is extended to operate on a non-empty page-table. Reorder the calls so that fix_hyp_pgtable_refcnt() and hyp_create_fixmap() complete before fix_host_ownership() is invoked. Fixes: 0d16d12 ("KVM: arm64: Fix-up hyp stage-1 refcounts for all pages mapped at EL2") Signed-off-by: Quentin Perret <qperret@google.com> Signed-off-by: Fuad Tabba <tabba@google.com> Link: https://patch.msgid.link/20260424084908.370776-7-tabba@google.com Signed-off-by: Marc Zyngier <maz@kernel.org> Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 70d1229 commit db7f65d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

arch/arm64/kvm/hyp/nvhe/setup.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,15 @@ void __noreturn __pkvm_init_finalise(void)
284284
};
285285
pkvm_pgtable.mm_ops = &pkvm_pgtable_mm_ops;
286286

287-
ret = fix_host_ownership();
287+
ret = fix_hyp_pgtable_refcnt();
288288
if (ret)
289289
goto out;
290290

291-
ret = fix_hyp_pgtable_refcnt();
291+
ret = hyp_create_pcpu_fixmap();
292292
if (ret)
293293
goto out;
294294

295-
ret = hyp_create_pcpu_fixmap();
295+
ret = fix_host_ownership();
296296
if (ret)
297297
goto out;
298298

0 commit comments

Comments
 (0)