From mboxrd@z Thu Jan 1 00:00:00 1970 From: yandong han Subject: how to set VM into debug mode ? what are xmx_entry_helper for? Date: Fri, 10 May 2013 14:09:39 +0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0950841993664541641==" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel List-Id: xen-devel@lists.xenproject.org --===============0950841993664541641== Content-Type: multipart/alternative; boundary=20cf301ee80b276b1004dc570355 --20cf301ee80b276b1004dc570355 Content-Type: text/plain; charset=ISO-8859-1 hi,all I have three problems,anyone can solve them or one of them or give me some clue? thank you (1) first, I want to know what job xmx_entry_helper does? (2) second , whether every VMENTRY will call xmx_entry_helper ?if not, which function will VMENTRY call everytime? (3)my target is setting VM into debug mode by set Trag_flag, the code below called vmx_properly_set_trap_flag, and I add it at the end of vmx_vmexit_handler(). but it does not work. inline void vmx_properly_set_trap_flag(struct vcpu *v) 1301 { 1302 /* we are currently stepping, so we need to set the trap flag 1303 * on the next instruction 1304 */ 1305 unsigned long int_state = __vmread(GUEST_INTERRUPTIBILITY_INFO); 1306 unsigned long activity_state = __vmread(GUEST_ACTIVITY_STATE); 1307 1308 unsigned long intercepts = __vmread(EXCEPTION_BITMAP); 1309 unsigned long mask = (1UL << TRAP_debug ); 1310 1311 unsigned long flags = __vmread(GUEST_RFLAGS); 1312 unsigned long flags_mask = (X86_EFLAGS_TF); 1313 1314 /* make sure the exception bitmap says to vmexit on 1315 * debug exceptions 1316 */ 1317 intercepts |= mask; 1318 __vmwrite(EXCEPTION_BITMAP, intercepts); 1319 1320 /* Default to setting trap flag to on */ 1321 flags |= flags_mask; 1322 1323 if((activity_state == 1)) 1324 { 1325 1326 /* this means we're in HLT mode. Disabling is OK since 1327 ** we will get an NMI to get out of HLT. 1328 ** The NMI will cause a VMExit which will reset TF 1329 ** execution 1330 **/ 1331 printk("Turning off SS due to HLT\n"); 1332 //flags &= ~(flags_mask); 1333 } 1334 1335 if((int_state & 3) ) 1336 { 1337 int_state &= ~(3); 1338 printk("init_state is 3\n"); 1339 //__vmwrite(GUEST_INTERRUPTIBILITY_INFO, int_state); 1340 } 1342 /* setting TF due to stepping enabled;*/ 1343 __vmwrite(GUEST_RFLAGS, flags); 1344 1345 } thank you , hope for your help -- ---------------------------------------------------------- regards, yandong --20cf301ee80b276b1004dc570355 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

hi,all
I have th= ree problems,anyone can solve them or one of them or give me some clue? tha= nk you

(1) =A0first, I want to know what job= =A0xmx_entry_helper =A0 does?
(2) second , whether every VMENTRY will call xmx_entry_helper = =A0 ?if not, which function =A0will VMENTRY call =A0everytime?
(3)my target is setting VM into debug mode =A0by set Trag_flag, =A0the = code below =A0called vmx_properly_set_trap_flag,=A0
and I add it at the end of vmx_vmexit_handler(). but it does not= work.



=




=A0inline void vmx_properly_set_trap_flag(struct = vcpu *v)
1301 {
1302 =A0 =A0 /* we are currently steppi= ng, so we need to set the trap flag
1303 =A0 =A0 * on the next in= struction
1304 =A0 =A0 */
1305 =A0 =A0 unsigned long int_state =3D __v= mread(GUEST_INTERRUPTIBILITY_INFO);
1306 =A0 =A0 unsigned long ac= tivity_state =3D __vmread(GUEST_ACTIVITY_STATE);
1307
1= 308 =A0 =A0 unsigned long intercepts =3D __vmread(EXCEPTION_BITMAP);
1309 =A0 =A0 unsigned long mask =3D (1UL << TRAP_debug );
<= div>1310
1311 =A0 =A0 unsigned long flags =3D __vmread(GUEST_RFLA= GS);
1312 =A0 =A0 unsigned long flags_mask =3D (X86_EFLAGS_TF);
1313
1314 =A0 =A0 /* make sure the exception bitmap says to vmexit on
=
1315 =A0 =A0 =A0* debug exceptions
1316 =A0 =A0 =A0*/
<= div>1317 =A0 =A0 intercepts |=3D mask;
1318 =A0 =A0 __vmwrite(EXC= EPTION_BITMAP, intercepts);
1319
1320 =A0 =A0 /* Default to setting trap flag to on */
1321 =A0 =A0 flags |=3D flags_mask;
1322
1323 = =A0 =A0 if((activity_state =3D=3D 1))
1324 =A0 =A0 {
13= 25
1326 =A0 =A0 =A0 =A0 /* this means we're in HLT mode. Disa= bling is OK since
1327 =A0 =A0 =A0 =A0 ** we will get an NMI to get out of HLT.
1328 =A0 =A0 =A0 =A0 ** The NMI will cause a VMExit which will reset TF
1329 =A0 =A0 =A0 =A0 ** execution
1330 =A0 =A0 =A0 =A0 *= */
1331 =A0 =A0 =A0 =A0 printk("Turning off SS due to HLT\n&= quot;);
1332 =A0 =A0 =A0 =A0 //flags &=3D ~(flags_mask);
1333 = =A0 =A0 }
1334
1335 =A0 =A0 if((int_state & 3) )
1336 =A0 =A0 {
1337 =A0 =A0 =A0 =A0 int_state &=3D ~(= 3);
1338 =A0 =A0 =A0 =A0 printk("init_state is 3\n");
1339 =A0 =A0 =A0 =A0 //__vmwrite(GUEST_INTERRUPTIBILITY_INFO, int_stat= e);
1340 =A0 =A0 }
1342 =A0 =A0 /* setting TF due = to stepping enabled;*/
1343 =A0 =A0 __vmwrite(GUEST_RFLAGS, flags= );
1344
1345 }



thank you , hope for your help=A0
--
-----------------------------------------------= -----------
regards,
yandong

--20cf301ee80b276b1004dc570355-- --===============0950841993664541641== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============0950841993664541641==--