Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

um: add mmap/mremap OS calls

For the upcoming shared-memory time-travel external
optimisations, we need to be able to mmap/mremap.
Add the necessary OS calls.

Link: https://patch.msgid.link/20240702192118.ca4472963638.Ic2da1d3a983fe57340c1b693badfa9c5bd2d8c61@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

+25
+2
arch/um/include/shared/os.h
··· 181 181 extern int os_sendmsg_fds(int fd, const void *buf, unsigned int len, 182 182 const int *fds, unsigned int fds_num); 183 183 int os_poll(unsigned int n, const int *fds); 184 + void *os_mmap_rw_shared(int fd, size_t size); 185 + void *os_mremap_rw_shared(void *old_addr, size_t old_size, size_t new_size); 184 186 185 187 /* start_up.c */ 186 188 extern void os_early_checks(void);
+23
arch/um/os-Linux/file.c
··· 17 17 #include <sys/stat.h> 18 18 #include <sys/sysmacros.h> 19 19 #include <sys/un.h> 20 + #include <sys/mman.h> 20 21 #include <sys/types.h> 21 22 #include <sys/eventfd.h> 22 23 #include <poll.h> ··· 718 717 } 719 718 720 719 return -EIO; 720 + } 721 + 722 + void *os_mmap_rw_shared(int fd, size_t size) 723 + { 724 + void *res = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); 725 + 726 + if (res == MAP_FAILED) 727 + return NULL; 728 + 729 + return res; 730 + } 731 + 732 + void *os_mremap_rw_shared(void *old_addr, size_t old_size, size_t new_size) 733 + { 734 + void *res; 735 + 736 + res = mremap(old_addr, old_size, new_size, MREMAP_MAYMOVE, NULL); 737 + 738 + if (res == MAP_FAILED) 739 + return NULL; 740 + 741 + return res; 721 742 }