From patchwork Thu Jul 20 16:04:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9855293 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 8DD8C60392 for ; Thu, 20 Jul 2017 16:06:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EC0328678 for ; Thu, 20 Jul 2017 16:06:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 737A3286DE; Thu, 20 Jul 2017 16:06:58 +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 162A728678 for ; Thu, 20 Jul 2017 16:06:58 +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 1dYDwH-0000DV-Dy; Thu, 20 Jul 2017 16:04: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 1dYDwG-0000DB-11 for xen-devel@lists.xenproject.org; Thu, 20 Jul 2017 16:04:32 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id 7D/9F-03368-F84D0795; Thu, 20 Jul 2017 16:04:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEIsWRWlGSWpSXmKPExsXitHRDpG7flYJ Ig3WTLSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ow1Dw4zFexQrti06yp7A+Mm6S5GTg4JAX+J /42XWUBsNgFliZ+dvWwgtoiAnkTTgeeMXYxcHMwCcxglps7tYgRJCAu4SOx4sosZxGYRUJXYf akdLM4rYC7R8/U9C8RQeYldbRdZQWxOAQuJNb++MoHYQkA1m/fPZ4GwFSQ6ph9jgugVlDg58w lYnFlAQuLgixfMExh5ZyFJzUKSWsDItIpRozi1qCy1SNfQQi+pKDM9oyQ3MTNH19DATC83tbg 4MT01JzGpWC85P3cTIzB8GIBgB+PNjQGHGCU5mJREeVkCCyKF+JLyUyozEosz4otKc1KLDzHK cHAoSfD+vASUEyxKTU+tSMvMAQYyTFqCg0dJhNfxMlCat7ggMbc4Mx0idYpRl+PVhP/fmIRY8 vLzUqXEeStAigRAijJK8+BGwKLqEqOslDAvI9BRQjwFqUW5mSWo8q8YxTkYlYR5o0Gm8GTmlc BtegV0BBPQEY/cwI4oSURISTUwhimVndG5YSbcNiu86P3fusud70RV1eMuJP3Xytcyn/c/eq6 C3SS5vP8ZwX+ZejkcOiZs0t27M8xk4pM9ZmaSa9ZLcz5nV7Pdaj77SUqtrf9Zkxuv/9zP9Z/o vnKX4NXJAUuVbW+ean4vtvXtXx/X7Xac9ySXnVnwRjU2Z3PkVRa3LVsCY6z5lFiKMxINtZiLi hMBNm06naUCAAA= X-Env-Sender: prvs=3674d857a=wei.liu2@citrix.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1500566668!107825623!1 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 6643 invoked from network); 20 Jul 2017 16:04:30 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-3.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 20 Jul 2017 16:04:30 -0000 X-IronPort-AV: E=Sophos;i="5.40,384,1496102400"; d="scan'208";a="432307678" From: Wei Liu To: Xen-devel Date: Thu, 20 Jul 2017 17:04:07 +0100 Message-ID: <20170720160426.2343-3-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 02/21] 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 Acked-by: George Dunlap --- 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 532b1ee7e7..defc2c9bcc 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4296,7 +4296,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); @@ -4326,8 +4326,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; @@ -4335,9 +4335,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 4aa22126d3..6c98672a4d 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__ */