[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] xen/gnttab: Refactor gnttab_clear_flag() to be gnttab_clear_flags()
commit 958524b25490d0a65ccea2e82665188be2f0ba3a Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> AuthorDate: Wed Nov 21 18:38:41 2018 +0000 Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CommitDate: Mon Jul 8 16:18:42 2019 -0500 xen/gnttab: Refactor gnttab_clear_flag() to be gnttab_clear_flags() To allow for further improvements, it is useful to be able to clear more than a single flag at once. Rework gnttab_clear_flag() into gnttab_clear_flags() which takes a bitmask rather than a bit number. No practical change yet. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> Acked-by: Julien Grall <julien.grall@xxxxxxx> --- xen/common/grant_table.c | 30 +++++++++++++++--------------- xen/include/asm-arm/grant_table.h | 6 +++--- xen/include/asm-x86/grant_table.h | 11 ++++------- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index 6d8f17d2ba..4bd5777d29 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -796,8 +796,8 @@ static int _set_status_v2(const grant_entry_header_t *shah, (scombo.domid != ldomid) || (!readonly && (scombo.flags & GTF_readonly)) ) { - gnttab_clear_flag(rd, _GTF_writing, status); - gnttab_clear_flag(rd, _GTF_reading, status); + gnttab_clear_flags(rd, GTF_writing, status); + gnttab_clear_flags(rd, GTF_reading, status); PIN_FAIL(done, GNTST_general_error, "Unstable flags (%x) or dom (%d); expected d%d (r/w: %d)\n", scombo.flags, scombo.domid, ldomid, !readonly); @@ -807,7 +807,7 @@ static int _set_status_v2(const grant_entry_header_t *shah, { if ( unlikely(scombo.flags & GTF_readonly) ) { - gnttab_clear_flag(rd, _GTF_writing, status); + gnttab_clear_flags(rd, GTF_writing, status); PIN_FAIL(done, GNTST_general_error, "Unstable grant readonly flag\n"); } @@ -1220,10 +1220,10 @@ map_grant_ref( unlock_out_clear: if ( !(op->flags & GNTMAP_readonly) && !(act->pin & (GNTPIN_hstw_mask|GNTPIN_devw_mask)) ) - gnttab_clear_flag(rd, _GTF_writing, status); + gnttab_clear_flags(rd, GTF_writing, status); if ( !act->pin ) - gnttab_clear_flag(rd, _GTF_reading, status); + gnttab_clear_flags(rd, GTF_reading, status); act_release_out: active_entry_release(act); @@ -1493,10 +1493,10 @@ unmap_common_complete(struct gnttab_unmap_common *op) if ( ((act->pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask)) == 0) && !(op->done & GNTMAP_readonly) ) - gnttab_clear_flag(rd, _GTF_writing, status); + gnttab_clear_flags(rd, GTF_writing, status); if ( act->pin == 0 ) - gnttab_clear_flag(rd, _GTF_reading, status); + gnttab_clear_flags(rd, GTF_reading, status); active_entry_release(act); grant_read_unlock(rgt); @@ -2354,11 +2354,11 @@ release_grant_for_copy( act->pin -= GNTPIN_hstw_inc; if ( !(act->pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask)) ) - gnttab_clear_flag(rd, _GTF_writing, status); + gnttab_clear_flags(rd, GTF_writing, status); } if ( !act->pin ) - gnttab_clear_flag(rd, _GTF_reading, status); + gnttab_clear_flags(rd, GTF_reading, status); active_entry_release(act); grant_read_unlock(rgt); @@ -2385,10 +2385,10 @@ static void fixup_status_for_copy_pin(struct domain *rd, uint16_t *status) { if ( !(act->pin & (GNTPIN_hstw_mask | GNTPIN_devw_mask)) ) - gnttab_clear_flag(rd, _GTF_writing, status); + gnttab_clear_flags(rd, GTF_writing, status); if ( !act->pin ) - gnttab_clear_flag(rd, _GTF_reading, status); + gnttab_clear_flags(rd, GTF_reading, status); } /* @@ -2639,10 +2639,10 @@ acquire_grant_for_copy( unlock_out_clear: if ( !(readonly) && !(act->pin & (GNTPIN_hstw_mask | GNTPIN_devw_mask)) ) - gnttab_clear_flag(rd, _GTF_writing, status); + gnttab_clear_flags(rd, GTF_writing, status); if ( !act->pin ) - gnttab_clear_flag(rd, _GTF_reading, status); + gnttab_clear_flags(rd, GTF_reading, status); unlock_out: active_entry_release(act); @@ -3677,11 +3677,11 @@ gnttab_release_mappings( } if ( (act->pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask)) == 0 ) - gnttab_clear_flag(rd, _GTF_writing, status); + gnttab_clear_flags(rd, GTF_writing, status); } if ( act->pin == 0 ) - gnttab_clear_flag(rd, _GTF_reading, status); + gnttab_clear_flags(rd, GTF_reading, status); active_entry_release(act); grant_read_unlock(rgt); diff --git a/xen/include/asm-arm/grant_table.h b/xen/include/asm-arm/grant_table.h index b0d673b0fe..ad120827ea 100644 --- a/xen/include/asm-arm/grant_table.h +++ b/xen/include/asm-arm/grant_table.h @@ -16,10 +16,10 @@ struct grant_table_arch { gfn_t *status_gfn; }; -static inline void gnttab_clear_flag(struct domain *d, - unsigned long nr, uint16_t *addr) +static inline void gnttab_clear_flags(struct domain *d, + unsigned int mask, uint16_t *addr) { - guest_clear_mask16(d, BIT(nr, UL), addr); + guest_clear_mask16(d, mask, addr); } static inline void gnttab_mark_dirty(struct domain *d, mfn_t mfn) diff --git a/xen/include/asm-x86/grant_table.h b/xen/include/asm-x86/grant_table.h index 121b33dc6e..568a6bb57c 100644 --- a/xen/include/asm-x86/grant_table.h +++ b/xen/include/asm-x86/grant_table.h @@ -60,14 +60,11 @@ static inline int replace_grant_host_mapping(uint64_t addr, mfn_t frame, #define gnttab_mark_dirty(d, f) paging_mark_dirty(d, f) -static inline void gnttab_clear_flag(struct domain *d, unsigned int nr, - uint16_t *st) +static inline void gnttab_clear_flags(struct domain *d, + unsigned int mask, uint16_t *addr) { - /* - * Note that this cannot be clear_bit(), as the access must be - * confined to the specified 2 bytes. - */ - asm volatile ("lock btrw %w1,%0" : "+m" (*st) : "Ir" (nr)); + /* Access must be confined to the specified 2 bytes. */ + asm volatile ("lock and %1,%0" : "+m" (*addr) : "ir" ((uint16_t)~mask)); } /* Foreign mappings of HVM-guest pages do not modify the type count. */ -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |