public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Krish Sadhukhan <krish.sadhukhan@oracle.com>
To: kvm@vger.kernel.org
Cc: rkrcmar@redhat.com, pbonzini@redhat.com, jmattson@google.com
Subject: [PATCH 1/2] kvm-unit-test: x86: Add a wrapper to check if the CPU supports NX bit in MSR_EFER
Date: Wed, 22 May 2019 19:45:44 -0400	[thread overview]
Message-ID: <20190522234545.5930-2-krish.sadhukhan@oracle.com> (raw)
In-Reply-To: <20190522234545.5930-1-krish.sadhukhan@oracle.com>

Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com>
---
 lib/x86/processor.h | 8 ++++++++
 x86/vmexit.c        | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/x86/processor.h b/lib/x86/processor.h
index 15237a5..2ca988e 100644
--- a/lib/x86/processor.h
+++ b/lib/x86/processor.h
@@ -476,4 +476,12 @@ static inline void set_bit(int bit, u8 *addr)
 			     : "+m" (*addr) : "Ir" (bit) : "cc", "memory");
 }
 
+static inline int efer_nx_enabled(void)
+{
+	if (cpuid(0x80000001).d & (1 << 20))
+		return 1;
+	else
+		return 0;
+}
+
 #endif
diff --git a/x86/vmexit.c b/x86/vmexit.c
index c12dd24..7053a46 100644
--- a/x86/vmexit.c
+++ b/x86/vmexit.c
@@ -526,7 +526,7 @@ static bool do_test(struct test *test)
 
 static void enable_nx(void *junk)
 {
-	if (cpuid(0x80000001).d & (1 << 20))
+	if (efer_nx_enabled())
 		wrmsr(MSR_EFER, rdmsr(MSR_EFER) | EFER_NX_MASK);
 }
 
-- 
2.20.1


  reply	other threads:[~2019-05-23  0:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22 23:45 [PATCH 0/2] kvm-unit-test: nVMX: Test "Load IA32_EFER" VM-exit control on vmentry of nested guests Krish Sadhukhan
2019-05-22 23:45 ` Krish Sadhukhan [this message]
2019-05-23 16:58   ` [PATCH 1/2] kvm-unit-test: x86: Add a wrapper to check if the CPU supports NX bit in MSR_EFER Jim Mattson
2019-06-04 13:59   ` Sean Christopherson
2019-05-22 23:45 ` [PATCH 2/2] kvm-unit-test: nVMX: Test "Load IA32_EFER" VM-exit control on vmentry of nested guests Krish Sadhukhan
2019-06-04 14:21   ` Sean Christopherson
2019-06-06 12:48 ` [PATCH 0/2] " Paolo Bonzini
2019-06-08  1:17   ` Krish Sadhukhan

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=20190522234545.5930-2-krish.sadhukhan@oracle.com \
    --to=krish.sadhukhan@oracle.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@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