Skip to contentSkip to conversation

how to get registers value in event of systemcall

Qemu-devel Antonio Ricci 4 participants 10 messages May 26, 2008 – Jun 3, 2008

lore
Share & tools
lore
#0 lore raw

Hi all,
i'd want to understand how to get registers value (eax, ebx, etc.) in the guest operating system at the moment of a system call. In my opinion i've to work on file target-i386/translate.c in the case of 0x80 in the function disas_insn(DisasContext *s, target_ulong pc_start). I can't understand how to get registers value. I've just read documentation about translation but I'm not able to get these informations.

Can you help me?

Thanks in advance

Signature · 13 lines
Antonio
My Mobile Phone: +393286739562
My Public Key: http://tonyr.altervista.org/chiave_pubblica
MSN: [email protected]
Skype: tonyr81fg
Linux Member #374272
*********************************************************************
What is the difference between Jurassic Park and Microsoft?
One is an over-rated high tech theme park based on prehistoric information and populated mostly by dinosaurs, the other is a Steven Spielberg movie.
*********************************************************************
There are only 10 types of people in this world:
those who understand binary, and those who don't.
*********************************************************************
#1 lore raw

Answering simply from my simple understanding of qemu...

Quoted 7 lines · Antonio Ricci

Hi all,
i'd want to understand how to get registers value (eax, ebx, etc.) in the guest operating system at the moment of a system call. In my opinion i've to work on file target-i386/translate.c in the case of 0x80 in the function
disas_insn(DisasContext *s, target_ulong pc_start). I can't understand how
to get registers value. I've just read documentation about translation but I'm not able to get these informations.

I think you should go to target-i386/translate.c:
gen_intermediate_code_internal(CPUState *env,
TranslationBlock *tb, int search_pc)

specifically, in "env" there is "regs" which hold the CPU registers.

target-i386/cpu.h contains the constants that show you the array structure of that "regs".

Good luck..

regards,

Mulyadi.

#2 lore raw
Quoted 6 lines
Quoted 5 lines

guest operating system at the moment of a system call. In my opinion i've to work on file target-i386/translate.c in the case of 0x80 in the function disas_insn(DisasContext *s, target_ulong pc_start). I can't understand how to get registers value. I've just read documentation about translation but I'm not able to get these informations.

Quoted 6 lines

I think you should go to target-i386/translate.c:
gen_intermediate_code_internal(CPUState *env,
TranslationBlock *tb, int search_pc)

specifically, in "env" there is "regs" which hold the CPU registers.

No, that won't work. Only a very limited subset of the CPU state is valid during translation. The same block may be executed many times with different inputs. If you want register values you have to do it at execution time, e.g. in do_interrupt.

Paul

#3 lore raw

Hi Paul,
thanks for your answer.
I've tried to have registers value from do interrupt and it seems to work. I've some questions for you:
1) Where these values are initialized? I can't find it.
2) Have I to work on each type of do_interrupt (that is do_interrupt, do_interrupt_user, etc.) to get register's value in all kind of syscalls?
3) If i want to avoid the execution of some type of syscall based on parameters is it possible in this way?

Thanks for your help

--
Antonio
My Mobile Phone: +393286739562
My Public Key: http://tonyr.altervista.org/chiave_pubblica
MSN: [email protected]
Skype: tonyr81fg
Linux Member #374272
*********************************************************************
What is the difference between Jurassic Park and Microsoft?
One is an over-rated high tech theme park based on prehistoric information and populated mostly by dinosaurs, the other is a Steven Spielberg movie.
*********************************************************************
There are only 10 types of people in this world:
those who understand binary, and those who don't.
*********************************************************************

Quoted 19 lines · Paul Brook
Quoted 11 lines
Quoted 5 lines

guest operating system at the moment of a system call. In my opinion i've to work on file target-i386/translate.c in the case of 0x80 in the function disas_insn(DisasContext *s, target_ulong pc_start). I can't understand how to get registers value. I've just read documentation about translation but I'm not able to get these informations.

I think you should go to target-i386/translate.c:
gen_intermediate_code_internal(CPUState *env,
TranslationBlock *tb, int search_pc)

specifically, in "env" there is "regs" which hold the CPU registers.

No, that won't work. Only a very limited subset of the CPU state is valid during translation. The same block may be executed many times with different inputs. If you want register values you have to do it at execution time, e.g. in do_interrupt.

Paul

#4 lore raw
In reply to Paul Brook
Quoted 2 lines · Paul Brook

No, that won't work. Only a very limited subset of the CPU state is valid during translation.

Paul,
I don't understand what you mean. Why can't I get registers value at translation time?

Quoted 3 lines

The same block may be executed many times with different inputs. If you want register values you have to do it at execution time, e.g. in do_interrupt.

Do you mean that If the same block is executed many times with different inputs it is translated just once?

