Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MNgMr-00034t-9y for qemu-devel@nongnu.org; Mon, 06 Jul 2009 01:03:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MNgMm-00034h-Kr for qemu-devel@nongnu.org; Mon, 06 Jul 2009 01:03:52 -0400 Received: from [199.232.76.173] (port=39240 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MNgMm-00034e-G5 for qemu-devel@nongnu.org; Mon, 06 Jul 2009 01:03:48 -0400 Received: from bay0-omc3-s31.bay0.hotmail.com ([65.54.246.231]:12309) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MNgMl-0007og-U5 for qemu-devel@nongnu.org; Mon, 06 Jul 2009 01:03:48 -0400 Message-ID: Content-Type: multipart/alternative; boundary="_61f5065d-a4c7-444f-bbe4-273afb782459_" From: Tommy Huang Date: Sun, 5 Jul 2009 22:03:46 -0700 MIME-Version: 1.0 Subject: [Qemu-devel] Modify TLB entry List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --_61f5065d-a4c7-444f-bbe4-273afb782459_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Hi All=2C I was trying to redirect the instruction fetch from a different page.=20 The way I used is to modify the TLB entry. The following is the code I extr= act from SecureQEMU project. The code is inside a function which is called by "gen_intermediate_code". if(pte1 =3D cte[env->eip >> TARGET_PAGE_BITS]) { =20 cpu_x86_handle_mmu_fault(env=2C env->eip=2C 0=2C 1=2C 1)=3B cpu_x86_handle_mmu_fault(env=2C env->eip + TARGET_PAGE_SIZE=2C 0= =2C 1=2C 1)=3B //Poison TLB Cache (Current Page + next page if needed) index1 =3D (env->eip >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1)=3B temp_addend1 =3D env->tlb_table[1][index1].addend=3B env->tlb_table[1][index1].addend =3D (pte1 - (env->eip & TARGET_PA= GE_MASK))=3B=20 ret =3D gen_intermediate_code_internal(env=2C tb=2C search_pc)=3B //Unpoison the TLB env->tlb_table[1][index1].addend =3D temp_addend1=3B if(pte2)=20 env->tlb_table[1][index2].addend =3D temp_addend2=3B =20 ... } In my case=2C it still fetches codes from original page instead of pte1. I = am sure control flow really entered this if block. Poisoning TLB seems not working to me. What is wrong here? I was wondering = if soft MMU is not turned on here so it never uses the tlb_table. btw=2C I use qemu 0.9.0=2C a pretty old version for compatibility. Any hint or suggestion is appreciated. Thanks in advance. Regards=2C Tommy _________________________________________________________________ Windows Live=99 SkyDrive=99: Get 25 GB of free online storage. http://windowslive.com/online/skydrive?ocid=3DTXT_TAGLM_WL_SD_25GB_062009= --_61f5065d-a4c7-444f-bbe4-273afb782459_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Hi All=2C

I was trying to redirect the instruction fetch from a diff= erent page.
The way I used is to modify the TLB entry. The following is= the code I extract from SecureQEMU project.
The code is inside a functi= on which is called by "gen_intermediate_code".

if(pte1 =3D cte[env-&= gt=3Beip >=3B>=3B TARGET_PAGE_BITS]) {
 =3B
 =3B =3B&= nbsp=3B =3B =3B =3B =3B =3B cpu_x86_handle_mmu_fault(en= v=2C env->=3Beip=2C 0=2C 1=2C 1)=3B
 =3B =3B =3B =3B&n= bsp=3B =3B =3B =3B cpu_x86_handle_mmu_fault(env=2C env->=3Bei= p + TARGET_PAGE_SIZE=2C 0=2C 1=2C 1)=3B

 =3B =3B =3B&nbs= p=3B =3B =3B =3B =3B //Poison TLB Cache (Current Page + nex= t page if needed)
 =3B =3B =3B =3B =3B =3B = =3B =3B index1 =3D (env->=3Beip >=3B>=3B TARGET_PAGE_BITS) &= =3B (CPU_TLB_SIZE - 1)=3B
 =3B =3B =3B =3B =3B = =3B =3B =3B temp_addend1 =3D env->=3Btlb_table[1][index1].addend= =3B
 =3B =3B =3B =3B =3B =3B =3B =3B env= ->=3Btlb_table[1][index1].addend =3D (pte1 - (env->=3Beip &=3B TARGE= T_PAGE_MASK))=3B

 =3B =3B =3B =3B =3B =3B&n= bsp=3B =3B ret =3D gen_intermediate_code_internal(env=2C tb=2C search_p= c)=3B

 =3B =3B =3B =3B =3B =3B =3B = =3B //Unpoison the TLB
 =3B =3B =3B =3B =3B =3B&= nbsp=3B =3B env->=3Btlb_table[1][index1].addend =3D temp_addend1=3B =3B =3B =3B =3B =3B =3B =3B =3B if(pte2)=
 =3B =3B =3B =3B =3B =3B =3B =3B = =3B =3B =3B env->=3Btlb_table[1][index2].addend =3D temp_addend2= =3B
 =3B =3B =3B =3B =3B =3B =3B =3B  =3B =3B =3B =3B =3B =3B =3B =3B ...
}<= br>
In my case=2C it still fetches codes from original page instead of p= te1. I am sure control flow really entered this if block.
Poisoning TLB = seems not working to me. What is wrong here? I was wondering if soft MMU is= not turned on here so it never uses the tlb_table.
btw=2C I use qemu 0.= 9.0=2C a pretty old version for compatibility.
Any hint or suggestion is= appreciated. Thanks in advance.

Regards=2C
Tommy


= Windows Live=99 SkyDrive=99: Get 25 GB of free online storage. Get it on your BlackBerry or iPhone. = --_61f5065d-a4c7-444f-bbe4-273afb782459_--