From patchwork Wed May 3 10:52:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 9709359 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 F05C760351 for ; Wed, 3 May 2017 10:53:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E205328427 for ; Wed, 3 May 2017 10:53:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D65EB285E9; Wed, 3 May 2017 10:53:41 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable 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 9256628427 for ; Wed, 3 May 2017 10:53:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753576AbdECKxW (ORCPT ); Wed, 3 May 2017 06:53:22 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:35145 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751280AbdECKxI (ORCPT ); Wed, 3 May 2017 06:53:08 -0400 Received: by mail-pg0-f65.google.com with SMTP id i63so8305496pgd.2; Wed, 03 May 2017 03:53:07 -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=bE892JZRUzoSj0VrefTDrj45cFJ2Kapg9kWCvXU2yV4=; b=fkboN+cD99opXF5qY6wRpYT1yXQBrv7zuwykkGw+AZSUIXyRBEjLC9Rlv/GTye4hAC i4dHSXaZUIchWQZMCejUsglxzR9KB6N2cBkwgDBrR0mfKyJqiVMPIpxub9zp+HNhriI9 S60NW+pAQ2Peg8Xq/YP88xCO20YC+DGKqJE2dVPSAGiTJqxs+Uuzgtnu32JApxHQlqIs fbPgj1/Bj7In19a0bAR4eR2VNVv2qoWt6djJvwis0/Suz9wZFbpWqgOsWE/C4TbU2slR lZT93hppq0OYEcsVPWsH2aQQ7PFGfxmHMyjVo2o3ikZyvOpQgWVplouflQ1HomfHvNwi DPmA== 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=bE892JZRUzoSj0VrefTDrj45cFJ2Kapg9kWCvXU2yV4=; b=tmroTBgcVyj+rTNS1OiQq2nlcvRJQ6UtXlmd5FPOVWd3rITIgdaxSOJllMgjqCFjNO U0vL6Z18cYkPDr5kB/wYde2u4HYGN4GXyVD80qdzE6+BA/2/P4XmACvbaTug6Pv5xN3R ZNR+gVV02Ma4XlPX/GEWSsHNtLYC+w2ZudIUa6cL+A9rQG87hzOuWB65LetpYgIEGsLd awFDLx5f8bVG7aKW33gfBe0xetNaob5gq9HSwuivF9ro2d1Et+0ZqgSfQy9c1YByB+Km RwO0mvp7hdEZp+DqnkXH/lFx6ZQbmDeEhlDL4MZREC4/aQP5djXhX6RemVDut/pIynmW PqrQ== X-Gm-Message-State: AN3rC/62wf1YDL6i+aIqB33pBXdO+yqYTbfgav2jvJs5ouyhm6fefWd8 7Acq9StUSVuL2A== X-Received: by 10.84.241.136 with SMTP id b8mr48610500pll.107.1493808787378; Wed, 03 May 2017 03:53:07 -0700 (PDT) Received: from eric.tencent.com ([203.205.141.35]) by smtp.gmail.com with ESMTPSA id d24sm4395561pfb.97.2017.05.03.03.53.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 May 2017 03:53:06 -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 Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, qemu-devel@nongnu.org, Xiao Guangrong Subject: [PATCH 1/7] KVM: MMU: correct the behavior of mmu_spte_update_no_track Date: Wed, 3 May 2017 18:52:18 +0800 Message-Id: <20170503105224.19049-2-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170503105224.19049-1-xiaoguangrong@tencent.com> References: <20170503105224.19049-1-xiaoguangrong@tencent.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 5586765..ba8e7af 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;