[PATCH kvm-unit-tests] msr: check MSR_*STAR eager loading

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

 



3.3-rc1+ loaded MSR_STAR too lazily, breaking workloads
that play with this MSR (or related MSRs) like nested vmx.

Verify that it is loaded eagerly.

Signed-off-by: Avi Kivity <avi@xxxxxxxxxx>
---
 x86/msr.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/x86/msr.c b/x86/msr.c
index c3e0014..307835d 100644
--- a/x86/msr.c
+++ b/x86/msr.c
@@ -2,6 +2,7 @@
 
 #include "libcflat.h"
 #include "processor.h"
+#include "msr.h"
 
 struct msr_info {
     int index;
@@ -109,6 +110,21 @@ static void test_msr_rw(int msr_index, unsigned long long input, unsigned long l
     report(sptr, expected == r);
 }
 
+static void test_syscall_lazy_load(void)
+{
+    extern void syscall_target();
+    u16 cs = read_cs(), ss = read_ss();
+    ulong tmp;
+
+    wrmsr(MSR_EFER, rdmsr(MSR_EFER) | EFER_SCE);
+    wrmsr(MSR_LSTAR, (ulong)syscall_target);
+    wrmsr(MSR_STAR, (uint64_t)cs << 32);
+    asm volatile("pushf; syscall; syscall_target: popf" : "=c"(tmp) : : "r11");
+    write_ss(ss);
+    // will crash horribly if broken
+    report("MSR_*STAR eager loading", true);
+}
+
 int main(int ac, char **av)
 {
     int i, j;
@@ -122,6 +138,8 @@ int main(int ac, char **av)
         }
     }
 
+    test_syscall_lazy_load();
+
     printf("%d tests, %d failures\n", nr_tests, nr_tests - nr_passed);
 
     return nr_passed == nr_tests ? 0 : 1;
-- 
1.7.9

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


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux