Skip to content

Commit

Permalink
update for decaf 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed May 28, 2014
1 parent edab613 commit fc23752
Show file tree
Hide file tree
Showing 51 changed files with 1,512 additions and 601 deletions.
5 changes: 2 additions & 3 deletions Makefile.objs
Original file line number Diff line number Diff line change
Expand Up @@ -428,15 +428,14 @@ vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS)
QEMU_CFLAGS+=$(GLIB_CFLAGS)

#libdecaf AWH
QEMU_CPPFLAGS+=$(QEMU_CFLAGS)
QEMU_CPPFLAGS+=-fPIC
#LOK: moved the callback interface into the shared directory
libdecaf-y=DECAF_callback.o DECAF_main.o DECAF_cmds.o
libdecaf-y+=hookapi.o windows_vmi.o vmi.o vmi_c_wrapper.o
libdecaf-y+=linux_procinfo.o linux_readelf.o linux_vmi.o
libdecaf-y+=function_map.o
libdecaf-y+=tainting/reduce_taint.o tainting/taintcheck_opt.o tainting/tainting.o
libdecaf-y+=tainting/taint_memory.o tainting/tcg_taint.o tainting/analysis_log.o
#libdecaf-y+=sqlite3/sqlite3.o
libdecaf-y+=tainting/taint_memory.o tainting/tcg_taint.o
libdecaf-y+=DECAF_vm_compress.o
libdecaf-y+=utils/HashtableWrapper.o
libdecaf-y+=utils/Output.o
Expand Down
19 changes: 18 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ target_list=""
# Distributions want to ensure that several features are compiled in, and it
# is impossible without a --enable-foo that exits if a feature is not found.

#AWH - LLVM support disabled by default
tcg_llvm="no"
#AWH - VMI enabled by default
enable_vmi="yes"
#AWH - TCG tainting off by default
Expand Down Expand Up @@ -811,11 +813,17 @@ for opt do
;;
--disable-tcg-ir-log) tcg_ir_log="no"
;;
# AWH - TCG LLVM support
--enable-tcg-llvm) tcg_llvm="yes"
;;
--disable-tcg-llvm) tcg_llvm="no"
;;
# AWH - VMI support
--enable-vmi) enable_vmi="yes"
;;
--disable-vmi) enable_vmi="no"
;;

*) echo "ERROR: unknown option $opt"; show_help="yes"
;;
esac
Expand Down Expand Up @@ -905,6 +913,7 @@ if [ "$softmmu" = "yes" ] ; then
default_target_list="\
i386-softmmu \
arm-softmmu \
mips-softmmu \
"
fi
#x86_64-softmmu \
Expand Down Expand Up @@ -1115,6 +1124,9 @@ echo " --enable-tcg-taint enable taint IR generation via TCG"
# AWH - TCG IR logging
echo " --disable-tcg-ir-log disable TCG IR logging buffers (default)"
echo " --enable-tcg-ir-log enable TCG IR logging buffers"
# AWH - TCG-to-LLVM translation
echo " --disable-tcg-llvm disable TCG-to-LLVM translation (default)"
echo " --enable-tcg-llvm enable TCG-to-LLVM translation"
# AWH - VMI enable
echo " --disable-vmi disable VMI support"
echo " --enable-vmi enable VMI support (default)"
Expand Down Expand Up @@ -2919,6 +2931,8 @@ echo "build guest agent $guest_agent"
echo "enable TCG taint $tcg_taint"
# AWH - TCG IR logging
echo "enable IR logging $tcg_ir_log"
#AWH - TCG LLVM
echo "enable TCG LLVM $tcg_llvm"
# AWH - VMI
echo "enable VMI $enable_vmi"

Expand Down Expand Up @@ -2967,7 +2981,10 @@ esac
if test "$enable_vmi" = "yes" ; then
echo "CONFIG_VMI_ENABLE=y" >> $config_host_mak
fi

