address translation
Hello group,
I have two questions, both regarding the virtual-physical translation of addresses (all in the virtual machine context).
1>
Can somebody tell me if the program counter value available in the following snippet from target-i386/translate.c
is virtual or physical? I learnt it may be virtual, in which case is there a way to extract the physical address corresponding to the
virtual address, or if it is physical, then is there a way to translate to its virtual address (within the virtual machine context)?
************************************************
/* convert one instruction. s->is_jmp is set if the translation must
be stopped. Return the next pc value */
static target_ulong disas_insn(DisasContext *s, target_ulong pc_start) {
int b, prefixes, aflag, dflag;
int shift, ot;
int modrm, reg, rm, mod, reg_addr, op, opreg, offset_addr, val; target_ulong next_eip, tval;
int rex_w, rex_r;
s->pc = pc_start; // This s->pc is what I am using to extract all
executed PC values
************************************************
2>
Second question I have is - Within the functions from target-i386/ops_mem.h for example,
void OPPROTO glue(glue(op_ldub, MEMSUFFIX), _T0_A0)(void) {
T0 = glue(ldub, MEMSUFFIX)(A0);
}
Is A0 the physical address? or is it virtual?
And how to I translate from one to another in either case?
Thanks in advance.
-Shashi.
Quoted 5 lines · Shashidhar Mysore
Hello group,
I have two questions, both regarding the virtual-physical translation of addresses (all in the virtual machine context).
Quoted 7 lines
1>
Can somebody tell me if the program counter value available in the following snippet fromtarget-i386/translate.c
is virtual or physical? I learnt it may be virtual, in which case is there a way to extract the physical address corresponding to the
virtual address, or if it is physical, then is there a way to translate to its virtual address (within the virtual machine context)?
It is virtual, I think cpu_get_phys_page_debug() + the offset should give you physical.
Quoted 13 lines
************************************************
/* convert one instruction.s->is_jmpis set if the translation must
be stopped. Return the next pc value */
statictarget_ulongdisas_insn(DisasContext *s, target_ulong pc_start){ int b, prefixes, aflag, dflag; int shift, ot; int modrm, reg, rm, mod, reg_addr, op, opreg, offset_addr, val; target_ulong next_eip, tval; int rex_w, rex_r; s->pc = pc_start; // This s->pc is what I am using to extract all
Quoted 1 line
executed PC values
This s->pc doesn't correspond to executed PC values, qemu is a translator.
Quoted 7 lines
************************************************
2>
Second question I have is - Within the functions fromtarget-i386/ops_mem.hfor example,
Quoted 7 lines
void OPPROTO
glue(glue(op_ldub, MEMSUFFIX), _T0_A0)(void){ T0 = glue(ldub, MEMSUFFIX)(A0);}
Is A0 the physical address? or is it virtual?
And how to I translate from one to another in either case?
Also virtual.
Regards
Thanks for the reply, Andrzej!
Some clarifications below ...
Quoted 12 lines · andrzej zaborowski
Quoted 12 lines
************************************************
/* convert one instruction.s->is_jmpis set if the translation must
be stopped. Return the next pc value */
statictarget_ulongdisas_insn(DisasContext *s, target_ulong pc_start){ int b, prefixes, aflag, dflag; int shift, ot; int modrm, reg, rm, mod, reg_addr, op, opreg, offset_addr, val; target_ulong next_eip, tval; int rex_w, rex_r;
Quoted 4 lines
Quoted 2 lines
s->pc = pc_start; // This s->pc is what I am using to extract allexecuted PC values
This
s->pcdoesn't correspond to executed PC values, qemu is a translator.
Can you tell me what s->pc is, in this context? Is the the start PC of a basic block that is about to be executed? Is there any way in which I could extract the trace of executed PCs in QEMU?
Regards,
-Shashi.
Quoted 17 lines · Shashidhar Mysore
Thanks for the reply, Andrzej!
Some clarifications below ...
Quoted 12 lines · andrzej zaborowski
Quoted 12 lines
************************************************
/* convert one instruction.s->is_jmpis set if the translation must
be stopped. Return the next pc value */
statictarget_ulongdisas_insn(DisasContext *s, target_ulong pc_start){ int b, prefixes, aflag, dflag; int shift, ot; int modrm, reg, rm, mod, reg_addr, op, opreg, offset_addr, val; target_ulong next_eip, tval; int rex_w, rex_r;
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
s->pc = pc_start; // This s->pc is what I am using to extract allexecuted PC values
This
s->pcdoesn't correspond to executed PC values, qemu is a translator.Can you tell me what
s->pcis, in this context? Is the the start PC of a
It is the PC of the disassembled instruction (hence disasm_insn).
Quoted 2 lines
basic block that is about to be executed? Is there any way in which I could extract the trace of executed PCs in QEMU?
Yes, there was a thread about this about two months ago.
Regards
Hi Andrzej,
There were actually two methods described in the thread referred to in the thread to which you were referring in your previous mail. :) The thread was -
http://thread.gmane.org/gmane.comp.emulators.qemu/16604
I used the patch provided by Stuart Brady (in the thread referred above) - and I believed that this is the one which helps me extract executed PC values, until you told me in your previous email that this is _not_ the case, and they are just the disassembled and not the executed PC trace! Can you please let me know if you were referring to the same thread or a different one?
Thanks,
-Shashi.
Quoted 41 lines · andrzej zaborowski
Quoted 10 lines · Shashidhar Mysore
Thanks for the reply, Andrzej!
Some clarifications below ...
Quoted 5 lines · andrzej zaborowski
Quoted 5 lines
************************************************
/* convert one instruction.s->is_jmpis set if the translation must
be stopped. Return the next pc value */
statictarget_ulongdisas_insn(DisasContext *s,target_ulong
pc_start)Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
{ int b, prefixes, aflag, dflag; int shift, ot; int modrm, reg, rm, mod, reg_addr, op, opreg, offset_addr, val; target_ulong next_eip, tval; int rex_w, rex_r; s->pc = pc_start; // This s->pc is what I am using to extractall
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
executed PC values
This
s->pcdoesn't correspond to executed PC values, qemu is atranslator.
Quoted 2 lines
Can you tell me what
s->pcis, in this context? Is the the start PC of aIt is the PC of the disassembled instruction (hence
disasm_insn).Quoted 1 line
basic block that is about to be executed? Is there any way in which I
could
Quoted 1 line
extract the trace of executed PCs in QEMU?
Yes, there was a thread about this about two months ago.
Regards