From: Jean Guyader Subject: [PATCH 5/7] mm: New XENMEM space, XENMAPSPACE_gmfn_range Date: Thu, 10 Nov 2011 11:35:29 +0000 Message-ID: <1320924931-6891-6-git-send-email-jean.guyader@eu.citrix.com> References: <1320924931-6891-1-git-send-email-jean.guyader@eu.citrix.com> <1320924931-6891-2-git-send-email-jean.guyader@eu.citrix.com> <1320924931-6891-3-git-send-email-jean.guyader@eu.citrix.com> <1320924931-6891-4-git-send-email-jean.guyader@eu.citrix.com> <1320924931-6891-5-git-send-email-jean.guyader@eu.citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------true" Return-path: In-Reply-To: <1320924931-6891-5-git-send-email-jean.guyader@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: keir@xen.org, allen.m.kay@intel.com, tim@xen.org, Jean Guyader , JBeulich@suse.com List-Id: xen-devel@lists.xenproject.org --------------true Content-Type: text/plain; charset="UTF-8"; format=fixed Content-Transfer-Encoding: 8bit XENMAPSPACE_gmfn_range is like XENMAPSPACE_gmfn but it runs on a range of pages. The size of the range is defined in a new field. This new field .size is located in the 16 bits padding between .domid and .space in struct xen_add_to_physmap to stay compatible with older versions. Signed-off-by: Jean Guyader --- xen/arch/x86/mm.c | 47 +++++++++++++++++++++++++++++++++++++- xen/arch/x86/x86_64/compat/mm.c | 12 ++++++++++ xen/include/public/memory.h | 4 +++ 3 files changed, 61 insertions(+), 2 deletions(-) --------------true Content-Type: text/x-patch; name="0005-mm-New-XENMEM-space-XENMAPSPACE_gmfn_range.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0005-mm-New-XENMEM-space-XENMAPSPACE_gmfn_range.patch" diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index c0da115..19d301b 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4592,8 +4592,8 @@ static int handle_iomem_range(unsigned long s, unsigned long e, void *p) return 0; } -int xenmem_add_to_physmap(struct domain *d, - struct xen_add_to_physmap *xatp) +int xenmem_add_to_physmap_once(struct domain *d, + struct xen_add_to_physmap *xatp) { struct page_info* page = NULL; unsigned long mfn = 0; @@ -4631,6 +4631,7 @@ int xenmem_add_to_physmap(struct domain *d, spin_unlock(&d->grant_table->lock); break; + case XENMAPSPACE_gmfn_range: case XENMAPSPACE_gmfn: { p2m_type_t p2mt; @@ -4691,6 +4692,37 @@ int xenmem_add_to_physmap(struct domain *d, return rc; } +int xenmem_add_to_physmap(struct domain *d, + struct xen_add_to_physmap *xatp) +{ + int rc = 0; + + if ( xatp->space == XENMAPSPACE_gmfn_range ) + { + while ( xatp->size > 0 ) + { + rc = xenmem_add_to_physmap_once(d, xatp); + if ( rc < 0 ) + return rc; + + xatp->idx++; + xatp->gpfn++; + xatp->size--; + + /* Check for continuation if it's not the last interation */ + if ( xatp->size > 0 && hypercall_preempt_check() ) + { + rc = -EAGAIN; + break; + } + } + + return rc; + } + + return xenmem_add_to_physmap_once(d, xatp); +} + long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg) { int rc; @@ -4716,6 +4748,17 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg) } rc = xenmem_add_to_physmap(d, &xatp); + if ( rc == -EAGAIN ) + { + if ( copy_to_guest(arg, &xatp, 1) ) + { + rcu_unlock_domain(d); + return -EFAULT; + } + + rc = hypercall_create_continuation( + __HYPERVISOR_memory_op, "ih", op, arg); + } rcu_unlock_domain(d); diff --git a/xen/arch/x86/x86_64/compat/mm.c b/xen/arch/x86/x86_64/compat/mm.c index 2c05099..8f4be25 100644 --- a/xen/arch/x86/x86_64/compat/mm.c +++ b/xen/arch/x86/x86_64/compat/mm.c @@ -63,6 +63,18 @@ int compat_arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg) XLAT_add_to_physmap(nat, &cmp); rc = arch_memory_op(op, guest_handle_from_ptr(nat, void)); + if ( rc < 0 ) + break; + + if ( rc == __HYPERVISOR_memory_op ) + { + hypercall_xlat_continuation(NULL, 0x2, nat, arg); + + XLAT_add_to_physmap(&cmp, nat); + + if ( copy_to_guest(arg, &cmp, 1) ) + return -EFAULT; + } break; } diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h index 08355e3..c5b78a8 100644 --- a/xen/include/public/memory.h +++ b/xen/include/public/memory.h @@ -208,10 +208,14 @@ struct xen_add_to_physmap { /* Which domain to change the mapping for. */ domid_t domid; + /* Number of pages to go through for gmfn_range */ + uint16_t size; + /* Source mapping space. */ #define XENMAPSPACE_shared_info 0 /* shared info page */ #define XENMAPSPACE_grant_table 1 /* grant table page */ #define XENMAPSPACE_gmfn 2 /* GMFN */ +#define XENMAPSPACE_gmfn_range 3 /* GMFN range */ unsigned int space; #define XENMAPIDX_grant_table_status 0x80000000 --------------true Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------true--