From patchwork Mon Aug 2 13:33:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 116502 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 o72DUv3M017898 for ; Mon, 2 Aug 2010 13:30:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753829Ab0HBNan (ORCPT ); Mon, 2 Aug 2010 09:30:43 -0400 Received: from va3ehsobe004.messaging.microsoft.com ([216.32.180.14]:56391 "EHLO VA3EHSOBE004.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751521Ab0HBNam (ORCPT ); Mon, 2 Aug 2010 09:30:42 -0400 Received: from mail135-va3-R.bigfish.com (10.7.14.236) by VA3EHSOBE004.bigfish.com (10.7.40.24) with Microsoft SMTP Server id 8.1.340.0; Mon, 2 Aug 2010 13:30:42 +0000 Received: from mail135-va3 (localhost.localdomain [127.0.0.1]) by mail135-va3-R.bigfish.com (Postfix) with ESMTP id 6FD6115011D; Mon, 2 Aug 2010 13:30:41 +0000 (UTC) X-SpamScore: 1 X-BigFish: VS1(zzzz1202hzzz32i2a8h87h61h) X-Spam-TCS-SCL: 0:0 X-FB-DOMAIN-IP-MATCH: fail Received: from mail135-va3 (localhost.localdomain [127.0.0.1]) by mail135-va3 (MessageSwitch) id 128075584149031_29415; Mon, 2 Aug 2010 13:30:41 +0000 (UTC) Received: from VA3EHSMHS003.bigfish.com (unknown [10.7.14.254]) by mail135-va3.bigfish.com (Postfix) with ESMTP id 08C51A1004D; Mon, 2 Aug 2010 13:30:41 +0000 (UTC) Received: from ausb3extmailp02.amd.com (163.181.251.22) by VA3EHSMHS003.bigfish.com (10.7.99.13) with Microsoft SMTP Server (TLS) id 14.0.482.44; Mon, 2 Aug 2010 13:30:39 +0000 Received: from ausb3twp01.amd.com (ausb3twp01.amd.com [163.181.250.37]) by ausb3extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with SMTP id o72DV35n031676; Mon, 2 Aug 2010 08:31:06 -0500 X-WSS-ID: 0L6J1IV-01-4X7-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 2171910285BE; Mon, 2 Aug 2010 08:30:31 -0500 (CDT) Received: from storexhtp02.amd.com (172.24.4.4) by sausexhtp01.amd.com (163.181.3.165) with Microsoft SMTP Server (TLS) id 8.2.254.0; Mon, 2 Aug 2010 08:30:34 -0500 Received: from gwo.osrc.amd.com (165.204.16.204) by storexhtp02.amd.com (172.24.4.4) with Microsoft SMTP Server id 8.2.254.0; Mon, 2 Aug 2010 09:30:34 -0400 Received: from lemmy.osrc.amd.com (lemmy.osrc.amd.com [165.204.15.93]) by gwo.osrc.amd.com (Postfix) with ESMTP id 5AB9D49C1FB; Mon, 2 Aug 2010 14:30:33 +0100 (BST) Received: by lemmy.osrc.amd.com (Postfix, from userid 1000) id 8769EA0429; Mon, 2 Aug 2010 15:33:39 +0200 (CEST) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti CC: , Joerg Roedel Subject: [PATCH 2/4] test: Add nested svm next_rip test Date: Mon, 2 Aug 2010 15:33:34 +0200 Message-ID: <1280756016-11330-3-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1280756016-11330-1-git-send-email-joerg.roedel@amd.com> References: <1280756016-11330-1-git-send-email-joerg.roedel@amd.com> MIME-Version: 1.0 X-Reverse-DNS: ausb3extmailp02.amd.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]); Mon, 02 Aug 2010 13:30:57 +0000 (UTC) diff --git a/kvm/test/x86/svm.c b/kvm/test/x86/svm.c index dd4a8da..4a7a662 100644 --- a/kvm/test/x86/svm.c +++ b/kvm/test/x86/svm.c @@ -209,6 +209,32 @@ static void test_cr3_intercept_bypass(struct test *test) test->scratch = a; } +static bool next_rip_supported(void) +{ + return (cpuid(SVM_CPUID_FUNC).d & 8); +} + +static void prepare_next_rip(struct test *test) +{ + test->vmcb->control.intercept |= (1ULL << INTERCEPT_RDTSC); +} + + +static void test_next_rip(struct test *test) +{ + asm volatile ("rdtsc\n\t" + ".globl exp_next_rip\n\t" + "exp_next_rip:\n\t" ::: "eax", "edx"); +} + +static bool check_next_rip(struct test *test) +{ + extern char exp_next_rip; + unsigned long address = (unsigned long)&exp_next_rip; + + return address == test->vmcb->control.next_rip; +} + static struct test tests[] = { { "null", default_supported, default_prepare, null_test, default_finished, null_check }, @@ -223,6 +249,9 @@ static struct test tests[] = { { "cr3 read intercept emulate", default_supported, prepare_cr3_intercept_bypass, test_cr3_intercept_bypass, default_finished, check_cr3_intercept }, + { "next_rip", next_rip_supported, prepare_next_rip, test_next_rip, + default_finished, check_next_rip }, + }; int main(int ac, char **av)