VAS segments are an extension to first class virtual address spaces that
can be used to share specific memory regions between multiple first class
virtual address spaces. VAS segments have a specific size and position in a
virtual address space and can thereby be used to share in-memory pointer
based data structures between multiple address spaces as well as other
in-memory data without the need to represent them in mmap-able files or
use shmem.
Similar to first class virtual address spaces, VAS segments must be created
and destroyed explicitly by a user. The system will never automatically
destroy or create a virtual segment. Via attaching a VAS segment to a first
class virtual address space, the memory that is contained in the VAS
segment can be accessed and changed.
Signed-off-by: Till Smejkal
Signed-off-by: Marco Benatto
---
arch/x86/entry/syscalls/syscall_32.tbl |7 +
arch/x86/entry/syscalls/syscall_64.tbl |7 +
include/linux/syscalls.h | 10 +
include/linux/vas.h| 114 +++
include/linux/vas_types.h | 91 ++-
include/uapi/asm-generic/unistd.h | 16 +-
include/uapi/linux/vas.h | 12 +
kernel/sys_ni.c|7 +
mm/vas.c | 1234 ++--
9 files changed, 1451 insertions(+), 47 deletions(-)
diff --git a/arch/x86/entry/syscalls/syscall_32.tbl
b/arch/x86/entry/syscalls/syscall_32.tbl
index 8c553eef8c44..a4f91d14a856 100644
--- a/arch/x86/entry/syscalls/syscall_32.tbl
+++ b/arch/x86/entry/syscalls/syscall_32.tbl
@@ -398,3 +398,10 @@
389i386active_vas sys_active_vas
390i386vas_getattr sys_vas_getattr
391i386vas_setattr sys_vas_setattr
+392i386vas_seg_create sys_vas_seg_create
+393i386vas_seg_delete sys_vas_seg_delete
+394i386vas_seg_findsys_vas_seg_find
+395i386vas_seg_attach sys_vas_seg_attach
+396i386vas_seg_detach sys_vas_seg_detach
+397i386vas_seg_getattr sys_vas_seg_getattr
+398i386vas_seg_setattr sys_vas_seg_setattr
diff --git a/arch/x86/entry/syscalls/syscall_64.tbl
b/arch/x86/entry/syscalls/syscall_64.tbl
index 72f1f0495710..a0f9503c3d28 100644
--- a/arch/x86/entry/syscalls/syscall_64.tbl
+++ b/arch/x86/entry/syscalls/syscall_64.tbl
@@ -347,6 +347,13 @@
338common active_vas sys_active_vas
339common vas_getattr sys_vas_getattr
340common vas_setattr sys_vas_setattr
+341common vas_seg_create sys_vas_seg_create
+342common vas_seg_delete sys_vas_seg_delete
+343common vas_seg_findsys_vas_seg_find
+344common vas_seg_attach sys_vas_seg_attach
+345common vas_seg_detach sys_vas_seg_detach
+346common vas_seg_getattr sys_vas_seg_getattr
+347common vas_seg_setattr sys_vas_seg_setattr
#
# x32-specific system call numbers start at 512 to avoid cache impact
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index fdea27d37c96..7380dcdc4bc1 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -66,6 +66,7 @@ struct perf_event_attr;
struct file_handle;
struct sigaltstack;
struct vas_attr;
+struct vas_seg_attr;
union bpf_attr;
#include
@@ -914,4 +915,13 @@ asmlinkage long sys_active_vas(void);
asmlinkage long sys_vas_getattr(int vid, struct vas_attr __user *attr);
asmlinkage long sys_vas_setattr(int vid, struct vas_attr __user *attr);
+asmlinkage long sys_vas_seg_create(const char __user *name, unsigned long
start,
+ unsigned long end, umode_t mode);
+asmlinkage long sys_vas_seg_delete(int sid);
+asmlinkage long sys_vas_seg_find(const char __user *name);
+asmlinkage long sys_vas_seg_attach(int vid, int sid, int type);
+asmlinkage long sys_vas_seg_detach(int vid, int sid);
+asmlinkage long sys_vas_seg_getattr(int sid, struct vas_seg_attr __user *attr);
+asmlinkage long sys_vas_seg_setattr(int sid, struct vas_seg_attr __user *attr);
+
#endif
diff --git a/include/linux/vas.h b/include/linux/vas.h
index 6a72e42f96d2..376b9fa1ee27 100644
--- a/include/linux/vas.h
+++ b/include/linux/vas.h
@@ -138,6 +138,120 @@ extern int vas_setattr(int vid, struct vas_attr *attr);
/***
+ * Management of VAS segments
+ ***/
+
+/**
+ * Lock and unlock helper for VAS segments.
+ **/
+#define vas_seg_lock(seg) mutex_lock(&(seg)->mtx)
+#define vas_seg_unlock(seg) mutex_unlock(&(seg)->mtx)
+
+/**
+ * Create a new VAS segment.
+ *
+ * @param[in] name:The name of the new VAS segment.
+ * @param[in] start: The address where the VAS segment begins.
+ * @param[in] end: The address where the VAS segment ends.
+ * @param[in] mode:The access rights for the VAS segment.
+ *
+ * @returns: The VAS segment ID on