From patchwork Tue Sep 14 15:59:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 179862 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o8EFwkGP023775 for ; Tue, 14 Sep 2010 15:58:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753046Ab0INP6n (ORCPT ); Tue, 14 Sep 2010 11:58:43 -0400 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 Received: from mail118-tx2-R.bigfish.com (10.9.14.241) by TX2EHSOBE006.bigfish.com (10.9.40.26) with Microsoft SMTP Server id 8.1.340.0; Tue, 14 Sep 2010 15:58:39 +0000 Received: from mail118-tx2 (localhost.localdomain [127.0.0.1]) by mail118-tx2-R.bigfish.com (Postfix) with ESMTP id 7AAE3AA8388; Tue, 14 Sep 2010 15:58:39 +0000 (UTC) X-SpamScore: 2 X-BigFish: VS2(ze80izzz1202hzz8275bhz32i87h2a8h43h61h) X-Spam-TCS-SCL: 0:0 X-FB-DOMAIN-IP-MATCH: fail Received: from mail118-tx2 (localhost.localdomain [127.0.0.1]) by mail118-tx2 (MessageSwitch) id 1284479918440542_22100; Tue, 14 Sep 2010 15:58:38 +0000 (UTC) Received: from TX2EHSMHS033.bigfish.com (unknown [10.9.14.246]) by mail118-tx2.bigfish.com (Postfix) with ESMTP id 68E565F804E; Tue, 14 Sep 2010 15:58:38 +0000 (UTC) Received: from ausb3extmailp01.amd.com (163.181.251.8) by TX2EHSMHS033.bigfish.com (10.9.99.133) with Microsoft SMTP Server (TLS) id 14.0.482.44; Tue, 14 Sep 2010 15:58:35 +0000 Received: from ausb3twp01.amd.com ([163.181.250.37]) by ausb3extmailp01.amd.com (Switch-3.2.7/Switch-3.2.7) with SMTP id o8EG17HV004662; Tue, 14 Sep 2010 11:01:22 -0500 X-WSS-ID: 0L8QV1J-01-0PM-02 X-M-MSG: Received: from sausexhtp01.amd.com (sausexhtp01.amd.com [163.181.3.165]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by ausb3twp01.amd.com (Tumbleweed MailGate 3.7.2) with ESMTP id 2E3E8102878D; Tue, 14 Sep 2010 10:58:30 -0500 (CDT) Received: from storexhtp01.amd.com (172.24.4.3) by sausexhtp01.amd.com (163.181.3.165) with Microsoft SMTP Server (TLS) id 8.3.83.0; Tue, 14 Sep 2010 10:58:34 -0500 Received: from gwo.osrc.amd.com (165.204.16.204) by storexhtp01.amd.com (172.24.4.3) with Microsoft SMTP Server id 8.3.83.0; Tue, 14 Sep 2010 11:58:32 -0400 Received: from lemmy.osrc.amd.com (lemmy.osrc.amd.com [165.204.15.93]) by gwo.osrc.amd.com (Postfix) with ESMTP id AFA8349C2B1; Tue, 14 Sep 2010 16:58:31 +0100 (BST) Received: by lemmy.osrc.amd.com (Postfix, from userid 1000) id 44E3CA024F; Tue, 14 Sep 2010 17:59:14 +0200 (CEST) From: Joerg Roedel To: Avi Kivity CC: , 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> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1284479952-4916-1-git-send-email-joerg.roedel@amd.com> References: <1284479952-4916-1-git-send-email-joerg.roedel@amd.com> MIME-Version: 1.0 X-Reverse-DNS: unknown 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 (demeter1.kernel.org [140.211.167.41]); Tue, 14 Sep 2010 15:58:46 +0000 (UTC) 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)