[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] tools/tests: Add EIP check to test_x86_emulator.c


  • To: xen-devel@xxxxxxxxxxxxx
  • From: Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx>
  • Date: Thu, 7 Aug 2014 11:16:02 +0300
  • Cc: ian.campbell@xxxxxxxxxx, Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx>, stefano.stabellini@xxxxxxxxxxxxx, andrew.cooper3@xxxxxxxxxx, ian.jackson@xxxxxxxxxxxxx, JBeulich@xxxxxxxx
  • Comment: DomainKeys? See http://domainkeys.sourceforge.net/
  • Delivery-date: Thu, 07 Aug 2014 08:16:35 +0000
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=bitdefender.com; b=1BrOlA9MEmdV6/TqPHv+MAgO1fZyzG5mvLGdF9zf9bEa/BXWuZdAvnl6TukjWJ4cyNfltB21YBvzUot6wr2Ktem9eK91u3dGwLhJ4Q2OC3qzjOwIOPctuIPsKb12b7cndQzj84xztK9BnDYECd0M20f+SRcx4W9MinXs08vmJGUgtmWkt8CTvVigKr/mFeIUwbAZHTsO/ESRP+reoNjqrxm0+zmxXqOT6OxSqLTN/0Jaw1pK8GteE6VK/9qyjfA8qgc2PScla8r6cN+sspzaMwL5wRWx+QRhjoIchBLW0x5T/eeZrhE+evKHf607somNxJtaq66gJpruFAMHoYKcow==; h=Received:Received:Received:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:X-BitDefender-Scanner:X-BitDefender-Spam:X-BitDefender-SpamStamp:X-BitDefender-CF-Stamp;
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>

The test now also checks that EIP was modified after emulating
instructions after (and including) the "movq %mm3,(%ecx)..."
code block.

Signed-off-by: Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx>
---
 tools/tests/x86_emulator/test_x86_emulator.c |   30 +++++++++++++++++---------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/tools/tests/x86_emulator/test_x86_emulator.c 
b/tools/tests/x86_emulator/test_x86_emulator.c
index 0a00d5a..dd4e986 100644
--- a/tools/tests/x86_emulator/test_x86_emulator.c
+++ b/tools/tests/x86_emulator/test_x86_emulator.c
@@ -615,7 +615,8 @@ int main(int argc, char **argv)
         regs.eip    = (unsigned long)&instr[0];
         regs.ecx    = (unsigned long)res;
         rc = x86_emulate(&ctxt, &emulops);
-        if ( (rc != X86EMUL_OKAY) || memcmp(res, res + 8, 32) )
+        if ( (rc != X86EMUL_OKAY) || memcmp(res, res + 8, 32) ||
+             (regs.eip == (unsigned long)&instr[0]) )
             goto fail;
         printf("okay\n");
     }
@@ -637,7 +638,8 @@ int main(int argc, char **argv)
         regs.ecx    = 0;
         regs.edx    = (unsigned long)res;
         rc = x86_emulate(&ctxt, &emulops);
-        if ( rc != X86EMUL_OKAY )
+        if ( rc != X86EMUL_OKAY ||
+             (regs.eip == (unsigned long)&instr[0]) )
             goto fail;
         asm ( "pcmpeqb %%mm3, %%mm3\n\t"
               "pcmpeqb %%mm5, %%mm3\n\t"
@@ -665,7 +667,8 @@ int main(int argc, char **argv)
         regs.eip    = (unsigned long)&instr[0];
         regs.ecx    = (unsigned long)res;
         rc = x86_emulate(&ctxt, &emulops);
-        if ( (rc != X86EMUL_OKAY) || memcmp(res, res + 8, 32) )
+        if ( (rc != X86EMUL_OKAY) || memcmp(res, res + 8, 32) ||
+             (regs.eip == (unsigned long)&instr[0]) )
             goto fail;
         printf("okay\n");
     }
