From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Cc: kvm@vger.kernel.org, rkrcmar@redhat.com, pbonzini@redhat.com,
jmattson@google.com
Subject: Re: [PATCH 1/2] kvm-unit-test: x86: Add a wrapper to check if the CPU supports NX bit in MSR_EFER
Date: Tue, 4 Jun 2019 06:59:09 -0700 [thread overview]
Message-ID: <20190604135908.GP13384@linux.intel.com> (raw)
In-Reply-To: <20190522234545.5930-2-krish.sadhukhan@oracle.com>
On Wed, May 22, 2019 at 07:45:44PM -0400, Krish Sadhukhan wrote:
> 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)
cpu_has_efer_nx() would be more appropriate. Most readers would expect
"enabled" to mean we're checking MSR_EFER.NX==1.
This can have a boolean return value.
> +{
> + if (cpuid(0x80000001).d & (1 << 20))
> + return 1;
> + else
> + return 0;
> +}
This can simply be:
return cpuid(0x80000001).d & (1 << 20);
or if gcc complains about boolean stuff:
return !!(cpuid(0x80000001).d & (1 << 20));
> +
> #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
>
next prev parent reply other threads:[~2019-06-04 13:59 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 ` [PATCH 1/2] kvm-unit-test: x86: Add a wrapper to check if the CPU supports NX bit in MSR_EFER Krish Sadhukhan
2019-05-23 16:58 ` Jim Mattson
2019-06-04 13:59 ` Sean Christopherson [this message]
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=20190604135908.GP13384@linux.intel.com \
--to=sean.j.christopherson@intel.com \
--cc=jmattson@google.com \
--cc=krish.sadhukhan@oracle.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 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.