On Tue, Nov 29, 2022, Maxim Levitsky wrote: > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index f18f579ebde81c..85d2a12c214dda 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -8138,9 +8138,14 @@ static void emulator_set_nmi_mask(struct x86_emulate_ctxt *ctxt, bool masked) > static_call(kvm_x86_set_nmi_mask)(emul_to_vcpu(ctxt), masked); > } > > -static unsigned emulator_get_hflags(struct x86_emulate_ctxt *ctxt) > +static bool emulator_in_smm(struct x86_emulate_ctxt *ctxt) > { > - return emul_to_vcpu(ctxt)->arch.hflags; > + return emul_to_vcpu(ctxt)->arch.hflags & HF_SMM_MASK; This needs to be is_smm() as HF_SMM_MASK is undefined if CONFIG_KVM_SMM=n. > +} > + > +static bool emulator_in_guest_mode(struct x86_emulate_ctxt *ctxt) > +{ > + return emul_to_vcpu(ctxt)->arch.hflags & HF_GUEST_MASK; And just use is_guest_mode() here.