Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1991005imm; Sat, 13 Oct 2018 07:56:38 -0700 (PDT) X-Google-Smtp-Source: ACcGV62lzbhHpZi//ldbrSqHJ9EQFIAXod254aVQQfHf1jg4yzpMQpMBqhW34XekmSgGXuL6Mxc3 X-Received: by 2002:a17:902:740a:: with SMTP id g10-v6mr9987790pll.198.1539442598164; Sat, 13 Oct 2018 07:56:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539442598; cv=none; d=google.com; s=arc-20160816; b=Fqn7e10byEMyLjdanfEdweq+0ziBQ+og9czDwdZ3yEgjDphEQ68z/9E5H0vz3FbXp4 XiuVpsjCO8WdJ34C+7W6Y9Rn92psNe9lH001zONaEHWlzcNhqIuIj4ZS3f0SwELfnqjt oR4QTaFmsakjJQ0bm53XzI3EPfg/j62O98/jlpvP7Mg7QEYWkKQP4pFT8B80KNm2sMey MR9aPWPbvGkoU0iOIbJ1IubiVssWIMFs/lDKI3bBMMgqgAUPNrzGLG7bnIBu9FxUfnoE bgPgCqH4tb8GpDPuW3IzhZuPolHZK/hPhuYOJWcls7Se9+q+5f17LRozLiWu5kEfckDC OyPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:in-reply-to:message-id:date :subject:cc:from:dkim-signature; bh=SLcpsb/KQ3TPJU0d4iQbAvxWnSdRgrbN95f0H43CeAw=; b=THFygYkq/x7htIGeZCyNfGtqTf4HpMhKYj5uwhsSgVoV2tnYExgAy77Ahgs8ghHSVT x9Msdu/Bfkvmz1xRnQ1gogxmW9ly9bEltKteSYzSdhcv2jcaBym9DbXLssNYoqpqNde+ PMtaTsHx74EpNExrcyOkI68LbXawKRE+p4g/yGkfwWgmXAMUSmFbjN6Sjls/VAChaNqz MoKxVECc6Z70v7u+4PpTBM8zyuJZA9ABq3pEgf6mkHN4fhL1D7PnuXn86MbQoQK++J/V /IlnHAGvYavwlKLrSm+L10gvBmjFcjUmVNu/xYg+b8O87iehGyZwlITu5U80kJUPDjV3 esyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=g0VnJccr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o79-v6si4927811pfa.267.2018.10.13.07.56.23; Sat, 13 Oct 2018 07:56:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=g0VnJccr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727123AbeJMWcs (ORCPT + 99 others); Sat, 13 Oct 2018 18:32:48 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:40916 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726281AbeJMWcs (ORCPT ); Sat, 13 Oct 2018 18:32:48 -0400 Received: by mail-pf1-f196.google.com with SMTP id g21-v6so595595pfi.7; Sat, 13 Oct 2018 07:55:22 -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=SLcpsb/KQ3TPJU0d4iQbAvxWnSdRgrbN95f0H43CeAw=; b=g0VnJccrNjfchgaprzW2kceKNmFDUrNGTjAOl/VyJqtgyxnogVSiSug7zaQ3ULIlMW jZ3PlgXOJoIm+kyvI0qA+cVbMiJVn+0kK4CnoWijPOBiBJbP5hOKBPydleYeDJAoK0Oy hyjyA2Xe5LW02ehR0rTuhH34yu+9QTMeAtjj0qsxuBc6Cj/4gpCTNL1wvuZYmCmpwmY9 xF066r3vIO7h4j/hmPWOZcWOI+TJ3+/HUpnt/ktXdyTrftLlDL77vIvpIUBhhE+/NzNM PD7f4kfJIcsTiK2DLx3KYhKGVYPID0hBbipGku1IJZu4cELZrWGhqDCdSRq9gZLmhFpa gOag== 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=SLcpsb/KQ3TPJU0d4iQbAvxWnSdRgrbN95f0H43CeAw=; b=tbi/QL2QwVspHDcYN6lij2kjKm+AXmcWxjJNE/4u3lHq+RqH8VcUf6lFzoQ3ZTwFkb emSDXpgPAk5khss4FFZ369jsRoaa2b8X1Quc9UTQw6KJaodPYT4Xdexjp+mmShCNB8PO nzvWL7/MWj0FBMZNS65WPSQ3+dOzXa8Hd6ZvjNyCR0L/u1dBKUbvzvUmFyU47WkStVwL gtHi/I3EiNb0A2pxOFFNXc0dKVpcOTAh28GswwTNSFv3GWWkNvzZbSLKB1Jo5tjhej7x Jj8UCRc8Pi88v72cVL8Bo/lc6rRjdJB5bU/BS5eSzrQYP/hQouSlvxd8nl3rWzMmtMua gLHg== X-Gm-Message-State: ABuFfoize7OjD2SDlpNB7jEi/bB9VCKyxA2zOyGyshPb/EAQRjECkCeM MRJUXo6ekn795k6twOuIoGU= X-Received: by 2002:a63:c044:: with SMTP id z4-v6mr9479108pgi.274.1539442521805; Sat, 13 Oct 2018 07:55:21 -0700 (PDT) Received: from localhost.corp.microsoft.com ([2404:f801:9000:18:d9bf:62c6:740b:9fc4]) by smtp.googlemail.com with ESMTPSA id v81-v6sm8688724pfj.25.2018.10.13.07.55.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 13 Oct 2018 07:55:21 -0700 (PDT) From: lantianyu1986@gmail.com X-Google-Original-From: Tianyu.Lan@microsoft.com Cc: Lan Tianyu , kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, pbonzini@redhat.com, rkrcmar@redhat.com, devel@linuxdriverproject.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, michael.h.kelley@microsoft.com, vkuznets@redhat.com Subject: [PATCH V4 10/15] KVM: Add spte's point in the struct kvm_mmu_page Date: Sat, 13 Oct 2018 22:54:01 +0800 Message-Id: <20181013145406.4911-11-Tianyu.Lan@microsoft.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20181013145406.4911-1-Tianyu.Lan@microsoft.com> References: <20181013145406.4911-1-Tianyu.Lan@microsoft.com> To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lan Tianyu It's necessary to check whether mmu page is last or large page when add mmu page into flush list. "spte" is needed for such check and so add spte point in the struct kvm_mmu_page. Signed-off-by: Lan Tianyu --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/mmu.c | 5 +++++ arch/x86/kvm/paging_tmpl.h | 2 ++ 3 files changed, 8 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 8279235285f8..c986ebefc9ac 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -333,6 +333,7 @@ struct kvm_mmu_page { int root_count; /* Currently serving as active root */ unsigned int unsync_children; struct kvm_rmap_head parent_ptes; /* rmap pointers to parent sptes */ + u64 *sptep; /* The page is obsolete if mmu_valid_gen != kvm->arch.mmu_valid_gen. */ unsigned long mmu_valid_gen; diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index e984a0067a43..393f4048dd7a 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -3165,6 +3165,7 @@ static int __direct_map(struct kvm_vcpu *vcpu, int write, int map_writable, pseudo_gfn = base_addr >> PAGE_SHIFT; sp = kvm_mmu_get_page(vcpu, pseudo_gfn, iterator.addr, iterator.level - 1, 1, ACC_ALL); + sp->sptep = iterator.sptep; link_shadow_page(vcpu, iterator.sptep, sp); } @@ -3602,6 +3603,7 @@ static int mmu_alloc_direct_roots(struct kvm_vcpu *vcpu) sp = kvm_mmu_get_page(vcpu, 0, 0, vcpu->arch.mmu->shadow_root_level, 1, ACC_ALL); ++sp->root_count; + sp->sptep = NULL; spin_unlock(&vcpu->kvm->mmu_lock); vcpu->arch.mmu->root_hpa = __pa(sp->spt); } else if (vcpu->arch.mmu->shadow_root_level == PT32E_ROOT_LEVEL) { @@ -3618,6 +3620,7 @@ static int mmu_alloc_direct_roots(struct kvm_vcpu *vcpu) i << 30, PT32_ROOT_LEVEL, 1, ACC_ALL); root = __pa(sp->spt); ++sp->root_count; + sp->sptep = NULL; spin_unlock(&vcpu->kvm->mmu_lock); vcpu->arch.mmu->pae_root[i] = root | PT_PRESENT_MASK; } @@ -3658,6 +3661,7 @@ static int mmu_alloc_shadow_roots(struct kvm_vcpu *vcpu) vcpu->arch.mmu->shadow_root_level, 0, ACC_ALL); root = __pa(sp->spt); ++sp->root_count; + sp->sptep = NULL; spin_unlock(&vcpu->kvm->mmu_lock); vcpu->arch.mmu->root_hpa = root; return 0; @@ -3695,6 +3699,7 @@ static int mmu_alloc_shadow_roots(struct kvm_vcpu *vcpu) 0, ACC_ALL); root = __pa(sp->spt); ++sp->root_count; + sp->sptep = NULL; spin_unlock(&vcpu->kvm->mmu_lock); vcpu->arch.mmu->pae_root[i] = root | pm_mask; diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 6bdca39829bc..833e8855bbc9 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h @@ -633,6 +633,7 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, table_gfn = gw->table_gfn[it.level - 2]; sp = kvm_mmu_get_page(vcpu, table_gfn, addr, it.level-1, false, access); + sp->sptep = it.sptep; } /* @@ -663,6 +664,7 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, sp = kvm_mmu_get_page(vcpu, direct_gfn, addr, it.level-1, true, direct_access); + sp->sptep = it.sptep; link_shadow_page(vcpu, it.sptep, sp); } -- 2.14.4