From patchwork Mon May 6 07:04: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: 2522861 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 1B4AEE014A for ; Mon, 6 May 2013 07:04:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752867Ab3EFHEo (ORCPT ); Mon, 6 May 2013 03:04:44 -0400 Received: from mail-pb0-f44.google.com ([209.85.160.44]:43442 "EHLO mail-pb0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752817Ab3EFHEm (ORCPT ); Mon, 6 May 2013 03:04:42 -0400 Received: by mail-pb0-f44.google.com with SMTP id wz17so1845529pbc.17 for ; Mon, 06 May 2013 00:04:42 -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=SeX4q+GCNQkg+FkDoblR41eQbhW6P2vtWuXwDRZDWDY=; b=EWWINpm+wk3/gkAIYK2Ph9Bha72PunXAF4byv1OD83wLI2t7P8g3fEuVwGaezCSter lW0Evg1tm5YmQ+4j+h5gZ2wtsa45BzP2LIA31i02JdPQOzees0A4JvJX7dEINu6ewUW5 EEXdt5Fhwz5hNBJrpW8oDYwpYARIVbXxWR4R2mjESvM/X7NiiuwE2RXKwIXtV5YBz6MF aGKdgv+Q0S76Mgld+djyGWX9FnFzz7X+r+yJd0muM93LWW31HFm03e1QHiGFJeiUFpiO h5Z1bZRCH+VfuhYibPn8JTquUub6axyLP5vFE68QrVlb5vNep/b9wheX/jysCgFXFpmJ 7U3A== X-Received: by 10.68.231.65 with SMTP id te1mr24513677pbc.98.1367823882218; Mon, 06 May 2013 00:04:42 -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 at4sm22705543pbc.40.2013.05.06.00.04.40 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 06 May 2013 00:04:41 -0700 (PDT) From: Jun Nakajima To: kvm@vger.kernel.org Subject: [PATCH v2 04/13] nEPT: Define EPT-specific link_shadow_page() Date: Mon, 6 May 2013 00:04:23 -0700 Message-Id: <1367823872-25895-4-git-send-email-jun.nakajima@intel.com> X-Mailer: git-send-email 1.8.2.1.610.g562af5b In-Reply-To: <1367823872-25895-3-git-send-email-jun.nakajima@intel.com> References: <1367823872-25895-1-git-send-email-jun.nakajima@intel.com> <1367823872-25895-2-git-send-email-jun.nakajima@intel.com> <1367823872-25895-3-git-send-email-jun.nakajima@intel.com> X-Gm-Message-State: ALoCoQlOH6l567X/eQK/LPdMwMSrafZdM7FYWZKr0Ojgg1kw7cKrMb3xgaOcVPLMHejn+em552vY 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 5644f61..51dca23 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);