On Wed, May 22, 2019 at 07:45:44PM -0400, Krish Sadhukhan wrote: > Signed-off-by: Krish Sadhukhan <krish.sadhukhan@xxxxxxxxxx> > Reviewed-by: Karl Heubaum <karl.heubaum@xxxxxxxxxx> > --- > 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 >