mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
userfaultfd: non-cooperative: add mremap() event
The event denotes that an area [start:end] moves to different location. Length change isn't reported as "new" addresses, if they appear on the uffd reader side they will not contain any data and the latter can just zeromap them. Waiting for the event ACK is also done outside of mmap sem, as for fork event. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Pavel Emelyanov <[email protected]> Signed-off-by: Mike Rapoport <[email protected]> Signed-off-by: Andrea Arcangeli <[email protected]> Cc: "Dr. David Alan Gilbert" <[email protected]> Cc: Hillf Danton <[email protected]> Cc: Michael Rapoport <[email protected]> Cc: Mike Kravetz <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
d3aadc8ed4
commit
72f87654c6
4 changed files with 76 additions and 6 deletions
|
|
@ -596,6 +596,43 @@ void dup_userfaultfd_complete(struct list_head *fcs)
|
|||
}
|
||||
}
|
||||
|
||||
void mremap_userfaultfd_prep(struct vm_area_struct *vma,
|
||||
struct vm_userfaultfd_ctx *vm_ctx)
|
||||
{
|
||||
struct userfaultfd_ctx *ctx;
|
||||
|
||||
ctx = vma->vm_userfaultfd_ctx.ctx;
|
||||
if (ctx && (ctx->features & UFFD_FEATURE_EVENT_REMAP)) {
|
||||
vm_ctx->ctx = ctx;
|
||||
userfaultfd_ctx_get(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
void mremap_userfaultfd_complete(struct vm_userfaultfd_ctx vm_ctx,
|
||||
unsigned long from, unsigned long to,
|
||||
unsigned long len)
|
||||
{
|
||||
struct userfaultfd_ctx *ctx = vm_ctx.ctx;
|
||||
struct userfaultfd_wait_queue ewq;
|
||||
|
||||
if (!ctx)
|
||||
return;
|
||||
|
||||
if (to & ~PAGE_MASK) {
|
||||
userfaultfd_ctx_put(ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
msg_init(&ewq.msg);
|
||||
|
||||
ewq.msg.event = UFFD_EVENT_REMAP;
|
||||
ewq.msg.arg.remap.from = from;
|
||||
ewq.msg.arg.remap.to = to;
|
||||
ewq.msg.arg.remap.len = len;
|
||||
|
||||
userfaultfd_event_wait_completion(ctx, &ewq);
|
||||
}
|
||||
|
||||
static int userfaultfd_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct userfaultfd_ctx *ctx = file->private_data;
|
||||
|
|
|
|||
Loading…
Reference in a new issue