From patchwork Thu Sep 14 12:58:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9953107 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 B1B5460317 for ; Thu, 14 Sep 2017 13:31:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACA2128CD3 for ; Thu, 14 Sep 2017 13:31:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A122928E1A; Thu, 14 Sep 2017 13:31:07 +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 3924728CD3 for ; Thu, 14 Sep 2017 13:31:07 +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 1dsUCA-0007zW-Ia; Thu, 14 Sep 2017 13:28:42 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsUC8-0007wo-Qk for xen-devel@lists.xenproject.org; Thu, 14 Sep 2017 13:28:40 +0000 Received: from [85.158.139.211] by server-2.bemta-5.messagelabs.com id EE/8E-02021-8048AB95; Thu, 14 Sep 2017 13:28:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEIsWRWlGSWpSXmKPExsXitHRDpC5Ly65 Ig3c7pS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1ox3Ex+wFhzSrPj17xpbA2OnYhcjJ4eEgL/E kmttTCA2m4CyxM/OXjYQW0RAT6LpwHPGLkYuDmaBOYwSU+d2MYIkhAWcJBadmcgOYrMIqEpcX LAQrIFXwFLi8vV5zBBD5SV2tV1kBbE5geJdH16CLRASsJDovbSfHcJWkOiYfowJoldQ4uTMJy wgNrOAhMTBFy+YJzDyzkKSmoUktYCRaRWjRnFqUVlqka6RkV5SUWZ6RkluYmaOrqGBqV5uanF xYnpqTmJSsV5yfu4mRmD41DMwMO5g3NPud4hRkoNJSZR3r+7OSCG+pPyUyozE4oz4otKc1OJD jDIcHEoSvIzNuyKFBItS01Mr0jJzgIEMk5bg4FES4b3fBJTmLS5IzC3OTIdInWLU5ei4efcPk xBLXn5eqpQ4rzbIDAGQoozSPLgRsKi6xCgrJczLyMDAIMRTkFqUm1mCKv+KUZyDUUmYdzrIKp 7MvBK4Ta+AjmACOuLM6R0gR5QkIqSkGhilBaQCm1TmXRBnbuQ+pFXLpvdBum9TCrNe6vqMb1t U5l/3uWkjbzWnvXNS4IydK3ZIbf3iwT5pTvuXvV8lxLeE3/TZ7RoVzLP2slU1a9ymtaYbN/XE 2N37HLlddoflUfNb/6ckM3W80HhdKH0s20f4Vnz5Nu7NSyblWUmfL3S2dP50wHPazb9KLMUZi YZazEXFiQBEWZk/pQIAAA== X-Env-Sender: prvs=423b67c62=wei.liu2@citrix.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1505395713!108719783!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33818 invoked from network); 14 Sep 2017 13:28:36 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-6.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 14 Sep 2017 13:28:36 -0000 X-IronPort-AV: E=Sophos;i="5.42,393,1500940800"; d="scan'208";a="439758527" From: Wei Liu To: Xen-devel Date: Thu, 14 Sep 2017 13:58:47 +0100 Message-ID: <20170914125852.22129-19-wei.liu2@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170914125852.22129-1-wei.liu2@citrix.com> References: <20170914125852.22129-1-wei.liu2@citrix.com> MIME-Version: 1.0 Cc: George Dunlap , Andrew Cooper , Wei Liu , Jan Beulich Subject: [Xen-devel] [PATCH v5 18/23] x86/mm: export some stuff via local mm.h 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP They will be used by PV mm code and mm hypercall code, which is going to be split into two files. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 30 +++++++++++------------------- xen/arch/x86/pv/mm.h | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index e11aac3b90..f9cc5a0f6f 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -154,13 +154,6 @@ struct rangeset *__read_mostly mmio_ro_ranges; uint32_t __read_mostly base_disallow_mask; -#define L2_DISALLOW_MASK base_disallow_mask - -#define l3_disallow_mask(d) (!is_pv_32bit_domain(d) ? \ - base_disallow_mask : 0xFFFFF198U) - -#define L4_DISALLOW_MASK (base_disallow_mask) - static s8 __read_mostly opt_mmio_relax; static int __init parse_mmio_relax(const char *s) @@ -545,9 +538,8 @@ static int alloc_segdesc_page(struct page_info *page) return i == 512 ? 0 : -EINVAL; } -static int get_page_and_type_from_mfn( - mfn_t mfn, unsigned long type, struct domain *d, - int partial, int preemptible) +int get_page_and_type_from_mfn(mfn_t mfn, unsigned long type, struct domain *d, + int partial, int preemptible) { struct page_info *page = mfn_to_page(mfn); int rc; @@ -930,7 +922,7 @@ get_page_from_l1e( * <0 => error code */ define_get_linear_pagetable(l2); -static int +int get_page_from_l2e( l2_pgentry_t l2e, unsigned long pfn, struct domain *d) { @@ -966,7 +958,7 @@ get_page_from_l2e( * <0 => error code */ define_get_linear_pagetable(l3); -static int +int get_page_from_l3e( l3_pgentry_t l3e, unsigned long pfn, struct domain *d, int partial) { @@ -999,7 +991,7 @@ get_page_from_l3e( * <0 => error code */ define_get_linear_pagetable(l4); -static int +int get_page_from_l4e( l4_pgentry_t l4e, unsigned long pfn, struct domain *d, int partial) { @@ -1087,7 +1079,7 @@ void put_page_from_l1e(l1_pgentry_t l1e, struct domain *l1e_owner) * NB. Virtual address 'l2e' maps to a machine address within frame 'pfn'. * Note also that this automatically deals correctly with linear p.t.'s. */ -static int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn) +int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn) { if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) || (l2e_get_pfn(l2e) == pfn) ) return 1; @@ -1105,8 +1097,8 @@ static int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn) return 0; } -static int put_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn, - int partial, bool defer) +int put_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn, int partial, + bool defer) { struct page_info *pg; @@ -1143,8 +1135,8 @@ static int put_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn, return put_page_and_type_preemptible(pg); } -static int put_page_from_l4e(l4_pgentry_t l4e, unsigned long pfn, - int partial, bool defer) +int put_page_from_l4e(l4_pgentry_t l4e, unsigned long pfn, int partial, + bool defer) { if ( (l4e_get_flags(l4e) & _PAGE_PRESENT) && (l4e_get_pfn(l4e) != pfn) ) @@ -1206,7 +1198,7 @@ static int alloc_l1_table(struct page_info *page) return ret; } -static int create_pae_xen_mappings(struct domain *d, l3_pgentry_t *pl3e) +int create_pae_xen_mappings(struct domain *d, l3_pgentry_t *pl3e) { struct page_info *page; l3_pgentry_t l3e3; diff --git a/xen/arch/x86/pv/mm.h b/xen/arch/x86/pv/mm.h index 43e797f201..b4bb214d95 100644 --- a/xen/arch/x86/pv/mm.h +++ b/xen/arch/x86/pv/mm.h @@ -1,6 +1,13 @@ #ifndef __PV_MM_H__ #define __PV_MM_H__ +#define L2_DISALLOW_MASK base_disallow_mask + +#define l3_disallow_mask(d) (!is_pv_32bit_domain(d) ? \ + base_disallow_mask : 0xFFFFF198U) + +#define L4_DISALLOW_MASK (base_disallow_mask) + l1_pgentry_t *map_guest_l1e(unsigned long linear, mfn_t *gl1mfn); void init_guest_l4_table(l4_pgentry_t l4tab[], const struct domain *d, @@ -8,6 +15,8 @@ void init_guest_l4_table(l4_pgentry_t l4tab[], const struct domain *d, int new_guest_cr3(mfn_t mfn); +int create_pae_xen_mappings(struct domain *d, l3_pgentry_t *pl3e); + /* Read a PV guest's l1e that maps this linear address. */ static inline l1_pgentry_t guest_get_eff_l1e(unsigned long linear) { @@ -152,4 +161,16 @@ static inline l4_pgentry_t adjust_guest_l4e(l4_pgentry_t l4e, return l4e; } +int get_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn, struct domain *d); +int get_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn, struct domain *d, + int partial); +int get_page_from_l4e(l4_pgentry_t l4e, unsigned long pfn, struct domain *d, + int partial); +int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn); +int put_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn, int partial, + bool defer); +int put_page_from_l4e(l4_pgentry_t l4e, unsigned long pfn, int partial, + bool defer); +int get_page_and_type_from_mfn(mfn_t mfn, unsigned long type, struct domain *d, + int partial, int preemptible); #endif /* __PV_MM_H__ */