Skip to contentSkip to conversation

test: emulator: lmsw may not clear cr0.pe

PATCH Applied Avi Kivity 2 participants 2 messages May 12, 2010 – May 14, 2010 KVM

lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH 1/1 test: emulator: lmsw may not clear cr0.pe

---
 kvm/user/test/x86/emulator.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
kvm/user/test/x86/emulator.c +9 -0
index 5406062..e677e3a 100644
@@ -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()
Signature · 1 line
1.7.0.4