Re: [PATCH 1/3] KVM: X86: Provides userspace with a capability to not intercept MWAIT
From: Radim KrÄmÃÅ
Date: Thu Mar 08 2018 - 15:56:05 EST
2018-03-08 21:31+0100, Radim KrÄmÃÅ:
> 2018-03-01 17:49+0800, Wanpeng Li:
> > @@ -264,10 +262,12 @@ static inline u64 nsec_to_cycles(struct kvm_vcpu *vcpu, u64 nsec)
> > __rem; \
> > })
> >
> > -static inline bool kvm_mwait_in_guest(void)
> > +#define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0)
> > +#define KVM_X86_DISABLE_VALID_EXITS (KVM_X86_DISABLE_EXITS_MWAIT)
> > +
> > +static inline bool kvm_mwait_in_guest(struct kvm *kvm)
> > {
> > - return boot_cpu_has(X86_FEATURE_MWAIT) &&
> > - !boot_cpu_has_bug(X86_BUG_MONITOR);
> > + return kvm->arch.mwait_in_guest;
>
> With this nice variable, the wrapper actually makes the code harder to
> read. Please use kvm->arch.mwait_in_guest directly (and the same for
> the other two future exits),
I take that back. kvm->arch.mwait_in_guest looks ok, but it would be
vmx->vcpu.kvm->arch.mwait_in_guest elsewhere and that is just too bad.