From: Joerg Roedel Subject: [PATCH 7/7] svm: Add test for the NPT page table walker Date: Tue, 14 Sep 2010 17:59:12 +0200 Message-ID: <1284479952-4916-8-git-send-email-joerg.roedel@amd.com> References: <1284479952-4916-1-git-send-email-joerg.roedel@amd.com> Mime-Version: 1.0 Content-Type: text/plain Cc: , Joerg Roedel To: Avi Kivity Return-path: Received: from tx2ehsobe003.messaging.microsoft.com ([65.55.88.13]:5142 "EHLO TX2EHSOBE006.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752291Ab0INP6l (ORCPT ); Tue, 14 Sep 2010 11:58:41 -0400 In-Reply-To: <1284479952-4916-1-git-send-email-joerg.roedel@amd.com> Sender: kvm-owner@vger.kernel.org List-ID: This patch adds a test to check if NPT faults that occur while walking the guest page table are reported correctly. Signed-off-by: Joerg Roedel --- x86/svm.c | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/x86/svm.c b/x86/svm.c index 3421736..dc3098f 100644 --- a/x86/svm.c +++ b/x86/svm.c @@ -560,6 +560,28 @@ static bool npt_rw_check(struct test *test) && (test->vmcb->control.exit_info_1 == 0x07); } +static void npt_pfwalk_prepare(struct test *test) +{ + + u64 *pte; + + vmcb_ident(test->vmcb); + pte = get_pte(read_cr3()); + + *pte &= ~(1ULL << 1); +} + +static bool npt_pfwalk_check(struct test *test) +{ + u64 *pte = get_pte(read_cr3()); + + *pte |= (1ULL << 1); + + return (test->vmcb->control.exit_code == SVM_EXIT_NPF) + && (test->vmcb->control.exit_info_1 == 0x7) + && (test->vmcb->control.exit_info_2 == read_cr3()); +} + static struct test tests[] = { { "null", default_supported, default_prepare, null_test, default_finished, null_check }, @@ -590,6 +612,8 @@ static struct test tests[] = { default_finished, npt_rsvd_check }, { "npt_rw", npt_supported, npt_rw_prepare, npt_rw_test, default_finished, npt_rw_check }, + { "npt_pfwalk", npt_supported, npt_pfwalk_prepare, null_test, + default_finished, npt_pfwalk_check }, }; int main(int ac, char **av) -- 1.7.0.4