* [igt-dev] [PATCH i-g-t v2 0/2] Fix i-g-t on old systems
@ 2018-07-24 22:20 Lucas De Marchi
2018-07-24 22:20 ` [igt-dev] [PATCH i-g-t v2 1/2] build: provide include for missing syscalls Lucas De Marchi
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Lucas De Marchi @ 2018-07-24 22:20 UTC (permalink / raw)
To: igt-dev
IGT now requires memfd_create() which is not available on old versions
of glibc (or some alternative libcs). This provides a minimal intrusive
way to keep building on those old systems without polluting the code
with a compatibility layer.
The approach is similar to what I've been using in other projects like
systemd, kmod, ardupilot, etc. The syscall numbers came from systemd.
v2: add support to autotools
Lucas De Marchi (2):
build: provide include for missing syscalls
build: provide stub implementation for memfd_create
benchmarks/Makefile.am | 3 ++-
configure.ac | 3 +++
debugger/Makefile.am | 3 ++-
lib/Makefile.am | 3 ++-
lib/stubs/syscalls/README | 6 ++++++
lib/stubs/syscalls/sys/mman.h | 37 ++++++++++++++++++++++++++++++++
lib/tests/Makefile.am | 1 +
meson.build | 5 ++++-
overlay/Makefile.am | 3 ++-
tests/Makefile.am | 1 +
tools/Makefile.am | 3 ++-
tools/null_state_gen/Makefile.am | 3 ++-
12 files changed, 64 insertions(+), 7 deletions(-)
create mode 100644 lib/stubs/syscalls/README
create mode 100644 lib/stubs/syscalls/sys/mman.h
--
2.17.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 13+ messages in thread
* [igt-dev] [PATCH i-g-t v2 1/2] build: provide include for missing syscalls
2018-07-24 22:20 [igt-dev] [PATCH i-g-t v2 0/2] Fix i-g-t on old systems Lucas De Marchi
@ 2018-07-24 22:20 ` Lucas De Marchi
2018-07-25 0:04 ` Rodrigo Vivi
2018-08-02 10:19 ` Tvrtko Ursulin
2018-07-24 22:20 ` [igt-dev] [PATCH i-g-t v2 2/2] build: provide stub implementation for memfd_create Lucas De Marchi
` (2 subsequent siblings)
3 siblings, 2 replies; 13+ messages in thread
From: Lucas De Marchi @ 2018-07-24 22:20 UTC (permalink / raw)
To: igt-dev
Add directory with README file to allow missing syscalls to be defined.
The syscalls themselves will be provided in follow up patches.
v2: add support to autotools
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
benchmarks/Makefile.am | 3 ++-
debugger/Makefile.am | 3 ++-
lib/Makefile.am | 3 ++-
lib/stubs/syscalls/README | 6 ++++++
lib/tests/Makefile.am | 1 +
meson.build | 2 +-
overlay/Makefile.am | 3 ++-
tests/Makefile.am | 1 +
tools/Makefile.am | 3 ++-
tools/null_state_gen/Makefile.am | 3 ++-
10 files changed, 21 insertions(+), 7 deletions(-)
create mode 100644 lib/stubs/syscalls/README
diff --git a/benchmarks/Makefile.am b/benchmarks/Makefile.am
index 055e4c3a..979b9490 100644
--- a/benchmarks/Makefile.am
+++ b/benchmarks/Makefile.am
@@ -11,7 +11,8 @@ endif
AM_CPPFLAGS = \
-I$(top_srcdir) \
-I$(top_srcdir)/include/drm-uapi \
- -I$(top_srcdir)/lib
+ -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/lib/stubs/syscalls
AM_CFLAGS = -I$(top_srcdir)/include/drm-uapi \
$(DRM_CFLAGS) $(CWARNFLAGS) $(CAIRO_CFLAGS) $(LIBUNWIND_CFLAGS) \
diff --git a/debugger/Makefile.am b/debugger/Makefile.am
index ceaab6f8..e3a084d2 100644
--- a/debugger/Makefile.am
+++ b/debugger/Makefile.am
@@ -7,7 +7,8 @@ noinst_PROGRAMS = debug_rdata
AM_CPPFLAGS = \
-I$(top_srcdir) \
-I$(top_srcdir)/lib \
- -I$(top_srcdir)/include/drm-uapi
+ -I$(top_srcdir)/include/drm-uapi \
+ -I$(top_srcdir)/lib/stubs/syscalls
AM_CFLAGS = \
$(DRM_CFLAGS) \
diff --git a/lib/Makefile.am b/lib/Makefile.am
index ab9eefe6..6251bdb8 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -52,7 +52,8 @@ endif
AM_CPPFLAGS = \
-I$(top_srcdir)/include/drm-uapi \
- -I$(top_srcdir)
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/lib/stubs/syscalls
AM_CFLAGS = \
$(CWARNFLAGS) \
diff --git a/lib/stubs/syscalls/README b/lib/stubs/syscalls/README
new file mode 100644
index 00000000..f05b9a6f
--- /dev/null
+++ b/lib/stubs/syscalls/README
@@ -0,0 +1,6 @@
+This directory contains stub implementations for syscalls missing from libc.
+This provides a way to build IGT on an old system, but it will not run
+correctly if the kernel is missing the functionality provided. In order to
+add a new definition, follow the same directory hierarchy as the standard
+location in which the header is defined so we don't have to clutter the
+codebase to support old systems.
diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am
index fb433d69..ad585b77 100644
--- a/lib/tests/Makefile.am
+++ b/lib/tests/Makefile.am
@@ -11,6 +11,7 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/include/drm-uapi \
-I$(srcdir)/../.. \
-I$(srcdir)/.. \
+ -I$(top_srcdir)/lib/stubs/syscalls \
-include "$(srcdir)/../../lib/check-ndebug.h" \
-DIGT_DATADIR=\""$(abs_srcdir)"\" \
-D_GNU_SOURCE
diff --git a/meson.build b/meson.build
index 5a931565..22118828 100644
--- a/meson.build
+++ b/meson.build
@@ -64,7 +64,7 @@ _tests_required = build_tests == 'true'
build_info = []
-inc = include_directories('include/drm-uapi', 'lib', '.')
+inc = include_directories('include/drm-uapi', 'lib', 'lib/stubs/syscalls', '.')
inc_for_gtkdoc = include_directories('lib')
diff --git a/overlay/Makefile.am b/overlay/Makefile.am
index 0f553b7c..4cf82dc6 100644
--- a/overlay/Makefile.am
+++ b/overlay/Makefile.am
@@ -7,7 +7,8 @@ endif
tracepoint_format.h: tracepoint_format.leg
$(LEG) -o $@ $<
-AM_CPPFLAGS = -I. -I$(top_srcdir)/include/drm-uapi
+AM_CPPFLAGS = -I. -I$(top_srcdir)/include/drm-uapi \
+ -I$(top_srcdir)/lib/stubs/syscalls
AM_CFLAGS = $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) \
$(CAIRO_CFLAGS) $(OVERLAY_CFLAGS) $(WERROR_CFLAGS) -I$(srcdir)/../lib
LDADD = $(DRM_LIBS) $(PCIACCESS_LIBS) $(CAIRO_LIBS) $(OVERLAY_LIBS) $(top_builddir)/lib/libigt_perf.la
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ba307b22..8712eb16 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -88,6 +88,7 @@ AM_CFLAGS = $(CWARNFLAGS) -Wno-unused-result $(DEBUG_CFLAGS)\
-I$(top_srcdir)/include/drm-uapi \
-I$(srcdir)/.. \
-I$(srcdir)/../lib \
+ -I$(top_srcdir)/lib/stubs/syscalls \
-include "$(srcdir)/../lib/check-ndebug.h" \
-DIGT_SRCDIR=\""$(abs_srcdir)"\" \
-DIGT_DATADIR=\""$(pkgdatadir)"\" \
diff --git a/tools/Makefile.am b/tools/Makefile.am
index a0b016dd..e7de4d90 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -13,7 +13,8 @@ intel_dp_compliance_LDADD = $(top_builddir)/lib/libintel_tools.la
SUBDIRS = null_state_gen registers
-AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include/drm-uapi -I$(top_srcdir)/lib
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include/drm-uapi -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/lib/stubs/syscalls
AM_CFLAGS = $(DEBUG_CFLAGS) $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) \
$(CAIRO_CFLAGS) $(LIBUNWIND_CFLAGS) -DIGT_DATADIR=\"$(pkgdatadir)\" \
$(WERROR_CFLAGS) -D_GNU_SOURCE
diff --git a/tools/null_state_gen/Makefile.am b/tools/null_state_gen/Makefile.am
index d1dc83ab..d4aa3d44 100644
--- a/tools/null_state_gen/Makefile.am
+++ b/tools/null_state_gen/Makefile.am
@@ -1,5 +1,6 @@
GPU_TOOLS_PATH := $(top_srcdir)
-AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include/drm-uapi
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include/drm-uapi \
+ -I$(top_srcdir)/lib/stubs/syscalls
AM_CFLAGS = $(DEBUG_CFLAGS) $(CWARNFLAGS)
noinst_PROGRAMS = intel_null_state_gen
--
2.17.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [igt-dev] [PATCH i-g-t v2 2/2] build: provide stub implementation for memfd_create
2018-07-24 22:20 [igt-dev] [PATCH i-g-t v2 0/2] Fix i-g-t on old systems Lucas De Marchi
2018-07-24 22:20 ` [igt-dev] [PATCH i-g-t v2 1/2] build: provide include for missing syscalls Lucas De Marchi
@ 2018-07-24 22:20 ` Lucas De Marchi
2018-07-25 0:04 ` Rodrigo Vivi
` (2 more replies)
2018-07-24 23:32 ` [igt-dev] ✓ Fi.CI.BAT: success for Fix i-g-t on old systems (rev2) Patchwork
2018-07-25 1:25 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
3 siblings, 3 replies; 13+ messages in thread
From: Lucas De Marchi @ 2018-07-24 22:20 UTC (permalink / raw)
To: igt-dev
When libc misses memfd_create(), provide a stub implementation to go
through the syscall() route. Syscall numbers are provided for platforms
currently supported by i-g-t only.
v2: add support to autotools
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
configure.ac | 3 +++
lib/stubs/syscalls/sys/mman.h | 37 +++++++++++++++++++++++++++++++++++
meson.build | 3 +++
3 files changed, 43 insertions(+)
create mode 100644 lib/stubs/syscalls/sys/mman.h
diff --git a/configure.ac b/configure.ac
index 0a5b0425..416a3240 100644
--- a/configure.ac
+++ b/configure.ac
@@ -81,6 +81,9 @@ AC_CHECK_FUNCS(timer_create, [], [
])
AC_SUBST(TIMER_LIBS)
+dnl Check for memfd_create
+AC_CHECK_FUNCS(memfd_create)
+
dnl Check for CPUID
cpuid="yes"
AC_TRY_LINK([
diff --git a/lib/stubs/syscalls/sys/mman.h b/lib/stubs/syscalls/sys/mman.h
new file mode 100644
index 00000000..2ac2da6a
--- /dev/null
+++ b/lib/stubs/syscalls/sys/mman.h
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: MIT */
+
+#pragma once
+
+#include_next <sys/mman.h>
+
+#if !defined(HAVE_MEMFD_CREATE) || !HAVE_MEMFD_CREATE
+#include <errno.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#ifndef __NR_memfd_create
+#if defined __x86_64__
+#define __NR_memfd_create 319
+#elif defined __i386__
+#define __NR_memfd_create 356
+#elif defined __arm__
+#define __NR_memfd_create 385
+#else
+#warning "__NR_memfd_create unknown for your architecture"
+#endif
+#endif
+
+static inline int missing_memfd_create(const char *name, unsigned int flags)
+{
+#ifdef __NR_memfd_create
+ return syscall(__NR_memfd_create, name, flags);
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+}
+
+#define memfd_create missing_memfd_create
+
+#endif
diff --git a/meson.build b/meson.build
index 22118828..63ac6292 100644
--- a/meson.build
+++ b/meson.build
@@ -196,6 +196,9 @@ if cc.has_member('struct sysinfo', 'totalram',
config.set('HAVE_STRUCT_SYSINFO_TOTALRAM', 1)
endif
+have = cc.has_function('memfd_create', prefix : '''#include <sys/mman.h>''', args : '-D_GNU_SOURCE')
+config.set10('HAVE_MEMFD_CREATE', have)
+
add_project_arguments('-D_GNU_SOURCE', language : 'c')
add_project_arguments('-include', 'config.h', language : 'c')
--
2.17.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [igt-dev] ✓ Fi.CI.BAT: success for Fix i-g-t on old systems (rev2)
2018-07-24 22:20 [igt-dev] [PATCH i-g-t v2 0/2] Fix i-g-t on old systems Lucas De Marchi
2018-07-24 22:20 ` [igt-dev] [PATCH i-g-t v2 1/2] build: provide include for missing syscalls Lucas De Marchi
2018-07-24 22:20 ` [igt-dev] [PATCH i-g-t v2 2/2] build: provide stub implementation for memfd_create Lucas De Marchi
@ 2018-07-24 23:32 ` Patchwork
2018-07-25 1:25 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
3 siblings, 0 replies; 13+ messages in thread
From: Patchwork @ 2018-07-24 23:32 UTC (permalink / raw)
To: Lucas De Marchi; +Cc: igt-dev
== Series Details ==
Series: Fix i-g-t on old systems (rev2)
URL : https://patchwork.freedesktop.org/series/46892/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4534 -> IGTPW_1643 =
== Summary - SUCCESS ==
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/46892/revisions/2/mbox/
== Known issues ==
Here are the changes found in IGTPW_1643 that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@kms_chamelium@dp-crc-fast:
fi-kbl-7500u: PASS -> DMESG-FAIL (fdo#103841)
==== Possible fixes ====
igt@gem_exec_flush@basic-wb-ro-default:
fi-glk-j4005: DMESG-WARN (fdo#105719) -> PASS
fdo#103841 https://bugs.freedesktop.org/show_bug.cgi?id=103841
fdo#105719 https://bugs.freedesktop.org/show_bug.cgi?id=105719
== Participating hosts (52 -> 41) ==
Missing (11): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-kbl-8809g fi-pnv-d510 fi-icl-u fi-skl-caroline fi-byt-clapper fi-bdw-samus
== Build changes ==
* IGT: IGT_4572 -> IGTPW_1643
CI_DRM_4534: a59bbda34ede6f5685fdc86b58f143bada751617 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_1643: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1643/
IGT_4572: 9b064015df14506b23cd2d7245a73e1b1d16ee1f @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1643/issues.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [igt-dev] [PATCH i-g-t v2 1/2] build: provide include for missing syscalls
2018-07-24 22:20 ` [igt-dev] [PATCH i-g-t v2 1/2] build: provide include for missing syscalls Lucas De Marchi
@ 2018-07-25 0:04 ` Rodrigo Vivi
2018-08-02 10:19 ` Tvrtko Ursulin
1 sibling, 0 replies; 13+ messages in thread
From: Rodrigo Vivi @ 2018-07-25 0:04 UTC (permalink / raw)
To: Lucas De Marchi; +Cc: igt-dev
On Tue, Jul 24, 2018 at 03:20:23PM -0700, Lucas De Marchi wrote:
> Add directory with README file to allow missing syscalls to be defined.
> The syscalls themselves will be provided in follow up patches.
>
> v2: add support to autotools
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> benchmarks/Makefile.am | 3 ++-
> debugger/Makefile.am | 3 ++-
> lib/Makefile.am | 3 ++-
> lib/stubs/syscalls/README | 6 ++++++
> lib/tests/Makefile.am | 1 +
> meson.build | 2 +-
> overlay/Makefile.am | 3 ++-
> tests/Makefile.am | 1 +
> tools/Makefile.am | 3 ++-
> tools/null_state_gen/Makefile.am | 3 ++-
> 10 files changed, 21 insertions(+), 7 deletions(-)
> create mode 100644 lib/stubs/syscalls/README
>
> diff --git a/benchmarks/Makefile.am b/benchmarks/Makefile.am
> index 055e4c3a..979b9490 100644
> --- a/benchmarks/Makefile.am
> +++ b/benchmarks/Makefile.am
> @@ -11,7 +11,8 @@ endif
> AM_CPPFLAGS = \
> -I$(top_srcdir) \
> -I$(top_srcdir)/include/drm-uapi \
> - -I$(top_srcdir)/lib
> + -I$(top_srcdir)/lib \
> + -I$(top_srcdir)/lib/stubs/syscalls
>
> AM_CFLAGS = -I$(top_srcdir)/include/drm-uapi \
> $(DRM_CFLAGS) $(CWARNFLAGS) $(CAIRO_CFLAGS) $(LIBUNWIND_CFLAGS) \
> diff --git a/debugger/Makefile.am b/debugger/Makefile.am
> index ceaab6f8..e3a084d2 100644
> --- a/debugger/Makefile.am
> +++ b/debugger/Makefile.am
> @@ -7,7 +7,8 @@ noinst_PROGRAMS = debug_rdata
> AM_CPPFLAGS = \
> -I$(top_srcdir) \
> -I$(top_srcdir)/lib \
> - -I$(top_srcdir)/include/drm-uapi
> + -I$(top_srcdir)/include/drm-uapi \
> + -I$(top_srcdir)/lib/stubs/syscalls
>
> AM_CFLAGS = \
> $(DRM_CFLAGS) \
> diff --git a/lib/Makefile.am b/lib/Makefile.am
> index ab9eefe6..6251bdb8 100644
> --- a/lib/Makefile.am
> +++ b/lib/Makefile.am
> @@ -52,7 +52,8 @@ endif
>
> AM_CPPFLAGS = \
> -I$(top_srcdir)/include/drm-uapi \
> - -I$(top_srcdir)
> + -I$(top_srcdir) \
> + -I$(top_srcdir)/lib/stubs/syscalls
>
> AM_CFLAGS = \
> $(CWARNFLAGS) \
> diff --git a/lib/stubs/syscalls/README b/lib/stubs/syscalls/README
> new file mode 100644
> index 00000000..f05b9a6f
> --- /dev/null
> +++ b/lib/stubs/syscalls/README
> @@ -0,0 +1,6 @@
> +This directory contains stub implementations for syscalls missing from libc.
> +This provides a way to build IGT on an old system, but it will not run
> +correctly if the kernel is missing the functionality provided. In order to
> +add a new definition, follow the same directory hierarchy as the standard
> +location in which the header is defined so we don't have to clutter the
> +codebase to support old systems.
> diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am
> index fb433d69..ad585b77 100644
> --- a/lib/tests/Makefile.am
> +++ b/lib/tests/Makefile.am
> @@ -11,6 +11,7 @@ AM_CPPFLAGS = \
> -I$(top_srcdir)/include/drm-uapi \
> -I$(srcdir)/../.. \
> -I$(srcdir)/.. \
> + -I$(top_srcdir)/lib/stubs/syscalls \
> -include "$(srcdir)/../../lib/check-ndebug.h" \
> -DIGT_DATADIR=\""$(abs_srcdir)"\" \
> -D_GNU_SOURCE
> diff --git a/meson.build b/meson.build
> index 5a931565..22118828 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -64,7 +64,7 @@ _tests_required = build_tests == 'true'
>
> build_info = []
>
> -inc = include_directories('include/drm-uapi', 'lib', '.')
> +inc = include_directories('include/drm-uapi', 'lib', 'lib/stubs/syscalls', '.')
>
> inc_for_gtkdoc = include_directories('lib')
>
> diff --git a/overlay/Makefile.am b/overlay/Makefile.am
> index 0f553b7c..4cf82dc6 100644
> --- a/overlay/Makefile.am
> +++ b/overlay/Makefile.am
> @@ -7,7 +7,8 @@ endif
> tracepoint_format.h: tracepoint_format.leg
> $(LEG) -o $@ $<
>
> -AM_CPPFLAGS = -I. -I$(top_srcdir)/include/drm-uapi
> +AM_CPPFLAGS = -I. -I$(top_srcdir)/include/drm-uapi \
> + -I$(top_srcdir)/lib/stubs/syscalls
> AM_CFLAGS = $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) \
> $(CAIRO_CFLAGS) $(OVERLAY_CFLAGS) $(WERROR_CFLAGS) -I$(srcdir)/../lib
> LDADD = $(DRM_LIBS) $(PCIACCESS_LIBS) $(CAIRO_LIBS) $(OVERLAY_LIBS) $(top_builddir)/lib/libigt_perf.la
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index ba307b22..8712eb16 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -88,6 +88,7 @@ AM_CFLAGS = $(CWARNFLAGS) -Wno-unused-result $(DEBUG_CFLAGS)\
> -I$(top_srcdir)/include/drm-uapi \
> -I$(srcdir)/.. \
> -I$(srcdir)/../lib \
> + -I$(top_srcdir)/lib/stubs/syscalls \
> -include "$(srcdir)/../lib/check-ndebug.h" \
> -DIGT_SRCDIR=\""$(abs_srcdir)"\" \
> -DIGT_DATADIR=\""$(pkgdatadir)"\" \
> diff --git a/tools/Makefile.am b/tools/Makefile.am
> index a0b016dd..e7de4d90 100644
> --- a/tools/Makefile.am
> +++ b/tools/Makefile.am
> @@ -13,7 +13,8 @@ intel_dp_compliance_LDADD = $(top_builddir)/lib/libintel_tools.la
>
> SUBDIRS = null_state_gen registers
>
> -AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include/drm-uapi -I$(top_srcdir)/lib
> +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include/drm-uapi -I$(top_srcdir)/lib \
> + -I$(top_srcdir)/lib/stubs/syscalls
> AM_CFLAGS = $(DEBUG_CFLAGS) $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) \
> $(CAIRO_CFLAGS) $(LIBUNWIND_CFLAGS) -DIGT_DATADIR=\"$(pkgdatadir)\" \
> $(WERROR_CFLAGS) -D_GNU_SOURCE
> diff --git a/tools/null_state_gen/Makefile.am b/tools/null_state_gen/Makefile.am
> index d1dc83ab..d4aa3d44 100644
> --- a/tools/null_state_gen/Makefile.am
> +++ b/tools/null_state_gen/Makefile.am
> @@ -1,5 +1,6 @@
> GPU_TOOLS_PATH := $(top_srcdir)
> -AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include/drm-uapi
> +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include/drm-uapi \
> + -I$(top_srcdir)/lib/stubs/syscalls
> AM_CFLAGS = $(DEBUG_CFLAGS) $(CWARNFLAGS)
>
> noinst_PROGRAMS = intel_null_state_gen
> --
> 2.17.1
>
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [igt-dev] [PATCH i-g-t v2 2/2] build: provide stub implementation for memfd_create
2018-07-24 22:20 ` [igt-dev] [PATCH i-g-t v2 2/2] build: provide stub implementation for memfd_create Lucas De Marchi
@ 2018-07-25 0:04 ` Rodrigo Vivi
2018-07-25 16:46 ` Antonio Argenziano
2018-08-02 10:18 ` Tvrtko Ursulin
2 siblings, 0 replies; 13+ messages in thread
From: Rodrigo Vivi @ 2018-07-25 0:04 UTC (permalink / raw)
To: Lucas De Marchi; +Cc: igt-dev
On Tue, Jul 24, 2018 at 03:20:24PM -0700, Lucas De Marchi wrote:
> When libc misses memfd_create(), provide a stub implementation to go
> through the syscall() route. Syscall numbers are provided for platforms
> currently supported by i-g-t only.
>
> v2: add support to autotools
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> configure.ac | 3 +++
> lib/stubs/syscalls/sys/mman.h | 37 +++++++++++++++++++++++++++++++++++
> meson.build | 3 +++
> 3 files changed, 43 insertions(+)
> create mode 100644 lib/stubs/syscalls/sys/mman.h
>
> diff --git a/configure.ac b/configure.ac
> index 0a5b0425..416a3240 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -81,6 +81,9 @@ AC_CHECK_FUNCS(timer_create, [], [
> ])
> AC_SUBST(TIMER_LIBS)
>
> +dnl Check for memfd_create
> +AC_CHECK_FUNCS(memfd_create)
> +
> dnl Check for CPUID
> cpuid="yes"
> AC_TRY_LINK([
> diff --git a/lib/stubs/syscalls/sys/mman.h b/lib/stubs/syscalls/sys/mman.h
> new file mode 100644
> index 00000000..2ac2da6a
> --- /dev/null
> +++ b/lib/stubs/syscalls/sys/mman.h
> @@ -0,0 +1,37 @@
> +/* SPDX-License-Identifier: MIT */
> +
> +#pragma once
> +
> +#include_next <sys/mman.h>
> +
> +#if !defined(HAVE_MEMFD_CREATE) || !HAVE_MEMFD_CREATE
> +#include <errno.h>
> +#include <sys/syscall.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +
> +#ifndef __NR_memfd_create
> +#if defined __x86_64__
> +#define __NR_memfd_create 319
> +#elif defined __i386__
> +#define __NR_memfd_create 356
> +#elif defined __arm__
> +#define __NR_memfd_create 385
> +#else
> +#warning "__NR_memfd_create unknown for your architecture"
> +#endif
> +#endif
> +
> +static inline int missing_memfd_create(const char *name, unsigned int flags)
> +{
> +#ifdef __NR_memfd_create
> + return syscall(__NR_memfd_create, name, flags);
> +#else
> + errno = ENOSYS;
> + return -1;
> +#endif
> +}
> +
> +#define memfd_create missing_memfd_create
> +
> +#endif
> diff --git a/meson.build b/meson.build
> index 22118828..63ac6292 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -196,6 +196,9 @@ if cc.has_member('struct sysinfo', 'totalram',
> config.set('HAVE_STRUCT_SYSINFO_TOTALRAM', 1)
> endif
>
> +have = cc.has_function('memfd_create', prefix : '''#include <sys/mman.h>''', args : '-D_GNU_SOURCE')
> +config.set10('HAVE_MEMFD_CREATE', have)
> +
> add_project_arguments('-D_GNU_SOURCE', language : 'c')
> add_project_arguments('-include', 'config.h', language : 'c')
>
> --
> 2.17.1
>
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 13+ messages in thread
* [igt-dev] ✓ Fi.CI.IGT: success for Fix i-g-t on old systems (rev2)
2018-07-24 22:20 [igt-dev] [PATCH i-g-t v2 0/2] Fix i-g-t on old systems Lucas De Marchi
` (2 preceding siblings ...)
2018-07-24 23:32 ` [igt-dev] ✓ Fi.CI.BAT: success for Fix i-g-t on old systems (rev2) Patchwork
@ 2018-07-25 1:25 ` Patchwork
3 siblings, 0 replies; 13+ messages in thread
From: Patchwork @ 2018-07-25 1:25 UTC (permalink / raw)
To: Lucas De Marchi; +Cc: igt-dev
== Series Details ==
Series: Fix i-g-t on old systems (rev2)
URL : https://patchwork.freedesktop.org/series/46892/
State : success
== Summary ==
= CI Bug Log - changes from IGT_4572_full -> IGTPW_1643_full =
== Summary - WARNING ==
Minor unknown changes coming with IGTPW_1643_full need to be verified
manually.
If you think the reported changes have nothing to do with the changes
introduced in IGTPW_1643_full, please notify your bug team to allow them
to document this new failure mode, which will reduce false positives in CI.
External URL: https://patchwork.freedesktop.org/api/1.0/series/46892/revisions/2/mbox/
== Possible new issues ==
Here are the unknown changes that may have been introduced in IGTPW_1643_full:
=== IGT changes ===
==== Warnings ====
igt@gem_exec_schedule@deep-blt:
shard-apl: SKIP -> PASS +3
igt@gem_exec_schedule@deep-bsd:
shard-glk: SKIP -> PASS +3
igt@gem_exec_schedule@deep-bsd1:
shard-kbl: SKIP -> PASS +1
igt@pm_rc6_residency@rc6-accuracy:
shard-snb: PASS -> SKIP
== Known issues ==
Here are the changes found in IGTPW_1643_full that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@gem_exec_suspend@basic-s3:
shard-kbl: NOTRUN -> INCOMPLETE (fdo#103665)
igt@kms_cursor_legacy@2x-long-nonblocking-modeset-vs-cursor-atomic:
shard-glk: NOTRUN -> FAIL (fdo#106509, fdo#105454)
igt@kms_setmode@basic:
shard-kbl: PASS -> FAIL (fdo#99912)
==== Possible fixes ====
igt@gem_ppgtt@blt-vs-render-ctxn:
shard-kbl: INCOMPLETE (fdo#103665, fdo#106023) -> PASS
igt@kms_flip@plain-flip-ts-check:
shard-glk: FAIL (fdo#100368) -> PASS
igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
shard-kbl: INCOMPLETE (fdo#103665) -> PASS
igt@kms_rotation_crc@sprite-rotation-180:
shard-snb: FAIL (fdo#103925) -> PASS
igt@kms_universal_plane@cursor-fb-leak-pipe-a:
shard-apl: FAIL (fdo#107241) -> PASS
igt@perf_pmu@rc6-runtime-pm-long:
shard-kbl: FAIL (fdo#105010) -> PASS
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925
fdo#105010 https://bugs.freedesktop.org/show_bug.cgi?id=105010
fdo#105454 https://bugs.freedesktop.org/show_bug.cgi?id=105454
fdo#106023 https://bugs.freedesktop.org/show_bug.cgi?id=106023
fdo#106509 https://bugs.freedesktop.org/show_bug.cgi?id=106509
fdo#107241 https://bugs.freedesktop.org/show_bug.cgi?id=107241
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
== Participating hosts (5 -> 5) ==
No changes in participating hosts
== Build changes ==
* IGT: IGT_4572 -> IGTPW_1643
* Linux: CI_DRM_4533 -> CI_DRM_4534
CI_DRM_4533: 712e7047cfc7a129df6d324f59cc5d4eb2879285 @ git://anongit.freedesktop.org/gfx-ci/linux
CI_DRM_4534: a59bbda34ede6f5685fdc86b58f143bada751617 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_1643: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1643/
IGT_4572: 9b064015df14506b23cd2d7245a73e1b1d16ee1f @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1643/shards.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [igt-dev] [PATCH i-g-t v2 2/2] build: provide stub implementation for memfd_create
2018-07-24 22:20 ` [igt-dev] [PATCH i-g-t v2 2/2] build: provide stub implementation for memfd_create Lucas De Marchi
2018-07-25 0:04 ` Rodrigo Vivi
@ 2018-07-25 16:46 ` Antonio Argenziano
2018-07-25 19:57 ` De Marchi, Lucas
2018-08-02 10:18 ` Tvrtko Ursulin
2 siblings, 1 reply; 13+ messages in thread
From: Antonio Argenziano @ 2018-07-25 16:46 UTC (permalink / raw)
To: Lucas De Marchi, igt-dev
On 24/07/18 15:20, Lucas De Marchi wrote:
> When libc misses memfd_create(), provide a stub implementation to go
> through the syscall() route. Syscall numbers are provided for platforms
> currently supported by i-g-t only.
>
> v2: add support to autotools
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> ---
> configure.ac | 3 +++
> lib/stubs/syscalls/sys/mman.h | 37 +++++++++++++++++++++++++++++++++++
> meson.build | 3 +++
I thought you were going to remove "#include <linux/memfd.h>" from
gem_userptr_blits and include the stub instead.
Antonio.
> 3 files changed, 43 insertions(+)
> create mode 100644 lib/stubs/syscalls/sys/mman.h
>
> diff --git a/configure.ac b/configure.ac
> index 0a5b0425..416a3240 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -81,6 +81,9 @@ AC_CHECK_FUNCS(timer_create, [], [
> ])
> AC_SUBST(TIMER_LIBS)
>
> +dnl Check for memfd_create
> +AC_CHECK_FUNCS(memfd_create)
> +
> dnl Check for CPUID
> cpuid="yes"
> AC_TRY_LINK([
> diff --git a/lib/stubs/syscalls/sys/mman.h b/lib/stubs/syscalls/sys/mman.h
> new file mode 100644
> index 00000000..2ac2da6a
> --- /dev/null
> +++ b/lib/stubs/syscalls/sys/mman.h
> @@ -0,0 +1,37 @@
> +/* SPDX-License-Identifier: MIT */
> +
> +#pragma once
> +
> +#include_next <sys/mman.h>
> +
> +#if !defined(HAVE_MEMFD_CREATE) || !HAVE_MEMFD_CREATE
> +#include <errno.h>
> +#include <sys/syscall.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +
> +#ifndef __NR_memfd_create
> +#if defined __x86_64__
> +#define __NR_memfd_create 319
> +#elif defined __i386__
> +#define __NR_memfd_create 356
> +#elif defined __arm__
> +#define __NR_memfd_create 385
> +#else
> +#warning "__NR_memfd_create unknown for your architecture"
> +#endif
> +#endif
> +
> +static inline int missing_memfd_create(const char *name, unsigned int flags)
> +{
> +#ifdef __NR_memfd_create
> + return syscall(__NR_memfd_create, name, flags);
> +#else
> + errno = ENOSYS;
> + return -1;
> +#endif
> +}
> +
> +#define memfd_create missing_memfd_create
> +
> +#endif
> diff --git a/meson.build b/meson.build
> index 22118828..63ac6292 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -196,6 +196,9 @@ if cc.has_member('struct sysinfo', 'totalram',
> config.set('HAVE_STRUCT_SYSINFO_TOTALRAM', 1)
> endif
>
> +have = cc.has_function('memfd_create', prefix : '''#include <sys/mman.h>''', args : '-D_GNU_SOURCE')
> +config.set10('HAVE_MEMFD_CREATE', have)
> +
> add_project_arguments('-D_GNU_SOURCE', language : 'c')
> add_project_arguments('-include', 'config.h', language : 'c')
>
>
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [igt-dev] [PATCH i-g-t v2 2/2] build: provide stub implementation for memfd_create
2018-07-25 16:46 ` Antonio Argenziano
@ 2018-07-25 19:57 ` De Marchi, Lucas
2018-07-25 21:28 ` Antonio Argenziano
0 siblings, 1 reply; 13+ messages in thread
From: De Marchi, Lucas @ 2018-07-25 19:57 UTC (permalink / raw)
To: igt-dev@lists.freedesktop.org, Argenziano, Antonio
On Wed, 2018-07-25 at 09:46 -0700, Antonio Argenziano wrote:
>
> On 24/07/18 15:20, Lucas De Marchi wrote:
> > When libc misses memfd_create(), provide a stub implementation to go
> > through the syscall() route. Syscall numbers are provided for platforms
> > currently supported by i-g-t only.
> >
> > v2: add support to autotools
> >
> > Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> > ---
> > configure.ac | 3 +++
> > lib/stubs/syscalls/sys/mman.h | 37 +++++++++++++++++++++++++++++++++++
> > meson.build | 3 +++
>
> I thought you were going to remove "#include <linux/memfd.h>" from
> gem_userptr_blits and include the stub instead.
I decided not to. To summarize:
In order to get the memfd_create() function definition one needs to include
sys/mman.h. The man page is wrong and I sent a patch.
linux/memfd.h is the kernel header (i.e. not from libc). It's useful to have
it if we are using or going to use new flags not present in the libc headers.
Or harmless. This is their content for me:
kernel header (linux/memfd.h):
/* flags for memfd_create(2) (unsigned int) */
#define MFD_CLOEXEC 0x0001U
#define MFD_ALLOW_SEALING 0x0002U
#define MFD_HUGETLB 0x0004U
libc header (bits/mman-shared.h which is down the include chain for
sys/mman.h):
#ifdef __USE_GNU
/* Flags for memfd_create. */
# ifndef MFD_CLOEXEC
# define MFD_CLOEXEC 1U
# define MFD_ALLOW_SEALING 2U
# define MFD_HUGETLB 4U
# endif
...
We could also check if linux/memfd.h is available or just remove the include
since we are not using any flag not available on libc, but IMO it's not
necessary or at least not for this patch.
Lucas De Marchi
>
> Antonio.
>
> > 3 files changed, 43 insertions(+)
> > create mode 100644 lib/stubs/syscalls/sys/mman.h
> >
> > diff --git a/configure.ac b/configure.ac
> > index 0a5b0425..416a3240 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -81,6 +81,9 @@ AC_CHECK_FUNCS(timer_create, [], [
> > ])
> > AC_SUBST(TIMER_LIBS)
> >
> > +dnl Check for memfd_create
> > +AC_CHECK_FUNCS(memfd_create)
> > +
> > dnl Check for CPUID
> > cpuid="yes"
> > AC_TRY_LINK([
> > diff --git a/lib/stubs/syscalls/sys/mman.h b/lib/stubs/syscalls/sys/mman.h
> > new file mode 100644
> > index 00000000..2ac2da6a
> > --- /dev/null
> > +++ b/lib/stubs/syscalls/sys/mman.h
> > @@ -0,0 +1,37 @@
> > +/* SPDX-License-Identifier: MIT */
> > +
> > +#pragma once
> > +
> > +#include_next <sys/mman.h>
> > +
> > +#if !defined(HAVE_MEMFD_CREATE) || !HAVE_MEMFD_CREATE
> > +#include <errno.h>
> > +#include <sys/syscall.h>
> > +#include <sys/types.h>
> > +#include <unistd.h>
> > +
> > +#ifndef __NR_memfd_create
> > +#if defined __x86_64__
> > +#define __NR_memfd_create 319
> > +#elif defined __i386__
> > +#define __NR_memfd_create 356
> > +#elif defined __arm__
> > +#define __NR_memfd_create 385
> > +#else
> > +#warning "__NR_memfd_create unknown for your architecture"
> > +#endif
> > +#endif
> > +
> > +static inline int missing_memfd_create(const char *name, unsigned int
> > flags)
> > +{
> > +#ifdef __NR_memfd_create
> > + return syscall(__NR_memfd_create, name, flags);
> > +#else
> > + errno = ENOSYS;
> > + return -1;
> > +#endif
> > +}
> > +
> > +#define memfd_create missing_memfd_create
> > +
> > +#endif
> > diff --git a/meson.build b/meson.build
> > index 22118828..63ac6292 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -196,6 +196,9 @@ if cc.has_member('struct sysinfo', 'totalram',
> > config.set('HAVE_STRUCT_SYSINFO_TOTALRAM', 1)
> > endif
> >
> > +have = cc.has_function('memfd_create', prefix : '''#include
> > <sys/mman.h>''', args : '-D_GNU_SOURCE')
> > +config.set10('HAVE_MEMFD_CREATE', have)
> > +
> > add_project_arguments('-D_GNU_SOURCE', language : 'c')
> > add_project_arguments('-include', 'config.h', language : 'c')
> >
> >
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [igt-dev] [PATCH i-g-t v2 2/2] build: provide stub implementation for memfd_create
2018-07-25 19:57 ` De Marchi, Lucas
@ 2018-07-25 21:28 ` Antonio Argenziano
2018-07-25 22:56 ` Rodrigo Vivi
0 siblings, 1 reply; 13+ messages in thread
From: Antonio Argenziano @ 2018-07-25 21:28 UTC (permalink / raw)
To: De Marchi, Lucas, igt-dev@lists.freedesktop.org
On 25/07/18 12:57, De Marchi, Lucas wrote:
> On Wed, 2018-07-25 at 09:46 -0700, Antonio Argenziano wrote:
>>
>> On 24/07/18 15:20, Lucas De Marchi wrote:
>>> When libc misses memfd_create(), provide a stub implementation to go
>>> through the syscall() route. Syscall numbers are provided for platforms
>>> currently supported by i-g-t only.
>>>
>>> v2: add support to autotools
>>>
>>> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
>>> ---
>>> configure.ac | 3 +++
>>> lib/stubs/syscalls/sys/mman.h | 37 +++++++++++++++++++++++++++++++++++
>>> meson.build | 3 +++
>>
>> I thought you were going to remove "#include <linux/memfd.h>" from
>> gem_userptr_blits and include the stub instead.
>
> I decided not to. To summarize:
>
> In order to get the memfd_create() function definition one needs to include
> sys/mman.h. The man page is wrong and I sent a patch.
>
> linux/memfd.h is the kernel header (i.e. not from libc). It's useful to have
> it if we are using or going to use new flags not present in the libc headers.
> Or harmless. This is their content for me:
>
> kernel header (linux/memfd.h):
> /* flags for memfd_create(2) (unsigned int) */
> #define MFD_CLOEXEC 0x0001U
> #define MFD_ALLOW_SEALING 0x0002U
> #define MFD_HUGETLB 0x0004U
>
> libc header (bits/mman-shared.h which is down the include chain for
> sys/mman.h):
>
> #ifdef __USE_GNU
> /* Flags for memfd_create. */
> # ifndef MFD_CLOEXEC
> # define MFD_CLOEXEC 1U
> # define MFD_ALLOW_SEALING 2U
> # define MFD_HUGETLB 4U
> # endif
> ...
>
> We could also check if linux/memfd.h is available or just remove the include
> since we are not using any flag not available on libc, but IMO it's not
> necessary or at least not for this patch.
Fair enough, time for me to modernize a little anyway :).
For both patches:
Acked-by: Antonio Argenziano <antonio.argenziano@intel.com>
>
>
> Lucas De Marchi
>
>>
>> Antonio.
>>
>>> 3 files changed, 43 insertions(+)
>>> create mode 100644 lib/stubs/syscalls/sys/mman.h
>>>
>>> diff --git a/configure.ac b/configure.ac
>>> index 0a5b0425..416a3240 100644
>>> --- a/configure.ac
>>> +++ b/configure.ac
>>> @@ -81,6 +81,9 @@ AC_CHECK_FUNCS(timer_create, [], [
>>> ])
>>> AC_SUBST(TIMER_LIBS)
>>>
>>> +dnl Check for memfd_create
>>> +AC_CHECK_FUNCS(memfd_create)
>>> +
>>> dnl Check for CPUID
>>> cpuid="yes"
>>> AC_TRY_LINK([
>>> diff --git a/lib/stubs/syscalls/sys/mman.h b/lib/stubs/syscalls/sys/mman.h
>>> new file mode 100644
>>> index 00000000..2ac2da6a
>>> --- /dev/null
>>> +++ b/lib/stubs/syscalls/sys/mman.h
>>> @@ -0,0 +1,37 @@
>>> +/* SPDX-License-Identifier: MIT */
>>> +
>>> +#pragma once
>>> +
>>> +#include_next <sys/mman.h>
>>> +
>>> +#if !defined(HAVE_MEMFD_CREATE) || !HAVE_MEMFD_CREATE
>>> +#include <errno.h>
>>> +#include <sys/syscall.h>
>>> +#include <sys/types.h>
>>> +#include <unistd.h>
>>> +
>>> +#ifndef __NR_memfd_create
>>> +#if defined __x86_64__
>>> +#define __NR_memfd_create 319
>>> +#elif defined __i386__
>>> +#define __NR_memfd_create 356
>>> +#elif defined __arm__
>>> +#define __NR_memfd_create 385
>>> +#else
>>> +#warning "__NR_memfd_create unknown for your architecture"
>>> +#endif
>>> +#endif
>>> +
>>> +static inline int missing_memfd_create(const char *name, unsigned int
>>> flags)
>>> +{
>>> +#ifdef __NR_memfd_create
>>> + return syscall(__NR_memfd_create, name, flags);
>>> +#else
>>> + errno = ENOSYS;
>>> + return -1;
>>> +#endif
>>> +}
>>> +
>>> +#define memfd_create missing_memfd_create
>>> +
>>> +#endif
>>> diff --git a/meson.build b/meson.build
>>> index 22118828..63ac6292 100644
>>> --- a/meson.build
>>> +++ b/meson.build
>>> @@ -196,6 +196,9 @@ if cc.has_member('struct sysinfo', 'totalram',
>>> config.set('HAVE_STRUCT_SYSINFO_TOTALRAM', 1)
>>> endif
>>>
>>> +have = cc.has_function('memfd_create', prefix : '''#include
>>> <sys/mman.h>''', args : '-D_GNU_SOURCE')
>>> +config.set10('HAVE_MEMFD_CREATE', have)
>>> +
>>> add_project_arguments('-D_GNU_SOURCE', language : 'c')
>>> add_project_arguments('-include', 'config.h', language : 'c')
>>>
>>>
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [igt-dev] [PATCH i-g-t v2 2/2] build: provide stub implementation for memfd_create
2018-07-25 21:28 ` Antonio Argenziano
@ 2018-07-25 22:56 ` Rodrigo Vivi
0 siblings, 0 replies; 13+ messages in thread
From: Rodrigo Vivi @ 2018-07-25 22:56 UTC (permalink / raw)
To: Antonio Argenziano; +Cc: igt-dev@lists.freedesktop.org, De Marchi, Lucas
On Wed, Jul 25, 2018 at 02:28:31PM -0700, Antonio Argenziano wrote:
>
>
> On 25/07/18 12:57, De Marchi, Lucas wrote:
> > On Wed, 2018-07-25 at 09:46 -0700, Antonio Argenziano wrote:
> > >
> > > On 24/07/18 15:20, Lucas De Marchi wrote:
> > > > When libc misses memfd_create(), provide a stub implementation to go
> > > > through the syscall() route. Syscall numbers are provided for platforms
> > > > currently supported by i-g-t only.
> > > >
> > > > v2: add support to autotools
> > > >
> > > > Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> > > > ---
> > > > configure.ac | 3 +++
> > > > lib/stubs/syscalls/sys/mman.h | 37 +++++++++++++++++++++++++++++++++++
> > > > meson.build | 3 +++
> > >
> > > I thought you were going to remove "#include <linux/memfd.h>" from
> > > gem_userptr_blits and include the stub instead.
> >
> > I decided not to. To summarize:
> >
> > In order to get the memfd_create() function definition one needs to include
> > sys/mman.h. The man page is wrong and I sent a patch.
> >
> > linux/memfd.h is the kernel header (i.e. not from libc). It's useful to have
> > it if we are using or going to use new flags not present in the libc headers.
> > Or harmless. This is their content for me:
> >
> > kernel header (linux/memfd.h):
> > /* flags for memfd_create(2) (unsigned int) */
> > #define MFD_CLOEXEC 0x0001U
> > #define MFD_ALLOW_SEALING 0x0002U
> > #define MFD_HUGETLB 0x0004U
> >
> > libc header (bits/mman-shared.h which is down the include chain for
> > sys/mman.h):
> >
> > #ifdef __USE_GNU
> > /* Flags for memfd_create. */
> > # ifndef MFD_CLOEXEC
> > # define MFD_CLOEXEC 1U
> > # define MFD_ALLOW_SEALING 2U
> > # define MFD_HUGETLB 4U
> > # endif
> > ...
> >
> > We could also check if linux/memfd.h is available or just remove the include
> > since we are not using any flag not available on libc, but IMO it's not
> > necessary or at least not for this patch.
>
> Fair enough, time for me to modernize a little anyway :).
>
> For both patches:
> Acked-by: Antonio Argenziano <antonio.argenziano@intel.com>
pushed, thanks
>
> >
> >
> > Lucas De Marchi
> >
> > >
> > > Antonio.
> > >
> > > > 3 files changed, 43 insertions(+)
> > > > create mode 100644 lib/stubs/syscalls/sys/mman.h
> > > >
> > > > diff --git a/configure.ac b/configure.ac
> > > > index 0a5b0425..416a3240 100644
> > > > --- a/configure.ac
> > > > +++ b/configure.ac
> > > > @@ -81,6 +81,9 @@ AC_CHECK_FUNCS(timer_create, [], [
> > > > ])
> > > > AC_SUBST(TIMER_LIBS)
> > > > +dnl Check for memfd_create
> > > > +AC_CHECK_FUNCS(memfd_create)
> > > > +
> > > > dnl Check for CPUID
> > > > cpuid="yes"
> > > > AC_TRY_LINK([
> > > > diff --git a/lib/stubs/syscalls/sys/mman.h b/lib/stubs/syscalls/sys/mman.h
> > > > new file mode 100644
> > > > index 00000000..2ac2da6a
> > > > --- /dev/null
> > > > +++ b/lib/stubs/syscalls/sys/mman.h
> > > > @@ -0,0 +1,37 @@
> > > > +/* SPDX-License-Identifier: MIT */
> > > > +
> > > > +#pragma once
> > > > +
> > > > +#include_next <sys/mman.h>
> > > > +
> > > > +#if !defined(HAVE_MEMFD_CREATE) || !HAVE_MEMFD_CREATE
> > > > +#include <errno.h>
> > > > +#include <sys/syscall.h>
> > > > +#include <sys/types.h>
> > > > +#include <unistd.h>
> > > > +
> > > > +#ifndef __NR_memfd_create
> > > > +#if defined __x86_64__
> > > > +#define __NR_memfd_create 319
> > > > +#elif defined __i386__
> > > > +#define __NR_memfd_create 356
> > > > +#elif defined __arm__
> > > > +#define __NR_memfd_create 385
> > > > +#else
> > > > +#warning "__NR_memfd_create unknown for your architecture"
> > > > +#endif
> > > > +#endif
> > > > +
> > > > +static inline int missing_memfd_create(const char *name, unsigned int
> > > > flags)
> > > > +{
> > > > +#ifdef __NR_memfd_create
> > > > + return syscall(__NR_memfd_create, name, flags);
> > > > +#else
> > > > + errno = ENOSYS;
> > > > + return -1;
> > > > +#endif
> > > > +}
> > > > +
> > > > +#define memfd_create missing_memfd_create
> > > > +
> > > > +#endif
> > > > diff --git a/meson.build b/meson.build
> > > > index 22118828..63ac6292 100644
> > > > --- a/meson.build
> > > > +++ b/meson.build
> > > > @@ -196,6 +196,9 @@ if cc.has_member('struct sysinfo', 'totalram',
> > > > config.set('HAVE_STRUCT_SYSINFO_TOTALRAM', 1)
> > > > endif
> > > > +have = cc.has_function('memfd_create', prefix : '''#include
> > > > <sys/mman.h>''', args : '-D_GNU_SOURCE')
> > > > +config.set10('HAVE_MEMFD_CREATE', have)
> > > > +
> > > > add_project_arguments('-D_GNU_SOURCE', language : 'c')
> > > > add_project_arguments('-include', 'config.h', language : 'c')
> > > >
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [igt-dev] [PATCH i-g-t v2 2/2] build: provide stub implementation for memfd_create
2018-07-24 22:20 ` [igt-dev] [PATCH i-g-t v2 2/2] build: provide stub implementation for memfd_create Lucas De Marchi
2018-07-25 0:04 ` Rodrigo Vivi
2018-07-25 16:46 ` Antonio Argenziano
@ 2018-08-02 10:18 ` Tvrtko Ursulin
2 siblings, 0 replies; 13+ messages in thread
From: Tvrtko Ursulin @ 2018-08-02 10:18 UTC (permalink / raw)
To: Lucas De Marchi, igt-dev
On 24/07/2018 23:20, Lucas De Marchi wrote:
> When libc misses memfd_create(), provide a stub implementation to go
> through the syscall() route. Syscall numbers are provided for platforms
> currently supported by i-g-t only.
>
> v2: add support to autotools
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> ---
> configure.ac | 3 +++
> lib/stubs/syscalls/sys/mman.h | 37 +++++++++++++++++++++++++++++++++++
> meson.build | 3 +++
> 3 files changed, 43 insertions(+)
> create mode 100644 lib/stubs/syscalls/sys/mman.h
>
> diff --git a/configure.ac b/configure.ac
> index 0a5b0425..416a3240 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -81,6 +81,9 @@ AC_CHECK_FUNCS(timer_create, [], [
> ])
> AC_SUBST(TIMER_LIBS)
>
> +dnl Check for memfd_create
> +AC_CHECK_FUNCS(memfd_create)
> +
> dnl Check for CPUID
> cpuid="yes"
> AC_TRY_LINK([
> diff --git a/lib/stubs/syscalls/sys/mman.h b/lib/stubs/syscalls/sys/mman.h
> new file mode 100644
> index 00000000..2ac2da6a
> --- /dev/null
> +++ b/lib/stubs/syscalls/sys/mman.h
> @@ -0,0 +1,37 @@
> +/* SPDX-License-Identifier: MIT */
> +
> +#pragma once
> +
> +#include_next <sys/mman.h>
> +
> +#if !defined(HAVE_MEMFD_CREATE) || !HAVE_MEMFD_CREATE
> +#include <errno.h>
> +#include <sys/syscall.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +
> +#ifndef __NR_memfd_create
> +#if defined __x86_64__
> +#define __NR_memfd_create 319
> +#elif defined __i386__
> +#define __NR_memfd_create 356
> +#elif defined __arm__
> +#define __NR_memfd_create 385
> +#else
> +#warning "__NR_memfd_create unknown for your architecture"
> +#endif
> +#endif
> +
> +static inline int missing_memfd_create(const char *name, unsigned int flags)
> +{
> +#ifdef __NR_memfd_create
> + return syscall(__NR_memfd_create, name, flags);
> +#else
> + errno = ENOSYS;
> + return -1;
> +#endif
> +}
> +
> +#define memfd_create missing_memfd_create
> +
> +#endif
> diff --git a/meson.build b/meson.build
> index 22118828..63ac6292 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -196,6 +196,9 @@ if cc.has_member('struct sysinfo', 'totalram',
> config.set('HAVE_STRUCT_SYSINFO_TOTALRAM', 1)
> endif
>
> +have = cc.has_function('memfd_create', prefix : '''#include <sys/mman.h>''', args : '-D_GNU_SOURCE')
> +config.set10('HAVE_MEMFD_CREATE', have)
> +
> add_project_arguments('-D_GNU_SOURCE', language : 'c')
> add_project_arguments('-include', 'config.h', language : 'c')
>
>
Looks OK to me.
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Regards,
Tvrtko
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [igt-dev] [PATCH i-g-t v2 1/2] build: provide include for missing syscalls
2018-07-24 22:20 ` [igt-dev] [PATCH i-g-t v2 1/2] build: provide include for missing syscalls Lucas De Marchi
2018-07-25 0:04 ` Rodrigo Vivi
@ 2018-08-02 10:19 ` Tvrtko Ursulin
1 sibling, 0 replies; 13+ messages in thread
From: Tvrtko Ursulin @ 2018-08-02 10:19 UTC (permalink / raw)
To: Lucas De Marchi, igt-dev
On 24/07/2018 23:20, Lucas De Marchi wrote:
> Add directory with README file to allow missing syscalls to be defined.
> The syscalls themselves will be provided in follow up patches.
>
> v2: add support to autotools
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> ---
> benchmarks/Makefile.am | 3 ++-
> debugger/Makefile.am | 3 ++-
> lib/Makefile.am | 3 ++-
> lib/stubs/syscalls/README | 6 ++++++
> lib/tests/Makefile.am | 1 +
> meson.build | 2 +-
> overlay/Makefile.am | 3 ++-
> tests/Makefile.am | 1 +
> tools/Makefile.am | 3 ++-
> tools/null_state_gen/Makefile.am | 3 ++-
> 10 files changed, 21 insertions(+), 7 deletions(-)
> create mode 100644 lib/stubs/syscalls/README
>
> diff --git a/benchmarks/Makefile.am b/benchmarks/Makefile.am
> index 055e4c3a..979b9490 100644
> --- a/benchmarks/Makefile.am
> +++ b/benchmarks/Makefile.am
> @@ -11,7 +11,8 @@ endif
> AM_CPPFLAGS = \
> -I$(top_srcdir) \
> -I$(top_srcdir)/include/drm-uapi \
> - -I$(top_srcdir)/lib
> + -I$(top_srcdir)/lib \
> + -I$(top_srcdir)/lib/stubs/syscalls
>
> AM_CFLAGS = -I$(top_srcdir)/include/drm-uapi \
> $(DRM_CFLAGS) $(CWARNFLAGS) $(CAIRO_CFLAGS) $(LIBUNWIND_CFLAGS) \
> diff --git a/debugger/Makefile.am b/debugger/Makefile.am
> index ceaab6f8..e3a084d2 100644
> --- a/debugger/Makefile.am
> +++ b/debugger/Makefile.am
> @@ -7,7 +7,8 @@ noinst_PROGRAMS = debug_rdata
> AM_CPPFLAGS = \
> -I$(top_srcdir) \
> -I$(top_srcdir)/lib \
> - -I$(top_srcdir)/include/drm-uapi
> + -I$(top_srcdir)/include/drm-uapi \
> + -I$(top_srcdir)/lib/stubs/syscalls
>
> AM_CFLAGS = \
> $(DRM_CFLAGS) \
> diff --git a/lib/Makefile.am b/lib/Makefile.am
> index ab9eefe6..6251bdb8 100644
> --- a/lib/Makefile.am
> +++ b/lib/Makefile.am
> @@ -52,7 +52,8 @@ endif
>
> AM_CPPFLAGS = \
> -I$(top_srcdir)/include/drm-uapi \
> - -I$(top_srcdir)
> + -I$(top_srcdir) \
> + -I$(top_srcdir)/lib/stubs/syscalls
>
> AM_CFLAGS = \
> $(CWARNFLAGS) \
> diff --git a/lib/stubs/syscalls/README b/lib/stubs/syscalls/README
> new file mode 100644
> index 00000000..f05b9a6f
> --- /dev/null
> +++ b/lib/stubs/syscalls/README
> @@ -0,0 +1,6 @@
> +This directory contains stub implementations for syscalls missing from libc.
> +This provides a way to build IGT on an old system, but it will not run
> +correctly if the kernel is missing the functionality provided. In order to
> +add a new definition, follow the same directory hierarchy as the standard
> +location in which the header is defined so we don't have to clutter the
> +codebase to support old systems.
> diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am
> index fb433d69..ad585b77 100644
> --- a/lib/tests/Makefile.am
> +++ b/lib/tests/Makefile.am
> @@ -11,6 +11,7 @@ AM_CPPFLAGS = \
> -I$(top_srcdir)/include/drm-uapi \
> -I$(srcdir)/../.. \
> -I$(srcdir)/.. \
> + -I$(top_srcdir)/lib/stubs/syscalls \
> -include "$(srcdir)/../../lib/check-ndebug.h" \
> -DIGT_DATADIR=\""$(abs_srcdir)"\" \
> -D_GNU_SOURCE
> diff --git a/meson.build b/meson.build
> index 5a931565..22118828 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -64,7 +64,7 @@ _tests_required = build_tests == 'true'
>
> build_info = []
>
> -inc = include_directories('include/drm-uapi', 'lib', '.')
> +inc = include_directories('include/drm-uapi', 'lib', 'lib/stubs/syscalls', '.')
>
> inc_for_gtkdoc = include_directories('lib')
>
> diff --git a/overlay/Makefile.am b/overlay/Makefile.am
> index 0f553b7c..4cf82dc6 100644
> --- a/overlay/Makefile.am
> +++ b/overlay/Makefile.am
> @@ -7,7 +7,8 @@ endif
> tracepoint_format.h: tracepoint_format.leg
> $(LEG) -o $@ $<
>
> -AM_CPPFLAGS = -I. -I$(top_srcdir)/include/drm-uapi
> +AM_CPPFLAGS = -I. -I$(top_srcdir)/include/drm-uapi \
> + -I$(top_srcdir)/lib/stubs/syscalls
> AM_CFLAGS = $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) \
> $(CAIRO_CFLAGS) $(OVERLAY_CFLAGS) $(WERROR_CFLAGS) -I$(srcdir)/../lib
> LDADD = $(DRM_LIBS) $(PCIACCESS_LIBS) $(CAIRO_LIBS) $(OVERLAY_LIBS) $(top_builddir)/lib/libigt_perf.la
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index ba307b22..8712eb16 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -88,6 +88,7 @@ AM_CFLAGS = $(CWARNFLAGS) -Wno-unused-result $(DEBUG_CFLAGS)\
> -I$(top_srcdir)/include/drm-uapi \
> -I$(srcdir)/.. \
> -I$(srcdir)/../lib \
> + -I$(top_srcdir)/lib/stubs/syscalls \
> -include "$(srcdir)/../lib/check-ndebug.h" \
> -DIGT_SRCDIR=\""$(abs_srcdir)"\" \
> -DIGT_DATADIR=\""$(pkgdatadir)"\" \
> diff --git a/tools/Makefile.am b/tools/Makefile.am
> index a0b016dd..e7de4d90 100644
> --- a/tools/Makefile.am
> +++ b/tools/Makefile.am
> @@ -13,7 +13,8 @@ intel_dp_compliance_LDADD = $(top_builddir)/lib/libintel_tools.la
>
> SUBDIRS = null_state_gen registers
>
> -AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include/drm-uapi -I$(top_srcdir)/lib
> +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include/drm-uapi -I$(top_srcdir)/lib \
> + -I$(top_srcdir)/lib/stubs/syscalls
> AM_CFLAGS = $(DEBUG_CFLAGS) $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) \
> $(CAIRO_CFLAGS) $(LIBUNWIND_CFLAGS) -DIGT_DATADIR=\"$(pkgdatadir)\" \
> $(WERROR_CFLAGS) -D_GNU_SOURCE
> diff --git a/tools/null_state_gen/Makefile.am b/tools/null_state_gen/Makefile.am
> index d1dc83ab..d4aa3d44 100644
> --- a/tools/null_state_gen/Makefile.am
> +++ b/tools/null_state_gen/Makefile.am
> @@ -1,5 +1,6 @@
> GPU_TOOLS_PATH := $(top_srcdir)
> -AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include/drm-uapi
> +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include/drm-uapi \
> + -I$(top_srcdir)/lib/stubs/syscalls
> AM_CFLAGS = $(DEBUG_CFLAGS) $(CWARNFLAGS)
>
> noinst_PROGRAMS = intel_null_state_gen
>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Regards,
Tvrtko
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2018-08-02 10:19 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-24 22:20 [igt-dev] [PATCH i-g-t v2 0/2] Fix i-g-t on old systems Lucas De Marchi
2018-07-24 22:20 ` [igt-dev] [PATCH i-g-t v2 1/2] build: provide include for missing syscalls Lucas De Marchi
2018-07-25 0:04 ` Rodrigo Vivi
2018-08-02 10:19 ` Tvrtko Ursulin
2018-07-24 22:20 ` [igt-dev] [PATCH i-g-t v2 2/2] build: provide stub implementation for memfd_create Lucas De Marchi
2018-07-25 0:04 ` Rodrigo Vivi
2018-07-25 16:46 ` Antonio Argenziano
2018-07-25 19:57 ` De Marchi, Lucas
2018-07-25 21:28 ` Antonio Argenziano
2018-07-25 22:56 ` Rodrigo Vivi
2018-08-02 10:18 ` Tvrtko Ursulin
2018-07-24 23:32 ` [igt-dev] ✓ Fi.CI.BAT: success for Fix i-g-t on old systems (rev2) Patchwork
2018-07-25 1:25 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).