From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: [PATCH 3/3] KVM test: add test case to trigger the bug which cause hugepage mapping corrupt Date: Fri, 23 Jul 2010 13:07:49 +0800 Message-ID: <4C4923A5.9070505@cn.fujitsu.com> References: <4C4921C5.4090809@cn.fujitsu.com> <4C4922BD.6090502@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , KVM list To: Avi Kivity Return-path: 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 In-Reply-To: <4C4922BD.6090502@cn.fujitsu.com> Sender: kvm-owner@vger.kernel.org List-ID: The test case can trigger the bug that fixed by commit e09e90a5 in the kvm tree to avoid regression Signed-off-by: Xiao Guangrong --- kvm/test/x86/access.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 46 insertions(+), 0 deletions(-) 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; -- 1.6.1.2