From: "Atif Hashmi" <atifhashmi@gmail.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Re: Detecting an assembly instruction in QEMU
Date: Tue, 17 Apr 2007 15:33:36 -0500 [thread overview]
Message-ID: <d5f3bd2b0704171333n5db6d79fj295e508722ac3574@mail.gmail.com> (raw)
In-Reply-To: <83a4d4ca0704170249l83c5d7bqe0b0f8cc8b5a4a58@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3272 bytes --]
HI Eduardo,
Thanks for you reply. I have update target-i386/translate.c as follows
if(modrm==0xC0)
{
stored_eip = pc_start - s->cs_base;
gen_op_movl_AL_AL();
}
else if(modrm==0xDB)
{
gen_op_movl_BL_BL(stored_eip);
gen_eob(s);
}
target-i386/op.c contains the following.
void OPPROTO op_movl_AL_AL()
{
helper_StartTransaction();
}
void OPPROTO op_movl_BL_BL()
{
if(helper_CommitTransaction())
{
EIP = PARAM1;
}
}
and helper.c looks like
void helper_StartTransaction()
{
printf("StartTransaction Called\n");
}
unsigned char helper_CommitTransaction()
{
static int i=0;
printf("CommitTransaction Called\n");
return 1;
}
Essentially, if we have a program like
int main()
{
__asm_volatile("mov %al %al"); //is detected in translation.c and
helper_StartTransaction is called
printf("middle");
__asm_volatile("mov %bl %bl"); //is detected in translation.c and
helper_CommitTransaction is called
}
We should continuously print "middle" on the QEMU screen while
"StartTransaction Called" and "End Transaction Called" for infinite amount
of time.
But I get the following behaviour.
On QEMU screen, "middle" is printed once, and I get the following on the
xterm
StartTransaction Called
CommitTransaction Called
StartTransaction Called
After that I get the QEMU prompt back and the program finishes. I still have
not been able to figure it out why after calling helper_StartTransaction()
for the seconds time the program does not continue? Is their anything else
that we have not considered.
I will really appreciate your help.
Regards,
Atif
On 4/17/07, Eduardo Felipe <edusaper@gmail.com> wrote:
>
> Hi
>
> 2007/4/17, Atif Hashmi <atifhashmi@gmail.com>:
> >
> >
> > But this prints "Transaction restart" once and then the program
> > finishes. This means that commit transaction is not called the second time.
> > Could you please tell me what am I doing wrong?
>
>
> Helper functions are outside the translated opcode stream and are invoked
> by call/ret:
>
> .------.
> | |
> | ---+--> helper_StartTransaction()
> | <--+-------------------/
> | |
> | |
> | ---+--> helper_CommitTransaction()
> | <--+-------------------/
> | |
> '------'
>
> When you longjmp from helper_CommitTransaction to helper_StartTransaction
> it's probable that you return back to the point where
> helper_CommitTransaction should have returned to, as it is the last address
> stored in the stack.
>
> Anyway, guest code between the start and the end of the transaction should
> not be rerun without updating guest machine state (eip, flags, etc.).
>
> You should better forget about using setjmp/longjmp. Maybe something like
> this could do the trick:
>
> when translating mov %al,%al:
> {
> ...
> ...
> store the address (eip) of mov %al,%al instruction somewhere
> gen_op_start_transaction();
> }
>
> when translating mov %bl, %bl:
> {
> ...
> ...
> gen_op_commit_transaction(stored_eip);
> gen_eob(s); // Stop translation to force guest state updating
> }
>
> op_commit_transaction should look like:
> {
> if ( helper_CommitTransaction() ) // helper should return !=0 on error
> EIP = PARAM1;
> }
>
> Regards,
> Eduardo
>
[-- Attachment #2: Type: text/html, Size: 6099 bytes --]
next prev parent reply other threads:[~2007-04-17 20:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-04 4:57 [Qemu-devel] Detecting an assembly instruction in QEMU Atif Hashmi
2007-04-05 17:37 ` [Qemu-devel] " Atif Hashmi
2007-04-06 12:15 ` Eduardo Felipe
2007-04-07 21:06 ` Atif Hashmi
2007-04-08 14:13 ` Eduardo Felipe
2007-04-08 21:38 ` Atif Hashmi
2007-04-08 22:14 ` Eduardo Felipe
2007-04-17 0:17 ` Atif Hashmi
2007-04-17 0:22 ` Atif Hashmi
2007-04-17 9:49 ` Eduardo Felipe
2007-04-17 20:33 ` Atif Hashmi [this message]
2007-04-22 13:09 ` Eduardo Felipe
2007-04-24 7:30 ` Atif Hashmi
2007-04-24 9:34 ` Eduardo Felipe
2007-04-25 16:21 ` Atif Hashmi
2007-04-25 16:50 ` Atif Hashmi
2007-04-26 14:03 ` Eduardo Felipe
2007-04-26 21:26 ` Atif Hashmi
2007-04-27 10:16 ` Eduardo Felipe
2007-05-01 20:28 ` Atif Hashmi
2007-04-11 16:05 ` Thiemo Seufer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d5f3bd2b0704171333n5db6d79fj295e508722ac3574@mail.gmail.com \
--to=atifhashmi@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).