diff mbox series

[RFC,kvmtool,v1,19/32] Add memfd_restricted system call

Message ID 20221202174417.1310826-20-tabba@google.com (mailing list archive)
State New, archived
Headers show
Series Add support for restricted guest memory in kvmtool | expand

Commit Message

Fuad Tabba Dec. 2, 2022, 5:44 p.m. UTC
This enables building kvmtool on a host that doesn't have the
kernel with the new extensions yet.

No functional change intended.

Signed-off-by: Fuad Tabba <tabba@google.com>
---
 util/util.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/util/util.c b/util/util.c
index 1f2e1a6..1424815 100644
--- a/util/util.c
+++ b/util/util.c
@@ -10,6 +10,17 @@ 
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <sys/statfs.h>
+#include <sys/syscall.h>
+
+#ifndef __NR_memfd_restricted
+#define __NR_memfd_restricted 451
+__SYSCALL(__NR_memfd_restricted, sys_memfd_restricted)
+#endif
+
+static inline int memfd_restricted(unsigned int flags)
+{
+	return syscall(__NR_memfd_restricted, flags);
+}
 
 static void report(const char *prefix, const char *err, va_list params)
 {