From 5fa3ab4ce3d4361880217d257e68d1242742d350 Mon Sep 17 00:00:00 2001 From: haozi007 Date: Tue, 6 Aug 2024 10:57:21 +0800 Subject: [PATCH] support user set remote mmap vma address 1. os auto assignment vma addr maybe conflict with vma in gpu living migrate scene; 2. so, we should give choice to user; Signed-off-by: haozi007 --- compel/include/uapi/infect.h | 1 + compel/src/lib/infect.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compel/include/uapi/infect.h b/compel/include/uapi/infect.h index cd62559097..696124db1d 100644 --- a/compel/include/uapi/infect.h +++ b/compel/include/uapi/infect.h @@ -120,6 +120,7 @@ struct infect_ctx { open_proc_fn open_proc; int log_fd; /* fd for parasite code to send messages to */ + unsigned long user_set_remote_map; }; extern struct infect_ctx *compel_infect_ctx(struct parasite_ctl *); diff --git a/compel/src/lib/infect.c b/compel/src/lib/infect.c index 79d00c9a10..dc0ffe268c 100644 --- a/compel/src/lib/infect.c +++ b/compel/src/lib/infect.c @@ -816,7 +816,7 @@ static int parasite_memfd_exchange(struct parasite_ctl *ctl, unsigned long size, uint8_t orig_code[MEMFD_FNAME_SZ] = MEMFD_FNAME; pid_t pid = ctl->rpid; long sret = -ENOSYS; - int ret, fd, lfd; + int ret, fd, lfd, remote_mmap_flags; if (ctl->ictx.flags & INFECT_NO_MEMFD) return 1; @@ -860,7 +860,11 @@ static int parasite_memfd_exchange(struct parasite_ctl *ctl, unsigned long size, goto err_cure; } - ctl->remote_map = remote_mmap(ctl, NULL, size, remote_prot, MAP_FILE | MAP_SHARED, fd, 0); + remote_mmap_flags = MAP_FILE | MAP_SHARED; + if (ctl->ictx.user_set_remote_map != 0L){ + remote_mmap_flags |= MAP_FIXED_NOREPLACE; + } + ctl->remote_map = remote_mmap(ctl, (void *)ctl->ictx.user_set_remote_map, size, remote_prot, remote_mmap_flags, fd, 0); if (!ctl->remote_map) { pr_err("Can't rmap memfd for parasite blob\n"); goto err_curef;