Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp536860pxx; Wed, 28 Oct 2020 10:32:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsKFZvxSnCxQ2QVwM2MmatrpJfLEx8x8UJlEbicP+ys2JAe547Ip9NVm/e4HutqDCVxZc+ X-Received: by 2002:a17:906:110b:: with SMTP id h11mr192785eja.156.1603906378386; Wed, 28 Oct 2020 10:32:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603906378; cv=none; d=google.com; s=arc-20160816; b=QjetzNyJq9N4LiaHG63CTRa5KGQneJaVBzQZZRnbiOVaL+D+/doxWQAii0cDdphOa8 lPJD952kmKjNwQ4yNhY+KyzD5QPeOKXnwYKbirOqCVwNVS4HvTuVkOL4ad//Uet/3jUV fdAJZThN/bX0utljGqAvwU35n9czZ0enpxEjH5XwQkeVuf2kzrivOQikrMF+n8OhU1+i B4GoldNRKgo+YpTBn+4Xg+TxV0hrIcr1PowVbREBaQBqhwaCwxD4IzK2t38LNbek7i7h wPeFi7f1vDqAFONhbkro1OPAOPHn5f4P6K6a2b+Kyk0/uquQAQ8+lh1e5pOqibgadu5c ibdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1JSEKmUwtDudlx8P0xj4Jzb+DRmGMvz96MU8Zo8S2sw=; b=QUPZXI6LSBudELD3IBZal8svzseCg5yLmsUiM42i7Q9RPh+GB0jZODa3NkpJgrKdYY aiFd6tGKYOsYnsBtIYdddf7+fnf1dp4KAMkxibhNqYFt2ZvF4ShedzPp6FiFb9jdDPxs s0zEfPVU/JUcAF+dIj6bfLZzpsXSIrq/PCWi6ILRulKo4j5XyrbIl2Cqpk+m4853EzQG b6RWxexY2x/J/ml2mNFrWvab/tY9MF2khDTu/OQPNfDAUe0a8eN9xbsPQKo9h0IH7iUd yYicUqu0TcpzwO2gSmCXEKa1hyqhsqXJUPykAtPzU5L7kRz8MduJgl7UoeT3HpX+n2Cb 3VzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P44DGEx9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ay1si32292edb.3.2020.10.28.10.32.35; Wed, 28 Oct 2020 10:32:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P44DGEx9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1821456AbgJ0Rnx (ORCPT + 99 others); Tue, 27 Oct 2020 13:43:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:58584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2896236AbgJ0Obq (ORCPT ); Tue, 27 Oct 2020 10:31:46 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4E80420754; Tue, 27 Oct 2020 14:31:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809105; bh=Yy+GqU2CwN8RCLW/R0CvlVdSAxJg6/NSoEFSDCjUSDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P44DGEx9hO4yFctA2Msn1DMRm9yJSqRBrrBL6oI9xty9bU47JFMERuWrjtPkDiIab KoQFpGGizf4VDzfXXCRpaeHDs6CxufbjWXxX8bx9xA4GoIL2gc/v6kXgivVV+tt8c1 koIHEUweeGSJLLR8VXFRIQqdjuif1Zl+RvtPxGRc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Junaid Shahid , Sean Christopherson , Paolo Bonzini Subject: [PATCH 5.4 050/408] KVM: x86/mmu: Commit zap of remaining invalid pages when recovering lpages Date: Tue, 27 Oct 2020 14:49:48 +0100 Message-Id: <20201027135457.388954138@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson commit e89505698c9f70125651060547da4ff5046124fc upstream. Call kvm_mmu_commit_zap_page() after exiting the "prepare zap" loop in kvm_recover_nx_lpages() to finish zapping pages in the unlikely event that the loop exited due to lpage_disallowed_mmu_pages being empty. Because the recovery thread drops mmu_lock() when rescheduling, it's possible that lpage_disallowed_mmu_pages could be emptied by a different thread without to_zap reaching zero despite to_zap being derived from the number of disallowed lpages. Fixes: 1aa9b9572b105 ("kvm: x86: mmu: Recovery of shattered NX large pages") Cc: Junaid Shahid Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Message-Id: <20200923183735.584-2-sean.j.christopherson@intel.com> Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/mmu.c | 1 + 1 file changed, 1 insertion(+) --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -6453,6 +6453,7 @@ static void kvm_recover_nx_lpages(struct cond_resched_lock(&kvm->mmu_lock); } } + kvm_mmu_commit_zap_page(kvm, &invalid_list); spin_unlock(&kvm->mmu_lock); srcu_read_unlock(&kvm->srcu, rcu_idx);