From patchwork Sun May 19 04:52:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nakajima, Jun" X-Patchwork-Id: 2589651 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 7E4553FD4E for ; Sun, 19 May 2013 04:52:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751379Ab3ESEws (ORCPT ); Sun, 19 May 2013 00:52:48 -0400 Received: from mail-pb0-f53.google.com ([209.85.160.53]:49964 "EHLO mail-pb0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751180Ab3ESEwl (ORCPT ); Sun, 19 May 2013 00:52:41 -0400 Received: by mail-pb0-f53.google.com with SMTP id un1so4428886pbc.12 for ; Sat, 18 May 2013 21:52:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=DoAZfIwKx1ymgapR8WkTv9RjFhNfPHs1XzYH4ge15JM=; b=FhmSu1FcbiFBz652GHYmvC22hdapD64Ewag3twPpiBytkAbCmaZ3DrQI66uNtfdi2H uIEVfNXSiCCbkMpHEpxpgBdfziYnenjY+syJKWqM6tOaFlu4S8lNTq4Kx6vP/jqZXQoB TxpFMFULn792zvn6tLtioRe4bn7m6chlJZn+6FVjqdOCr9rL+H2KQ2emjkjAkmQfSErU JxifxdZUx/SGbRKUmeQdvoVmpE4gfSLv1jQ8YIRhyiQrC5Ra83l+tIIHe9LAyV+PnSPt CSP6VlT7Gf/0vc9n/V4l3ZEVEqCqnHCNZFSC5py4Cs01XW4wzVcAqMzqeLdj12zJAgvt TLFg== X-Received: by 10.66.102.97 with SMTP id fn1mr28660961pab.116.1368939161046; Sat, 18 May 2013 21:52:41 -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 xl10sm19601448pac.15.2013.05.18.21.52.39 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 18 May 2013 21:52:40 -0700 (PDT) From: Jun Nakajima To: kvm@vger.kernel.org Cc: Gleb Natapov , Paolo Bonzini Subject: [PATCH v3 04/13] nEPT: Define EPT-specific link_shadow_page() Date: Sat, 18 May 2013 21:52:23 -0700 Message-Id: <1368939152-11406-4-git-send-email-jun.nakajima@intel.com> X-Mailer: git-send-email 1.8.2.1.610.g562af5b In-Reply-To: <1368939152-11406-1-git-send-email-jun.nakajima@intel.com> References: <1368939152-11406-1-git-send-email-jun.nakajima@intel.com> X-Gm-Message-State: ALoCoQnHoh5aEXk7yKM+YWNic4fJlWQDUkKrP39RJaZLlNPYROq8IQa+nmhjlXv6KwJHleQEUCWc Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nadav Har'El 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);