Add the test to trigger the bug that "rep ins" causes vcpu->mmio_fragments
overflow overflow while move large data from ioport to MMIO

Signed-off-by: Xiao Guangrong <xiaoguangr...@linux.vnet.ibm.com>
---
 x86/emulator.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/x86/emulator.c b/x86/emulator.c
index 24b33d1..0735405 100644
--- a/x86/emulator.c
+++ b/x86/emulator.c
@@ -731,6 +731,18 @@ static void test_crosspage_mmio(volatile uint8_t *mem)
     report("cross-page mmio write", mem[4095] == 0xaa && mem[4096] == 0x88);
 }

+static void test_string_io_mmio(volatile uint8_t *mem)
+{
+       /* Cross MMIO pages.*/
+       volatile uint8_t *mmio = mem + 4032;
+
+       asm volatile("outw %%ax, %%dx  \n\t" : : "a"(0x9999), 
"d"(TESTDEV_IO_PORT));
+
+       asm volatile ("cld; rep insb" : : "d" (TESTDEV_IO_PORT), "D" (mmio), 
"c" (1024));
+
+       report("string_io_mmio", mmio[1023] == 0x99);
+}
+
 static void test_lgdt_lidt(volatile uint8_t *mem)
 {
     struct descriptor_table_ptr orig, fresh = {};
@@ -878,6 +890,8 @@ int main()

        test_crosspage_mmio(mem);

+       test_string_io_mmio(mem);
+
        printf("\nSUMMARY: %d tests, %d failures\n", tests, fails);
        return fails ? 1 : 0;
 }
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to