From patchwork Tue Sep 5 14:52:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9939161 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6D31160350 for ; Tue, 5 Sep 2017 14:52:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F1962897B for ; Tue, 5 Sep 2017 14:52:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 542F528995; Tue, 5 Sep 2017 14:52:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFBA42897B for ; Tue, 5 Sep 2017 14:52:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751996AbdIEOwf (ORCPT ); Tue, 5 Sep 2017 10:52:35 -0400 Received: from mail-wm0-f52.google.com ([74.125.82.52]:35719 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751941AbdIEOwV (ORCPT ); Tue, 5 Sep 2017 10:52:21 -0400 Received: by mail-wm0-f52.google.com with SMTP id f199so364945wme.0 for ; Tue, 05 Sep 2017 07:52:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=P40sPM+bpPwt4Ofd4X9sttgTW53WOA7sah6mw3xKPZ8=; b=eqPh+6w+vXOLscbws0/1XKfqTgQMgcXoPwM/kCYTdJbN/nl71GP4UPbNNlSSosR0ul 6bCW1ivjhtVxWcZmRDa+YMEGP6P6EWLd38ufBXgiKKMdSwD2sSgl6DbH8cscWhp+09Mz 00Fs3UYT3FQKAgaNOvKRQYn+EdPtAiJxOAl5o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=P40sPM+bpPwt4Ofd4X9sttgTW53WOA7sah6mw3xKPZ8=; b=RVCkOw/UMrK5yF8ZnaZWZVLW01hiv/zeVAgTpFq2EmiYR7PGONY/opEWvjrdiE87wy XM32YiN4Jc/u30akaG8oBQoJRTLQcQt5+54ARb1g31wCt4CpzTzzas/6SpDc2ky0cdgf EdlXtzHEfK+43Qx3HWaB8WdzrOV9PwwDe/WChBpVF2KB92ZIlsHtYEbvAGvttkgxZX6d hJCqotmV2/jQcJPFyZSBfj2Z3Cb2ehqNHIrJNAgDBsOnUESbHFsCPETV3uafyNmkH2Hi mVH4BqLLpvPTLa+pPWLx3GGC3QprKxfcfpH5bSrq+fZT1h53ylziayVyweCwk9VlJpTD xSYg== X-Gm-Message-State: AHPjjUhgjg5bWyfOr6oT9c4O8lf2CffppCoGeBmgmVJNxMJP8lFWtutP J9ZP6t0ycFQBv7aM X-Google-Smtp-Source: ADKCNb6AE+/mGmSz1M4zpEmAU2iL2KFvQnPaGZsDjMJII/MW++NW/lNe/EEgV+C/a+jWqKXrA8kJPA== X-Received: by 10.80.218.10 with SMTP id z10mr3372658edj.224.1504623139483; Tue, 05 Sep 2017 07:52:19 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id a28sm293809edc.14.2017.09.05.07.52.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Sep 2017 07:52:18 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: Marc Zyngier , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Suzuki K Poulose , stable@vger.kernel.org, Suzuki K Poulose Subject: [PULL 3/8] KVM: arm/arm64: Handle hva aging while destroying the vm Date: Tue, 5 Sep 2017 16:52:02 +0200 Message-Id: <20170905145207.18447-4-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170905145207.18447-1-cdall@linaro.org> References: <20170905145207.18447-1-cdall@linaro.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Suzuki K Poulose The mmu_notifier_release() callback of KVM triggers cleaning up the stage2 page table on kvm-arm. However there could be other notifier callbacks in parallel with the mmu_notifier_release(), which could cause the call backs ending up in an empty stage2 page table. Make sure we check it for all the notifier callbacks. Cc: stable@vger.kernel.org Fixes: commit 293f29363 ("kvm-arm: Unmap shadow pagetables properly") Reported-by: Alex Graf Reviewed-by: Christoffer Dall Signed-off-by: Suzuki K Poulose Signed-off-by: Marc Zyngier --- 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 0e1fc75..2ea21da 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -1718,12 +1718,16 @@ static int kvm_test_age_hva_handler(struct kvm *kvm, gpa_t gpa, u64 size, void * int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end) { + if (!kvm->arch.pgd) + return 0; trace_kvm_age_hva(start, end); return handle_hva_to_gpa(kvm, start, end, kvm_age_hva_handler, NULL); } int kvm_test_age_hva(struct kvm *kvm, unsigned long hva) { + if (!kvm->arch.pgd) + return 0; trace_kvm_test_age_hva(hva); return handle_hva_to_gpa(kvm, hva, hva, kvm_test_age_hva_handler, NULL); }