From patchwork Thu May 9 00:53:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nakajima, Jun" X-Patchwork-Id: 2542401 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id E1FA3DF2E5 for ; Thu, 9 May 2013 00:53:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754792Ab3EIAxd (ORCPT ); Wed, 8 May 2013 20:53:33 -0400 Received: from mail-pb0-f52.google.com ([209.85.160.52]:37152 "EHLO mail-pb0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752619Ab3EIAxb (ORCPT ); Wed, 8 May 2013 20:53:31 -0400 Received: by mail-pb0-f52.google.com with SMTP id xa7so1590911pbc.25 for ; Wed, 08 May 2013 17:53:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=G407Mt8pv30kPxVxbyZZVWJ0WlxudIZxXO9742ySa1A=; b=m3ItslLvpbak8ECM5oO/0d36WdSxw30tV1zJ4PxvnL/6L6UmTiI34JJHeRT3L8/iGT bNuKE4vSG94gdGuOHEZFCheGigKlP6TguOz9+ZizumJlSSf6i6jA6Yu2asfWt90/Kafn WGWoR+lKTwnBDOxd2AEAfL0rMeYjAUQm6d87ta9C4CeYYQlGSc8yUIj292eDZJOQVvOI BrP0zr610FA3G0vqrvetPkIpuzwQO3WU9o5DFfoW88KqyDypTYUqCxy2ZiPpn1WtS9lF 4vNKJAJlSuOCySe3Ua9+EAAHeXdt4V2VIl5+HdU/5VbGNsDv9WO6BqP0WmKcZ7mCuQL2 H80Q== X-Received: by 10.66.149.170 with SMTP id ub10mr10608847pab.58.1368060811101; Wed, 08 May 2013 17:53:31 -0700 (PDT) Received: from localhost (c-98-207-34-191.hsd1.ca.comcast.net. [98.207.34.191]) by mx.google.com with ESMTPSA id nt2sm728084pbc.17.2013.05.08.17.53.29 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 08 May 2013 17:53:30 -0700 (PDT) From: Jun Nakajima To: kvm@vger.kernel.org Subject: [PATCH v3 04/13] nEPT: Define EPT-specific link_shadow_page() Date: Wed, 8 May 2013 17:53:16 -0700 Message-Id: <1368060805-2790-4-git-send-email-jun.nakajima@intel.com> X-Mailer: git-send-email 1.8.2.1.610.g562af5b In-Reply-To: <1368060805-2790-3-git-send-email-jun.nakajima@intel.com> References: <1368060805-2790-1-git-send-email-jun.nakajima@intel.com> <1368060805-2790-2-git-send-email-jun.nakajima@intel.com> <1368060805-2790-3-git-send-email-jun.nakajima@intel.com> X-Gm-Message-State: ALoCoQnd02zb8UdKEmq+e5B4kZFo9HjeFrZPT2F4+IeejXb7+WL+bRLls3tomZGI+pIb4tjHgBrf Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Since link_shadow_page() is used by a routine in mmu.c, add an EPT-specific link_shadow_page() in paging_tmp.h, rather than moving it. Signed-off-by: Nadav Har'El Signed-off-by: Jun Nakajima Signed-off-by: Xinhao Xu --- arch/x86/kvm/paging_tmpl.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 4c45654..dc495f9 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h @@ -461,6 +461,18 @@ static void FNAME(pte_prefetch)(struct kvm_vcpu *vcpu, struct guest_walker *gw, } } +#if PTTYPE == PTTYPE_EPT +static void FNAME(link_shadow_page)(u64 *sptep, struct kvm_mmu_page *sp) +{ + u64 spte; + + spte = __pa(sp->spt) | VMX_EPT_READABLE_MASK | VMX_EPT_WRITABLE_MASK | + VMX_EPT_EXECUTABLE_MASK; + + mmu_spte_set(sptep, spte); +} +#endif + /* * Fetch a shadow pte for a specific level in the paging hierarchy. * If the guest tries to write a write-protected page, we need to @@ -513,7 +525,11 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, goto out_gpte_changed; if (sp) +#if PTTYPE == PTTYPE_EPT + FNAME(link_shadow_page)(it.sptep, sp); +#else link_shadow_page(it.sptep, sp); +#endif } for (; @@ -533,7 +549,11 @@ 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, it.sptep); +#if PTTYPE == PTTYPE_EPT + FNAME(link_shadow_page)(it.sptep, sp); +#else link_shadow_page(it.sptep, sp); +#endif } clear_sp_write_flooding_count(it.sptep);