From patchwork Thu Aug 15 15:12:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 11095851 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EC697746 for ; Thu, 15 Aug 2019 15:12:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D48101FFDB for ; Thu, 15 Aug 2019 15:12:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C867528908; Thu, 15 Aug 2019 15:12:34 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 6E1131FFDB for ; Thu, 15 Aug 2019 15:12:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732490AbfHOPMb (ORCPT ); Thu, 15 Aug 2019 11:12:31 -0400 Received: from mga04.intel.com ([192.55.52.120]:25322 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732464AbfHOPMa (ORCPT ); Thu, 15 Aug 2019 11:12:30 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Aug 2019 08:12:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,389,1559545200"; d="scan'208";a="171139099" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.41]) by orsmga008.jf.intel.com with ESMTP; 15 Aug 2019 08:12:29 -0700 From: Sean Christopherson To: Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Alex Willamson Subject: [PATCH] KVM: x86/MMU: Zap all when removing memslot if VM has assigned device Date: Thu, 15 Aug 2019 08:12:28 -0700 Message-Id: <20190815151228.32242-1-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <1565855169-29491-1-git-send-email-pbonzini@redhat.com> References: <1565855169-29491-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Alex Williamson reported regressions with device assignment when KVM changed its memslot removal logic to zap only the SPTEs for the memslot being removed. The source of the bug is unknown at this time, and root causing the issue will likely be a slow process. In the short term, fix the regression by zapping all SPTEs when removing a memslot from a VM with assigned device(s). Fixes: 4e103134b862 ("KVM: x86/mmu: Zap only the relevant pages when removing a memslot", 2019-02-05) Reported-by: Alex Willamson Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson --- An alternative idea to a full revert. I assume this would be easy to backport, and also easy to revert or quirk depending on where the bug is hiding. arch/x86/kvm/mmu.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 8f72526e2f68..358b93882ac6 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -5659,6 +5659,17 @@ static void kvm_mmu_invalidate_zap_pages_in_memslot(struct kvm *kvm, bool flush; gfn_t gfn; + /* + * Zapping only the removed memslot introduced regressions for VMs with + * assigned devices. It is unknown what piece of code is buggy. Until + * the source of the bug is identified, zap everything if the VM has an + * assigned device. + */ + if (kvm_arch_has_assigned_device(kvm)) { + kvm_mmu_zap_all(kvm); + return; + } + spin_lock(&kvm->mmu_lock); if (list_empty(&kvm->arch.active_mmu_pages))