From patchwork Fri Jul 23 05:07:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 113830 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6N5BuGi023650 for ; Fri, 23 Jul 2010 05:11:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752475Ab0GWFLy (ORCPT ); Fri, 23 Jul 2010 01:11:54 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:52071 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752219Ab0GWFLy (ORCPT ); Fri, 23 Jul 2010 01:11:54 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 9C8C0170131; Fri, 23 Jul 2010 13:11:52 +0800 (CST) Received: from fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id o6N590Q3003227; Fri, 23 Jul 2010 13:09:00 +0800 Received: from [10.167.141.99] (unknown [10.167.141.99]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 075E010C1CB; Fri, 23 Jul 2010 13:12:25 +0800 (CST) Message-ID: <4C4923A5.9070505@cn.fujitsu.com> Date: Fri, 23 Jul 2010 13:07:49 +0800 From: Xiao Guangrong User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: Avi Kivity CC: Marcelo Tosatti , KVM list Subject: [PATCH 3/3] KVM test: add test case to trigger the bug which cause hugepage mapping corrupt References: <4C4921C5.4090809@cn.fujitsu.com> <4C4922BD.6090502@cn.fujitsu.com> In-Reply-To: <4C4922BD.6090502@cn.fujitsu.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 23 Jul 2010 05:11:56 +0000 (UTC) diff --git a/kvm/test/x86/access.c b/kvm/test/x86/access.c index be51a55..a833df5 100644 --- a/kvm/test/x86/access.c +++ b/kvm/test/x86/access.c @@ -629,6 +629,49 @@ static void ac_test_show(ac_test_t *at) printf("%s", line); } +/* + * This test case is used to triger the bug which is fixed by + * commit e09e90a5 in the kvm tree + */ +static int corrupt_hugepage_triger(ac_pool_t *pool) +{ + ac_test_t at1, at2; + + ac_test_init(&at1, (void *)(0x123400000000)); + ac_test_init(&at2, (void *)(0x666600000000)); + + at2.flags[AC_CPU_CR0_WP] = 1; + at2.flags[AC_PDE_PSE] = 1; + at2.flags[AC_PDE_PRESENT] = 1; + ac_test_setup_pte(&at2, pool); + if (!ac_test_do_access(&at2)) + goto err; + + at1.flags[AC_CPU_CR0_WP] = 1; + at1.flags[AC_PDE_PSE] = 1; + at1.flags[AC_PDE_WRITABLE] = 1; + at1.flags[AC_PDE_PRESENT] = 1; + ac_test_setup_pte(&at1, pool); + if (!ac_test_do_access(&at1)) + goto err; + + at1.flags[AC_ACCESS_WRITE] = 1; + ac_set_expected_status(&at1); + if (!ac_test_do_access(&at1)) + goto err; + + at2.flags[AC_ACCESS_WRITE] = 1; + ac_set_expected_status(&at2); + if (!ac_test_do_access(&at2)) + goto err; + + return 1; + +err: + printf("corrupt_hugepage_triger test fail\n"); + return 0; +} + int ac_test_exec(ac_test_t *at, ac_pool_t *pool) { int r; @@ -656,6 +699,9 @@ int ac_test_run(void) successes += ac_test_exec(&at, &pool); } while (ac_test_bump(&at)); + ++tests; + successes += corrupt_hugepage_triger(&pool); + printf("\n%d tests, %d failures\n", tests, tests - successes); return successes == tests;