From patchwork Tue Jun 20 09:15:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 9798913 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 646DC601BC for ; Tue, 20 Jun 2017 09:17:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AC222810E for ; Tue, 20 Jun 2017 09:17:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F4552847B; Tue, 20 Jun 2017 09:17:07 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A93D12810E for ; Tue, 20 Jun 2017 09:17:06 +0000 (UTC) Received: from localhost ([::1]:47448 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNFHU-00007b-Vp for patchwork-qemu-devel@patchwork.kernel.org; Tue, 20 Jun 2017 05:17:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52906) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNFGG-00007T-3i for qemu-devel@nongnu.org; Tue, 20 Jun 2017 05:15:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNFGD-0007lw-Fy for qemu-devel@nongnu.org; Tue, 20 Jun 2017 05:15:48 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:35616) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNFGD-0007lb-Aj for qemu-devel@nongnu.org; Tue, 20 Jun 2017 05:15:45 -0400 Received: by mail-pf0-x242.google.com with SMTP id s66so21597948pfs.2 for ; Tue, 20 Jun 2017 02:15: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=vZcoCSc9WxvlHIjp0cOrhqNjJq3cwt7Hl0zsOxg0HAo=; b=QTe+27rdxkvWcJ1oM9DvO1oKZ6Yl8+wIXT7vZ8oDXv3Z4x7IlAfdQ+eNlD4kGbHejP e78HoP1204kSAB6yLgTPWi31nRI2SndH3bC8NSTgFKabaNZank0qKY7hq/7sXzqGYB0/ qrKRauFzIeNN8sBvEoYCU1U/N3pkEqjjrhcBnsFTqUiIvJS1wlfd7a0rJAs4wBOKv4Vw 5PRhXyDlozK+8pAUPuK042J2StoK4s+s+HO/NNKoX4mrMKQrsHvkUwIqbSRuqSRphuNB 6RBDgpthDh6pAMFHzsR/ubDM+4n6AOZqFSuLhV3fgB61137+RMpAJ028LwtZXiyfXzW/ yf4w== 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=vZcoCSc9WxvlHIjp0cOrhqNjJq3cwt7Hl0zsOxg0HAo=; b=Cpn2cNMAo6g398rILgGhrhysVBi9fE48lLKTyc9miucjNljWrH9TVEI4NRjBiPxUgr LlBrdFB63coBIkphT8/FYEwbKyyg1FXWezUn1QFfX6+h7cF95rnvwwLeuVWsMPcxQnoN yath3r4UHy//WO3ODhpWwhrx8NwKVnnRwkd3XnNaRqOfB6zzbsvrzZYyI9P91/HNAYLS V6Oe15aRd9nRF6aCUO7LYYfsL5VQ0onhLuczk4An/Z9UcILCgDhX2rjQxwdmu6JcLJjK JNqmCtwZ5hYPoLJKOsqI+Kx+j92HxEjqSGVNr3Cr3il38/VrA8fCsqx7knjUtN/Trd5r eYdw== X-Gm-Message-State: AKS2vOzp1gLwg/R2+h65B4UZ/MAjX3cQAJoFaFXyg3GgGopjUFcQVPim CWPVXMiwJkVpfw== X-Received: by 10.98.198.201 with SMTP id x70mr26971619pfk.232.1497950144608; Tue, 20 Jun 2017 02:15:44 -0700 (PDT) Received: from eric.tencent.com ([203.205.141.35]) by smtp.gmail.com with ESMTPSA id o12sm26343810pfi.9.2017.06.20.02.15.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Jun 2017 02:15:44 -0700 (PDT) From: guangrong.xiao@gmail.com X-Google-Original-From: xiaoguangrong@tencent.com To: pbonzini@redhat.com, mtosatti@redhat.com, avi.kivity@gmail.com, rkrcmar@redhat.com Date: Tue, 20 Jun 2017 17:15:20 +0800 Message-Id: <20170620091526.4287-2-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170620091526.4287-1-xiaoguangrong@tencent.com> References: <20170620091526.4287-1-xiaoguangrong@tencent.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v2 1/7] KVM: MMU: correct the behavior of mmu_spte_update_no_track X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Xiao Guangrong , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Xiao Guangrong Current behavior of mmu_spte_update_no_track() does not match the name of _no_track() as actually the A/D bits are tracked and returned to the caller This patch introduces the real _no_track() function to update the spte regardless of A/D bits and rename the original function to _track() The _no_track() function will be used by later patches to update upper spte which need not care of A/D bits indeed Signed-off-by: Xiao Guangrong --- arch/x86/kvm/mmu.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 5d3376f..d18c17c 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -583,10 +583,29 @@ static void mmu_spte_set(u64 *sptep, u64 new_spte) } /* - * Update the SPTE (excluding the PFN), but do not track changes in its + * Update the SPTE (excluding the PFN) regardless of accessed/dirty + * status which is used to update the upper level spte. + */ +static void mmu_spte_update_no_track(u64 *sptep, u64 new_spte) +{ + u64 old_spte = *sptep; + + WARN_ON(!is_shadow_present_pte(new_spte)); + + if (!is_shadow_present_pte(old_spte)) { + mmu_spte_set(sptep, new_spte); + return; + } + + __update_clear_spte_fast(sptep, new_spte); +} + +/* + * Update the SPTE (excluding the PFN), the original value is + * returned, based on it, the caller can track changes of its * accessed/dirty status. */ -static u64 mmu_spte_update_no_track(u64 *sptep, u64 new_spte) +static u64 mmu_spte_update_track(u64 *sptep, u64 new_spte) { u64 old_spte = *sptep; @@ -621,7 +640,7 @@ static u64 mmu_spte_update_no_track(u64 *sptep, u64 new_spte) static bool mmu_spte_update(u64 *sptep, u64 new_spte) { bool flush = false; - u64 old_spte = mmu_spte_update_no_track(sptep, new_spte); + u64 old_spte = mmu_spte_update_track(sptep, new_spte); if (!is_shadow_present_pte(old_spte)) return false;