--- ./configure.orig	2018-02-06 21:22:23.112834262 +0200
+++ ./configure	2018-02-06 21:36:35.539466249 +0200
@@ -3920,7 +3920,7 @@
 # check if memfd is supported
 memfd=no
 cat > $TMPC << EOF
-#include <sys/memfd.h>
+#include <sys/mman.h>
 
 int main(void)
 {
--- ./util/memfd.c.orig	2017-12-13 19:27:20.000000000 +0200
+++ ./util/memfd.c	2018-02-06 21:38:36.596127990 +0200
@@ -31,9 +31,7 @@
 
 #include "qemu/memfd.h"
 
-#ifdef CONFIG_MEMFD
-#include <sys/memfd.h>
-#elif defined CONFIG_LINUX
+#if defined CONFIG_LINUX && !defined CONFIG_MEMFD
 #include <sys/syscall.h>
 #include <asm/unistd.h>
 
