From: Abhinav Srivastava Subject: Query regarding x86_emulate_memop() function Date: Fri, 6 Jun 2008 22:38:22 +0530 (IST) Message-ID: <183091.80963.qm@web7909.mail.in.yahoo.com> 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@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Hi there, I have a question regarding the functionality of x86_emulate_memop (Xen 3.1= ) or x86_emulate (Xen 3.2) function. This function gets called from sh_page= _fault() function which is invoked when Xen receives a page fault. Since I am not clear completely about the emulation operation performed by = Xen, I have following questions with a below mentioned scenario? 1) Suppose I have a memory location that I need to protect it from being wr= itten by a guest OS. Since a page table protection works at a page level, w= e have to mark that complete page read-only inside the shadow page table. S= o, whenever a guest tries to write on that page, writes are propagated to s= hadow page table. Due to read only page this would create a page-fault and = sh_page_fault code would be invoked. In the sh_page_fault code, we can chec= k whether on this page the memory location which is being written (using CR= 2 register) is protected or not. If not, my goal is to let this operation g= o through. And, I heard here this emulation thing comes into the picture. After checking and deciding this operation should go through, i call "goto = emulate" from sh_page_fault code assuming it would emulate that operation a= nd update the eip to the next instruction. Question: Is this understanding correct? The reason why I am asking is that= since page is write-protected, it means while emulating it should again fa= ult. Then, how does this emulation work? And, what is the use of this funct= ion? In what context it should be used and in what context it is invoked fr= om sh_page_fault(). And, if I have to achieve above-mentioned (scenario) functionality which pa= rt of the code I should lookinto/change to achieve that. I would really appreciate if some could explain me this. Thanks, Abhinav =0A=0A=0A Bring your gang together. Do your thing. Find your favourite= Yahoo! group at http://in.promos.yahoo.com/groups/