On Wed, Sep 13, 2017 at 11:44 PM, Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote: > On 13/09/2017 16:06, Ladi Prosek wrote: >> + bool left_smm; /* post_leave_smm() needs to be called after emulation */ > > This is already stored (more or less) in hflags. Would it work to > invoke the hook from kvm_smm_changed instead? I would have to reorder some of the calls under "if (writeback)" in x86_emulate_instruction to make it work. The hook needs to be called after all vcpu state has been synced. For example now kvm_rip_write runs after kvm_set_hflags so it would overwrite the rip restored by the hook. The left_smm field is indeed not necessary though. What if I leave it as a separate statement in x86_emulate_instruction to make the ordering requirement explicit, but use hflags to detect that we've left SMM? Thanks! Ladi