-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
blank branch copy of https://github.com/gthparch/qsimplugin
- Loading branch information
0 parents
commit c4272a9
Showing
22 changed files
with
15,519 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*Images/*.img | ||
*Images/vmlinuz | ||
buildDirARM64/ | ||
buildDirX86/ | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[submodule "qemu"] | ||
path = qemu | ||
url = https://github.com/gthparch/qemu.git | ||
branch = feature/qsim_plugins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apt: | ||
update: true | ||
language: cpp | ||
before_script: | ||
- ./build.sh | ||
script: | ||
- make -C qemu/plugins/qsimPlugin | ||
- make -C qemu/plugins/testPlugin | ||
- make -C debugTool && make -C debugTool/testcases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
sudo apt install sshpass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
example invocation: | ||
python run.py --imgconfig arm64Images/config.json --benchmark simpleBenchmark/ --plugin qemu/plugins/qsimPlugin/qsim-plugin.so | ||
|
||
[![Build Status](https://travis-ci.com/farzonl/qsimPlugin.svg?branch=master)](https://travis-ci.com/farzonl/qsimPlugin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"drive": "arm64disk.img", | ||
"kernel": "vmlinuz", | ||
"initrd": "initrd.img", | ||
"username" : "qsim", | ||
"password" : "qsim12" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
if [ ! -d buildDirARM64 ]; then | ||
echo "buildDirARM64 dir created" | ||
mkdir buildDirARM64 | ||
fi | ||
if [ ! -d buildDirx86 ]; then | ||
echo "buildDirX86 dir created" | ||
mkdir buildDirX86 | ||
fi | ||
git submodule init | ||
git submodule update | ||
#if [ ! -d qemu ]; then | ||
# git clone https://github.com/gthparch/qemu.git | ||
# git checkout feature/qsim_plugin | ||
#fi | ||
cd buildDirARM64 | ||
../qemu/configure --target-list=aarch64-softmmu --enable-plugins | ||
make -j 4 & | ||
cd .. | ||
cd buildDirX86 | ||
../qemu/configure --target-list=i386-softmmu --enable-plugins | ||
make -j 4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"memory": "4096M", | ||
"emuMachineType": "virt", | ||
"global": "virtio-blk-device.scsi=off", | ||
"devices": ["virtio-scsi-device,id=scsi", "scsi-hd,drive=coreimg", | ||
"virtio-net-device,netdev=unet"], | ||
"netdev": "user,id=unet", | ||
"portNumber": "2851", | ||
"append": "root=/dev/sda2", | ||
"nographic" : true, | ||
"driveParam": "id=coreimg,cache=unsafe,if=none", | ||
"remoteBenchmarkDir": "benchmark", | ||
"remotescriptExec" : "runner.sh" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.o | ||
*_dynamicLibVerify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#_____________STATIC STUFF__________________________________________ | ||
OPTIONS = -std=c++11 -D VERBOSE | ||
FILES := main.o $(shell echo src/*.cpp | sed -e 's/cpp/o/g') | ||
UNAME := $(shell uname) | ||
EXE := $(UNAME)_dynamicLibVerify | ||
CC := g++ | ||
INCPATH := `pkg-config gmodule-2.0 --cflags` | ||
INCPATH += -I include | ||
LIBPATH := `pkg-config gmodule-2.0 --libs` | ||
CFLAGS := $(INCPATH) $(LIBPATH) $(OPTIONS) | ||
#_____________STATIC STUFF________________________________________________ | ||
|
||
#Small enough project so lets rebuild everytime | ||
run : build-release | ||
./$(EXE) | ||
|
||
run-debug : build-debug | ||
./$(EXE) | ||
|
||
run-gdb : build-debug | ||
gdb --args ./$(EXE) | ||
|
||
edit0 : | ||
nano -c main.cpp | ||
|
||
edit1 : | ||
ifeq ($(UNAME), Linux) | ||
kate *.cpp *.hpp & | ||
endif | ||
ifeq ($(UNAME), Darwin) | ||
@echo 'N/A' | ||
endif | ||
|
||
run-valgrind : build-debug | ||
valgrind --leak-check=yes --show-reachable=yes --tool=memcheck ./EXE | ||
|
||
build-release : CFLAGS += -O3 | ||
build-release : $(EXE) | ||
|
||
%.o: %.cpp | ||
$(CC) -c -o $@ $< $(CFLAGS) | ||
|
||
$(EXE) : $(FILES) | ||
$(CC) $^ -o $(EXE) $(CFLAGS) | ||
|
||
build-debug : CFLAGS += -g -DDEBUG | ||
build-debug : $(EXE) | ||
|
||
clean : | ||
rm -rf *.o* $(EXE)* | ||
|
||
rebuild : clean build-release | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
#ifndef __PLUGIN__LOAD_HPP__ | ||
#define __PLUGIN__LOAD_HPP__ | ||
class PluginLoad { | ||
public: | ||
static bool plugin_load(const char *filename); | ||
private: | ||
PluginLoad() = delete; | ||
}; | ||
#endif // __PLUGIN__LOAD_HPP__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include "pluginLoad.hpp" | ||
|
||
int main(int argc, char **argv) { | ||
if(argc == 2) { | ||
PluginLoad::plugin_load(argv[1]); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include <stdio.h> | ||
#include <gmodule.h> | ||
#include "pluginLoad.hpp" | ||
|
||
|
||
#ifdef VERBOSE | ||
#define DB_PRINTF(f_, ...) printf((f_), ##__VA_ARGS__) | ||
#else | ||
#define DB_PRINTF(f_, ...) (void)0 | ||
#endif | ||
|
||
//#include "/usr/include/glib-2.0/gmodule.h" | ||
typedef bool (*PluginInitFunc)(const char *); | ||
typedef bool (*PluginNeedsBeforeInsnFunc)(u_int64_t, void *); | ||
typedef void (*PluginBeforeInsnFunc)(u_int64_t, void *); | ||
typedef void (*PluginAfterMemFunc)(void *, u_int64_t, int, int); | ||
typedef void (*PluginBeeforeInterupt)(void *, u_int64_t); | ||
|
||
PluginInitFunc* init; | ||
PluginNeedsBeforeInsnFunc* needs_before_insn; | ||
PluginBeforeInsnFunc* before_insn; | ||
PluginAfterMemFunc* after_mem; | ||
bool enable_instrumentation = true; | ||
|
||
bool PluginLoad::plugin_load(const char *filename) | ||
{ | ||
GModule *g_module; | ||
bool retValue = true; | ||
if (!filename) { | ||
DB_PRINTF("plugin name was not specified"); | ||
return false; | ||
} | ||
g_module = g_module_open(filename, | ||
G_MODULE_BIND_LAZY); | ||
if (!g_module) { | ||
DB_PRINTF("can't load plugin '%s'", filename); | ||
DB_PRINTF("error: %s",g_module_error ()); | ||
return false; | ||
} | ||
DB_PRINTF("plugin '%s' Loaded!", filename); | ||
|
||
if (!g_module_symbol(g_module, "plugin_init", (gpointer*)&init) ) { | ||
DB_PRINTF("plugin_init failed to load is: 0x%p !", init); | ||
DB_PRINTF("plugin_init error: %s",g_module_error ()); | ||
retValue = false; | ||
|
||
} | ||
/* Get the instrumentation callbacks */ | ||
if (! g_module_symbol(g_module, "plugin_needs_before_insn", (gpointer*)&needs_before_insn) ) { | ||
DB_PRINTF("needs_before_insn is: 0x%p !", needs_before_insn); | ||
DB_PRINTF("needs_before_insn error: %s",g_module_error ()); | ||
retValue = false; | ||
} | ||
if (! g_module_symbol(g_module, "plugin_before_insn",(gpointer*)&before_insn) ) { | ||
DB_PRINTF("before_insn is: 0x%p !", before_insn); | ||
DB_PRINTF("before_insn error: %s",g_module_error ()); | ||
retValue = false; | ||
} | ||
|
||
if (! g_module_symbol(g_module, "plugin_after_mem", | ||
(gpointer*)&after_mem) ) { | ||
|
||
DB_PRINTF("after_mem is: 0x%p !", after_mem); | ||
DB_PRINTF("after_mem error: %s",g_module_error ()); | ||
retValue = false; | ||
} | ||
|
||
g_module_close (g_module); | ||
return retValue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*_TestCases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#_____________STATIC STUFF__________________________________________ | ||
OPTIONS = -std=c++11 | ||
FILES := test.o $(shell echo ../src/*.cpp | sed -e 's/cpp/o/g') | ||
UNAME := $(shell uname) | ||
EXE := $(UNAME)_TestCases | ||
CC := g++ | ||
|
||
INCPATH := `pkg-config gmodule-2.0 --cflags` -I include -I ../include | ||
LIBPATH := `pkg-config gmodule-2.0 --libs` | ||
CFLAGS := $(INCPATH) $(LIBPATH) $(OPTIONS) | ||
#_____________STATIC STUFF________________________________________________ | ||
|
||
#Small enough project so lets rebuild everytime | ||
run : build-release | ||
./$(EXE) | ||
|
||
run-debug : build-debug | ||
./$(EXE) | ||
|
||
run-gdb : build-debug | ||
gdb --args ./$(EXE) | ||
|
||
edit0 : | ||
nano -c main.cpp | ||
|
||
edit1 : | ||
ifeq ($(UNAME), Linux) | ||
kate *.cpp *.hpp & | ||
endif | ||
ifeq ($(UNAME), Darwin) | ||
@echo 'N/A' | ||
endif | ||
|
||
run-valgrind : build-debug | ||
valgrind --leak-check=yes --show-reachable=yes --tool=memcheck ./EXE | ||
|
||
build-release : CFLAGS += -O3 | ||
build-release : $(EXE) | ||
|
||
%.o: %.cpp | ||
$(CC) -c -o $@ $< $(CFLAGS) | ||
|
||
$(EXE) : $(FILES) | ||
$(CC) $^ -o $(EXE) $(CFLAGS) | ||
|
||
build-debug : CFLAGS += -g -DDEBUG | ||
build-debug : $(EXE) | ||
|
||
clean : | ||
rm -rf *.o* $(EXE)* | ||
|
||
rebuild : clean build-release |
Oops, something went wrong.