Skip to content

Commit

Permalink
infiniband: Fix alignment of mmap cookies to support VIPT caching
Browse files Browse the repository at this point in the history
When vmalloc_user is used to create memory that is supposed to be mmap'd
to user space, it is necessary for the mmap cookie (eg the offset) to be
aligned to SHMLBA.

This creates a situation where all virtual mappings of the same physical
page share the same virtual cache index and guarantees VIPT coherence.
Otherwise the cache is non-coherent and the kernel will not see writes
by userspace when reading the shared page (or vice-versa).

Reported-by: Josh Beavers <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
Signed-off-by: Doug Ledford <[email protected]>
  • Loading branch information
jgunthorpe authored and dledford committed Mar 24, 2017
1 parent 86f46ab commit cb88645
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions drivers/infiniband/sw/rdmavt/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ struct rvt_mmap_info *rvt_create_mmap_info(struct rvt_dev_info *rdi,

spin_lock_irq(&rdi->mmap_offset_lock);
if (rdi->mmap_offset == 0)
rdi->mmap_offset = PAGE_SIZE;
rdi->mmap_offset = ALIGN(PAGE_SIZE, SHMLBA);
ip->offset = rdi->mmap_offset;
rdi->mmap_offset += size;
rdi->mmap_offset += ALIGN(size, SHMLBA);
spin_unlock_irq(&rdi->mmap_offset_lock);

INIT_LIST_HEAD(&ip->pending_mmaps);
Expand Down
4 changes: 2 additions & 2 deletions drivers/infiniband/sw/rxe/rxe_mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ struct rxe_mmap_info *rxe_create_mmap_info(struct rxe_dev *rxe,
spin_lock_bh(&rxe->mmap_offset_lock);

if (rxe->mmap_offset == 0)
rxe->mmap_offset = PAGE_SIZE;
rxe->mmap_offset = ALIGN(PAGE_SIZE, SHMLBA);

ip->info.offset = rxe->mmap_offset;
rxe->mmap_offset += size;
rxe->mmap_offset += ALIGN(size, SHMLBA);

spin_unlock_bh(&rxe->mmap_offset_lock);

Expand Down

0 comments on commit cb88645

Please sign in to comment.