Update memory access instrumentation code
This commit is contained in:
parent
cacec881cf
commit
a652e773d9
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: instrument.cc,v 1.22 2008-03-03 15:09:30 sshwarts Exp $
|
||||
// $Id: instrument.cc,v 1.23 2008-04-19 10:12:09 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -134,7 +134,7 @@ static void branch_taken(unsigned cpu, bx_address new_eip)
|
||||
if (!active || !instruction[cpu].valid) return;
|
||||
|
||||
// find linear address
|
||||
bx_address laddr = BX_CPU(cpu)->get_segment_base(BX_SEG_REG_CS) + new_eip;
|
||||
bx_address laddr = BX_CPU(cpu)->get_laddr(BX_SEG_REG_CS, new_eip);
|
||||
|
||||
instruction[cpu].is_branch = 1;
|
||||
instruction[cpu].is_taken = 1;
|
||||
@ -212,7 +212,7 @@ void bx_instr_hwinterrupt(unsigned cpu, unsigned vector, Bit16u cs, bx_address e
|
||||
}
|
||||
}
|
||||
|
||||
void bx_instr_mem_data(unsigned cpu, bx_address lin, unsigned size, unsigned rw)
|
||||
void bx_instr_mem_data(unsigned cpu, unsigned seg, bx_address offset, unsigned len, unsigned rw)
|
||||
{
|
||||
unsigned index;
|
||||
bx_phy_address phy;
|
||||
@ -224,6 +224,7 @@ void bx_instr_mem_data(unsigned cpu, bx_address lin, unsigned size, unsigned rw)
|
||||
return;
|
||||
}
|
||||
|
||||
bx_address lin = BX_CPU(cpu)->get_laddr(seg, offset);
|
||||
bx_bool page_valid = BX_CPU(cpu)->dbg_xlate_linear2phy(lin, &phy);
|
||||
phy = A20ADDR(phy);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: instrument.h,v 1.26 2008-04-15 21:27:11 sshwarts Exp $
|
||||
// $Id: instrument.h,v 1.27 2008-04-19 10:12:09 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -76,7 +76,7 @@ void bx_instr_interrupt(unsigned cpu, unsigned vector);
|
||||
void bx_instr_exception(unsigned cpu, unsigned vector);
|
||||
void bx_instr_hwinterrupt(unsigned cpu, unsigned vector, Bit16u cs, bx_address eip);
|
||||
|
||||
void bx_instr_mem_data(unsigned cpu, bx_address lin, unsigned size, unsigned rw);
|
||||
void bx_instr_mem_data_access(unsigned cpu, unsigned seg, bx_address offset, unsigned len, unsigned rw);
|
||||
|
||||
/* simulation init, shutdown, reset */
|
||||
# define BX_INSTR_INIT(cpu_id) bx_instr_init(cpu_id)
|
||||
@ -127,8 +127,8 @@ void bx_instr_mem_data(unsigned cpu, bx_address lin, unsigned size, unsigned rw)
|
||||
# define BX_INSTR_LIN_ACCESS(cpu_id, lin, phy, len, rw)
|
||||
|
||||
/* memory access */
|
||||
# define BX_INSTR_MEM_CODE(cpu_id, linear, size)
|
||||
# define BX_INSTR_MEM_DATA(cpu_id, linear, size, rw) bx_instr_mem_data(cpu_id, linear, size, rw)
|
||||
# define BX_INSTR_MEM_DATA_ACCESS(cpu_id, seg, offset, len, rw) \
|
||||
bx_instr_mem_data_access(cpu_id, seg, offset, len, rw)
|
||||
|
||||
/* called from memory object */
|
||||
# define BX_INSTR_PHY_WRITE(cpu_id, addr, len)
|
||||
@ -192,8 +192,7 @@ void bx_instr_mem_data(unsigned cpu, bx_address lin, unsigned size, unsigned rw)
|
||||
# define BX_INSTR_LIN_ACCESS(cpu_id, lin, phy, len, rw)
|
||||
|
||||
/* memory access */
|
||||
# define BX_INSTR_MEM_CODE(cpu_id, linear, size)
|
||||
# define BX_INSTR_MEM_DATA(cpu_id, linear, size, rw)
|
||||
# define BX_INSTR_MEM_DATA_ACCESS(cpu_id, seg, offset, len, rw)
|
||||
|
||||
/* called from memory object */
|
||||
# define BX_INSTR_PHY_WRITE(cpu_id, addr, len)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: instrument.cc,v 1.17 2008-03-03 15:09:30 sshwarts Exp $
|
||||
// $Id: instrument.cc,v 1.18 2008-04-19 10:12:09 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -98,7 +98,7 @@ void bxInstrumentation::branch_taken(bx_address new_eip)
|
||||
if (!active || !valid) return;
|
||||
|
||||
// find linear address
|
||||
bx_address laddr = BX_CPU(cpu_id)->get_segment_base(BX_SEG_REG_CS) + new_eip;
|
||||
bx_address laddr = BX_CPU(cpu_id)->get_laddr(BX_SEG_REG_CS, new_eip);
|
||||
|
||||
is_branch = 1;
|
||||
is_taken = 1;
|
||||
@ -176,7 +176,7 @@ void bxInstrumentation::bx_instr_hwinterrupt(unsigned vector, Bit16u cs, bx_addr
|
||||
}
|
||||
}
|
||||
|
||||
void bxInstrumentation::bx_instr_mem_data(bx_address lin, unsigned size, unsigned rw)
|
||||
void bxInstrumentation::bx_instr_mem_data_access(unsigned seg, bx_address offset, unsigned len, unsigned rw)
|
||||
{
|
||||
bx_phy_address phy;
|
||||
|
||||
@ -187,6 +187,7 @@ void bxInstrumentation::bx_instr_mem_data(bx_address lin, unsigned size, unsigne
|
||||
return;
|
||||
}
|
||||
|
||||
bx_address lin = BX_CPU(cpu_id)->get_laddr(seg, offset);
|
||||
bx_bool page_valid = BX_CPU(cpu_id)->dbg_xlate_linear2phy(lin, &phy);
|
||||
phy = A20ADDR(phy);
|
||||
|
||||
@ -200,6 +201,6 @@ void bxInstrumentation::bx_instr_mem_data(bx_address lin, unsigned size, unsigne
|
||||
data_access[num_data_accesses].laddr = lin;
|
||||
data_access[num_data_accesses].paddr = phy;
|
||||
data_access[num_data_accesses].op = rw;
|
||||
data_access[num_data_accesses].size = size;
|
||||
data_access[num_data_accesses].size = len;
|
||||
num_data_accesses++;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: instrument.h,v 1.24 2008-04-15 21:27:11 sshwarts Exp $
|
||||
// $Id: instrument.h,v 1.25 2008-04-19 10:12:09 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -117,7 +117,7 @@ public:
|
||||
void bx_instr_exception(unsigned vector);
|
||||
void bx_instr_hwinterrupt(unsigned vector, Bit16u cs, bx_address eip);
|
||||
|
||||
void bx_instr_mem_data(bx_address linear, unsigned size, unsigned rw);
|
||||
void bx_instr_mem_data_access(unsigned seg, bx_address offset, unsigned len, unsigned rw);
|
||||
|
||||
private:
|
||||
void branch_taken(bx_address new_eip);
|
||||
@ -176,8 +176,8 @@ extern bxInstrumentation *icpu;
|
||||
/* memory access */
|
||||
# define BX_INSTR_LIN_ACCESS(cpu_id, lin, phy, len, rw)
|
||||
|
||||
# define BX_INSTR_MEM_CODE(cpu_id, linear, size)
|
||||
# define BX_INSTR_MEM_DATA(cpu_id, linear, size, rw) icpu[cpu_id].bx_instr_mem_data(linear, size, rw)
|
||||
# define BX_INSTR_MEM_DATA_ACCESS(cpu_id, seg, offset, len, rw) \
|
||||
icpu[cpu_id].bx_instr_mem_data_access(seg, offset, len, rw)
|
||||
|
||||
/* called from memory object */
|
||||
# define BX_INSTR_PHY_WRITE(cpu_id, addr, len)
|
||||
@ -241,8 +241,7 @@ extern bxInstrumentation *icpu;
|
||||
# define BX_INSTR_LIN_ACCESS(cpu_id, lin, phy, len, rw)
|
||||
|
||||
/* memory access */
|
||||
# define BX_INSTR_MEM_CODE(cpu_id, linear, size)
|
||||
# define BX_INSTR_MEM_DATA(cpu_id, linear, size, rw)
|
||||
# define BX_INSTR_MEM_DATA_ACCESS(cpu_id, seg, offset, len, rw)
|
||||
|
||||
/* called from memory object */
|
||||
# define BX_INSTR_PHY_WRITE(cpu_id, addr, len)
|
||||
|
@ -200,12 +200,15 @@ Currently the callback is not supported when repeat-speedups optimization is
|
||||
enabled.
|
||||
|
||||
|
||||
void bx_instr_mem_data(unsigned cpu, bx_address linear, unsigned len, unsigned rw);
|
||||
void bx_instr_mem_data_access(unsigned cpu, unsigned seg, bx_address offset, unsigned len, unsigned rw);
|
||||
|
||||
The callback is called each time, when Bochs simulator executes linear memory
|
||||
access. In contrast to previous callback it will be called even if memory
|
||||
access fails because of any reason (for example protection failure or page
|
||||
fault).
|
||||
The callback is called each time, when Bochs simulator executes segment based
|
||||
linear memory access. In contrast to previous callback it will be called even
|
||||
if memory access fails because of any reason (for example segment protection
|
||||
failure or page fault).
|
||||
|
||||
The callback will not be called for system memory accesses like sys desriptor
|
||||
tables reads/writes or new stack pushes during far call or exception.
|
||||
|
||||
|
||||
void bx_instr_phy_read(unsigned cpu, bx_address addr, unsigned len);
|
||||
@ -228,6 +231,16 @@ Known problems:
|
||||
|
||||
2. BX_INSTR_MEM_DATA doesn't work when repeat-speedups feature is enabled.
|
||||
|
||||
3. BX_INSTR_OPCODE doesn't work with trace cache optimization enabled
|
||||
|
||||
Feature requests:
|
||||
|
||||
1. BX_INSTR_CNEAR_BRANCH_NOT_TAKEN callback should have an additional
|
||||
'not taken' new_EIP parameter.
|
||||
|
||||
2. BX_INSTR_SMI, BX_INSTR_NMI, BX_INSTR_SIPI and other external events
|
||||
callbacks
|
||||
|
||||
3.
|
||||
|
||||
While using Bochs as a reference model for simulations, the simulator needs
|
||||
@ -241,15 +254,3 @@ BX_INSTR_MEM_DATA() hook because it does not get called for these
|
||||
instructions. Should this be changed along with some other instructions
|
||||
that exhibit this?
|
||||
Brian Slechta
|
||||
|
||||
5. BX_INSTR_OPCODE doesn't work with trace cache optimization enabled
|
||||
|
||||
Feature requests:
|
||||
|
||||
1. BX_INSTR_CNEAR_BRANCH_NOT_TAKEN callback should have an additional
|
||||
'not taken' new_EIP parameter.
|
||||
|
||||
2. X86-64 support
|
||||
|
||||
3. BX_INSTR_SMI, BX_INSTR_NMI, BX_INSTR_SIPI and other external events
|
||||
callbacks
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: instrument.cc,v 1.25 2008-04-15 21:27:11 sshwarts Exp $
|
||||
// $Id: instrument.cc,v 1.26 2008-04-19 10:12:09 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -69,9 +69,7 @@ void bx_instr_outp(Bit16u addr, unsigned len) {}
|
||||
void bx_instr_inp2(Bit16u addr, unsigned len, unsigned val) {}
|
||||
void bx_instr_outp2(Bit16u addr, unsigned len, unsigned val) {}
|
||||
|
||||
void bx_instr_mem_code(unsigned cpu, bx_address linear, unsigned len) {}
|
||||
void bx_instr_mem_data(unsigned cpu, bx_address linear, unsigned len, unsigned rw) {}
|
||||
|
||||
void bx_instr_mem_data_access(unsigned cpu, unsigned seg, bx_address offset, unsigned len, unsigned rw) {}
|
||||
void bx_instr_lin_access(unsigned cpu, bx_address lin, bx_address phy, unsigned len, unsigned rw) {}
|
||||
|
||||
void bx_instr_phy_write(unsigned cpu, bx_address addr, unsigned len) {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: instrument.h,v 1.31 2008-04-15 21:27:11 sshwarts Exp $
|
||||
// $Id: instrument.h,v 1.32 2008-04-19 10:12:09 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -97,9 +97,7 @@ void bx_instr_outp(Bit16u addr, unsigned len);
|
||||
void bx_instr_inp2(Bit16u addr, unsigned len, unsigned val);
|
||||
void bx_instr_outp2(Bit16u addr, unsigned len, unsigned val);
|
||||
|
||||
void bx_instr_mem_code(unsigned cpu, bx_address linear, unsigned size);
|
||||
void bx_instr_mem_data(unsigned cpu, bx_address linear, unsigned size, unsigned rw);
|
||||
|
||||
void bx_instr_mem_data(unsigned cpu, unsigned seg, bx_address offset, unsigned len, unsigned rw);
|
||||
void bx_instr_lin_access(unsigned cpu, bx_address lin, bx_address phy, unsigned len, unsigned rw);
|
||||
|
||||
void bx_instr_phy_write(unsigned cpu, bx_address addr, unsigned len);
|
||||
@ -160,8 +158,7 @@ void bx_instr_wrmsr(unsigned cpu, unsigned addr, Bit64u value);
|
||||
# define BX_INSTR_LIN_ACCESS(cpu_id, lin, phy, len, rw) bx_instr_lin_access(cpu_id, lin, phy, len, rw)
|
||||
|
||||
/* memory access */
|
||||
# define BX_INSTR_MEM_CODE(cpu_id, linear, size) bx_instr_mem_code(cpu_id, linear, size)
|
||||
# define BX_INSTR_MEM_DATA(cpu_id, linear, size, rw) bx_instr_mem_data(cpu_id, linear, size, rw)
|
||||
# define BX_INSTR_MEM_DATA_ACCESS(cpu_id, seg, offset, len, rw) bx_instr_mem_data(cpu_id, seg, offset, len, rw)
|
||||
|
||||
/* called from memory object */
|
||||
# define BX_INSTR_PHY_WRITE(cpu_id, addr, len) bx_instr_phy_write(cpu_id, addr, len)
|
||||
@ -225,8 +222,7 @@ void bx_instr_wrmsr(unsigned cpu, unsigned addr, Bit64u value);
|
||||
# define BX_INSTR_LIN_ACCESS(cpu_id, lin, phy, len, rw)
|
||||
|
||||
/* memory access */
|
||||
# define BX_INSTR_MEM_CODE(cpu_id, linear, size)
|
||||
# define BX_INSTR_MEM_DATA(cpu_id, linear, size, rw)
|
||||
# define BX_INSTR_MEM_DATA_ACCESS(cpu_id, seg, offset, len, rw)
|
||||
|
||||
/* called from memory object */
|
||||
# define BX_INSTR_PHY_WRITE(cpu_id, addr, len)
|
||||
|
Loading…
x
Reference in New Issue
Block a user