From 0b6736459a927dc50b9d8230280d9075a6506eeb Mon Sep 17 00:00:00 2001 From: Quentin Perret Date: Mon, 3 Apr 2023 13:46:27 +0000 Subject: [PATCH] ANDROID: KVM: arm64: Fix the host ownership later The fix_host_ownership() path walks the hypervisor's stage-1 page-table to adjust the host's stage-2 accordingly. However, this is done before the hyp stage-1 refcount has been fixed up, and before the hyp percpu fixmap has been created. This all works right now as we start off with an empty host stage-2, so none of the changes require the usage of the fixmap for e.g. CMOs. To prepare the ground for doing fix_host_ownership() with a non-empty page-table, finalize the hyp stage-1 upfront. Bug: 264070847 Change-Id: I6aff3ac2f835be3fb3fba7660540c0a9b99c097d Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/nvhe/setup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/setup.c b/arch/arm64/kvm/hyp/nvhe/setup.c index 50d7c86037d9..569f3be83a17 100644 --- a/arch/arm64/kvm/hyp/nvhe/setup.c +++ b/arch/arm64/kvm/hyp/nvhe/setup.c @@ -357,10 +357,6 @@ void __noreturn __pkvm_init_finalise(void) }; pkvm_pgtable.mm_ops = &pkvm_pgtable_mm_ops; - ret = fix_host_ownership(); - if (ret) - goto out; - ret = fix_hyp_pgtable_refcnt(); if (ret) goto out; @@ -369,6 +365,10 @@ void __noreturn __pkvm_init_finalise(void) if (ret) goto out; + ret = fix_host_ownership(); + if (ret) + goto out; + ret = unmap_protected_regions(); if (ret) goto out;