On Tue, Jun 25, 2013 at 04:51:31PM +0800, Arthur Chunqi Li wrote: > 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"); > + The test can be compiled for 64 bit only so we need to put it in an #ifdef. Previous patches that introduced testing infrastructure are 64 bit specific too, so now emulator.c can be compiled for 64bit only, we should fix that one day. > + inregs = (struct regs){ .rax = 0x1234 }; > + trap_emulator(mem, alt_insn_page, &insn_modrm_spl); > + report("access spl via modr/m", outregs.rax == 0x1234); I'd prefer to write report variant like the one in realmode.c that checks all registers for consistency. Then the report would be like that: report("access spl via modr/m", R_SP, outregs.rsp == 0x34); > + > + 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 -- Gleb. -- 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