From patchwork Thu Nov 10 23:45:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Lai X-Patchwork-Id: 9422251 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 C5B8660484 for ; Thu, 10 Nov 2016 23:46:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCFA729858 for ; Thu, 10 Nov 2016 23:46:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1EDC2985B; Thu, 10 Nov 2016 23:46:29 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AC0132985A for ; Thu, 10 Nov 2016 23:46:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c4z0k-0005lH-HA; Thu, 10 Nov 2016 23:44:02 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c4z0i-0005ke-JR for xen-devel@lists.xensource.com; Thu, 10 Nov 2016 23:44:00 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id 30/60-15840-04605285; Thu, 10 Nov 2016 23:44:00 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprGIsWRWlGSWpSXmKPExsXS1taRomvPphp h8PUkr8W9Ke/ZHRg9tvftYg9gjGLNzEvKr0hgzZi8eilrwU/NiraFR5gaGF8odjFycggJVEhc O7qVGcSWEOCVOLJsBmsXIweQ7SexbL4ETMmxzj1AYS4gezmjxKFzS9kgEiUSd6Z8BOtlE1CVW H5uEiOILSKgKLFu9TsWEJtZIE1i7aYvYPXCAkESM34dZgexWYDqlz7oYgLZxSvgLNF0LR7iBD mJm+c6wUZyCrhIPLzzgxVilbPEyqPfmScw8i9gZFjFqFGcWlSWWqRraKaXVJSZnlGSm5iZo2t oYKyXm1pcnJiempOYVKyXnJ+7iREYOgxAsINx1XbPQ4ySHExKoryK01UihPiS8lMqMxKLM+KL SnNSiw8xynBwKEnwXmZRjRASLEpNT61Iy8wBBjFMWoKDR0mEV4kVKM1bXJCYW5yZDpE6xWjM8 WbXywdMHHtmvXrAJMSSl5+XKiXOOxNkkgBIaUZpHtwgWHRdYpSVEuZlBDpNiKcgtSg3swRV/h WjOAejkjDvV5ApPJl5JXD7XgGdwgR0yow4FZBTShIRUlINjEKHFq7YP8NszdvVwr4eDmrTFz1 a/cD73fSTu/QV2X749h30aVU+cCJRxEa5/UGXzony7x8LMrb1G67Ms90k1Bus65UQr2Do49zl w59k784267GxHXuzpEg5WwpfULzui422c6paf2ubrhB4/iBifp1C4d7riw7usZv9bu/+yMdH1 CpOP+j9psRSnJFoqMVcVJwIAOomlzepAgAA X-Env-Sender: pclai@intel.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1478821434!12254751!2 X-Originating-IP: [134.134.136.100] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.0.13; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31589 invoked from network); 10 Nov 2016 23:43:57 -0000 Received: from mga07.intel.com (HELO mga07.intel.com) (134.134.136.100) by server-4.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 10 Nov 2016 23:43:57 -0000 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP; 10 Nov 2016 15:43:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,620,1473145200"; d="scan'208";a="29918930" Received: from scymds02.sc.intel.com ([10.82.195.37]) by orsmga004.jf.intel.com with ESMTP; 10 Nov 2016 15:43:54 -0800 Received: from pclaidev.sc.intel.com (pclaidev.sc.intel.com [143.183.85.157]) by scymds02.sc.intel.com with ESMTP id uAANhsWR016919; Thu, 10 Nov 2016 15:43:54 -0800 Received: by pclaidev.sc.intel.com (Postfix, from userid 1002) id BCC65204A6; Thu, 10 Nov 2016 15:45:52 -0800 (PST) From: Paul Lai To: xen-devel@lists.xensource.com Date: Thu, 10 Nov 2016 15:45:52 -0800 Message-Id: <1478821552-1497-4-git-send-email-paul.c.lai@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1478821552-1497-1-git-send-email-paul.c.lai@intel.com> References: <1478821552-1497-1-git-send-email-paul.c.lai@intel.com> Cc: ravi.sahita@intel.com, george.dunlap@citrix.com, jbeulich@suse.com Subject: [Xen-devel] [PATCH Altp2m cleanup 2/3 v12 3/3] Moving ept code to ept specific files. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The was requested in: https://lists.xenproject.org/archives/html/xen-devel/2015-07/msg04323.html Renamed p2m_init_altp2m_helper() to p2m_init_altp2m_ept(). Signed-off-by: Paul Lai Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: George Dunlap --- xen/arch/x86/mm/p2m-ept.c | 39 +++++++++++++++++++++++++++++++++++ xen/arch/x86/mm/p2m.c | 43 ++------------------------------------- xen/include/asm-x86/hvm/vmx/vmx.h | 3 +++ xen/include/asm-x86/p2m.h | 9 +++----- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index 13cab24..04878f5 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -1329,6 +1329,45 @@ void setup_ept_dump(void) register_keyhandler('D', ept_dump_p2m_table, "dump VT-x EPT tables", 0); } +void p2m_init_altp2m_ept(struct domain *d, unsigned int i) +{ + struct p2m_domain *p2m = d->arch.altp2m_p2m[i]; + struct ept_data *ept; + + p2m->min_remapped_gfn = gfn_x(INVALID_GFN); + p2m->max_remapped_gfn = 0; + ept = &p2m->ept; + ept->asr = pagetable_get_pfn(p2m_get_pagetable(p2m)); + d->arch.altp2m_eptp[i] = ept_get_eptp(ept); +} + +unsigned int p2m_find_altp2m_by_eptp(struct domain *d, uint64_t eptp) +{ + struct p2m_domain *p2m; + struct ept_data *ept; + unsigned int i; + + altp2m_list_lock(d); + + for ( i = 0; i < MAX_ALTP2M; i++ ) + { + if ( d->arch.altp2m_eptp[i] == mfn_x(INVALID_MFN) ) + continue; + + p2m = d->arch.altp2m_p2m[i]; + ept = &p2m->ept; + + if ( eptp == ept_get_eptp(ept) ) + goto out; + } + + i = INVALID_ALTP2M; + + out: + altp2m_list_unlock(d); + return i; +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 6a45185..aa627d8 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -2342,33 +2342,6 @@ int unmap_mmio_regions(struct domain *d, return i == nr ? 0 : i ?: ret; } -unsigned int p2m_find_altp2m_by_eptp(struct domain *d, uint64_t eptp) -{ - struct p2m_domain *p2m; - struct ept_data *ept; - unsigned int i; - - altp2m_list_lock(d); - - for ( i = 0; i < MAX_ALTP2M; i++ ) - { - if ( d->arch.altp2m_eptp[i] == mfn_x(INVALID_MFN) ) - continue; - - p2m = d->arch.altp2m_p2m[i]; - ept = &p2m->ept; - - if ( eptp == ept_get_eptp(ept) ) - goto out; - } - - i = INVALID_ALTP2M; - - out: - altp2m_list_unlock(d); - return i; -} - bool_t p2m_switch_vcpu_altp2m_by_id(struct vcpu *v, unsigned int idx) { struct domain *d = v->domain; @@ -2474,18 +2447,6 @@ void p2m_flush_altp2m(struct domain *d) altp2m_list_unlock(d); } -static void p2m_init_altp2m_helper(struct domain *d, unsigned int i) -{ - struct p2m_domain *p2m = d->arch.altp2m_p2m[i]; - struct ept_data *ept; - - p2m->min_remapped_gfn = gfn_x(INVALID_GFN); - p2m->max_remapped_gfn = 0; - ept = &p2m->ept; - ept->asr = pagetable_get_pfn(p2m_get_pagetable(p2m)); - d->arch.altp2m_eptp[i] = ept_get_eptp(ept); -} - int p2m_init_altp2m_by_id(struct domain *d, unsigned int idx) { int rc = -EINVAL; @@ -2497,7 +2458,7 @@ int p2m_init_altp2m_by_id(struct domain *d, unsigned int idx) if ( d->arch.altp2m_eptp[idx] == mfn_x(INVALID_MFN) ) { - p2m_init_altp2m_helper(d, idx); + p2m_init_altp2m_ept(d, idx); rc = 0; } @@ -2517,7 +2478,7 @@ int p2m_init_next_altp2m(struct domain *d, uint16_t *idx) if ( d->arch.altp2m_eptp[i] != mfn_x(INVALID_MFN) ) continue; - p2m_init_altp2m_helper(d, i); + p2m_init_altp2m_ept(d, i); *idx = i; rc = 0; diff --git a/xen/include/asm-x86/hvm/vmx/vmx.h b/xen/include/asm-x86/hvm/vmx/vmx.h index 4cdd9b1..9f4c7de 100644 --- a/xen/include/asm-x86/hvm/vmx/vmx.h +++ b/xen/include/asm-x86/hvm/vmx/vmx.h @@ -561,6 +561,9 @@ void ept_p2m_uninit(struct p2m_domain *p2m); void ept_walk_table(struct domain *d, unsigned long gfn); bool_t ept_handle_misconfig(uint64_t gpa); void setup_ept_dump(void); +void p2m_init_altp2m_ept(struct domain *d, unsigned int i); +/* Locate an alternate p2m by its EPTP */ +unsigned int p2m_find_altp2m_by_eptp(struct domain *d, uint64_t eptp); void update_guest_eip(void); diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 7035860..0e72880 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -23,8 +23,8 @@ * along with this program; If not, see . */ -#ifndef _XEN_P2M_H -#define _XEN_P2M_H +#ifndef _XEN_ASM_X86_P2M_H +#define _XEN_ASM_X86_P2M_H #include #include @@ -784,9 +784,6 @@ static inline struct p2m_domain *p2m_get_altp2m(struct vcpu *v) return v->domain->arch.altp2m_p2m[index]; } -/* Locate an alternate p2m by its EPTP */ -unsigned int p2m_find_altp2m_by_eptp(struct domain *d, uint64_t eptp); - /* Switch alternate p2m for a single vcpu */ bool_t p2m_switch_vcpu_altp2m_by_id(struct vcpu *v, unsigned int idx); @@ -848,7 +845,7 @@ static inline unsigned int p2m_get_iommu_flags(p2m_type_t p2mt) return flags; } -#endif /* _XEN_P2M_H */ +#endif /* _XEN_ASM_X86_P2M_H */ /* * Local variables: