From patchwork Fri Oct 19 07:39:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 1616991 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id E81EEDF26F for ; Fri, 19 Oct 2012 07:39:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755024Ab2JSHjQ (ORCPT ); Fri, 19 Oct 2012 03:39:16 -0400 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:58413 "EHLO e28smtp06.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752288Ab2JSHjP (ORCPT ); Fri, 19 Oct 2012 03:39:15 -0400 Received: from /spool/local by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 19 Oct 2012 13:09:13 +0530 Received: from d28relay02.in.ibm.com (9.184.220.59) by e28smtp06.in.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 19 Oct 2012 13:09:11 +0530 Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q9J7dAQ221823514; Fri, 19 Oct 2012 13:09:10 +0530 Received: from d28av02.in.ibm.com (loopback [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q9JD8Qii016263; Sat, 20 Oct 2012 00:08:27 +1100 Received: from localhost.localdomain ([9.123.236.99]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q9JD8P61016197; Sat, 20 Oct 2012 00:08:25 +1100 Message-ID: <5081039C.1040303@linux.vnet.ibm.com> Date: Fri, 19 Oct 2012 15:39:08 +0800 From: Xiao Guangrong User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120911 Thunderbird/15.0.1 MIME-Version: 1.0 To: Xiao Guangrong CC: Avi Kivity , Marcelo Tosatti , Gleb Natapov , LKML , KVM Subject: [PATCH] emulator test: add "rep ins" mmio access test References: <5081033C.4060503@linux.vnet.ibm.com> In-Reply-To: <5081033C.4060503@linux.vnet.ibm.com> x-cbid: 12101907-9574-0000-0000-000004EEAAFB Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- 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; }