All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: jasowang@redhat.com, mtosatti@redhat.com, avi@redhat.com,
	kvm@vger.kernel.org
Subject: [PATCH kvm-unit-tests 08/10] Check whether in long mode before testing vmexit caused by cr8 access
Date: Tue, 24 Aug 2010 21:47:51 +0800	[thread overview]
Message-ID: <20100824134751.17082.29122.stgit@FreeLancer> (raw)
In-Reply-To: <20100824134523.17082.8727.stgit@FreeLancer>

CR8 is only availabe when in long mode.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 x86/vmexit.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/x86/vmexit.c b/x86/vmexit.c
index 819c24b..34b0af4 100644
--- a/x86/vmexit.c
+++ b/x86/vmexit.c
@@ -48,6 +48,7 @@ static void vmcall(void)
 
 #define MSR_EFER 0xc0000080
 #define EFER_NX_MASK            (1ull << 11)
+#define EFER_LMA_MASK           (1ull << 10)
 
 static void mov_from_cr8(void)
 {
@@ -68,6 +69,15 @@ static int is_smp(void)
 	return cpu_count() > 1;
 }
 
+static int is_long_mode(void)
+{
+#ifdef __i386__
+        return 0;
+#else
+        return rdmsr(MSR_EFER) | EFER_LMA_MASK;
+#endif
+}
+
 static void nop(void *junk)
 {
 }
@@ -100,8 +110,8 @@ static struct test {
 } tests[] = {
 	{ cpuid_test, "cpuid", .parallel = 1,  },
 	{ vmcall, "vmcall", .parallel = 1, },
-	{ mov_from_cr8, "mov_from_cr8", .parallel = 1, },
-	{ mov_to_cr8, "mov_to_cr8" , .parallel = 1, },
+	{ mov_from_cr8, "mov_from_cr8", is_long_mode, .parallel = 1, },
+	{ mov_to_cr8, "mov_to_cr8" , is_long_mode, .parallel = 1, },
 	{ inl_pmtimer, "inl_from_pmtimer", .parallel = 1, },
 	{ ipi, "ipi", is_smp, .parallel = 0, },
 	{ ipi_halt, "ipi+halt", is_smp, .parallel = 0, },


  parent reply	other threads:[~2010-08-24 13:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-24 13:46 [PATCH kvm-unit-tests 00/10] Minor cleanup and fix for 32bit test Jason Wang
2010-08-24 13:46 ` [PATCH kvm-unit-tests 01/10] Do not track config.mak and kvmtrace Jason Wang
2010-08-24 13:47 ` [PATCH kvm-unit-tests 02/10] Remove trailing whitespaces Jason Wang
2010-08-24 13:47 ` [PATCH kvm-unit-tests 03/10] Makefile cleanup Jason Wang
2010-08-24 13:47 ` [PATCH kvm-unit-tests 04/10] Correct the path in README Jason Wang
2010-08-24 13:47 ` [PATCH kvm-unit-tests 05/10] Drop print.S Jason Wang
2010-08-24 13:47 ` [PATCH kvm-unit-tests 06/10] Remove the duplicated rdmsr/wrmsr Jason Wang
2010-08-24 13:47 ` [PATCH kvm-unit-tests 07/10] Correct the tss size Jason Wang
2010-08-24 13:57   ` Avi Kivity
2010-08-24 13:47 ` Jason Wang [this message]
2010-08-24 13:58   ` [PATCH kvm-unit-tests 08/10] Check whether in long mode before testing vmexit caused by cr8 access Avi Kivity
2010-08-24 13:47 ` [PATCH kvm-unit-tests 09/10] Do not test IA32_EFER in 32bit mode Jason Wang
2010-08-24 13:48 ` [PATCH kvm-unit-tests 10/10] Add the 32bit smp initialization code Jason Wang

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=20100824134751.17082.29122.stgit@FreeLancer \
    --to=jasowang@redhat.com \
    --cc=avi@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.