There's room for speeding up emulation of invalid guest state.  Let's
track our progress by adding a very small performance test.

Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
---
 x86/realmode.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/x86/realmode.c b/x86/realmode.c
index ae91b9e..2f83b93 100644
--- a/x86/realmode.c
+++ b/x86/realmode.c
@@ -1534,6 +1534,30 @@ static void test_nopl(void)
        report("nopl", 0, 1);
 }
 
+static void test_rdtsc(void)
+{
+       u64 start, end;
+       u32 cyc;
+       char n[12], *p;
+       MK_INSN(rdtsc_10, "rdtsc; mov %eax, %ebx; mov %edx, %esi\n"
+                         "mov $996, %ecx\n"
+                         "1: loop 1b\n"
+                         "rdtsc");
+       exec_in_big_real_mode(&insn_rdtsc_10);
+       start = ((u64)outregs.esi << 32) | outregs.ebx;
+       end = ((u64)outregs.edx << 32) | outregs.eax;
+       p = &n[11];
+       *p = 0;
+       cyc = (end - start);
+       cyc /= 1000;
+       while (cyc > 0) {
+               *--p = '0' + (cyc % 10);
+               cyc /= 10;
+       }
+       print_serial(p);
+       print_serial(" cycles/emulated instruction\n");
+}
+
 void realmode_start(void)
 {
        test_null();
@@ -1580,6 +1604,7 @@ void realmode_start(void)
        test_salc();
        test_fninit();
        test_nopl();
+       test_rdtsc();
 
        exit(0);
 }
-- 
1.8.5.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to