From patchwork Wed May 25 15:56:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9135701 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 67BCE607D5 for ; Wed, 25 May 2016 15:58:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FA9028249 for ; Wed, 25 May 2016 15:58:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3400928255; Wed, 25 May 2016 15:58:55 +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 9B5B028249 for ; Wed, 25 May 2016 15:58:54 +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 1b5bB1-0008Uh-3w; Wed, 25 May 2016 15:56:55 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b5bB0-0008UK-6r for xen-devel@lists.xen.org; Wed, 25 May 2016 15:56:54 +0000 Received: from [85.158.137.68] by server-17.bemta-3.messagelabs.com id 99/59-23929-44BC5475; Wed, 25 May 2016 15:56:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRWlGSWpSXmKPExsVysyfVTdf5tGu 4wZnL8hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0b3u8CCqfoVvV+62RsYfyt1MXJxCAlsYpTY Nm0HC4RzmlFi+fKjrF2MnBxsApoSdz5/YgKxRQSkJa59vswIUsQs8IpRomX6EhaQhLBAmsTfP 1vYuhg5OFgEVCU2bJIECfMKOEvsaFoEViIhICdx8thkVpASTgEXic4GsJFCQCVz/t5mmcDIvY CRYRWjenFqUVlqka65XlJRZnpGSW5iZo6uoYGxXm5qcXFiempOYlKxXnJ+7iZGoG8ZgGAHY+N 3p0OMkhxMSqK8T9a4hgvxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4FU6BZQTLEpNT61Iy8wBBhlM WoKDR0mE1wAkzVtckJhbnJkOkTrFqCglzqsJkhAASWSU5sG1wQL7EqOslDAvI9AhQjwFqUW5m SWo8q8YxTkYlYR5PUGm8GTmlcBNBwYf0M0ivP5fnEEWlyQipKQaGKfdVF3g0n6+//WFgIz6P5 8TbnRfcj17LCLJ7qzH11kyz5ce4rvN+UbY8PyhhFclF11TAico2vqE9SifsLarvpibznWXY7+ V6/Zd3usNKz9MP/F+c0KTbtJuPZfTeXueM8x6lB65yy5zXcu0kOiarTMVX8o6pJn1OVw6cX6y 1cXFrzZP6S+7clyJpTgj0VCLuag4EQAw+ZiAZwIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1464191810!32410506!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 63995 invoked from network); 25 May 2016 15:56:51 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-31.messagelabs.com with SMTP; 25 May 2016 15:56:51 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 513612AA; Wed, 25 May 2016 08:57:14 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.215.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DF2B33F218; Wed, 25 May 2016 08:56:48 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 25 May 2016 16:56:40 +0100 Message-Id: <1464191801-1294-2-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464191801-1294-1-git-send-email-julien.grall@arm.com> References: <1464191801-1294-1-git-send-email-julien.grall@arm.com> Cc: sstabellini@kernel.org, wei.liu2@citrix.com, andrew.cooper3@citrix.com, Ian.Jackson@eu.citrix.com, george.dunlap@citrix.com, tim@xen.org, Julien Grall , shannon.zhao@linaro.org Subject: [Xen-devel] [for-4.7 v2 1/2] xen: XENMEM_add_to_physmap_batch: Mark 'foreign_id' as reserved for dev_mmio 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The field 'foreign_id' is not used when the space is dev_mmio. As the space is not yet part of the stable ABI, the field is marked as reserved for future use. The value should always be 0, other values will return -EOPNOTSUPP. Signed-off-by: Julien Grall --- Changes in v2: - Return -EOPNOTSUPP rather than -ENOSYS - Introduce a union in the sturcutre xenmem_add_to_physmap_batch --- xen/arch/arm/mm.c | 9 +++++++-- xen/arch/x86/mm.c | 4 ++-- xen/common/compat/memory.c | 2 ++ xen/common/memory.c | 12 +++++++++--- xen/include/public/memory.h | 10 +++++++++- xen/include/xen/mm.h | 3 ++- 6 files changed, 31 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index b46e23e..79f4310 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1047,7 +1047,7 @@ void share_xen_page_with_privileged_guests( int xenmem_add_to_physmap_one( struct domain *d, unsigned int space, - domid_t foreign_domid, + union add_to_physmap_batch_extra extra, unsigned long idx, xen_pfn_t gpfn) { @@ -1103,7 +1103,8 @@ int xenmem_add_to_physmap_one( { struct domain *od; p2m_type_t p2mt; - od = rcu_lock_domain_by_any_id(foreign_domid); + + od = rcu_lock_domain_by_any_id(extra.foreign_domid); if ( od == NULL ) return -ESRCH; @@ -1143,6 +1144,10 @@ int xenmem_add_to_physmap_one( break; } case XENMAPSPACE_dev_mmio: + /* extra should be 0. Reserved for future use. */ + if ( extra.res0 ) + return -EOPNOTSUPP; + rc = map_dev_mmio_region(d, gpfn, 1, idx); return rc; diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 03a4d5b..0b67103 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4769,7 +4769,7 @@ static int handle_iomem_range(unsigned long s, unsigned long e, void *p) int xenmem_add_to_physmap_one( struct domain *d, unsigned int space, - domid_t foreign_domid, + union add_to_physmap_batch_extra extra, unsigned long idx, xen_pfn_t gpfn) { @@ -4830,7 +4830,7 @@ int xenmem_add_to_physmap_one( break; } case XENMAPSPACE_gmfn_foreign: - return p2m_add_foreign(d, idx, gpfn, foreign_domid); + return p2m_add_foreign(d, idx, gpfn, extra.foreign_domid); default: break; } diff --git a/xen/common/compat/memory.c b/xen/common/compat/memory.c index 19a914d..e56e187 100644 --- a/xen/common/compat/memory.c +++ b/xen/common/compat/memory.c @@ -253,6 +253,8 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) compat) unsigned int size = cmp.atpb.size; xen_ulong_t *idxs = (void *)(nat.atpb + 1); xen_pfn_t *gpfns = (void *)(idxs + limit); + enum XLAT_add_to_physmap_batch_u u = + XLAT_add_to_physmap_batch_u_res0; if ( copy_from_guest(&cmp.atpb, compat, 1) || !compat_handle_okay(cmp.atpb.idxs, size) || diff --git a/xen/common/memory.c b/xen/common/memory.c index 644f81a..b1ac8b9 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -639,9 +639,15 @@ static int xenmem_add_to_physmap(struct domain *d, { unsigned int done = 0; long rc = 0; + union add_to_physmap_batch_extra extra; + + if ( xatp->space != XENMAPSPACE_gmfn_foreign ) + extra.res0 = 0; + else + extra.foreign_domid = DOMID_INVALID; if ( xatp->space != XENMAPSPACE_gmfn_range ) - return xenmem_add_to_physmap_one(d, xatp->space, DOMID_INVALID, + return xenmem_add_to_physmap_one(d, xatp->space, extra, xatp->idx, xatp->gpfn); if ( xatp->size < start ) @@ -658,7 +664,7 @@ static int xenmem_add_to_physmap(struct domain *d, while ( xatp->size > done ) { - rc = xenmem_add_to_physmap_one(d, xatp->space, DOMID_INVALID, + rc = xenmem_add_to_physmap_one(d, xatp->space, extra, xatp->idx, xatp->gpfn); if ( rc < 0 ) break; @@ -719,7 +725,7 @@ static int xenmem_add_to_physmap_batch(struct domain *d, } rc = xenmem_add_to_physmap_one(d, xatpb->space, - xatpb->foreign_domid, + xatpb->u, idx, gpfn); if ( unlikely(__copy_to_guest_offset(xatpb->errs, 0, &rc, 1)) ) diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h index fe52ee1..a5ab139 100644 --- a/xen/include/public/memory.h +++ b/xen/include/public/memory.h @@ -259,7 +259,15 @@ struct xen_add_to_physmap_batch { /* Number of pages to go through */ uint16_t size; - domid_t foreign_domid; /* IFF gmfn_foreign */ + +#if __XEN_INTERFACE_VERSION__ < 0x00040700 + domid_t foreign_domid; /* IFF gmfn_foreign. Should be 0 for other spaces. */ +#else + union add_to_physmap_batch_extra { + domid_t foreign_domid; /* gmfn_foreign */ + uint16_t res0; /* All the other spaces. Should be 0 */ + } u; +#endif /* Indexes into space being mapped. */ XEN_GUEST_HANDLE(xen_ulong_t) idxs; diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index d4721fc..d82e0a4 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -50,6 +50,7 @@ #include #include #include +#include TYPE_SAFE(unsigned long, mfn); #define PRI_mfn "05lx" @@ -505,7 +506,7 @@ void scrub_one_page(struct page_info *); #endif int xenmem_add_to_physmap_one(struct domain *d, unsigned int space, - domid_t foreign_domid, + union add_to_physmap_batch_extra extra, unsigned long idx, xen_pfn_t gpfn); /* Returns 1 on success, 0 on error, negative if the ring