summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom St Denis <tom.stdenis@amd.com>2019-03-20 11:02:28 -0400
committerTom St Denis <tom.stdenis@amd.com>2019-03-20 11:02:28 -0400
commit1a96575ae0a9a942c0d97dc4888afc0958caf477 (patch)
tree72d8945475cd2bd184bc4da0ac3bac1d7e4cf4a4
parentd3a7e1917394e24bcc9cc8f25fcf32b445965f53 (diff)
add ability to disable LLVM dependency at build time
Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
-rw-r--r--CMakeLists.txt5
-rw-r--r--README5
-rw-r--r--doc/sphinx/source/build.rst12
-rw-r--r--src/lib/lowlevel/linux/umr_shader_disasm.c30
4 files changed, 51 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 20e0b92..3ce82f7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,6 +33,9 @@ include_directories(${PCIACCESS_INCLUDE_DIR})
find_package(LibDRM REQUIRED)
include_directories(${LIBDRM_INCLUDE_DIR})
+if($ENV{UMR_NO_LLVM})
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUMR_NO_LLVM")
+else()
find_package(LLVM REQUIRED COMPONENTS all)
include_directories(${LLVM_INCLUDE_DIR})
@@ -49,7 +52,7 @@ if(LLVM_CMAKE_DIR)
MCDisassembler
)
endif()
-
+endif()
set(REQUIRED_EXTERNAL_LIBS
${CURSES_LIBRARIES}
diff --git a/README b/README
index 1efd561..37e7f15 100644
--- a/README
+++ b/README
@@ -47,6 +47,11 @@ NOTE: Allowing untrusted users access to umr may lead to system
comprimises, instability, and hardware damage. Do not setuid this
tool on multi-user systems.
+NOTE: You may disable LLVM dependencies by adding UMR_NO_LLVM to your
+environment. e.g.,
+
+ $ UMR_NO_LLVM=1 cmake ../
+
Running umr
------------
diff --git a/doc/sphinx/source/build.rst b/doc/sphinx/source/build.rst
index a2a54ac..96a1e42 100644
--- a/doc/sphinx/source/build.rst
+++ b/doc/sphinx/source/build.rst
@@ -75,3 +75,15 @@ Though keep in mind that this introduces a security vulnerability so you should
and development machines and not deployed machines.
At this point umr should be installed and can be invoked by running the command ‘umr’.
+
+-----------------
+Optional Packages
+-----------------
+
+You may disable LLVM dependencies by adding UMR_NO_LLVM to your shell environment:
+
+::
+
+ $ UMR_NO_LLVM=1 cmake .
+
+This will disable shader disassembly and result in "..." being printed for all opcode decodes.
diff --git a/src/lib/lowlevel/linux/umr_shader_disasm.c b/src/lib/lowlevel/linux/umr_shader_disasm.c
index 82db478..d6e698b 100644
--- a/src/lib/lowlevel/linux/umr_shader_disasm.c
+++ b/src/lib/lowlevel/linux/umr_shader_disasm.c
@@ -23,6 +23,8 @@
*
*/
#include "umr.h"
+
+#ifndef UMR_NO_LLVM
#include <llvm-c/Disassembler.h>
#include <llvm-c/Target.h>
@@ -104,3 +106,31 @@ int umr_shader_disasm(struct umr_asic *asic,
LLVMDisasmDispose(disasm_ref);
return 0;
}
+
+#else
+
+/**
+ * umr_shader_disasm - Diassemble a shader
+ *
+ * @inst: Shader program
+ * @inst_bytes: number of bytes in shader
+ * @PC: Shader address in virtual memory
+ * @disasm_text: array of pointers that are assigned pointers
+ * to disassembled shader.
+ */
+int umr_shader_disasm(struct umr_asic *asic,
+ uint8_t *inst, unsigned inst_bytes,
+ uint64_t PC,
+ char ***disasm_text)
+{
+ unsigned x;
+
+ *disasm_text = calloc(inst_bytes/4, sizeof(**disasm_text));
+
+ for (x = 0; x < inst_bytes; x += 4) {
+ (*disasm_text)[x/4] = strdup("...");
+ }
+ return 0;
+}
+
+#endif