From patchwork Thu Oct 4 01:48:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10625459 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 DBF7017E0 for ; Thu, 4 Oct 2018 01:48:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBA0828D81 for ; Thu, 4 Oct 2018 01:48:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFC4728DD0; Thu, 4 Oct 2018 01:48:43 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 451A028DB6 for ; Thu, 4 Oct 2018 01:48:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726661AbeJDIjd (ORCPT ); Thu, 4 Oct 2018 04:39:33 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:45595 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726268AbeJDIjd (ORCPT ); Thu, 4 Oct 2018 04:39:33 -0400 Received: by mail-pg1-f193.google.com with SMTP id t70-v6so2350546pgd.12 for ; Wed, 03 Oct 2018 18:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oAMsVMJ5ojuElRAFO8g2k9+F8n7UAtFkG7Q8nRVaYlA=; b=CT+az2sPyH/pFmatuie9q4pISaS5zTWQ+bGcKGhTtGfnI6K/o7GHyKvD2ZEzxeM3aN IkBXHpYiO4rA1fvqeEJgaAjuDnJPw/0QHyn/w8Ct3PUwNwH2u1Nm/7TsApozdysnGw1y 1cW74+7gmg4eY1yS4D6xiDJrna0lkxJhZasyOsMZhhiQoP7vFfAWtSOQGF1pcYrRMIYH 3v47DNze1X7/3YBOT+3N0lZTphNGXJhogq3emGX1/HWY7pY5MCWSRCXslvorfgWWj8sd OTsrubgSOlVB/2FdI8khSo8xRUYveOZj9SBi4wroAWWtOysvnfrZxSEaDD19fGSQL/jn kR0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oAMsVMJ5ojuElRAFO8g2k9+F8n7UAtFkG7Q8nRVaYlA=; b=lGFZVPXuc8GWFbEwoKiUYn7b3Whspfi9qHzC15fLG4tTVRlRJjtmNIyciB8R6M0VR4 /SGplYaD3VgmzCP+E4xg+F79fsTcTgU5Rod6wrtl15Wm7gZ/NhM+SHdcfV+ofuBG62Ms H9qq5OmTX2po8UNHa+1Prda8zdxfWRfKVPWG/QnDmbgUpVMgun+oYIv9Vsb/+2E3j2/P Q6N3BtUk33ZruknVz1WaTOma/MfLx6/ggRUuMUe5+nih3Ek6zegfrf041hnzuD3Bjf8j ZYEVZA0PrIMWcwX/fwGkh/QtmhwK4U264aq/xsEJV5aHWXPZxZgTzqBcV/hOYWzjin5f KqLA== X-Gm-Message-State: ABuFfojJqBFGlQekqemF8g/ju9ZfqDXQdh4enusrTBdStt0gXM17WfCV vtWtn7U+O07sDyw9+0HADhE= X-Google-Smtp-Source: ACcGV63pClwNNPwIIWFJJiEtdLkINFfNiWIbJZjs61CULMWu68ZXbucpOWBCdUy512kFvMme33irYg== X-Received: by 2002:aa7:8598:: with SMTP id w24-v6mr4423684pfn.77.1538617715916; Wed, 03 Oct 2018 18:48:35 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id k71-v6sm3861045pge.44.2018.10.03.18.48.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 18:48:35 -0700 (PDT) From: Wei Yang To: pbonzini@redhat.com, rkrcmar@redhat.com Cc: x86@kernel.org, kvm@vger.kernel.org, Wei Yang Subject: [Patch v2 1/3] KVM: x86: rename pte_list_remove to __pte_list_remove Date: Thu, 4 Oct 2018 09:48:01 +0800 Message-Id: <20181004014803.94963-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20181004014803.94963-1-richard.weiyang@gmail.com> References: <20180926075853.28715-1-richard.weiyang@gmail.com> <20181004014803.94963-1-richard.weiyang@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is a patch preparing for further change. Signed-off-by: Wei Yang --- arch/x86/kvm/mmu.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 9dca99948e12..834b36737fa2 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -1249,24 +1249,25 @@ pte_list_desc_remove_entry(struct kvm_rmap_head *rmap_head, mmu_free_pte_list_desc(desc); } -static void pte_list_remove(u64 *spte, struct kvm_rmap_head *rmap_head) +static void __pte_list_remove(u64 *spte, struct kvm_rmap_head *rmap_head) { struct pte_list_desc *desc; struct pte_list_desc *prev_desc; int i; if (!rmap_head->val) { - printk(KERN_ERR "pte_list_remove: %p 0->BUG\n", spte); + printk(KERN_ERR "__pte_list_remove: %p 0->BUG\n", spte); BUG(); } else if (!(rmap_head->val & 1)) { - rmap_printk("pte_list_remove: %p 1->0\n", spte); + rmap_printk("__pte_list_remove: %p 1->0\n", spte); if ((u64 *)rmap_head->val != spte) { - printk(KERN_ERR "pte_list_remove: %p 1->BUG\n", spte); + printk(KERN_ERR "__pte_list_remove: %p 1->BUG\n", + spte); BUG(); } rmap_head->val = 0; } else { - rmap_printk("pte_list_remove: %p many->many\n", spte); + rmap_printk("__pte_list_remove: %p many->many\n", spte); desc = (struct pte_list_desc *)(rmap_head->val & ~1ul); prev_desc = NULL; while (desc) { @@ -1280,7 +1281,7 @@ static void pte_list_remove(u64 *spte, struct kvm_rmap_head *rmap_head) prev_desc = desc; desc = desc->more; } - pr_err("pte_list_remove: %p many->many\n", spte); + pr_err("__pte_list_remove: %p many->many\n", spte); BUG(); } } @@ -1333,7 +1334,7 @@ static void rmap_remove(struct kvm *kvm, u64 *spte) sp = page_header(__pa(spte)); gfn = kvm_mmu_page_get_gfn(sp, spte - sp->spt); rmap_head = gfn_to_rmap(kvm, gfn, sp); - pte_list_remove(spte, rmap_head); + __pte_list_remove(spte, rmap_head); } /* @@ -1977,7 +1978,7 @@ static void mmu_page_add_parent_pte(struct kvm_vcpu *vcpu, static void mmu_page_remove_parent_pte(struct kvm_mmu_page *sp, u64 *parent_pte) { - pte_list_remove(parent_pte, &sp->parent_ptes); + __pte_list_remove(parent_pte, &sp->parent_ptes); } static void drop_parent_pte(struct kvm_mmu_page *sp, From patchwork Thu Oct 4 01:48:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10625463 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 90C7E16B1 for ; Thu, 4 Oct 2018 01:48:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FEF128D81 for ; Thu, 4 Oct 2018 01:48:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73D4B28DD0; Thu, 4 Oct 2018 01:48:50 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 2142328D81 for ; Thu, 4 Oct 2018 01:48:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727009AbeJDIjm (ORCPT ); Thu, 4 Oct 2018 04:39:42 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:45410 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726735AbeJDIjm (ORCPT ); Thu, 4 Oct 2018 04:39:42 -0400 Received: by mail-pf1-f195.google.com with SMTP id a23-v6so2527395pfi.12 for ; Wed, 03 Oct 2018 18:48:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=24A7xM5YpXWnOHNY3PZgh1W3mst6s6MWiGeYkvM/U1I=; b=OxZd6RmgwCnFR6ckPHpsC3IHtioGV92mszG109FL1GQDSxHM4xCOZWzfK7K0LTVMRL v+NkCRIFNR0cUH4WYCv3myXEpsQDKmszZlkqVf//jEaBknBNjBE8vWXUA0ilYRvWB0DQ uxpTQHqxm+vP/U+e8GbE9HP8I+pFY1hg6rAuy4fSK21pYrQYMmR/oD0r5QxEY+o/sAp/ E4y/bszZaEAQyPtTWHehMeteEc3X/Qxj1N7AiFzEXioXo4IOrwAa0FVZvXild7TomxJw ibXfH3zM77ud1EP51D+EauRTOYD7e+V2ORaIkAP76LWtFW2SRINlIiXLoUhlDdfA1k4Y N75g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=24A7xM5YpXWnOHNY3PZgh1W3mst6s6MWiGeYkvM/U1I=; b=XDwrysaHsgDUlG1iX216pnpAWYfbCRlSmONrDoE3OHtHx6eGZWDfNw8bddS4ARXwwy N9HWuLXuRFE3C47l6umrY1CyxcpUZHdXwusmS/2rnNQcIFKlbGb95n0X4BiQur+3u7PF ZBTAQFloyzE8lExP7xPiKTYsyMg5z7FQt7PVBdCPdGWsJeO8Nk3ivhpkZEtu9LmcRq1D 3O2K94wbMawwYSwQZy/Kbz6EuTKSn0uMBoss8C8PorInDLK7nSaafT/O/YmvWDaNHJZ3 XM/eV3Zp6cl9MmUdGiiAVpjUYpIQ73HMhPfL76ba1vK3+sAV3iXNRc5qioNf8PyRLQrA be0A== X-Gm-Message-State: ABuFfohCGeZ17EWFpkddQ+WgL/KrXKTMzq2j9nMX66J4EVuls5fjq5Zc BhFhEJw8IqAvz/Ro9tQIdJduYs/u X-Google-Smtp-Source: ACcGV63LHIN8Gvm4fLjJi9nhJqlrZcCRyQdaOtqi+5H+MXQIfXZb0dMafl1/iAx1yhJfsenYju23Pg== X-Received: by 2002:a62:37c1:: with SMTP id e184-v6mr4420424pfa.112.1538617724755; Wed, 03 Oct 2018 18:48:44 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id x186-v6sm4858737pfx.152.2018.10.03.18.48.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 18:48:44 -0700 (PDT) From: Wei Yang To: pbonzini@redhat.com, rkrcmar@redhat.com Cc: x86@kernel.org, kvm@vger.kernel.org, Wei Yang Subject: [Patch v2 2/3] KVM: x86: a new pte_list_remove including mmu_spte_clear_track_bits Date: Thu, 4 Oct 2018 09:48:02 +0800 Message-Id: <20181004014803.94963-3-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20181004014803.94963-1-richard.weiyang@gmail.com> References: <20180926075853.28715-1-richard.weiyang@gmail.com> <20181004014803.94963-1-richard.weiyang@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP rmap_remove() would remove the sptep after locating the correct rmap_head. While in several cases, the caller has already known the correct rmap_head. This patch introduces a new pte_list_remove() which removes sptep directly from rmap_head after clearing the track bits. Since it is for sure the spte is present, it is safe to do the removal. Signed-off-by: Wei Yang --- arch/x86/kvm/mmu.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 834b36737fa2..00853b4d6658 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -1286,6 +1286,12 @@ static void __pte_list_remove(u64 *spte, struct kvm_rmap_head *rmap_head) } } +static void pte_list_remove(struct kvm_rmap_head *rmap_head, u64 *sptep) +{ + mmu_spte_clear_track_bits(sptep); + __pte_list_remove(sptep, rmap_head); +} + static struct kvm_rmap_head *__gfn_to_rmap(gfn_t gfn, int level, struct kvm_memory_slot *slot) { @@ -1670,7 +1676,7 @@ static bool kvm_zap_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head) while ((sptep = rmap_get_first(rmap_head, &iter))) { rmap_printk("%s: spte %p %llx.\n", __func__, sptep, *sptep); - drop_spte(kvm, sptep); + pte_list_remove(rmap_head, sptep); flush = true; } @@ -1706,7 +1712,7 @@ static int kvm_set_pte_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head, need_flush = 1; if (pte_write(*ptep)) { - drop_spte(kvm, sptep); + pte_list_remove(rmap_head, sptep); goto restart; } else { new_spte = *sptep & ~PT64_BASE_ADDR_MASK; @@ -5599,7 +5605,7 @@ static bool kvm_mmu_zap_collapsible_spte(struct kvm *kvm, if (sp->role.direct && !kvm_is_reserved_pfn(pfn) && PageTransCompoundMap(pfn_to_page(pfn))) { - drop_spte(kvm, sptep); + pte_list_remove(rmap_head, sptep); need_tlb_flush = 1; goto restart; } From patchwork Thu Oct 4 01:48:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10625465 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 E63BB16B1 for ; Thu, 4 Oct 2018 01:48:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D59D228D81 for ; Thu, 4 Oct 2018 01:48:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA0DE28DD0; Thu, 4 Oct 2018 01:48:57 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 804ED28D81 for ; Thu, 4 Oct 2018 01:48:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726858AbeJDIjv (ORCPT ); Thu, 4 Oct 2018 04:39:51 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:41951 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726735AbeJDIjv (ORCPT ); Thu, 4 Oct 2018 04:39:51 -0400 Received: by mail-pg1-f195.google.com with SMTP id 23-v6so2366386pgc.8 for ; Wed, 03 Oct 2018 18:48:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=spfwQK7k0PL3HQSwL4FZDE9wrIvfEzpuhHK93i+w2Mc=; b=ukHD/RA+cypcPJhBdw6MiCDL2vOJ5nXPqC8snALF2jTYFywt/0IzrVb/oObp2wXHsn SC3DdUGhFijXhgA9MKQLf/I8b2l7YEjRRNrBUTruttePase/incxZi3342/O/1gfgb2D sSUTSjGm7+2ix6fJ4PlE+CzsmAALSGoycZGD553FKDy2jPOlsTfWp8E09IX1J9N0+xPX a3x1zVB2RepcukGYhORPraJuXIdNhuvEE5OwbnNUjFcbwNzRRPozRQo7WaIa+NFISikH Xui9A5rI9Itb1gv27QzA1f/dvyodYxvi9YjIC89AznGnQ67ry2HcSaINvqpX0N4YTGpd O25Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=spfwQK7k0PL3HQSwL4FZDE9wrIvfEzpuhHK93i+w2Mc=; b=P7g2HnEXXMiXtmaIXxs1k96I5Ie76qtdxiZBcvp1KBfzGluzBU20lyHlGItwQBkQN6 hiDZD6DDRwXbarvYtZBYBF+1mSQb3i2mvrfsIp8G7OE1gFwhRr6wAbhCDbzRIMY5YydJ 86aeAszh58VK2SSgNa/ZV+zdLaUB370YCrsOlbToBamC8qMe+gaj3RjC8U57fbO8j+xa n+SYGkZe0nEsriMzfuCHuPCHqUS3KSrn0IieL+pn8w+RtAWxqi0R6DtbI4xGT+85jaDz 93HrTSWQsSc99TIvmbs32vW4oqLLZ3EkRWo2hAEmMnuUD1JKMyPSO0DVygclsfIlU8rv DDFQ== X-Gm-Message-State: ABuFfoicD1t5CDmpw2rG6TgFafJKqy5KHmh4mNOpTdVVws8X5KufAanp lljeGqc10vtYHYOyk7/Tbh6e4Si0 X-Google-Smtp-Source: ACcGV61n6opCy3/XQscg6B/EAVkAXG4lQPJoTwXyn5YZMg/Uv9u0EAYW97bsS3YkCgTB0CpujXKpoQ== X-Received: by 2002:a62:56c1:: with SMTP id h62-v6mr4342772pfj.107.1538617733888; Wed, 03 Oct 2018 18:48:53 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id n13-v6sm2797729pgr.73.2018.10.03.18.48.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 18:48:53 -0700 (PDT) From: Wei Yang To: pbonzini@redhat.com, rkrcmar@redhat.com Cc: x86@kernel.org, kvm@vger.kernel.org, Wei Yang Subject: [Patch v2 3/3] KVM: x86: extract mmu_spte_clear_track_bits in the loop of kvm_set_pte_rmapp Date: Thu, 4 Oct 2018 09:48:03 +0800 Message-Id: <20181004014803.94963-4-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20181004014803.94963-1-richard.weiyang@gmail.com> References: <20180926075853.28715-1-richard.weiyang@gmail.com> <20181004014803.94963-1-richard.weiyang@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the loop of kvm_set_pte_rmapp(), both branch of if clause would call mmu_spte_clear_track_bits(). * one indirectly by pte_list_remove in *if* branch * one directly in *else* branch This patch extracts this behavior and call it before if clause. Signed-off-by: Wei Yang --- arch/x86/kvm/mmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 00853b4d6658..26269948bf8c 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -1710,9 +1710,10 @@ static int kvm_set_pte_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head, sptep, *sptep, gfn, level); need_flush = 1; + mmu_spte_clear_track_bits(sptep); if (pte_write(*ptep)) { - pte_list_remove(rmap_head, sptep); + __pte_list_remove(sptep, rmap_head); goto restart; } else { new_spte = *sptep & ~PT64_BASE_ADDR_MASK; @@ -1723,7 +1724,6 @@ static int kvm_set_pte_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head, new_spte = mark_spte_for_access_track(new_spte); - mmu_spte_clear_track_bits(sptep); mmu_spte_set(sptep, new_spte); } }