From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BB42C10F0E for ; Mon, 15 Apr 2019 14:44:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2699C20880 for ; Mon, 15 Apr 2019 14:44:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727304AbfDOOoL (ORCPT ); Mon, 15 Apr 2019 10:44:11 -0400 Received: from mga18.intel.com ([134.134.136.126]:44943 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726102AbfDOOoL (ORCPT ); Mon, 15 Apr 2019 10:44:11 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Apr 2019 07:44:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,354,1549958400"; d="scan'208";a="291704215" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.181]) by orsmga004.jf.intel.com with ESMTP; 15 Apr 2019 07:44:10 -0700 Date: Mon, 15 Apr 2019 07:44:10 -0700 From: Sean Christopherson To: Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= Cc: kvm@vger.kernel.org Subject: Re: [PATCH] KVM: x86/mmu: Fix an inverted list_empty() check when zapping sptes Message-ID: <20190415144410.GA24010@linux.intel.com> References: <20190413025541.20303-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190413025541.20303-1-sean.j.christopherson@intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Fri, Apr 12, 2019 at 07:55:41PM -0700, Sean Christopherson wrote: > A recently introduced helper for handling zap vs. remote flush > incorrectly bails early, effectively leaking defunct shadow pages. > Manifests as a slab BUG when exiting KVM due to the shadow pages > being alive when their associated cache is destroyed. > > ========================================================================== > BUG kvm_mmu_page_header: Objects remaining in kvm_mmu_page_header on ... > -------------------------------------------------------------------------- > Disabling lock debugging due to kernel taint > INFO: Slab 0x00000000fc436387 objects=26 used=23 fp=0x00000000d023caee ... > CPU: 6 PID: 4315 Comm: rmmod Tainted: G B 5.1.0-rc2+ #19 > Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 > Call Trace: > dump_stack+0x46/0x5b > slab_err+0xad/0xd0 > ? on_each_cpu_mask+0x3c/0x50 > ? ksm_migrate_page+0x60/0x60 > ? on_each_cpu_cond_mask+0x7c/0xa0 > ? __kmalloc+0x1ca/0x1e0 > __kmem_cache_shutdown+0x13a/0x310 > shutdown_cache+0xf/0x130 > kmem_cache_destroy+0x1d5/0x200 > kvm_mmu_module_exit+0xa/0x30 [kvm] > kvm_arch_exit+0x45/0x60 [kvm] > kvm_exit+0x6f/0x80 [kvm] > vmx_exit+0x1a/0x50 [kvm_intel] > __x64_sys_delete_module+0x153/0x1f0 > ? exit_to_usermode_loop+0x88/0xc0 > do_syscall_64+0x4f/0x100 > entry_SYSCALL_64_after_hwframe+0x44/0xa9 > > Fixes: a21136345cb6f ("KVM: x86/mmu: Split remote_flush+zap case out of kvm_mmu_flush_or_zap()") > Cc: stable@vger.kernel.org Stable doesn't need to be Cc'd. I got my kernel versions mixed up, this bug only exists in 5.1. > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/mmu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c > index bd0727019674..e10962dfc203 100644 > --- a/arch/x86/kvm/mmu.c > +++ b/arch/x86/kvm/mmu.c > @@ -2238,7 +2238,7 @@ static bool kvm_mmu_remote_flush_or_zap(struct kvm *kvm, > struct list_head *invalid_list, > bool remote_flush) > { > - if (!remote_flush && !list_empty(invalid_list)) > + if (!remote_flush && list_empty(invalid_list)) > return false; > > if (!list_empty(invalid_list)) > -- > 2.21.0 >