From: Marcelo Tosatti <mtosatti@redhat.com>
To: kvm <kvm@vger.kernel.org>
Cc: Avi Kivity <avi@redhat.com>
Subject: kvm test: vmexit: enable NX
Date: Tue, 8 Jun 2010 15:33:29 -0300 [thread overview]
Message-ID: <20100608183329.GA12737@amt.cnet> (raw)
Enable NX to disable MSR autoload/save. This is the common case anyway.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
diff --git a/kvm/test/x86/vmexit.c b/kvm/test/x86/vmexit.c
index c3a01e0..f267a19 100644
--- a/kvm/test/x86/vmexit.c
+++ b/kvm/test/x86/vmexit.c
@@ -45,6 +45,24 @@ static void vmcall(void)
asm volatile ("vmcall" : "+a"(a), "=b"(b), "=c"(c), "=d"(d));
}
+#define MSR_EFER 0xc0000080
+#define EFER_NX_MASK (1ull << 11)
+
+unsigned long long rdmsr(unsigned index)
+{
+ unsigned a, d;
+
+ asm volatile("rdmsr" : "=a"(a), "=d"(d) : "c"(index));
+ return ((unsigned long long)d << 32) | a;
+}
+
+void wrmsr(unsigned index, unsigned long long val)
+{
+ unsigned a = val, d = val >> 32;
+
+ asm volatile("wrmsr" : : "a"(a), "d"(d), "c"(index));
+}
+
static void mov_from_cr8(void)
{
unsigned long cr8;
@@ -151,12 +169,20 @@ static void do_test(struct test *test)
#define ARRAY_SIZE(_x) (sizeof(_x) / sizeof((_x)[0]))
+static void enable_nx(void *junk)
+{
+ wrmsr(MSR_EFER, rdmsr(MSR_EFER) | EFER_NX_MASK);
+}
+
int main(void)
{
int i;
smp_init();
+ for (i = cpu_count(); i > 0; i--)
+ on_cpu(i-1, enable_nx, 0);
+
for (i = 0; i < ARRAY_SIZE(tests); ++i)
do_test(&tests[i]);
next reply other threads:[~2010-06-08 18:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-08 18:33 Marcelo Tosatti [this message]
2010-06-09 11:07 ` kvm test: vmexit: enable NX Avi Kivity
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=20100608183329.GA12737@amt.cnet \
--to=mtosatti@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
/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