Skip to content

Commit 30dcc56

Browse files
committed
xen: assume XENFEAT_gnttab_map_avail_bits being set for pv guests
XENFEAT_gnttab_map_avail_bits is always set in Xen 4.0 and newer. Remove coding assuming it might be zero. Signed-off-by: Juergen Gross <jgross@suse.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Link: https://lore.kernel.org/r/20210730071804.4302-4-jgross@suse.com Signed-off-by: Juergen Gross <jgross@suse.com>
1 parent 2526cff commit 30dcc56

1 file changed

Lines changed: 2 additions & 34 deletions

File tree

drivers/xen/gntdev.c

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -266,20 +266,13 @@ static int find_grant_ptes(pte_t *pte, unsigned long addr, void *data)
266266
{
267267
struct gntdev_grant_map *map = data;
268268
unsigned int pgnr = (addr - map->vma->vm_start) >> PAGE_SHIFT;
269-
int flags = map->flags | GNTMAP_application_map | GNTMAP_contains_pte;
269+
int flags = map->flags | GNTMAP_application_map | GNTMAP_contains_pte |
270+
(1 << _GNTMAP_guest_avail0);
270271
u64 pte_maddr;
271272

272273
BUG_ON(pgnr >= map->count);
273274
pte_maddr = arbitrary_virt_to_machine(pte).maddr;
274275

275-
/*
276-
* Set the PTE as special to force get_user_pages_fast() fall
277-
* back to the slow path. If this is not supported as part of
278-
* the grant map, it will be done afterwards.
279-
*/
280-
if (xen_feature(XENFEAT_gnttab_map_avail_bits))
281-
flags |= (1 << _GNTMAP_guest_avail0);
282-
283276
gnttab_set_map_op(&map->map_ops[pgnr], pte_maddr, flags,
284277
map->grants[pgnr].ref,
285278
map->grants[pgnr].domid);
@@ -288,14 +281,6 @@ static int find_grant_ptes(pte_t *pte, unsigned long addr, void *data)
288281
return 0;
289282
}
290283

291-
#ifdef CONFIG_X86
292-
static int set_grant_ptes_as_special(pte_t *pte, unsigned long addr, void *data)
293-
{
294-
set_pte_at(current->mm, addr, pte, pte_mkspecial(*pte));
295-
return 0;
296-
}
297-
#endif
298-
299284
int gntdev_map_grant_pages(struct gntdev_grant_map *map)
300285
{
301286
int i, err = 0;
@@ -1055,23 +1040,6 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
10551040
err = vm_map_pages_zero(vma, map->pages, map->count);
10561041
if (err)
10571042
goto out_put_map;
1058-
} else {
1059-
#ifdef CONFIG_X86
1060-
/*
1061-
* If the PTEs were not made special by the grant map
1062-
* hypercall, do so here.
1063-
*
1064-
* This is racy since the mapping is already visible
1065-
* to userspace but userspace should be well-behaved
1066-
* enough to not touch it until the mmap() call
1067-
* returns.
1068-
*/
1069-
if (!xen_feature(XENFEAT_gnttab_map_avail_bits)) {
1070-
apply_to_page_range(vma->vm_mm, vma->vm_start,
1071-
vma->vm_end - vma->vm_start,
1072-
set_grant_ptes_as_special, NULL);
1073-
}
1074-
#endif
10751043
}
10761044

10771045
return 0;

0 commit comments

Comments
 (0)