From: Avi Kivity <avi@redhat.com>
To: Joerg Roedel <joerg.roedel@amd.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
kvm@vger.kernel.org
Subject: [PATCH 2/6] test: add intercepted and unintercepted cr3 read tests for svm
Date: Wed, 28 Jul 2010 19:25:47 +0300 [thread overview]
Message-ID: <1280334351-6395-3-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1280334351-6395-1-git-send-email-avi@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
kvm/test/x86/svm.c | 26 +++++++++++++++++++++++++-
1 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/kvm/test/x86/svm.c b/kvm/test/x86/svm.c
index 5bb64ff..222356d 100644
--- a/kvm/test/x86/svm.c
+++ b/kvm/test/x86/svm.c
@@ -146,12 +146,36 @@ static bool check_vmrun(struct test *test)
return test->vmcb->control.exit_code == SVM_EXIT_VMRUN;
}
+static void prepare_cr3_intercept(struct test *test)
+{
+ default_prepare(test);
+ test->vmcb->control.intercept_cr_read |= 1 << 3;
+}
+
+static void test_cr3_intercept(struct test *test)
+{
+ asm volatile ("mov %%cr3, %0" : "=r"(test->scratch) : : "memory");
+}
+
+static bool check_cr3_intercept(struct test *test)
+{
+ return test->vmcb->control.exit_code == SVM_EXIT_READ_CR3;
+}
+
+static bool check_cr3_nointercept(struct test *test)
+{
+ return null_check(test) && test->scratch == read_cr3();
+}
+
static struct test tests[] = {
{ "null", default_prepare, null_test, default_finished, null_check },
{ "vmrun", default_prepare, test_vmrun, default_finished, check_vmrun },
{ "vmrun intercept check", prepare_no_vmrun_int, null_test,
default_finished, check_no_vmrun_int },
-
+ { "cr3 read intercept", prepare_cr3_intercept, test_cr3_intercept,
+ default_finished, check_cr3_intercept },
+ { "cr3 read nointercept", default_prepare, test_cr3_intercept,
+ default_finished, check_cr3_nointercept },
};
int main(int ac, char **av)
--
1.7.1
next prev parent reply other threads:[~2010-07-28 16:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-28 16:25 [PATCH 0/6] svm intercept tests Avi Kivity
2010-07-28 16:25 ` [PATCH 1/6] test: add scratch word for use by svm tests Avi Kivity
2010-07-28 16:25 ` Avi Kivity [this message]
2010-07-28 16:25 ` [PATCH 3/6] test: add pause() instruction accessor Avi Kivity
2010-07-28 16:25 ` [PATCH 4/6] test: add cli() and sti() instruction accessors Avi Kivity
2010-07-28 16:25 ` [PATCH 5/6] test: ensure svm tests are executed with interrupts disabled by default Avi Kivity
2010-07-28 16:25 ` [PATCH 6/6] test: verify that the emulator honours svm intercepts Avi Kivity
2010-07-28 18:04 ` Avi Kivity
2010-07-29 7:43 ` Roedel, Joerg
2010-07-29 7:48 ` Avi Kivity
2010-07-29 7:59 ` Roedel, Joerg
2010-07-29 8:45 ` Avi Kivity
2010-07-29 8:16 ` [PATCH 0/6] svm intercept tests Roedel, Joerg
2010-07-29 21:40 ` Marcelo Tosatti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1280334351-6395-3-git-send-email-avi@redhat.com \
--to=avi@redhat.com \
--cc=joerg.roedel@amd.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox