From patchwork Thu Jul 20 16:04:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9855331 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 E81FD600F5 for ; Thu, 20 Jul 2017 16:18:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8B0A286DE for ; Thu, 20 Jul 2017 16:18:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDC6A286FD; Thu, 20 Jul 2017 16:18:44 +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 6CFCA286DE for ; Thu, 20 Jul 2017 16:18:44 +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 1dYE7t-0002v3-HB; Thu, 20 Jul 2017 16:16:33 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dYE7s-0002tB-JL for xen-devel@lists.xenproject.org; Thu, 20 Jul 2017 16:16:32 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id 81/76-03406-067D0795; Thu, 20 Jul 2017 16:16:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRWlGSWpSXmKPExsXitHRDpG789YJ Ig3ndchbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bUSXvYCuaqVJx68pWlgfGjdBcjJ4eEgL/E zP7LTCA2m4CyxM/OXjYQW0RAT6LpwHPGLkYuDmaBOYwSU+d2MYIkhAWcJTrWXQcrYhFQlZh1e DoriM0rYCHx8MAUVoih8hK72i6C2ZxA8TW/voItEBIwl9i8fz4LhK0g0TH9GBNEr6DEyZlPwO LMAhISB1+8YJ7AyDsLSWoWktQCRqZVjOrFqUVlqUW6ZnpJRZnpGSW5iZk5uoYGZnq5qcXFiem pOYlJxXrJ+bmbGIHBwwAEOxjnnfA/xCjJwaQkyssSWBApxJeUn1KZkVicEV9UmpNafIhRhoND SYKX4RpQTrAoNT21Ii0zBxjGMGkJDh4lEV5BkDRvcUFibnFmOkTqFKMux6sJ/78xCbHk5eelS onz2oAUCYAUZZTmwY2AxdQlRlkpYV5GoKOEeApSi3IzS1DlXzGKczAqCfOuuwo0hSczrwRu0y ugI5iAjnjkBnZESSJCSqqB0anRZ6Lx3uqVl77q8Pve32DofHnD5dqtB09JvOzvXPs5wMQj9f+ 3QLXl07OehHGEFFrGyZ+rKZwk2rLVd4LdLyEzhbdRhrafVyioPiy9vYuj56HZs7X8ySsXBG+o 3CScty1Uojm8tFz5r9Zj2XnPjsznyWBKltP+Pkf74aeyiMRjKytuFHoGKrEUZyQaajEXFScCA LvJ0hmkAgAA X-Env-Sender: prvs=3674d857a=wei.liu2@citrix.com X-Msg-Ref: server-10.tower-21.messagelabs.com!1500567380!67573675!5 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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 49266 invoked from network); 20 Jul 2017 16:16:31 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-10.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 20 Jul 2017 16:16:31 -0000 X-IronPort-AV: E=Sophos;i="5.40,384,1496102400"; d="scan'208";a="432310741" From: Wei Liu To: Xen-devel Date: Thu, 20 Jul 2017 17:04:26 +0100 Message-ID: <20170720160426.2343-22-wei.liu2@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170720160426.2343-1-wei.liu2@citrix.com> References: <20170720160426.2343-1-wei.liu2@citrix.com> MIME-Version: 1.0 Cc: George Dunlap , Andrew Cooper , Wei Liu , Jan Beulich Subject: [Xen-devel] [PATCH v3 21/21] x86/mm: add "pv_" prefix to new_guest_cr3 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 Also take the chance to change d to currd. This function can't be moved yet. It can only be moved with other functions. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 18 +++++++++--------- xen/arch/x86/pv/emul-priv-op.c | 3 ++- xen/include/asm-x86/mm.h | 1 - xen/include/asm-x86/pv/mm.h | 7 +++++++ 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 5687e29824..2493ea7fd3 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -2695,14 +2695,14 @@ int vcpu_destroy_pagetables(struct vcpu *v) return rc != -EINTR ? rc : -ERESTART; } -int new_guest_cr3(unsigned long mfn) +int pv_new_guest_cr3(unsigned long mfn) { struct vcpu *curr = current; - struct domain *d = curr->domain; + struct domain *currd = curr->domain; int rc; unsigned long old_base_mfn; - if ( is_pv_32bit_domain(d) ) + if ( is_pv_32bit_domain(currd) ) { unsigned long gt_mfn = pagetable_get_pfn(curr->arch.guest_table); l4_pgentry_t *pl4e = map_domain_page(_mfn(gt_mfn)); @@ -2748,9 +2748,9 @@ int new_guest_cr3(unsigned long mfn) return 0; } - rc = paging_mode_refcounts(d) - ? (!get_page_from_pagenr(mfn, d) ? 0 : -EINVAL) - : get_page_and_type_from_pagenr(mfn, PGT_root_page_table, d, 0, 1); + rc = paging_mode_refcounts(currd) + ? (!get_page_from_pagenr(mfn, currd) ? 0 : -EINVAL) + : get_page_and_type_from_pagenr(mfn, PGT_root_page_table, currd, 0, 1); switch ( rc ) { case 0: @@ -2766,7 +2766,7 @@ int new_guest_cr3(unsigned long mfn) invalidate_shadow_ldt(curr, 0); - if ( !VM_ASSIST(d, m2p_strict) && !paging_mode_refcounts(d) ) + if ( !VM_ASSIST(currd, m2p_strict) && !paging_mode_refcounts(currd) ) fill_ro_mpt(mfn); curr->arch.guest_table = pagetable_from_pfn(mfn); update_cr3(curr); @@ -2777,7 +2777,7 @@ int new_guest_cr3(unsigned long mfn) { struct page_info *page = mfn_to_page(old_base_mfn); - if ( paging_mode_refcounts(d) ) + if ( paging_mode_refcounts(currd) ) put_page(page); else switch ( rc = put_page_and_type_preemptible(page) ) @@ -3102,7 +3102,7 @@ long do_mmuext_op( else if ( unlikely(paging_mode_translate(currd)) ) rc = -EINVAL; else - rc = new_guest_cr3(op.arg1.mfn); + rc = pv_new_guest_cr3(op.arg1.mfn); break; case MMUEXT_NEW_USER_BASEPTR: { diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c index 85185b6b29..936757e03c 100644 --- a/xen/arch/x86/pv/emul-priv-op.c +++ b/xen/arch/x86/pv/emul-priv-op.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -768,7 +769,7 @@ static int priv_op_write_cr(unsigned int reg, unsigned long val, page = get_page_from_gfn(currd, gfn, NULL, P2M_ALLOC); if ( !page ) break; - rc = new_guest_cr3(page_to_mfn(page)); + rc = pv_new_guest_cr3(page_to_mfn(page)); put_page(page); switch ( rc ) diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 19c80da995..f48ce7555d 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -534,7 +534,6 @@ void audit_domains(void); #endif -int new_guest_cr3(unsigned long pfn); void make_cr3(struct vcpu *v, unsigned long mfn); void update_cr3(struct vcpu *v); int vcpu_destroy_pagetables(struct vcpu *); diff --git a/xen/include/asm-x86/pv/mm.h b/xen/include/asm-x86/pv/mm.h index 8fd542e630..0192580b41 100644 --- a/xen/include/asm-x86/pv/mm.h +++ b/xen/include/asm-x86/pv/mm.h @@ -94,8 +94,12 @@ void pv_init_guest_l4_table(l4_pgentry_t[], const struct domain *, bool zap_ro_mpt); void pv_arch_init_memory(void); +int pv_new_guest_cr3(unsigned long pfn); + #else +#include + static inline void pv_get_guest_eff_l1e(unsigned long addr, l1_pgentry_t *eff_l1e) {} @@ -119,6 +123,9 @@ static inline void pv_init_guest_l4_table(l4_pgentry_t[], const struct domain *, bool zap_ro_mpt) {} static inline void pv_arch_init_memory(void) {} + +static inline int pv_new_guest_cr3(unsigned long pfn) { return -EINVAL; } + #endif #endif /* __X86_PV_MM_H__ */