[PATCH kvm-unit-tests] x86: test mov DR with ignored mod bits

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

 



Tests whether the emulator ignores the mod bits on mov DR instruction.  The
test performs regular mov to DR0 and reads back the data using custom mov from
DR0 while mod bits are set to zero. The expected result is obviously the value
which was written to DR0 before.

The test is performed in realmode and is only expected to fail if the CPU does
not support unrestricted mode. Note that mov-CR/DR in protected mode are
usually not handled by the emulator, as their data is available in the exit
information fields.

Signed-off-by: Nadav Amit <namit@xxxxxxxxxxxxxxxxx>
---
 x86/realmode.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/x86/realmode.c b/x86/realmode.c
index 9c22d41..839ac34 100644
--- a/x86/realmode.c
+++ b/x86/realmode.c
@@ -1636,6 +1636,16 @@ static void test_perf_memory_rmw(void)
 	print_serial(" cycles/emulated memory RMW instruction\n");
 }
 
+void test_dr_mod(void)
+{
+	MK_INSN(drmod, "movl %ebx, %dr0\n\t"
+		       ".byte 0x0f \n\t .byte 0x21 \n\t .byte 0x0\n\t");
+	inregs.eax = 0xdead;
+	inregs.ebx = 0xaced;
+	exec_in_big_real_mode(&insn_drmod);
+	report("mov dr with mod bits", R_AX | R_BX, outregs.eax == 0xaced);
+}
+
 void realmode_start(void)
 {
 	test_null();
@@ -1681,6 +1691,7 @@ void realmode_start(void)
 	test_xlat();
 	test_salc();
 	test_fninit();
+	test_dr_mod();
 	test_nopl();
 	test_perf_loop();
 	test_perf_mov();
-- 
1.9.1

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