From patchwork Tue Oct 11 23:40:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Lai X-Patchwork-Id: 9371863 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 F24AF60865 for ; Tue, 11 Oct 2016 23:40:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E360728FD2 for ; Tue, 11 Oct 2016 23:40:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D60652911D; Tue, 11 Oct 2016 23:40:36 +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 5543D28FD4 for ; Tue, 11 Oct 2016 23:40:36 +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 1bu6ca-0007Gw-8O; Tue, 11 Oct 2016 23:38:08 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bu6cZ-0007Gk-KD for xen-devel@lists.xensource.com; Tue, 11 Oct 2016 23:38:07 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id 5B/55-21986-ED77DF75; Tue, 11 Oct 2016 23:38:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmplkeJIrShJLcpLzFFi42Jpa+sQ0b1b/jf c4MFNM4t7U96zOzB6bO/bxR7AGMWamZeUX5HAmtG5QbTgo3TFu2+bGRsYb4t2MXJyCAlUSnzf /JQVxJYQ4JU4smwGlB0gsf7hdCaImgqJ5v2rmLsYuYDsZYwS77pa2CASJRK9jSeYQWw2AVWJ5 ecmMYLYIgKKEutWv2MBsZkF0iTWbvrCBtIsLPCKUWL74RtgRSxADV9vdIEV8Qo4S/x4PA9qs5 zEzXOdYEM5BVwkDq35BnQFB9AyZ4npU+QnMPIvYGRYxahRnFpUllqka2yol1SUmZ5RkpuYmaN raGCml5taXJyYnpqTmFSsl5yfu4kRGDwMQLCDsWlR4CFGSQ4mJVHeXL6/4UJ8SfkplRmJxRnx RaU5qcWHGGU4OJQkeA+UAeUEi1LTUyvSMnOAYQyTluDgURLh3QGS5i0uSMwtzkyHSJ1iVJQS5 90LkhAASWSU5sG1wWLnEqOslDAvI9AhQjwFqUW5mSWo8q8YxTkYlYR5+0Gm8GTmlcBNBwYa0M 0ivDaT/oAsLklESEk1MMo4h39a5nbvxOq8lHR1o/aAmatFlm99EW6ypnuxklut8P32OR9uJFU amm/4weHj93hLU5e418VF7BHK0QI/WTx+Kr2TnJdbXMpyY8rivf2MGklFn/RNwjsX/tPb+eK/ gcTBDkHe5w7FW1vnRB97tvkiY4npes1OzgyO22mR613rH57RNFZLUGIpzkg01GIuKk4EADSYd dKYAgAA X-Env-Sender: pclai@intel.com X-Msg-Ref: server-14.tower-21.messagelabs.com!1476229083!32253266!1 X-Originating-IP: [134.134.136.20] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjAgPT4gMzU1MzU4\n X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64152 invoked from network); 11 Oct 2016 23:38:05 -0000 Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by server-14.tower-21.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 11 Oct 2016 23:38:05 -0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 11 Oct 2016 16:38:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.31,479,1473145200"; d="scan'208"; a="1069190126" Received: from scymds01.sc.intel.com ([10.82.194.37]) by fmsmga002.fm.intel.com with ESMTP; 11 Oct 2016 16:38:02 -0700 Received: from pclaidev.sc.intel.com (pclaidev.sc.intel.com [143.183.85.56]) by scymds01.sc.intel.com with ESMTP id u9BNc2i5017943; Tue, 11 Oct 2016 16:38:02 -0700 Received: by pclaidev.sc.intel.com (Postfix, from userid 1002) id D0BE420124; Tue, 11 Oct 2016 16:40:11 -0700 (PDT) From: Paul Lai To: xen-devel@lists.xensource.com Date: Tue, 11 Oct 2016 16:40:11 -0700 Message-Id: <1476229211-9974-3-git-send-email-paul.c.lai@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476229211-9974-1-git-send-email-paul.c.lai@intel.com> References: <1476229211-9974-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 v10 2/2] Moving ept code to ept specific files as requested in: https://lists.xenproject.org/archives/html/xen-devel/2015-07/msg04323.html Renamed p2m_init_altp2m_helper() to p2m_init_altp2m_ept(). 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 Signed-off-by: Paul Lai Reviewed-by: Konrad Rzeszutek Wilk --- v10 Added Reviewed-by stamp --- xen/arch/x86/mm/p2m-ept.c | 39 +++++++++++++++++++++++++++++++++++++++ xen/arch/x86/mm/p2m.c | 43 ++----------------------------------------- 2 files changed, 41 insertions(+), 41 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 9526fff..9fecbc9 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;