diff mbox

test: emulator: lmsw may not clear cr0.pe

Message ID 1273651210-29007-1-git-send-email-avi@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Avi Kivity May 12, 2010, 8 a.m. UTC
None
diff mbox

Patch

diff --git a/kvm/user/test/x86/emulator.c b/kvm/user/test/x86/emulator.c
index 5406062..e677e3a 100644
--- a/kvm/user/test/x86/emulator.c
+++ b/kvm/user/test/x86/emulator.c
@@ -267,6 +267,15 @@  void test_lmsw(void)
 	asm("lmsw %0" : : "m"(*pmsw));
 	printf("before %lx after %lx\n", cr0, read_cr0());
 	report("lmsw (2)", cr0 == read_cr0());
+
+	/* lmsw can't clear cr0.pe */
+	msw = (cr0 & ~1ul) ^ 4;  /* change EM to force trap */
+	asm("lmsw %0" : : "r"(msw));
+	report("lmsw (3)", (cr0 ^ read_cr0()) == 4 && (cr0 & 1));
+
+	/* back to normal */
+	msw = cr0;
+	asm("lmsw %0" : : "r"(msw));
 }
 
 int main()