From patchwork Thu Aug 17 14:44: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: 9906479 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 39F8C6038C for ; Thu, 17 Aug 2017 14:47:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B90B28B29 for ; Thu, 17 Aug 2017 14:47:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 206DA28B2D; Thu, 17 Aug 2017 14:47:33 +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 5398F28B2C for ; Thu, 17 Aug 2017 14:47:32 +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 1diM2h-0000xE-DC; Thu, 17 Aug 2017 14:45:03 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1diM2g-0000x1-25 for xen-devel@lists.xenproject.org; Thu, 17 Aug 2017 14:45:02 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id 88/C9-02181-DEBA5995; Thu, 17 Aug 2017 14:45:01 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBIsWRWlGSWpSXmKPExsXitHRDpO6b1VM jDe7PMbD4vmUykwOjx+EPV1gCGKNYM/OS8isSWDO+tjWyFxwxr7hwZDl7A+MF7S5GTg4JAX+J F+vvsoPYbALKEj87e9lAbBEBPYmmA88Zuxi5OJgF5jBKTJ3bxQiSEBZwlug7+pMFxGYRUJU49 PoYWJxXwEKi79JMNoih8hK72i6ygticApYShyYtZgaxhYBqZn9oZ4ewFSQ6ph9jgugVlDg58w nYTGYBCYmDL14wT2DknYUkNQtJagEj0ypGjeLUorLUIl1jA72kosz0jJLcxMwcXUMDY73c1OL ixPTUnMSkYr3k/NxNjMDwqWdgYNzB2HnC7xCjJAeTkijv71lTIoX4kvJTKjMSizPii0pzUosP McpwcChJ8LqvmhopJFiUmp5akZaZAwxkmLQEB4+SCG8rSJq3uCAxtzgzHSJ1itGYY0HPhi9MH K8m/P/GJMSSl5+XKiXOew+kVACkNKM0D24QLMIuMcpKCfMyMjAwCPEUpBblZpagyr9iFOdgVB LmnQEyhSczrwRu3yugU5iATrnSPgnklJJEhJRUA2PlJPNZDxWnvTIK11jnY7Dnx/KY1gl2HBa 2jzYJCpi4t/7rXMVVoi321vWD2PXl0au/ypelR1h+PMpnVu3s8eb+hH+/p9QdvvmAnadxn84C A53sNRU3ow3UP+Q8fp+5d17ZH0fV5tM+j4KSLqo1mjnu+5hpar2k5NaCWYlcs5TDdvl0aR/Sj lViKc5INNRiLipOBAAPiBFpqwIAAA== X-Env-Sender: prvs=395e6b081=wei.liu2@citrix.com X-Msg-Ref: server-14.tower-31.messagelabs.com!1502981098!110297526!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.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 62987 invoked from network); 17 Aug 2017 14:45:00 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-14.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 17 Aug 2017 14:45:00 -0000 X-IronPort-AV: E=Sophos;i="5.41,388,1498521600"; d="scan'208";a="435893160" From: Wei Liu To: Xen-devel Date: Thu, 17 Aug 2017 15:44:26 +0100 Message-ID: <20170817144456.18989-2-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 01/31] x86/mm: carve out create_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 create_grant_host_mapping an inline function. This requires making create_grant_{hvm,pv}_mapping non-static. Provide {hvm,pv}/grant_table.h. Include the headers where necessary. The two functions create_grant_{hvm,pv}_mapping will be moved later in a dedicated patch with all their helpers. Signed-off-by: Wei Liu Reviewed-by: Jan Beulich --- xen/arch/x86/mm.c | 16 +++++------ xen/include/asm-x86/grant_table.h | 16 +++++++++-- xen/include/asm-x86/hvm/grant_table.h | 53 +++++++++++++++++++++++++++++++++++ xen/include/asm-x86/pv/grant_table.h | 52 ++++++++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 10 deletions(-) create mode 100644 xen/include/asm-x86/hvm/grant_table.h create mode 100644 xen/include/asm-x86/pv/grant_table.h diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 31fe8a1472..28bcff2c99 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -123,6 +123,9 @@ #include #include +#include +#include + /* Mapping of the fixmap space needed early. */ l1_pgentry_t __section(".bss.page_aligned") __aligned(PAGE_SIZE) l1_fixmap[L1_PAGETABLE_ENTRIES]; @@ -4014,9 +4017,9 @@ static int destroy_grant_va_mapping( return replace_grant_va_mapping(addr, frame, l1e_empty(), v); } -static int create_grant_p2m_mapping(uint64_t addr, unsigned long frame, - unsigned int flags, - unsigned int cache_flags) +int create_grant_p2m_mapping(uint64_t addr, unsigned long frame, + unsigned int flags, + unsigned int cache_flags) { p2m_type_t p2mt; int rc; @@ -4037,15 +4040,12 @@ static int create_grant_p2m_mapping(uint64_t addr, unsigned long frame, return GNTST_okay; } -int create_grant_host_mapping(uint64_t addr, unsigned long frame, - unsigned int flags, unsigned int cache_flags) +int create_grant_pv_mapping(uint64_t addr, unsigned long frame, + unsigned int flags, unsigned int cache_flags) { l1_pgentry_t pte; uint32_t grant_pte_flags; - if ( paging_mode_external(current->domain) ) - return create_grant_p2m_mapping(addr, frame, flags, cache_flags); - grant_pte_flags = _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_GNTTAB; if ( cpu_has_nx ) diff --git a/xen/include/asm-x86/grant_table.h b/xen/include/asm-x86/grant_table.h index 1561bdab0d..559ad2f275 100644 --- a/xen/include/asm-x86/grant_table.h +++ b/xen/include/asm-x86/grant_table.h @@ -7,14 +7,26 @@ #ifndef __ASM_GRANT_TABLE_H__ #define __ASM_GRANT_TABLE_H__ +#include + +#include +#include + #define INITIAL_NR_GRANT_FRAMES 4 /* * Caller must own caller's BIGLOCK, is responsible for flushing the TLB, and * must hold a reference to the page. */ -int create_grant_host_mapping(uint64_t addr, unsigned long frame, - unsigned int flags, unsigned int cache_flags); +static inline int create_grant_host_mapping(uint64_t addr, unsigned long frame, + unsigned int flags, + unsigned int cache_flags) +{ + if ( paging_mode_external(current->domain) ) + return create_grant_p2m_mapping(addr, frame, flags, cache_flags); + 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); diff --git a/xen/include/asm-x86/hvm/grant_table.h b/xen/include/asm-x86/hvm/grant_table.h new file mode 100644 index 0000000000..83202c219c --- /dev/null +++ b/xen/include/asm-x86/hvm/grant_table.h @@ -0,0 +1,53 @@ +/* + * asm-x86/hvm/grant_table.h + * + * Grant table interfaces for HVM guests + * + * Copyright (C) 2017 Wei Liu + * + * This program is free software; you can redistribute it and/or + * modify it under the terms and conditions of the GNU General Public + * License, version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; If not, see . + */ + +#ifndef __X86_HVM_GRANT_TABLE_H__ +#define __X86_HVM_GRANT_TABLE_H__ + +#ifdef CONFIG_HVM + +int create_grant_p2m_mapping(uint64_t addr, unsigned long frame, + unsigned int flags, + unsigned int cache_flags); + +#else + +#include + +static inline int create_grant_p2m_mapping(uint64_t addr, unsigned long frame, + unsigned int flags, + unsigned int cache_flags) +{ + return GNTST_general_error; +} + +#endif + +#endif /* __X86_HVM_GRANT_TABLE_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/asm-x86/pv/grant_table.h b/xen/include/asm-x86/pv/grant_table.h new file mode 100644 index 0000000000..165ebce22f --- /dev/null +++ b/xen/include/asm-x86/pv/grant_table.h @@ -0,0 +1,52 @@ +/* + * asm-x86/pv/grant_table.h + * + * Grant table interfaces for PV guests + * + * Copyright (C) 2017 Wei Liu + * + * This program is free software; you can redistribute it and/or + * modify it under the terms and conditions of the GNU General Public + * License, version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; If not, see . + */ + +#ifndef __X86_PV_GRANT_TABLE_H__ +#define __X86_PV_GRANT_TABLE_H__ + +#ifdef CONFIG_PV + +int create_grant_pv_mapping(uint64_t addr, unsigned long frame, + unsigned int flags, unsigned int cache_flags); + +#else + +#include + +static inline int create_grant_pv_mapping(uint64_t addr, unsigned long frame, + unsigned int flags, + unsigned int cache_flags) +{ + return GNTST_general_error; +} + +#endif + +#endif /* __X86_PV_GRANT_TABLE_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */