From patchwork Thu Aug 17 14:44:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9906489 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 53E57603B5 for ; Thu, 17 Aug 2017 14:47:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45EFE28B2D for ; Thu, 17 Aug 2017 14:47:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A79528B37; Thu, 17 Aug 2017 14:47: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 CFE9B28B2F for ; Thu, 17 Aug 2017 14:47:43 +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 1diM3L-0001CJ-7i; Thu, 17 Aug 2017 14:45:43 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1diM3K-0001AZ-BS for xen-devel@lists.xenproject.org; Thu, 17 Aug 2017 14:45:42 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id C9/93-03557-51CA5995; Thu, 17 Aug 2017 14:45:41 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEIsWRWlGSWpSXmKPExsXitHSDva7omqm RBotvcVl83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmb365gK9ihXPHw1T7GBsZN0l2MnBwSAv4S 97f0M4HYbALKEj87e9lAbBEBPYmmA88Zuxi5OJgF5jBKTJ3bxQiSEBZwkTi06TaYzSKgKtH18 DuYzStgIXFm4gU2iKHyErvaLrKC2JwClhKHJi1mBrGFgGpmf2hnh7AVJDqmH2OC6BWUODnzCQ uIzSwgIXHwxQvmCYy8s5CkZiFJLWBkWsWoUZxaVJZapGtsrJdUlJmeUZKbmJmja2hgppebWly cmJ6ak5hUrJecn7uJERg+DECwg3Hn+sBDjJIcTEqivL9nTYkU4kvKT6nMSCzOiC8qzUktPsQo w8GhJMH7eNXUSCHBotT01Iq0zBxgIMOkJTh4lER4/4OkeYsLEnOLM9MhUqcYdTleTfj/jUmIJ S8/L1VKnDdyNVCRAEhRRmke3AhYVF1ilJUS5mUEOkqIpyC1KDezBFX+FaM4B6OSMO91kFU8mX klcJteAR3BBHTElfZJIEeUJCKkpBoYi67ZLgmZcvDr7acC8zauj26d9LTuycaei9eSq+dMZNi 0Z23Iq8uv7y+uupD7Y1XOs8s/Vq/qeNF11CBGsM3k68M+DSXzC+lbFuS2HNmrJGvNemV6rngA Z2mvkNzEcrVF8q9SZoqoijkx3sg/GP9W2F6sxtOv5bmwWGfn1PI5iwOUvnPVPt9oqcRSnJFoq MVcVJwIAAdKp2WlAgAA X-Env-Sender: prvs=395e6b081=wei.liu2@citrix.com X-Msg-Ref: server-10.tower-27.messagelabs.com!1502981136!89057399!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 40610 invoked from network); 17 Aug 2017 14:45:40 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-10.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 17 Aug 2017 14:45:40 -0000 X-IronPort-AV: E=Sophos;i="5.41,388,1498521600"; d="scan'208";a="444178354" From: Wei Liu To: Xen-devel Date: Thu, 17 Aug 2017 15:44:27 +0100 Message-ID: <20170817144456.18989-3-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 02/31] x86/mm: carve out replace_grant_pv_mapping 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 And at once make it an inline function. Add declarations of replace_grant_{hvm,pv}_mapping to respective header files. The code movement will be done later. Signed-off-by: Wei Liu Reviewed-by: Jan Beulich --- xen/arch/x86/mm.c | 9 +++------ xen/include/asm-x86/grant_table.h | 10 ++++++++-- xen/include/asm-x86/hvm/grant_table.h | 8 ++++++++ xen/include/asm-x86/pv/grant_table.h | 8 ++++++++ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 28bcff2c99..d7d04772c5 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4068,7 +4068,7 @@ int create_grant_pv_mapping(uint64_t addr, unsigned long frame, return create_grant_va_mapping(addr, pte, current); } -static int replace_grant_p2m_mapping( +int replace_grant_p2m_mapping( uint64_t addr, unsigned long frame, uint64_t new_addr, unsigned int flags) { unsigned long gfn = (unsigned long)(addr >> PAGE_SHIFT); @@ -4098,8 +4098,8 @@ static int replace_grant_p2m_mapping( return GNTST_okay; } -int replace_grant_host_mapping( - uint64_t addr, unsigned long frame, uint64_t new_addr, unsigned int flags) +int replace_grant_pv_mapping(uint64_t addr, unsigned long frame, + uint64_t new_addr, unsigned int flags) { struct vcpu *curr = current; l1_pgentry_t *pl1e, ol1e; @@ -4107,9 +4107,6 @@ int replace_grant_host_mapping( struct page_info *l1pg; int rc; - if ( paging_mode_external(current->domain) ) - return replace_grant_p2m_mapping(addr, frame, new_addr, flags); - if ( flags & GNTMAP_contains_pte ) { if ( !new_addr ) diff --git a/xen/include/asm-x86/grant_table.h b/xen/include/asm-x86/grant_table.h index 559ad2f275..33b2f88b96 100644 --- a/xen/include/asm-x86/grant_table.h +++ b/xen/include/asm-x86/grant_table.h @@ -27,8 +27,14 @@ static inline int create_grant_host_mapping(uint64_t addr, unsigned long frame, return create_grant_pv_mapping(addr, frame, flags, cache_flags); } -int replace_grant_host_mapping( - uint64_t addr, unsigned long frame, uint64_t new_addr, unsigned int flags); +static inline int replace_grant_host_mapping(uint64_t addr, unsigned long frame, + uint64_t new_addr, + unsigned int flags) +{ + if ( paging_mode_external(current->domain) ) + return replace_grant_p2m_mapping(addr, frame, new_addr, flags); + return replace_grant_pv_mapping(addr, frame, new_addr, flags); +} #define gnttab_create_shared_page(d, t, i) \ do { \ diff --git a/xen/include/asm-x86/hvm/grant_table.h b/xen/include/asm-x86/hvm/grant_table.h index 83202c219c..4b1afa179b 100644 --- a/xen/include/asm-x86/hvm/grant_table.h +++ b/xen/include/asm-x86/hvm/grant_table.h @@ -26,6 +26,8 @@ int create_grant_p2m_mapping(uint64_t addr, unsigned long frame, unsigned int flags, unsigned int cache_flags); +int replace_grant_p2m_mapping(uint64_t addr, unsigned long frame, + uint64_t new_addr, unsigned int flags); #else @@ -38,6 +40,12 @@ static inline int create_grant_p2m_mapping(uint64_t addr, unsigned long frame, return GNTST_general_error; } +int replace_grant_p2m_mapping(uint64_t addr, unsigned long frame, + uint64_t new_addr, unsigned int flags) +{ + return GNTST_general_error; +} + #endif #endif /* __X86_HVM_GRANT_TABLE_H__ */ diff --git a/xen/include/asm-x86/pv/grant_table.h b/xen/include/asm-x86/pv/grant_table.h index 165ebce22f..c6474973cd 100644 --- a/xen/include/asm-x86/pv/grant_table.h +++ b/xen/include/asm-x86/pv/grant_table.h @@ -25,6 +25,8 @@ int create_grant_pv_mapping(uint64_t addr, unsigned long frame, unsigned int flags, unsigned int cache_flags); +int replace_grant_pv_mapping(uint64_t addr, unsigned long frame, + uint64_t new_addr, unsigned int flags); #else @@ -37,6 +39,12 @@ static inline int create_grant_pv_mapping(uint64_t addr, unsigned long frame, return GNTST_general_error; } +int replace_grant_pv_mapping(uint64_t addr, unsigned long frame, + uint64_t new_addr, unsigned int flags) +{ + return GNTST_general_error; +} + #endif #endif /* __X86_PV_GRANT_TABLE_H__ */