From b1a6ad0c2c6e16a378928f0f4c40494eee4b8f58 Mon Sep 17 00:00:00 2001
From: Alexander Graf <agraf@suse.de>
Date: Thu, 22 Jun 2017 17:06:57 +0200
Subject: [PATCH] KVM: arm/arm64: Handle hva aging while destroying the vm
Patch-mainline: v4.13-rc4
Git-commit: 7e5a672289c9754d07e1c3b33649786d3d70f5e4
References: bsc#1045298
If we want to age an HVA while the VM is getting destroyed, we have a
tiny race window during which we may end up dereferencing invalid pointers.
This patch adds a check for that case.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
virt/kvm/arm/mmu.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c
index a159de8..e586b9e 100644
--- a/virt/kvm/arm/mmu.c
+++ b/virt/kvm/arm/mmu.c
@@ -859,6 +859,10 @@ static pud_t *stage2_get_pud(struct kvm *kvm, struct kvm_mmu_memory_cache *cache
pgd_t *pgd;
pud_t *pud;
+ /* Do we clash with kvm_free_stage2_pgd()? */
+ if (!kvm->arch.pgd)
+ return NULL;
+
pgd = kvm->arch.pgd + stage2_pgd_index(addr);
if (WARN_ON(stage2_pgd_none(*pgd))) {
if (!cache)
--
1.8.5.6