Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1682104

Re: [PATCH v2] KVM: arm/arm64: Handle hva aging while destroying the vm

From Alexander Graf <agraf@suse.de>
Newsgroups linux.kernel
Subject Re: [PATCH v2] KVM: arm/arm64: Handle hva aging while destroying the vm
Date 2017-07-06 09:10 +0200
Message-ID <u095g-1az-19@gated-at.bofh.it> (permalink)
References <tZLYZ-2A3-7@gated-at.bofh.it> <tZOk9-3ZB-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On 05.07.17 10:57, Suzuki K Poulose wrote:
> Hi Alex,
> 
> On Wed, Jul 05, 2017 at 08:20:31AM +0200, Alexander Graf wrote:
>> The kvm_age_hva callback may be called all the way concurrently while
>> kvm_mmu_notifier_release() is running.
>>
>> The release function sets kvm->arch.pgd = NULL which the aging function
>> however implicitly relies on in stage2_get_pud(). That means they can
>> race and the aging function may dereference a NULL pgd pointer.
>>
>> This patch adds a check for that case, so that we leave the aging
>> function silently.
>>
>> Cc: stable@vger.kernel.org
>> Fixes: 293f29363 ("kvm-arm: Unmap shadow pagetables properly")
>> Signed-off-by: Alexander Graf <agraf@suse.de>
>>
>> ---
>>
>> v1 -> v2:
>>
>>    - Fix commit message
>>    - Add Fixes and stable tags
>> ---
>>   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 f2d5b6c..227931f 100644
>> --- a/virt/kvm/arm/mmu.c
>> +++ b/virt/kvm/arm/mmu.c
>> @@ -861,6 +861,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;
>> +
> 
> I think this check should be moved up in the chain. We call kvm_age_hva(), with
> the kvm->mmu_lock held and we don't release it till we reach here. So, ideally,
> if we find the PGD is null when we reach kvm_age_hva(), we could simply return
> there, like we do for other call backs from the KVM mmu_notifier.

That probably works too - I'm not sure which version is more consistent 
as well as more maintainable in the long run. I'll leave the call here 
to Christoffer.


Alex

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2] KVM: arm/arm64: Handle hva aging while destroying the vm Alexander Graf <agraf@suse.de> - 2017-07-05 08:30 +0200
  Re: [PATCH v2] KVM: arm/arm64: Handle hva aging while destroying the  vm Suzuki K Poulose <Suzuki.Poulose@arm.com> - 2017-07-05 11:00 +0200
    Re: [PATCH v2] KVM: arm/arm64: Handle hva aging while destroying the  vm Alexander Graf <agraf@suse.de> - 2017-07-06 09:10 +0200
      Re: [PATCH v2] KVM: arm/arm64: Handle hva aging while destroying the  vm Christoffer Dall <cdall@linaro.org> - 2017-07-06 09:50 +0200
        Re: [PATCH v2] KVM: arm/arm64: Handle hva aging while destroying the  vm Andrea Arcangeli <aarcange@redhat.com> - 2017-07-06 11:40 +0200
          Re: [PATCH v2] KVM: arm/arm64: Handle hva aging while destroying the  vm Christoffer Dall <cdall@linaro.org> - 2017-07-06 11:50 +0200
        Re: [PATCH v2] KVM: arm/arm64: Handle hva aging while destroying the  vm Suzuki K Poulose <Suzuki.Poulose@arm.com> - 2017-07-06 11:40 +0200
          Re: [PATCH v2] KVM: arm/arm64: Handle hva aging while destroying the  vm Christoffer Dall <cdall@linaro.org> - 2017-07-06 11:50 +0200
            Re: [PATCH v2] KVM: arm/arm64: Handle hva aging while destroying the  vm Suzuki K Poulose <Suzuki.Poulose@arm.com> - 2017-07-14 18:50 +0200
              Re: [PATCH v2] KVM: arm/arm64: Handle hva aging while destroying the  vm Christoffer Dall <cdall@linaro.org> - 2017-07-16 22:00 +0200
                Re: [PATCH v2] KVM: arm/arm64: Handle hva aging while destroying the  vm Suzuki K Poulose <Suzuki.Poulose@arm.com> - 2017-07-17 15:10 +0200
                Re: [PATCH v2] KVM: arm/arm64: Handle hva aging while destroying the vm Christoffer Dall <cdall@linaro.org> - 2017-07-17 16:50 +0200
                Re: [PATCH v2] KVM: arm/arm64: Handle hva aging while destroying the  vm Andrea Arcangeli <aarcange@redhat.com> - 2017-07-17 17:20 +0200
                Re: [PATCH v2] KVM: arm/arm64: Handle hva aging while destroying the  vm Christoffer Dall <cdall@linaro.org> - 2017-07-17 20:30 +0200
                Re: [PATCH v2] KVM: arm/arm64: Handle hva aging while destroying the  vm Alexander Graf <agraf@suse.de> - 2017-07-17 22:50 +0200
    Re: [PATCH v2] KVM: arm/arm64: Handle hva aging while destroying the  vm Christoffer Dall <cdall@linaro.org> - 2017-07-06 10:20 +0200

csiph-web