Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4171826pxb; Mon, 8 Feb 2021 09:33:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQebCtdPm8fqcurXX6U5g6WWC6nlzaf76BYOfl77OzIy7+eE2oYlm0u9lxKQLxmYPRCUv2 X-Received: by 2002:a17:906:b055:: with SMTP id bj21mr18298890ejb.355.1612805594728; Mon, 08 Feb 2021 09:33:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612805594; cv=none; d=google.com; s=arc-20160816; b=vw0ZlKAK1UN/uSlArs7l6Lso5T70ll+7+8sn22fzIItVLyTisuYlxDM/PahvepuuOH AfxuslYxgZY3Nchny+VwkxPL2NLAvrn4mEjPKFYVHF/hP4kwgfXTuw/6A8UXPFcupu5e bDk8UPMz2B1LQd5tIffBjGoRnJwkqMr5AnfBXtcjDX6IXv2ptR5Uu4DNky/HC9W5E0aK oLFcNUTyyAQTApdaXN7dG2WHVkERz4c2EUveaek8UmS82NjiXnbaW/Cm++QYjpR4gS/7 TmUkwoJM1iOMTEoWzNP2ikCR59IkKyFEC2blfdUMe+Hd1/+Mrag6EOjcjSpHNDN+J90J X8Bg== 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=EtTE0jFZ3Tu6dlXT30BAMGr/KXJajuhe180gVuJJubQ=; b=Uz+6fdTopLZfzxc0nYI8NRnhEjfuI5qU+6ofG8gtUSBYavFPDrL541LmO16knzR8mn ppgwN8oOPaK1aiuI3fk3pNNmeKySSFVRsF/ksN5rLcTruJC4fjWxhNHFLyy/jIyOuKS1 By5exDP2nwQFqGGtY87eMNKkkuWpktmSYvrqXKIF9AXYT+8nNyLWd6Zz2FDDX5vBmowS Tm/XE5rntqnAmQFK1SmuaTc8XbR6mflZ9hR7X9AmsdQQzBFmmC4Jj2RdXVdNlPOwbqVF Z3Y3gtyM2jE1+cbs+b2x86dvnuKbwMERKcDuS/K6ytdvxZ3b73KaFauTaU06gStwVkd+ cihg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ccXBFz6n; 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=pass (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 g26si11880745edy.55.2021.02.08.09.32.50; Mon, 08 Feb 2021 09:33:14 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=ccXBFz6n; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231654AbhBHRaA (ORCPT + 99 others); Mon, 8 Feb 2021 12:30:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:35870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233845AbhBHP2G (ORCPT ); Mon, 8 Feb 2021 10:28:06 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 815C464F24; Mon, 8 Feb 2021 15:16:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612797380; bh=B3P5vINbAH+EgV1UE2nZenvUeBS/tjObfCMxGbhtdHY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ccXBFz6nJhUy85E59id7eRzY2x9WxUR5ojgPUQDdamA52qYHyWkSKHJ8+Erlm1m7k HBoz7+J4hXl/s8XHM2+Rr6nNL5hOc7rUcov7wu08G9rA+WL9gImjnq7SrSSww7MnV+ qZxrwcnu/4R9uNVC7qZzKFLkgcsbZ8EILkUIE7xU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ben Gardon , Paolo Bonzini Subject: [PATCH 5.10 089/120] KVM: x86/mmu: Fix TDP MMU zap collapsible SPTEs Date: Mon, 8 Feb 2021 16:01:16 +0100 Message-Id: <20210208145821.941981549@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145818.395353822@linuxfoundation.org> References: <20210208145818.395353822@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: Ben Gardon commit 87aa9ec939ec7277b730786e19c161c9194cc8ca upstream. There is a bug in the TDP MMU function to zap SPTEs which could be replaced with a larger mapping which prevents the function from doing anything. Fix this by correctly zapping the last level SPTEs. Cc: stable@vger.kernel.org Fixes: 14881998566d ("kvm: x86/mmu: Support disabling dirty logging for the tdp MMU") Signed-off-by: Ben Gardon Message-Id: <20210202185734.1680553-11-bgardon@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/mmu/tdp_mmu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -1037,8 +1037,8 @@ bool kvm_tdp_mmu_slot_set_dirty(struct k } /* - * Clear non-leaf entries (and free associated page tables) which could - * be replaced by large mappings, for GFNs within the slot. + * Clear leaf entries which could be replaced by large mappings, for + * GFNs within the slot. */ static void zap_collapsible_spte_range(struct kvm *kvm, struct kvm_mmu_page *root, @@ -1050,7 +1050,7 @@ static void zap_collapsible_spte_range(s tdp_root_for_each_pte(iter, root, start, end) { if (!is_shadow_present_pte(iter.old_spte) || - is_last_spte(iter.old_spte, iter.level)) + !is_last_spte(iter.old_spte, iter.level)) continue; pfn = spte_to_pfn(iter.old_spte);