The first mapping created on a gntdev file descriptor is placed at the top
of the offset space, so file_index + count * PAGE_SIZE wraps to 0 and
setting an unmap notification on it always fails with EINVAL.
gmap->file_index + gmap->count * PAGE_SIZE = 0xfffffffffffff000 + 1 * 0x1000 = 0
Avoid the wrap by subtracting the file index from the input index on the
other side of the comparison, and using OFF_TO_IDX() so there's no need to
convert the count into bytes.
Fixes: 78eb32933bb3 ("xen: add a grant-table user-space device")
PR: 300888
Reported by: Scott Blomenkamp
Sponsored by: Advanced Micro Devices, Inc.
MFC after: 1 week