From 7ab22b914dc203248b8f2d031b6017d1bf0664c2 Mon Sep 17 00:00:00 2001 From: Fuad Tabba Date: Tue, 8 Feb 2022 16:10:02 +0000 Subject: [PATCH] ANDROID: KVM: arm64: Change variable names to avoid confusing size and count Change the variable names to avoid confusion between total memory area size or just the number of pages. Use host_kvm.vtcr to make future refactoring easier. Simplifies future fixes of the bug below. Bug: 216808671 Signed-off-by: Fuad Tabba Change-Id: Ica0a0dfcf839dae0625a26a2095e56212385bbe7 --- arch/arm64/kvm/hyp/nvhe/pkvm.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c index b69f61ce7db3..31147eadd71a 100644 --- a/arch/arm64/kvm/hyp/nvhe/pkvm.c +++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c @@ -568,8 +568,9 @@ int __pkvm_init_shadow(struct kvm *kvm, struct kvm_shadow_vm *vm = kern_hyp_va(shadow_va); phys_addr_t shadow_pa = hyp_virt_to_phys(vm); u64 pfn = hyp_phys_to_pfn(shadow_pa); - u64 nr_pages = shadow_size >> PAGE_SHIFT; - u64 pgd_size; + u64 nr_shadow_pages = shadow_size >> PAGE_SHIFT; + u64 nr_pgd_pages; + size_t pgd_size; int nr_vcpus = 0; int ret = 0; @@ -592,15 +593,16 @@ int __pkvm_init_shadow(struct kvm *kvm, if (ret) goto err; - ret = __pkvm_host_donate_hyp(pfn, nr_pages); + ret = __pkvm_host_donate_hyp(pfn, nr_shadow_pages); if (ret) goto err; /* Ensure we're working with a clean slate. */ memset(vm, 0, shadow_size); vm->arch.vtcr = host_kvm.arch.vtcr; - pgd_size = kvm_pgtable_stage2_pgd_size(vm->arch.vtcr) >> PAGE_SHIFT; - ret = __pkvm_host_donate_hyp(hyp_virt_to_pfn(pgd), pgd_size); + pgd_size = kvm_pgtable_stage2_pgd_size(host_kvm.arch.vtcr); + nr_pgd_pages = pgd_size >> PAGE_SHIFT; + ret = __pkvm_host_donate_hyp(hyp_virt_to_pfn(pgd), nr_pgd_pages); if (ret) goto err_remove_mappings; @@ -623,7 +625,7 @@ err_remove_shadow_table: remove_shadow_table(vm->shadow_handle); err_remove_pgd: - WARN_ON(__pkvm_hyp_donate_host(hyp_virt_to_pfn(pgd), pgd_size)); + WARN_ON(__pkvm_hyp_donate_host(hyp_virt_to_pfn(pgd), nr_pgd_pages)); err_remove_mappings: unpin_host_vcpus(vm);