lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 25 Jan 2017 10:53:33 -0300
From:   Arnaldo Carvalho de Melo <acme@...nel.org>
To:     Ingo Molnar <mingo@...nel.org>
Cc:     linux-kernel@...r.kernel.org, Andi Kleen <ak@...ux.intel.com>,
        Arnaldo Carvalho de Melo <acme@...hat.com>
Subject: [PATCH 06/23] perf tools: Add probing for the XED disassembler library

From: Andi Kleen <ak@...ux.intel.com>

Can be downloaded from https://github.com/intelxed/xed

v2: Hide. Require XED=1 to enable. Add XED_DIR
v3: Remove -lxed from probe all. Don't touch FEATURE_DISPLAY.
v4: Move to FEATURE_FLAGS_BASIC

Committer Notes:

>From https://intelxed.github.io/:

 ---
The X86 Encoder Decoder (XED), is a software library (and associated
headers) for encoding and decoding X86 (IA32 and Intel64) instructions.
The decoder takes sequences of 1-15 bytes along with machine mode
information and produces a data structure describing the opcode,
operands, and flags. The encoder takes a similar data structure and
produces a sequence of 1 to 15 bytes. Disassembly is essentially a
printing pass on the data structure.

XED is the encoder/decoder used by Pin and the IntelĀ® Software
Development Emulator (SDE). XED is used by the ASIM performance model,
ZSIM, IntelĀ® VTune Amplifier, IACA, as well as in projects at McAfee,
Wind River, and many other projects inside and outside Intel.

XED supports the notion of layers of instructions. As new instructions
are made public corresponding to future processors, the associated
layers are added to the tables of instructions in the "datafiles"
subdirectory. (Intel announces and documents instructions in the ISE and
SDM documents typically).
 ---

XED License: Apache, version 2.0.

Also remove it from test-all.c, since it is not normally available on
distros at this time and not selected by default.

For the same reason, move it from FEATURE_TESTS_BASIC to
FEATURE_TESTS_EXTRA, to avoid always trying to build
tools/build/feature/test-xed.c.

One has to define XED=1 to build WITH the XED disassembler to be used in
'perf script'.  It is also possible to set XED_DIR=/path to set the XED
directory.

Added the XED_DIR to CFLAGS in addition to the feature detection
specific CFLAGS, so that the following patches can work.

Testing it:

WITHOUT XED in the system, NOT explicitely selecting it:

  $ make O=/tmp/build/perf -C tools/perf install-bin
  $ cat /tmp/build/perf/feature/test-xed.make.output
  cat: /tmp/build/perf/feature/test-xed.make.output: No such file or directory
  $

The feature test is NOT performed, ok.

WITHOUT XED in the system, EXPLICITELY selecting it:

  $ make XED=1 O=/tmp/build/perf -C tools/perf install-bin
  $ cat /tmp/build/perf/feature/test-xed.make.output
  test-xed.c:1:31: fatal error: xed/xed-interface.h: No such file or directory
   #include <xed/xed-interface.h>
                               ^
  compilation terminated.
  $

Ok, the test _IS_ performed, the required devel files are not found, the
build is done without XED.

Now lets try building and installing xed in this system:

  $ git clone https://github.com/intelxed/mbuild.git
  $ git clone https://github.com/intelxed/xed.git
  $ cd xed
  $ ./mfile.py
  $ ./mfile.py install

And lets try enabling XED, informing where 'mfile.py install' installed
it:

  $ make XED=1 XED_DIR=/home/acme/git/xed/kits/xed-install-base-2017-01-23-lin-x86-64/ O=/tmp/build/perf -C tools/perf install-bin
  $ ls -la /tmp/build/perf/feature/test-xed.make.output
  -rw-rw-r--. 1 acme acme 0 Jan 23 10:57 /tmp/build/perf/feature/test-xed.make.output
  $

But it still doesn't link with
/home/acme/git/xed/kits/xed-install-base-2017-01-23-lin-x86-64/lib/libxed.a
because the feature will only be used in the following csets.

Signed-off-by: Andi Kleen <ak@...ux.intel.com>
Acked-by: Jiri Olsa <jolsa@...nel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@...hat.com>
Link: http://lkml.kernel.org/r/20170119014150.19218-2-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
 tools/build/Makefile.feature   |  4 +++-
 tools/build/feature/Makefile   |  6 +++++-
 tools/build/feature/test-all.c | 14 ++++++++++++++
 tools/build/feature/test-xed.c |  9 +++++++++
 tools/perf/Makefile.config     | 19 +++++++++++++++++++
 tools/perf/Makefile.perf       |  3 +++
 6 files changed, 53 insertions(+), 2 deletions(-)
 create mode 100644 tools/build/feature/test-xed.c

diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index e3fb5ecbdcb6..a3fa78296cb5 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -78,7 +78,8 @@ FEATURE_TESTS_EXTRA :=                  \
          liberty-z                      \
          libunwind-debug-frame          \
          libunwind-debug-frame-arm      \
-         libunwind-debug-frame-aarch64
+         libunwind-debug-frame-aarch64  \
+         xed
 
 FEATURE_TESTS ?= $(FEATURE_TESTS_BASIC)
 
@@ -140,6 +141,7 @@ ifeq ($(feature-all), 1)
   $(call feature_check,compile-x32)
   $(call feature_check,bionic)
   $(call feature_check,libbabeltrace)
+  $(call feature_check,xed)
 else
   $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat)))
 endif
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index b564a2eea039..4f1aa82b867a 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -48,7 +48,8 @@ FILES=                                          \
          test-get_cpuid.bin                     \
          test-sdt.bin                           \
          test-cxx.bin                           \
-         test-jvmti.bin
+         test-jvmti.bin				\
+         test-xed.bin
 
 FILES := $(addprefix $(OUTPUT),$(FILES))
 
@@ -123,6 +124,9 @@ $(OUTPUT)test-numa_num_possible_cpus.bin:
 $(OUTPUT)test-libunwind.bin:
 	$(BUILD) -lelf
 
+$(OUTPUT)test-xed.bin:
+	$(BUILD) -lxed
+
 $(OUTPUT)test-libunwind-debug-frame.bin:
 	$(BUILD) -lelf
 $(OUTPUT)test-libunwind-x86.bin:
diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
index 699e43627397..cffe9fcda7c4 100644
--- a/tools/build/feature/test-all.c
+++ b/tools/build/feature/test-all.c
@@ -129,6 +129,19 @@
 #undef main
 #endif
 
+#if 0
+/*
+ * Disable xed check for test-all, because it is not available
+ * in most distributions. Will reenable when it becomes generally
+ * available in major distros.
+ */
+#define main main_test_xed
+#  include "test-xed.c"
+#endif
+#else
+#define main_test_xed while(0)
+#endif
+
 #define main main_test_lzma
 # include "test-lzma.c"
 #undef main
@@ -183,6 +196,7 @@ int main(int argc, char *argv[])
 	main_test_bpf();
 	main_test_libcrypto();
 	main_test_sdt();
+	main_test_xed();
 
 	return 0;
 }
diff --git a/tools/build/feature/test-xed.c b/tools/build/feature/test-xed.c
new file mode 100644
index 000000000000..ef9aebf1559d
--- /dev/null
+++ b/tools/build/feature/test-xed.c
@@ -0,0 +1,9 @@
+#include <xed/xed-interface.h>
+#include <xed/xed-decode.h>
+#include <xed/xed-decoded-inst-api.h>
+
+int main(void)
+{
+	xed_tables_init();
+	return 0;
+}
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 03cf947755b9..fd798d118739 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -684,6 +684,25 @@ ifndef NO_ZLIB
   endif
 endif
 
+ifdef XED
+  ifdef XED_DIR
+    XED_CFLAGS  := -DHAVE_XED_SUPPORT -I$(XED_DIR)/include
+    XED_LDFLAGS := -L$(XED_DIR)/lib
+  endif
+  FEATURE_CHECK_CFLAGS-xed := $(XED_CFLAGS)
+  # override for lib64?
+  FEATURE_CHECK_LDFLAGS-xed := $(XED_LDFLAGS) -lxed
+  $(call feature_check,xed)
+  ifeq ($(feature-xed), 1)
+    CFLAGS += $(XED_CFLAGS)
+    LDFLAGS += $(XED_LDFLAGS)
+    EXTLIBS += -lxed
+    $(call detected,CONFIG_XED)
+  else
+    msg := $(warning No xed found, disables x86 disassembler support, please install xed);
+  endif
+endif
+
 ifndef NO_LZMA
   ifeq ($(feature-lzma), 1)
     CFLAGS += -DHAVE_LZMA_SUPPORT
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 4da19b6ba94a..f6760309edd3 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -84,6 +84,9 @@ include ../scripts/utilities.mak
 # Define NO_SDT if you do not want to define SDT event in perf tools,
 # note that it doesn't disable SDT scanning support.
 #
+# Define XED=1 to build WITH the XED disassembler for perf script
+# Can also set XED_DIR=/path to set XED directory.
+#
 # Define FEATURES_DUMP to provide features detection dump file
 # and bypass the feature detection
 #
-- 
2.9.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