@@ -371,6 +371,8 @@
447 common memfd_secret sys_memfd_secret
448 common process_mrelease sys_process_mrelease
449 common futex_waitv sys_futex_waitv
+450 common mshare sys_mshare
+451 common mshare_unlink sys_mshare_unlink
#
# Due to a historical design error, certain syscalls are numbered differently
@@ -883,8 +883,13 @@ __SYSCALL(__NR_process_mrelease, sys_process_mrelease)
#define __NR_futex_waitv 449
__SYSCALL(__NR_futex_waitv, sys_futex_waitv)
+#define __NR_mshare 450
+__SYSCALL(__NR_mshare, sys_mshare)
+#define __NR_mshare_unlink 451
+__SYSCALL(__NR_mshare_unlink, sys_mshare_unlink)
+
#undef __NR_syscalls
-#define __NR_syscalls 450
+#define __NR_syscalls 452
/*
* 32 bit systems traditionally used different
@@ -35,7 +35,7 @@ CFLAGS_init-mm.o += $(call cc-disable-warning, override-init)
CFLAGS_init-mm.o += $(call cc-disable-warning, initializer-overrides)
mmu-y := nommu.o
-mmu-$(CONFIG_MMU) := highmem.o memory.o mincore.o \
+mmu-$(CONFIG_MMU) := highmem.o memory.o mincore.o mshare.o \
mlock.o mmap.o mmu_gather.o mprotect.o mremap.o \
msync.o page_vma_mapped.o pagewalk.o \
pgtable-generic.o rmap.o vmalloc.o
new file mode 100644
@@ -0,0 +1,60 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * mm/mshare.c
+ *
+ * Page table sharing code
+ *
+ *
+ * Copyright (C) 2021 Oracle Corp. All rights reserved.
+ * Authors: Matthew Wilcox
+ * Khalid Aziz
+ */
+
+#include <linux/anon_inodes.h>
+#include <linux/fs.h>
+#include <linux/syscalls.h>
+
+static const struct file_operations mshare_fops = {
+};
+
+/*
+ * mshare syscall. Returns a file descriptor
+ */
+SYSCALL_DEFINE5(mshare, const char *, name, unsigned long, addr,
+ unsigned long, len, int, oflag, mode_t, mode)
+{
+ int fd;
+
+ /*
+ * Address range being shared must be aligned to pgdir
+ * boundary and its size must be a multiple of pgdir size
+ */
+ if ((addr | len) & (PGDIR_SIZE - 1))
+ return -EINVAL;
+
+ /*
+ * Allocate a file descriptor to return
+ *
+ * TODO: This code ignores the object name completely. Add
+ * support for that
+ */
+ fd = anon_inode_getfd("mshare", &mshare_fops, NULL, O_RDWR);
+
+ return fd;
+}
+
+/*
+ * mshare_unlink syscall. Close and remove the named mshare'd object
+ */
+SYSCALL_DEFINE1(mshare_unlink, const char *, name)
+{
+ int fd;
+
+ /*
+ * Delete the named object
+ *
+ * TODO: Mark mshare'd range for deletion
+ *
+ */
+ return 0;
+}