Thanks for help
--
Antonio
My Mobile Phone: +393286739562
My Public Key: http://tonyr.altervista.org/chiave_pubblica
MSN: [email protected]
Skype: tonyr81fg
Linux Member #374272
*********************************************************************
What is the difference between Jurassic Park and Microsoft?
One is an over-rated high tech theme park based on prehistoric information and populated mostly by dinosaurs, the other is a Steven Spielberg movie.
*********************************************************************
There are only 10 types of people in this world:
those who understand binary, and those who don't.
*********************************************************************

#5 lore raw
In reply to Paul Brook
Quoted 1 line · Paul Brook

No, that won't work. Only a very limited subset of the CPU state is

valid

Quoted 1 line

during translation.

Paul,
I don't understand what you mean. Why can't I get registers value at translation time?

Quoted 2 lines

The same block may be executed many times with different inputs. If you want register values you have to do it at execution

time,

Quoted 1 line

e.g. in do_interrupt.

Do you mean that If the same block is executed many times with different inputs it is translated just once?

Thanks for help
--
Antonio
My Mobile Phone: +393286739562
My Public Key: http://tonyr.altervista.org/chiave_pubblica
MSN: [email protected]
Skype: tonyr81fg
Linux Member #374272
*********************************************************************
What is the difference between Jurassic Park and Microsoft? One is an over-rated high tech theme park based on prehistoric information and populated mostly by dinosaurs, the other is a Steven Spielberg movie.
*********************************************************************
There are only 10 types of people in this world:
those who understand binary, and those who don't.
*********************************************************************

#6 lore raw
Quoted 6 lines · Antonio Ricci
Quoted 2 lines · Paul Brook

No, that won't work. Only a very limited subset of the CPU state is valid during translation.

I don't understand what you mean. Why can't I get registers value at translation time?

For the reason below.

Quoted 6 lines
Quoted 3 lines

The same block may be executed many times with different inputs. If you want register values you have to do it at execution time, e.g. in do_interrupt.

Do you mean that If the same block is executed many times with different inputs it is translated just once?

Yes.

Paul

#7 lore raw
In reply to Paul Brook

Hi Paul,
thanks for your answer.
I've tried to have registers value from do interrupt and it seems to work. I've some questions for you:
1) Where these values are initialized? I can't find it.
2) Have I to work on each type of do_interrupt (that is do_interrupt, do_interrupt_user, etc.) to get register's value in all kind of syscalls?
3) If i want to avoid the execution of some type of syscall based on parameters is it possible in this way?

Thanks for your help

--
Antonio
My Mobile Phone: +393286739562
My Public Key: http://tonyr.altervista.org/chiave_pubblica
MSN: [email protected]
Skype: tonyr81fg
Linux Member #374272
*********************************************************************
What is the difference between Jurassic Park and Microsoft? One is an over-rated high tech theme park based on prehistoric information and populated mostly by dinosaurs, the other is a Steven Spielberg movie.
*********************************************************************
There are only 10 types of people in this world:
those who understand binary, and those who don't.
*********************************************************************

Quoted 19 lines · Paul Brook
Quoted 11 lines
Quoted 5 lines

guest operating system at the moment of a system call. In my opinion i've to work on file target-i386/translate.c in the case of 0x80 in the function disas_insn(DisasContext *s, target_ulong pc_start). I can't understand how to get registers value. I've just read documentation about translation but I'm not able to get these informations.

I think you should go to target-i386/translate.c:
gen_intermediate_code_internal(CPUState *env,
TranslationBlock *tb, int search_pc)

specifically, in "env" there is "regs" which hold the CPU registers.

No, that won't work. Only a very limited subset of the CPU state is valid during translation. The same block may be executed many times with different inputs. If you want register values you have to do it at execution time, e.g. in do_interrupt.

Paul

#8 lore raw
Quoted 5 lines · Antonio Ricci

Hi Paul,
thanks for your answer.
I've tried to have registers value from do interrupt and it seems to work. I've some questions for you:
1) Where these values are initialized? I can't find it.

If you look in cpu_exec.c/cpu_exec() you will see a call to env_to_regs before the loop that contains the do_interrupt call. Does that answer your question?

Laurent

#9 lore raw

Thanks Laurent, it is the answer I need.

Regards

--
Antonio
My Mobile Phone: +393286739562
My Public Key: http://tonyr.altervista.org/chiave_pubblica
MSN: [email protected]
Skype: tonyr81fg
Linux Member #374272
*********************************************************************
What is the difference between Jurassic Park and Microsoft?
One is an over-rated high tech theme park based on prehistoric information and populated mostly by dinosaurs, the other is a Steven Spielberg movie.
*********************************************************************
There are only 10 types of people in this world:
those who understand binary, and those who don't.
*********************************************************************

Quoted 17 lines · Laurent Desnogues
Quoted 5 lines · Antonio Ricci

Hi Paul,
thanks for your answer.
I've tried to have registers value from do interrupt and it seems to work. I've some questions for you:
1) Where these values are initialized? I can't find it.

If you look in cpu_exec.c/cpu_exec() you will see a call to env_to_regs before the loop that contains the do_interrupt call. Does that answer your question?

Laurent