[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3 1/6] xen: improve changes to xen_add_to_physmap
This is an incremental patch on top of c0bc926083b5987a3e9944eec2c12ad0580100e2: in order to retain binary compatibility, it is better to introduce foreign_domid as part of a union containing both size and foreign_domid. Changes in v2: - do not use an anonymous union. Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> --- tools/firmware/hvmloader/pci.c | 2 +- xen/arch/arm/mm.c | 2 +- xen/arch/x86/mm.c | 10 +++++----- xen/arch/x86/x86_64/compat/mm.c | 6 ++++++ xen/include/public/memory.h | 11 +++++++---- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/tools/firmware/hvmloader/pci.c b/tools/firmware/hvmloader/pci.c index fd56e50..6375989 100644 --- a/tools/firmware/hvmloader/pci.c +++ b/tools/firmware/hvmloader/pci.c @@ -212,7 +212,7 @@ void pci_setup(void) xatp.space = XENMAPSPACE_gmfn_range; xatp.idx = hvm_info->low_mem_pgend; xatp.gpfn = hvm_info->high_mem_pgend; - xatp.size = nr_pages; + xatp.u.size = nr_pages; if ( hypercall_memory_op(XENMEM_add_to_physmap, &xatp) != 0 ) BUG(); hvm_info->high_mem_pgend += nr_pages; diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 08bc55b..2400e1c 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -506,7 +506,7 @@ static int xenmem_add_to_physmap_once( paddr_t maddr; struct domain *od; - rc = rcu_lock_target_domain_by_id(xatp->foreign_domid, &od); + rc = rcu_lock_target_domain_by_id(xatp->u.foreign_domid, &od); if ( rc < 0 ) return rc; maddr = p2m_lookup(od, xatp->idx << PAGE_SHIFT); diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 9f63974..f5c704e 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4630,7 +4630,7 @@ static int xenmem_add_to_physmap(struct domain *d, this_cpu(iommu_dont_flush_iotlb) = 1; start_xatp = *xatp; - while ( xatp->size > 0 ) + while ( xatp->u.size > 0 ) { rc = xenmem_add_to_physmap_once(d, xatp); if ( rc < 0 ) @@ -4638,10 +4638,10 @@ static int xenmem_add_to_physmap(struct domain *d, xatp->idx++; xatp->gpfn++; - xatp->size--; + xatp->u.size--; /* Check for continuation if it's not the last interation */ - if ( xatp->size > 0 && hypercall_preempt_check() ) + if ( xatp->u.size > 0 && hypercall_preempt_check() ) { rc = -EAGAIN; break; @@ -4651,8 +4651,8 @@ static int xenmem_add_to_physmap(struct domain *d, if ( need_iommu(d) ) { this_cpu(iommu_dont_flush_iotlb) = 0; - iommu_iotlb_flush(d, start_xatp.idx, start_xatp.size - xatp->size); - iommu_iotlb_flush(d, start_xatp.gpfn, start_xatp.size - xatp->size); + iommu_iotlb_flush(d, start_xatp.idx, start_xatp.u.size - xatp->u.size); + iommu_iotlb_flush(d, start_xatp.gpfn, start_xatp.u.size - xatp->u.size); } return rc; diff --git a/xen/arch/x86/x86_64/compat/mm.c b/xen/arch/x86/x86_64/compat/mm.c index f497503..5bcd2fd 100644 --- a/xen/arch/x86/x86_64/compat/mm.c +++ b/xen/arch/x86/x86_64/compat/mm.c @@ -59,10 +59,16 @@ int compat_arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg) { struct compat_add_to_physmap cmp; struct xen_add_to_physmap *nat = COMPAT_ARG_XLAT_VIRT_BASE; + enum XLAT_add_to_physmap_u u; if ( copy_from_guest(&cmp, arg, 1) ) return -EFAULT; + if ( cmp.space == XENMAPSPACE_gmfn_range ) + u = XLAT_add_to_physmap_u_size; + if ( cmp.space == XENMAPSPACE_gmfn_foreign ) + u = XLAT_add_to_physmap_u_foreign_domid; + XLAT_add_to_physmap(nat, &cmp); rc = arch_memory_op(op, guest_handle_from_ptr(nat, void)); diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h index b2adfbe..7d4ee26 100644 --- a/xen/include/public/memory.h +++ b/xen/include/public/memory.h @@ -208,8 +208,12 @@ 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; + union { + /* Number of pages to go through for gmfn_range */ + uint16_t size; + /* IFF gmfn_foreign */ + domid_t foreign_domid; + } u; /* Source mapping space. */ #define XENMAPSPACE_shared_info 0 /* shared info page */ @@ -217,8 +221,7 @@ struct xen_add_to_physmap { #define XENMAPSPACE_gmfn 2 /* GMFN */ #define XENMAPSPACE_gmfn_range 3 /* GMFN range */ #define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another guest */ - uint16_t space; - domid_t foreign_domid; /* IFF gmfn_foreign */ + unsigned int space; #define XENMAPIDX_grant_table_status 0x80000000 -- 1.7.2.5 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |