[PATCH 3/3] emulator: Add spl/bpl/sil/dil access via modrm

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

 



Add test case of accessing spl/bpl/sil/dil via modrm in emulator.

Signed-off-by: Arthur Chunqi Li <yzt356@xxxxxxxxx>
---
 x86/emulator.c |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/x86/emulator.c b/x86/emulator.c
index bd02d5c..bea9513 100755
--- a/x86/emulator.c
+++ b/x86/emulator.c
@@ -840,6 +840,31 @@ static void test_nopl(uint64_t *mem, void *alt_insn_page)
     report("nopl", 1);
 }
 
+static void test_modrm(uint64_t *mem, void *alt_insn_page)
+{
+    
+    MK_INSN(modrm_spl,"mov %al, %spl\n\t");
+    MK_INSN(modrm_bpl,"mov %cl, %bpl\n\t");
+    MK_INSN(modrm_sil,"mov %dl, %sil\n\t");
+    MK_INSN(modrm_dil,"mov %bl, %dil\n\t");
+
+    inregs = (struct regs){ .rax = 0x1234 };
+    trap_emulator(mem, alt_insn_page, &insn_modrm_spl);
+    report("access spl via modr/m", outregs.rax == 0x1234);
+
+    inregs = (struct regs){ .rcx = 0x1234 };
+    trap_emulator(mem, alt_insn_page, &insn_modrm_bpl);
+    report("access bpl via modr/m", outregs.rcx == 0x1234);
+
+    inregs = (struct regs){ .rdx = 0x1234 };
+    trap_emulator(mem, alt_insn_page, &insn_modrm_sil);
+    report("access sil via modr/m", outregs.rdx == 0x1234);
+
+    inregs = (struct regs){ .rbx = 0x1234 };
+    trap_emulator(mem, alt_insn_page, &insn_modrm_dil);
+    report("access dil via modr/m", outregs.rbx == 0x1234);
+}
+
 static void test_crosspage_mmio(volatile uint8_t *mem)
 {
     volatile uint16_t w, *pw;
@@ -1037,6 +1062,7 @@ int main()
 	test_mmx_movq_mf(mem, alt_insn_page);
 	test_movabs(mem, alt_insn_page);
 	test_nopl(mem, alt_insn_page);
+	test_modrm(mem, alt_insn_page);
 
 	test_crosspage_mmio(mem);
 
-- 
1.7.9.5

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