From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HdkOW-0000Kq-DD for qemu-devel@nongnu.org; Tue, 17 Apr 2007 05:54:40 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HdkOT-0000KN-Pb for qemu-devel@nongnu.org; Tue, 17 Apr 2007 05:54:39 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HdkOT-0000KK-K6 for qemu-devel@nongnu.org; Tue, 17 Apr 2007 05:54:37 -0400 Received: from wr-out-0506.google.com ([64.233.184.234]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HdkJk-0001CU-Uj for qemu-devel@nongnu.org; Tue, 17 Apr 2007 05:49:45 -0400 Received: by wr-out-0506.google.com with SMTP id i20so3044345wra for ; Tue, 17 Apr 2007 02:49:42 -0700 (PDT) Message-ID: <83a4d4ca0704170249l83c5d7bqe0b0f8cc8b5a4a58@mail.gmail.com> Date: Tue, 17 Apr 2007 11:49:41 +0200 From: "Eduardo Felipe" Subject: Re: [Qemu-devel] Re: Detecting an assembly instruction in QEMU In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_68502_8401762.1176803381519" References: <83a4d4ca0704060515l172d6f9ep59b6467c6e49f250@mail.gmail.com> <83a4d4ca0704080713t596e4d83lbd1c495d92eda581@mail.gmail.com> <83a4d4ca0704081514v584660e4h8a36e5d1aee16d82@mail.gmail.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org ------=_Part_68502_8401762.1176803381519 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi 2007/4/17, Atif Hashmi : > > > 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 ------=_Part_68502_8401762.1176803381519 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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
------=_Part_68502_8401762.1176803381519--