Exemple #1
0
/*
 * push_shack()
 *  Push next guest eip into shadow stack.
 */
void push_shack(CPUState *env, TCGv_ptr cpu_env, target_ulong next_eip) {
	TCGv_ptr temp_shack_top = tcg_temp_new_ptr();
	TCGv_ptr temp_shack_end = tcg_temp_new_ptr();
	TCGv_ptr temp_entry_ptr = tcg_temp_new_ptr();
	TCGv temp_next_eip = tcg_temp_local_new_i32();
	// int flush_label = gen_new_label();
	shack_hash_entry *entry;

	//Load the entry. Entry is the constant for each next_eip
	int table_index = next_eip & (SHACK_SIZE-1);
	entry = &shadow_hash_list[table_index];
	
	// load to temp
	tcg_gen_ld_ptr(temp_shack_top, cpu_env, offsetof(CPUState, shack_top));
	tcg_gen_ld_ptr(temp_shack_end, cpu_env, offsetof(CPUState, shack_end));
	tcg_gen_movi_i32(temp_next_eip, next_eip);
	tcg_gen_movi_i32(temp_entry_ptr ,entry);

	//- branch to flush
	// tcg_gen_brcond_ptr(TCG_COND_EQ, temp_shack_top, temp_shack_end, flush_label);

	// push to stack
	tcg_gen_st_ptr(temp_entry_ptr, temp_shack_top, 0);
	tcg_gen_addi_ptr(temp_shack_top, temp_shack_top, sizeof(uint64_t));
	tcg_gen_st_ptr(temp_shack_top, cpu_env, offsetof(CPUState, shack_top));

	// gen_set_label(flush_label);
	// printf("");//do nothing
	// // flush stack
	// helper_shack_flush(env);
	// tcg_gen_mov_tl(temp_shack_top, tcg_const_tl((int32_t)(env->shack + 1)));
}
Exemple #2
0
static void gen_exception(int excp) {
	TCGv tmp = new_tmp();
	tcg_gen_movi_i32(tmp, excp);
	gen_helper_exception(tmp);
	dead_tmp(tmp);
}