@@ -687,7 +690,8 @@ int main(int argc, char **argv)
         regs.ecx    = 0;
         regs.edx    = (unsigned long)res;
         rc = x86_emulate(&ctxt, &emulops);
-        if ( rc != X86EMUL_OKAY )
+        if ( rc != X86EMUL_OKAY ||
+             (regs.eip == (unsigned long)&instr[0]) )
             goto fail;
         asm ( "pcmpeqb %%xmm2, %%xmm2\n\t"
               "pcmpeqb %%xmm4, %%xmm2\n\t"
@@ -716,7 +720,8 @@ int main(int argc, char **argv)
         regs.eip    = (unsigned long)&instr[0];
         regs.ecx    = (unsigned long)res;
         rc = x86_emulate(&ctxt, &emulops);
-        if ( (rc != X86EMUL_OKAY) || memcmp(res, res + 16, 64) )
+        if ( (rc != X86EMUL_OKAY) || memcmp(res, res + 16, 64) ||
+             (regs.eip == (unsigned long)&instr[0]) )
             goto fail;
         printf("okay\n");
     }
@@ -744,7 +749,8 @@ int main(int argc, char **argv)
         regs.ecx    = 0;
         regs.edx    = (unsigned long)res;
         rc = x86_emulate(&ctxt, &emulops);
-        if ( rc != X86EMUL_OKAY )
+        if ( rc != X86EMUL_OKAY ||
+             (regs.eip == (unsigned long)&instr[0]) )
             goto fail;
 #if 0 /* Don't use AVX2 instructions for now */
         asm ( "vpcmpeqb %%ymm2, %%ymm2, %%ymm2\n\t"
@@ -784,7 +790,8 @@ int main(int argc, char **argv)
         regs.ecx    = (unsigned long)(res + 2);
         regs.edx    = 0;
         rc = x86_emulate(&ctxt, &emulops);
-        if ( (rc != X86EMUL_OKAY) || memcmp(res, res + 8, 32) )
+        if ( (rc != X86EMUL_OKAY) || memcmp(res, res + 8, 32) ||
+             (regs.eip == (unsigned long)&instr[0]) )
             goto fail;
         printf("okay\n");
     }
@@ -809,7 +816,8 @@ int main(int argc, char **argv)
         regs.ecx    = 0;
         regs.edx    = (unsigned long)res;
         rc = x86_emulate(&ctxt, &emulops);
-        if ( rc != X86EMUL_OKAY )
+        if ( rc != X86EMUL_OKAY ||
+             (regs.eip == (unsigned long)&instr[0]) )
             goto fail;
         asm ( "cmpeqps %1, %%xmm7\n\t"
               "movmskps %%xmm7, %0" : "=r" (rc) : "m" (res[8]) );
@@ -837,7 +845,8 @@ int main(int argc, char **argv)
         regs.ecx    = (unsigned long)(res + 2);
         regs.edx    = 0;
         rc = x86_emulate(&ctxt, &emulops);
-        if ( (rc != X86EMUL_OKAY) || memcmp(res, res + 8, 32) )
+        if ( (rc != X86EMUL_OKAY) || memcmp(res, res + 8, 32) ||
+             (regs.eip == (unsigned long)&instr[0]) )
             goto fail;
         printf("okay\n");
     }
@@ -862,7 +871,8 @@ int main(int argc, char **argv)
         regs.ecx    = 0;
         regs.edx    = (unsigned long)res;
         rc = x86_emulate(&ctxt, &emulops);
-        if ( rc != X86EMUL_OKAY )
+        if ( rc != X86EMUL_OKAY ||
+             (regs.eip == (unsigned long)&instr[0]) )
             goto fail;
         asm ( "vcmpeqps %1, %%ymm7, %%ymm0\n\t"
               "vmovmskps %%ymm0, %0" : "=r" (rc) : "m" (res[8]) );
-- 
1.7.9.5


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.