From patchwork Wed Oct 19 20:32:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Lai X-Patchwork-Id: 9385361 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 6F184607D0 for ; Wed, 19 Oct 2016 20:33:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6212B28EBB for ; Wed, 19 Oct 2016 20:33:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56DDF29214; Wed, 19 Oct 2016 20:33:16 +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 B505A28EBB for ; Wed, 19 Oct 2016 20:33:15 +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 1bwxVa-0003yy-4j; Wed, 19 Oct 2016 20:30:42 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bwxVY-0003ym-Lm for xen-devel@lists.xensource.com; Wed, 19 Oct 2016 20:30:40 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id E1/3C-28857-FE7D7085; Wed, 19 Oct 2016 20:30:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmkeJIrShJLcpLzFFi42Jpa+tI0X1/nT3 CoGctr8W9Ke/ZHRg9tvftYg9gjGLNzEvKr0hgzdj+6iJ7wW7Ziinz37E2MPaLdzFycggJVEq8 fH2IDcSWEOCVOLJsBmsXIweQ7SdxejknREmFxNlZm5i7GLmA7GWMEr//bmeDSJRI9F04yQhis wmoSiw/NwnMFhFQlFi3+h0LiM0skCaxdtMXsHphgSCJjQfb2EHmswDVf53FBWLyCrhI9F9lhb hATuLmuU5mEJtTwFXi77kPLBCbXCTufl3GOoGRfwEjwypGjeLUorLUIl0jM72kosz0jJLcxMw cXUMDM73c1OLixPTUnMSkYr3k/NxNjMDAYQCCHYxnFgQeYpTkYFIS5eXpY48Q4kvKT6nMSCzO iC8qzUktPsQow8GhJMGbfA0oJ1iUmp5akZaZAwxhmLQEB4+SCG8hSJq3uCAxtzgzHSJ1ilFRS pz33VWghABIIqM0D64NFjeXGGWlhHkZgQ4R4ilILcrNLEGVf8UozsGoJMxbCzKeJzOvBG76K6 DFTECLz+WxgCwuSURISTUwnuYrPTHD84fref/rXj8iwyqVzmzen1sVubGoSt5n9d8tffazlnD 9f14Uf/NRyT3rE/euXNw69Qarxfnqfsn4hEkNWvO+ipRHO6xwvFX3fcekb6tFzghk3l17/SaL LB/jTw2/kj+JZxZO5mi8nDc3ZvGqX3/rZMKsF4oFfdRje/fmmuW2bK1drkosxRmJhlrMRcWJA IDojgCWAgAA X-Env-Sender: pclai@intel.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1476909036!16457803!1 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 55277 invoked from network); 19 Oct 2016 20:30:38 -0000 Received: from mga07.intel.com (HELO mga07.intel.com) (134.134.136.100) by server-6.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 19 Oct 2016 20:30:38 -0000 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP; 19 Oct 2016 13:30:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,367,1473145200"; d="scan'208";a="21456433" Received: from scymds02.sc.intel.com ([10.82.195.37]) by fmsmga005.fm.intel.com with ESMTP; 19 Oct 2016 13:30:36 -0700 Received: from pclaidev.sc.intel.com (pclaidev.sc.intel.com [143.183.85.56]) by scymds02.sc.intel.com with ESMTP id u9JKUZP5008017; Wed, 19 Oct 2016 13:30:35 -0700 Received: by pclaidev.sc.intel.com (Postfix, from userid 1002) id 25D5F204FA; Wed, 19 Oct 2016 13:32:23 -0700 (PDT) From: Paul Lai To: xen-devel@lists.xensource.com Date: Wed, 19 Oct 2016 13:32:23 -0700 Message-Id: <1476909143-28616-3-git-send-email-paul.c.lai@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476909143-28616-1-git-send-email-paul.c.lai@intel.com> References: <1476909143-28616-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 v11 2/2] 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 --- v11 Fixing length of title that was reqested in v9, but missed in v10. --- 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;