From patchwork Thu Aug 17 14:44:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9906519 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 63AAB6038C for ; Thu, 17 Aug 2017 14:49:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5551F28B3B for ; Thu, 17 Aug 2017 14:49:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A69628B3D; Thu, 17 Aug 2017 14:49:37 +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 B3D6228B3C for ; Thu, 17 Aug 2017 14:49:35 +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 1diM59-0002q8-66; Thu, 17 Aug 2017 14:47:35 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1diM57-0002na-Ig for xen-devel@lists.xenproject.org; Thu, 17 Aug 2017 14:47:33 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id 13/49-01729-48CA5995; Thu, 17 Aug 2017 14:47:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRWlGSWpSXmKPExsXitHSDvW7jmqm RBstfilp83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBlrb29lLeg1rVi67BRbA+Ns6S5GTg4JAX+J zbPPMoHYbALKEj87e9lAbBEBPYmmA88Zuxi5OJgF5jBKTJ3bxQiSEBZwlTh97R0riM0ioCoxc fN5oAYODl4BS4nNX6ogZspL7Gq7CFbCCRQ+NGkxM4gtJGAhMftDOzuErSDRMf0Y2F5eAUGJkz OfsIDYzAISEgdfvGCewMg7C0lqFpLUAkamVYwaxalFZalFuoYGeklFmekZJbmJmTlAnqlebmp xcWJ6ak5iUrFecn7uJkZg8DAAwQ7GNVOdDzFKcjApifL+njUlUogvKT+lMiOxOCO+qDQntfgQ owwHh5IEb+HqqZFCgkWp6akVaZk5wDCGSUtw8CiJ8FaCpHmLCxJzizPTIVKnGHU5Xk34/41Ji CUvPy9VSpw3EqRIAKQoozQPbgQspi4xykoJ8zICHSXEU5BalJtZgir/ilGcg1FJmNcXZApPZl 4J3KZXQEcwAR1xpX0SyBEliQgpqQbGyqQ1sQUHdkV9Y0tY9HPjwtCLLxt+/FNttvmccU4r3t2 /w0xUfFHrvx9Vf49+/3rSrVX+j6jecz+Vcr/dwuo/ru2rN53+Nryb+e0spqinti/W2MV+lmrp 09++P51B9MnByfOOKUYffCkzwTbCdkZaw/VbB8pkRe9t+nNQKS1cdOrX+9rcJlZNSizFGYmGW sxFxYkAEEIJFKQCAAA= X-Env-Sender: prvs=395e6b081=wei.liu2@citrix.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1502981244!104877606!3 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 1706 invoked from network); 17 Aug 2017 14:47:29 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-6.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 17 Aug 2017 14:47:29 -0000 X-IronPort-AV: E=Sophos;i="5.41,388,1498521600"; d="scan'208";a="444178802" From: Wei Liu To: Xen-devel Date: Thu, 17 Aug 2017 15:44:35 +0100 Message-ID: <20170817144456.18989-11-wei.liu2@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170817144456.18989-1-wei.liu2@citrix.com> References: <20170817144456.18989-1-wei.liu2@citrix.com> MIME-Version: 1.0 Cc: George Dunlap , Andrew Cooper , Wei Liu , Jan Beulich Subject: [Xen-devel] [PATCH v4 10/31] x86/mm: move {un, }adjust_guest_* to pv/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 Those macros will soon be used in different files. They are PV specific so move them to pv/mm.h. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 47 --------------------------------------------- xen/include/asm-x86/pv/mm.h | 47 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index dc4ac5592a..4ac69b3804 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -1151,53 +1151,6 @@ get_page_from_l4e( return rc; } -#define adjust_guest_l1e(pl1e, d) \ - do { \ - if ( likely(l1e_get_flags((pl1e)) & _PAGE_PRESENT) && \ - likely(!is_pv_32bit_domain(d)) ) \ - { \ - /* _PAGE_GUEST_KERNEL page cannot have the Global bit set. */ \ - if ( (l1e_get_flags((pl1e)) & (_PAGE_GUEST_KERNEL|_PAGE_GLOBAL)) \ - == (_PAGE_GUEST_KERNEL|_PAGE_GLOBAL) ) \ - gdprintk(XENLOG_WARNING, \ - "Global bit is set to kernel page %lx\n", \ - l1e_get_pfn((pl1e))); \ - if ( !(l1e_get_flags((pl1e)) & _PAGE_USER) ) \ - l1e_add_flags((pl1e), (_PAGE_GUEST_KERNEL|_PAGE_USER)); \ - if ( !(l1e_get_flags((pl1e)) & _PAGE_GUEST_KERNEL) ) \ - l1e_add_flags((pl1e), (_PAGE_GLOBAL|_PAGE_USER)); \ - } \ - } while ( 0 ) - -#define adjust_guest_l2e(pl2e, d) \ - do { \ - if ( likely(l2e_get_flags((pl2e)) & _PAGE_PRESENT) && \ - likely(!is_pv_32bit_domain(d)) ) \ - l2e_add_flags((pl2e), _PAGE_USER); \ - } while ( 0 ) - -#define adjust_guest_l3e(pl3e, d) \ - do { \ - if ( likely(l3e_get_flags((pl3e)) & _PAGE_PRESENT) ) \ - l3e_add_flags((pl3e), likely(!is_pv_32bit_domain(d)) ? \ - _PAGE_USER : \ - _PAGE_USER|_PAGE_RW); \ - } while ( 0 ) - -#define adjust_guest_l4e(pl4e, d) \ - do { \ - if ( likely(l4e_get_flags((pl4e)) & _PAGE_PRESENT) && \ - likely(!is_pv_32bit_domain(d)) ) \ - l4e_add_flags((pl4e), _PAGE_USER); \ - } while ( 0 ) - -#define unadjust_guest_l3e(pl3e, d) \ - do { \ - if ( unlikely(is_pv_32bit_domain(d)) && \ - likely(l3e_get_flags((pl3e)) & _PAGE_PRESENT) ) \ - l3e_remove_flags((pl3e), _PAGE_USER|_PAGE_RW|_PAGE_ACCESSED); \ - } while ( 0 ) - void put_page_from_l1e(l1_pgentry_t l1e, struct domain *l1e_owner) { unsigned long pfn = l1e_get_pfn(l1e); diff --git a/xen/include/asm-x86/pv/mm.h b/xen/include/asm-x86/pv/mm.h index 72c04c684f..b3887989b6 100644 --- a/xen/include/asm-x86/pv/mm.h +++ b/xen/include/asm-x86/pv/mm.h @@ -23,6 +23,53 @@ #ifdef CONFIG_PV +#define adjust_guest_l1e(pl1e, d) \ + do { \ + if ( likely(l1e_get_flags((pl1e)) & _PAGE_PRESENT) && \ + likely(!is_pv_32bit_domain(d)) ) \ + { \ + /* _PAGE_GUEST_KERNEL page cannot have the Global bit set. */ \ + if ( (l1e_get_flags((pl1e)) & (_PAGE_GUEST_KERNEL|_PAGE_GLOBAL)) \ + == (_PAGE_GUEST_KERNEL|_PAGE_GLOBAL) ) \ + gdprintk(XENLOG_WARNING, \ + "Global bit is set to kernel page %lx\n", \ + l1e_get_pfn((pl1e))); \ + if ( !(l1e_get_flags((pl1e)) & _PAGE_USER) ) \ + l1e_add_flags((pl1e), (_PAGE_GUEST_KERNEL|_PAGE_USER)); \ + if ( !(l1e_get_flags((pl1e)) & _PAGE_GUEST_KERNEL) ) \ + l1e_add_flags((pl1e), (_PAGE_GLOBAL|_PAGE_USER)); \ + } \ + } while ( 0 ) + +#define adjust_guest_l2e(pl2e, d) \ + do { \ + if ( likely(l2e_get_flags((pl2e)) & _PAGE_PRESENT) && \ + likely(!is_pv_32bit_domain(d)) ) \ + l2e_add_flags((pl2e), _PAGE_USER); \ + } while ( 0 ) + +#define adjust_guest_l3e(pl3e, d) \ + do { \ + if ( likely(l3e_get_flags((pl3e)) & _PAGE_PRESENT) ) \ + l3e_add_flags((pl3e), likely(!is_pv_32bit_domain(d)) ? \ + _PAGE_USER : \ + _PAGE_USER|_PAGE_RW); \ + } while ( 0 ) + +#define adjust_guest_l4e(pl4e, d) \ + do { \ + if ( likely(l4e_get_flags((pl4e)) & _PAGE_PRESENT) && \ + likely(!is_pv_32bit_domain(d)) ) \ + l4e_add_flags((pl4e), _PAGE_USER); \ + } while ( 0 ) + +#define unadjust_guest_l3e(pl3e, d) \ + do { \ + if ( unlikely(is_pv_32bit_domain(d)) && \ + likely(l3e_get_flags((pl3e)) & _PAGE_PRESENT) ) \ + l3e_remove_flags((pl3e), _PAGE_USER|_PAGE_RW|_PAGE_ACCESSED); \ + } while ( 0 ) + void pv_get_guest_eff_l1e(unsigned long addr, l1_pgentry_t *eff_l1e); void pv_get_guest_eff_kern_l1e(struct vcpu *v, unsigned long addr,