ANDROID: KVM: arm64: Fix accounting when VM creation fails
When VM creation fails part-way through __pkvm_create_hyp_vm(), we end up destroying the partial state by calling __pkvm_destroy_hyp_vm() before the memory accounting metadata has been updated. Consequently, we underflow the counters and report wildly incorrect information: # cat /sys/kernel/debug/kvm/protected_pgtable_mem 18446744073709543424 Move the accounting updates immediately after the memcach refill so that the metadata is in-sync with the donations, even if we fail to create the VM. Bug: 278749606 Bug: 373813803 Fixes: 68404834 ("ANDROID: KVM: arm64: Count KVM s2 mmu usage in nVHE protected mode") Fixes: 590fdd82 ("ANDROID: KVM: arm64: Add memory accounting for the VM pagetable memory") Signed-off-by:Will Deacon <willdeacon@google.com> Change-Id: If4ae9816df009ca2a74aff5964676465c25fe6dc
Loading
Please sign in to comment