[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] xen/arm: p2m: Introduce helpers to insert and remove mapping
commit e8119e44a585ef0b343af9e6ae00b906b840b492 Author: Julien Grall <julien.grall@xxxxxxx> AuthorDate: Tue Jul 12 14:59:33 2016 +0100 Commit: Stefano Stabellini <sstabellini@xxxxxxxxxx> CommitDate: Wed Jul 13 18:52:09 2016 +0100 xen/arm: p2m: Introduce helpers to insert and remove mapping More the half of the arguments of INSERT and REMOVE are the same for each callers. Simplify the callers of apply_p2m_changes by adding new helpers which will fill common arguments with default values. Signed-off-by: Julien Grall <julien.grall@xxxxxxx> Acked-by: Stefano Stabellini <sstabellini@xxxxxxxxxx> --- xen/arch/arm/p2m.c | 70 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 2ba9477..dd890c2 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1158,17 +1158,40 @@ out: return rc; } +static inline int p2m_insert_mapping(struct domain *d, + gfn_t start_gfn, + unsigned long nr, + mfn_t mfn, + int mattr, p2m_type_t t) +{ + return apply_p2m_changes(d, INSERT, + pfn_to_paddr(gfn_x(start_gfn)), + pfn_to_paddr(gfn_x(start_gfn) + nr), + pfn_to_paddr(mfn_x(mfn)), + mattr, 0, t, d->arch.p2m.default_access); +} + +static inline int p2m_remove_mapping(struct domain *d, + gfn_t start_gfn, + unsigned long nr, + mfn_t mfn) +{ + return apply_p2m_changes(d, REMOVE, + pfn_to_paddr(gfn_x(start_gfn)), + pfn_to_paddr(gfn_x(start_gfn) + nr), + pfn_to_paddr(mfn_x(mfn)), + /* arguments below not used when removing mapping */ + MATTR_MEM, 0, p2m_invalid, + d->arch.p2m.default_access); +} + int map_regions_rw_cache(struct domain *d, gfn_t gfn, unsigned long nr, mfn_t mfn) { - return apply_p2m_changes(d, INSERT, - pfn_to_paddr(gfn_x(gfn)), - pfn_to_paddr(gfn_x(gfn) + nr), - pfn_to_paddr(mfn_x(mfn)), - MATTR_MEM, 0, p2m_mmio_direct, - d->arch.p2m.default_access); + return p2m_insert_mapping(d, gfn, nr, mfn, + MATTR_MEM, p2m_mmio_direct); } int unmap_regions_rw_cache(struct domain *d, @@ -1176,12 +1199,7 @@ int unmap_regions_rw_cache(struct domain *d, unsigned long nr, mfn_t mfn) { - return apply_p2m_changes(d, REMOVE, - pfn_to_paddr(gfn_x(gfn)), - pfn_to_paddr(gfn_x(gfn) + nr), - pfn_to_paddr(mfn_x(mfn)), - MATTR_MEM, 0, p2m_invalid, - d->arch.p2m.default_access); + return p2m_remove_mapping(d, gfn, nr, mfn); } int map_mmio_regions(struct domain *d, @@ -1189,12 +1207,8 @@ int map_mmio_regions(struct domain *d, unsigned long nr, mfn_t mfn) { - return apply_p2m_changes(d, INSERT, - pfn_to_paddr(gfn_x(start_gfn)), - pfn_to_paddr(gfn_x(start_gfn) + nr), - pfn_to_paddr(mfn_x(mfn)), - MATTR_DEV, 0, p2m_mmio_direct, - d->arch.p2m.default_access); + return p2m_insert_mapping(d, start_gfn, nr, mfn, + MATTR_DEV, p2m_mmio_direct); } int unmap_mmio_regions(struct domain *d, @@ -1202,12 +1216,7 @@ int unmap_mmio_regions(struct domain *d, unsigned long nr, mfn_t mfn) { - return apply_p2m_changes(d, REMOVE, - pfn_to_paddr(gfn_x(start_gfn)), - pfn_to_paddr(gfn_x(start_gfn) + nr), - pfn_to_paddr(mfn_x(mfn)), - MATTR_DEV, 0, p2m_invalid, - d->arch.p2m.default_access); + return p2m_remove_mapping(d, start_gfn, nr, mfn); } int map_dev_mmio_region(struct domain *d, @@ -1237,22 +1246,15 @@ int guest_physmap_add_entry(struct domain *d, unsigned long page_order, p2m_type_t t) { - return apply_p2m_changes(d, INSERT, - pfn_to_paddr(gfn_x(gfn)), - pfn_to_paddr(gfn_x(gfn) + (1 << page_order)), - pfn_to_paddr(mfn_x(mfn)), MATTR_MEM, 0, t, - d->arch.p2m.default_access); + return p2m_insert_mapping(d, gfn, (1 << page_order), mfn, + MATTR_MEM, t); } void guest_physmap_remove_page(struct domain *d, gfn_t gfn, mfn_t mfn, unsigned int page_order) { - apply_p2m_changes(d, REMOVE, - pfn_to_paddr(gfn_x(gfn)), - pfn_to_paddr(gfn_x(gfn) + (1<<page_order)), - pfn_to_paddr(mfn_x(mfn)), MATTR_MEM, 0, p2m_invalid, - d->arch.p2m.default_access); + p2m_remove_mapping(d, gfn, (1 << page_order), mfn); } int p2m_alloc_table(struct domain *d) -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |