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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 B3797C6379F for ; Tue, 27 Oct 2020 17:16:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B67520809 for ; Tue, 27 Oct 2020 17:16:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603818999; bh=C1ayFxe0sZ0A3ghas3cZGBURR93wVfuJ7LUuAjENuNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=z4i3T7EYPWwaB5FOiWcYALEvwRY8ocUX4CebTCLuB+0+J9PCnuDphYGCO27bsDyPp TfPvEgWezNilW80QItOQQzHmT958WFUjWuGC5rasvR+eE+RIEA0Om2JhfetIkB/N40 rZHMolc2gW9X44uSSsdseA/Jq8EkBaPdnZZS5pG4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1782526AbgJ0O5N (ORCPT ); Tue, 27 Oct 2020 10:57:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:50396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1773012AbgJ0Ouv (ORCPT ); Tue, 27 Oct 2020 10:50:51 -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 01B5D207DE; Tue, 27 Oct 2020 14:50:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810250; bh=C1ayFxe0sZ0A3ghas3cZGBURR93wVfuJ7LUuAjENuNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sw/cofHwVguc0wOa/JoI4rmKeCFwUrnrzLiTT6MT8zpPlbUF8HGuVRNBJJBVkbjha prpLibQ2hgr5Iaref/2J9+680DR4v9pW47eQ1aWOVMqUSdQz/Pc0ZGR2vR6eW72Wz5 ZcPy/byPc6+1kH0RdJfF/hjrypllu1LvJP50ehqk= 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.8 072/633] KVM: x86/mmu: Commit zap of remaining invalid pages when recovering lpages Date: Tue, 27 Oct 2020 14:46:55 +0100 Message-Id: <20201027135526.081631580@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@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/mmu.c | 1 + 1 file changed, 1 insertion(+) --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -6341,6 +6341,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);