From: Abhinav Srivastava Subject: Question related to Single-step execution and Emulation Date: Tue, 24 Jun 2008 08:44:04 +0530 (IST) Message-ID: <959752.87355.qm@web7902.mail.in.yahoo.com> Reply-To: abhinavs_iitkgp@yahoo.co.in Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel List-Id: xen-devel@lists.xenproject.org Hi all, I am trying to perform single-stepping and instruction emulation both in Xe= n-3.2.1. I am using the following approach: First, I mark a guest page "not present" inside the shadow page table so th= at I could intercept any operation that involves this page. When the guest = tries to access that page, it faults and control goes to Xen (sh_page_fault= function). There, I emulate that operation and return the control to guest= to execute next instruction. I could get my first part working. In the second part after emulating the instruction inside Xen, I want to pe= rform single-step execution from next instruction onwards so that I could m= onitor further execution of guest from that point. To achieve that I did following: After emulating an instruction inside Xen = and before sending the control back to guest OS, I set the EFLAGS's trap bi= t set by doing following operation: regs->eflag |=3D X86_EFLAGS_TF And return the control from sh_page_fault function by saying "return EFAULT= _FIXED". My understanding is that with this flag set when guest completes the execut= ion of the next instruction, it traps to Xen with exit reason TRAP_debug an= d do_debug handler should be invoked inside x86/traps.c. From there, again = I set X86_EFLAGS_TF flag to get guest trapped for next instruction and so o= n. When i want it to be end I will set X86_EFLAGS_RF flag. However, when I perform above-mentioned procedure I get to see a message "T= race/breakpoint trap" in my guest OS only once and my do_debug or (debugger= _trap_entry method with vector =3D Trap_debug) does not get invoked at all = inside Xen. Since trap is not coming into Xen, I am not able to get the con= trol after execution of instructions. It seems like with my above-described method, I am injecting TRAP_debug exc= eption for the instruction that I emulate inside the Xen. And, eflag is not= set in the context of next instruction that will be executed inside the gu= est, which should trap with debug exception. It would be great if someone could explain me what i am doing wrong here an= d if yes what would be the right approach to perform single-step execution = in Xen. Thanks in advance. Regards, Abhinav =0A=0A=0A Explore your hobbies and interests. Go to http://in.promos.y= ahoo.com/groups/