These activate a faster path that does not set EFER in the
user return notifier.  Time the difference between the two.

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

diff --git a/x86/vmexit.c b/x86/vmexit.c
index 3bd0c81..a0380ab 100644
--- a/x86/vmexit.c
+++ b/x86/vmexit.c
@@ -3,6 +3,7 @@
 #include "processor.h"
 #include "atomic.h"
 #include "x86/vm.h"
+#include "x86/msr.h"
 #include "x86/desc.h"
 #include "x86/pci.h"
 
@@ -10,6 +11,7 @@ struct test {
        void (*func)(void);
        const char *name;
        int (*valid)(void);
+       void (*after)(void);
        int parallel;
        bool (*next)(struct test *);
 };
@@ -119,6 +121,17 @@ static void inl_nop_kernel(void)
     inb(0x4d0);
 }
 
+static int set_sce(void)
+{
+    wrmsr(MSR_EFER, rdmsr(MSR_EFER) | EFER_SCE);
+    return true;
+}
+
+static void clear_sce(void)
+{
+    wrmsr(MSR_EFER, rdmsr(MSR_EFER) & ~EFER_SCE);
+}
+
 static void outl_elcr_kernel(void)
 {
     outb(0x4d0, 0);
@@ -315,7 +328,11 @@ static struct test tests[] = {
 #endif
        { inl_pmtimer, "inl_from_pmtimer", .parallel = 1, },
        { inl_nop_qemu, "inl_from_qemu", .parallel = 1 },
+       { inl_nop_qemu, "inl_from_qemu (EFER guest = EFER host)", .parallel = 1,
+          .valid = set_sce, .after = clear_sce },
        { inl_nop_kernel, "inl_from_kernel", .parallel = 1 },
+       { inl_nop_kernel, "inl_from_kernel (EFER guest = EFER host)", .parallel 
= 1,
+          .valid = set_sce, .after = clear_sce },
        { outl_elcr_kernel, "outl_to_kernel", .parallel = 1 },
        { mov_dr, "mov_dr", .parallel = 1 },
        { ipi, "ipi", is_smp, .parallel = 0, },
@@ -381,6 +398,9 @@ static bool do_test(struct test *test)
                t2 = rdtsc();
        } while ((t2 - t1) < GOAL);
        printf("%s %d\n", test->name, (int)((t2 - t1) / iterations));
+       if (test->after) {
+               test->after();
+       }
        return test->next;
 }
 
-- 
1.8.3.1

--
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