#AWH - TCG LLVM
if test "$tcg_llvm" = "yes" ; then
echo "CONFIG_TCG_LLVM=y" >> $config_host_mak
fi
#AWH - TCG tainting
if test "$tcg_taint" = "yes" ; then
echo "CONFIG_TCG_TAINT=y" >> $config_host_mak
Expand Down
19 changes: 19 additions & 0 deletions exec-all.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,17 @@ void tlb_set_page(CPUState *env, target_ulong vaddr,
#define USE_DIRECT_JUMP
#endif

#ifdef CONFIG_TCG_LLVM
struct TCGLLVMTranslationBlock;
struct TCGLLVMContext;
#ifdef __cplusplus
namespace llvm { class Function; }
using llvm::Function;
#else
struct Function;
#endif
#endif /* CONFIG_TCG_LLVM */

struct TranslationBlock {
target_ulong pc; /* simulated PC corresponding to this block (EIP + CS base) */
target_ulong cs_base; /* CS base for this block */
Expand Down Expand Up @@ -203,6 +214,14 @@ struct TranslationBlock {
struct TranslationBlock *jmp_next[2];
struct TranslationBlock *jmp_first;
uint32_t icount;
#ifdef CONFIG_TCG_LLVM
/* pointer to LLVM translated code */
struct TCGLLVMContext *tcg_llvm_context;
struct Function *llvm_function;
uint8_t *llvm_tc_ptr;
uint8_t *llvm_tc_end;
struct TranslationBlock* llvm_tb_next[2];
#endif /* CONFIG_TCG_LLVM */
#ifdef CONFIG_TCG_IR_LOG
uint8_t DECAF_logged; /* AWH - Has this been logged to disk? */
uint16_t *DECAF_gen_opc_buf; /* AWH - IR ops in this TB */
Expand Down
13 changes: 6 additions & 7 deletions exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,20 +575,19 @@ static void code_gen_alloc(unsigned long tb_size)
map_exec(code_gen_prologue, sizeof(code_gen_prologue));
code_gen_buffer_max_size = code_gen_buffer_size -
(TCG_MAX_OP_SIZE * OPC_BUF_SIZE);
#if (defined(CONFIG_TCG_IR_LOG) && (TCG_TARGET_REG_BITS == 32))
/* AWH - For people running DECAF on a 32-bit machine, the IR storage
will require too much RAM. So, for 32-bit systems, we make the number
of code blocks much smaller. */
#if defined(CONFIG_TCG_IR_LOG)
/* AWH - IR storage requires too much RAM for the default code_gen_max_blocks.
So, we make the number of code blocks much smaller. */
code_gen_max_blocks = code_gen_buffer_size / CODE_GEN_AVG_BLOCK_SIZE / 16;
#else
code_gen_max_blocks = code_gen_buffer_size / CODE_GEN_AVG_BLOCK_SIZE;
#endif /* CONFIG_TCG_IR_LOG && (TCG_TARGET_REG_BITS == 32) */
#endif /* CONFIG_TCG_IR_LOG */
tbs = g_malloc(code_gen_max_blocks * sizeof(TranslationBlock));
#ifdef CONFIG_TCG_IR_LOG
fprintf(stderr, "AWH: code_gen_alloc(): code_gen_max_blocks: %d\n", code_gen_max_blocks);
fprintf(stderr, "AWH: code_gen_alloc(): gDECAF_gen_opc_buf: %d\n", (OPC_MAX_SIZE+ TCG_IR_LOG_PADDING) * sizeof(uint16_t) * code_gen_max_blocks);
fprintf(stderr, "AWH: code_gen_alloc(): gDECAF_gen_opc_buf: %dk\n", ((OPC_MAX_SIZE+ TCG_IR_LOG_PADDING) * sizeof(uint16_t) * code_gen_max_blocks) >> 10);
gDECAF_gen_opc_buf = g_malloc((OPC_MAX_SIZE + TCG_IR_LOG_PADDING) * sizeof(uint16_t) * code_gen_max_blocks);
fprintf(stderr, "AWH: code_gen_alloc(): gDECAF_gen_opparam_buf: %d\n", (OPC_MAX_SIZE + TCG_IR_LOG_PADDING) * sizeof(TCGArg) * 6 * code_gen_max_blocks);
fprintf(stderr, "AWH: code_gen_alloc(): gDECAF_gen_opparam_buf: %dk\n", ((OPC_MAX_SIZE + TCG_IR_LOG_PADDING) * sizeof(TCGArg) * 6 * code_gen_max_blocks) >> 10);
gDECAF_gen_opparam_buf = g_malloc((OPC_MAX_SIZE + TCG_IR_LOG_PADDING) * sizeof(TCGArg) * 6 * code_gen_max_blocks);

for (i = 0; i < code_gen_max_blocks; i++) {
Expand Down
4 changes: 3 additions & 1 deletion hw/ps2.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
extern void * cpu_single_env;
extern int taint_keystroke_enabled;
extern void DECAF_taint_keystroke(int keycode);
extern void DECAF_keystroke_read(uint8_t taint_status);
extern void DECAF_keystroke_place(int keycode);
#endif /* CONFIG_TCG_TAINT */

/* debug PC keyboard */
Expand Down Expand Up @@ -157,7 +159,7 @@ void ps2_queue(void *opaque, int b)
}

#ifdef CONFIG_TCG_TAINT
void ps2_queue_taint(void *opaque, int b)
static void ps2_queue_taint(void *opaque, int b)
{
PS2State *s = (PS2State *)opaque;
PS2Queue *q = &s->queue;
Expand Down
Loading

0 comments on commit fc23752

Please sign in to comment.