Question about grant table
Hi
I have a question regarding a grant table. I have a case when I have some shared (between domains) pages mapped to the user space. I created a special driver which implements mmap(). That, in turns, will execute gnttab_map_refs(). This all works fine until I want to do something like exec().
After I do exec(), I want to mmap() the *same* pages (i.e. using the same grant references) to some new user address space which is chosen by mmap(). During exec(), it will invalidate user address space, and release() from mmu_notifier will be called. This means, that my driver will execute gnttab_unmap_refs. After exec() succeeded, I invoke mmap() again which will do gnttab_map_refs().
At this point I get kernel errors like this:
[ 198.939095] BUG: Bad page map in process a.out pte:80000002457f1167 pmd:245094067
[ 198.939099] page:ffffea000915fc40 count:1 mapcount:-1 mapping: (null) index:0xffff8802d958f720 [ 198.939102] page flags: 0x8000000000000814(referenced|dirty|private)
[ 198.939109] addr:00007fd302f40000 vm_flags:000e00fb anon_vma: (null) mapping:ffff8802d782f760 index:0 [ 198.939124] vma->vm_ops->fault: 0x0
[ 198.939128] vma->vm_file->f_op->mmap: syscall_driver_mmap+0x0/0xc9 [syscall_driver]
So, I have two questions in this regard:
1. Does gnttab_unmap_refs removes grant references, so that I cannot use them any longer? What would be proper way to preserve grant references but at the same time unmap from the current user address space shared pages?
2. What happens to the counters like count, mapcount when I do gnttab_map_refs() and gnntab_unmap_refs()?
Thanks,
Ruslan
Quoted 26 lines
Quoted 1 line
Quoted 1 line · Ruslan Nikolaev
Hi
I have a question regarding a grant table. I have a case when I have some shared (between domains) pages mapped to the user space. I created a special driver which implements
mmap(). That, in turns, will executegnttab_map_refs(). This all works fine until I want to do something likeexec().After I do
exec(), I want tommap()the *same* pages (i.e. using the same grant references) to some new user address space which is chosen bymmap(). Duringexec(), it will invalidate user address space, andrelease()frommmu_notifierwill be called. This means, that my driver will executegnttab_unmap_refs. Afterexec()succeeded, I invokemmap()again which will dognttab_map_refs().At this point I get kernel errors like this:
[ 198.939095] BUG: Bad page map in process a.out pte:80000002457f1167 pmd:245094067 [ 198.939099] page:ffffea000915fc40 count:1 mapcount:-1 mapping: (null) index:0xffff8802d958f720 [ 198.939102] page flags: 0x8000000000000814(referenced|dirty|private) [ 198.939109] addr:00007fd302f40000 vm_flags:000e00fb anon_vma: (null) mapping:ffff8802d782f760 index:0 [ 198.939124] vma->vm_ops->fault: 0x0 [ 198.939128] vma->vm_file->f_op->mmap: syscall_driver_mmap+0x0/0xc9
Quoted 1 line
[
syscall_driver]
This I cannot spot in the upstream kernel (and you also didn't indicate that you use something different), so I think you need to start investigation at that end.
Jan
Quoted 16 lines
So, I have two questions in this regard:
1. Doesgnttab_unmap_refsremoves grant references, so that I cannot use them any longer? What would be proper way to preserve grant references but at the same time unmap from the current user address space shared pages?2. What happens to the counters like count, mapcount when I do
gnttab_map_refs()andgnntab_unmap_refs()?Thanks,
Ruslan_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Ok. Can you tell what 'clear_pte' for gnttab_unmap_refs exactly do?
Ruslan.
----- Original Message -----
From: Jan Beulich <[email protected]>
To: Ruslan Nikolaev <[email protected]>
Cc: "[email protected]" <[email protected]>
Sent: Tuesday, April 24, 2012 3:58 AM
Subject: Re: [Xen-devel] Question about grant table
Quoted 16 lines
Quoted 1 line
Quoted 1 line · Ruslan Nikolaev
Hi
I have a question regarding a grant table. I have a case when I have some shared (between domains) pages mapped to the user space. I created a special driver which implements
mmap(). That, in turns, will executegnttab_map_refs(). This all works fine until I want to do something likeexec().After I do
exec(), I want tommap()the *same* pages (i.e. using the same grant references) to some new user address space which is chosen bymmap(). Duringexec(), it will invalidate user address space, andrelease()frommmu_notifierwill be called. This means, that my driver will executegnttab_unmap_refs. Afterexec()succeeded, I invokemmap()again which will dognttab_map_refs().
Quoted 11 lines
At this point I get kernel errors like this:
[ 198.939095] BUG: Bad page map in process a.out pte:80000002457f1167 pmd:245094067
[ 198.939099] page:ffffea000915fc40 count:1 mapcount:-1 mapping:
(null) index:0xffff8802d958f720
[ 198.939102] page flags: 0x8000000000000814(referenced|dirty|private) [ 198.939109] addr:00007fd302f40000 vm_flags:000e00fbanon_vma:
(null) mapping:ffff8802d782f760 index:0
[ 198.939124]vma->vm_ops->fault:0x0
[ 198.939128]vma->vm_file->f_op->mmap:syscall_driver_mmap+0x0/0xc9[syscall_driver]
This I cannot spot in the upstream kernel (and you also didn't indicate that you use something different), so I think you need to start investigation at that end.
Jan
Quoted 8 lines
So, I have two questions in this regard:
1. Doesgnttab_unmap_refsremoves grant references, so that I cannot use them any longer? What would be proper way to preserve grant references but at the same time unmap from the current user address space shared pages?2. What happens to the counters like count, mapcount when I do
gnttab_map_refs()andgnntab_unmap_refs()?
Quoted 8 lines
Thanks,
Ruslan_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel