From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ladi Prosek Subject: Re: [PATCH 1/5] KVM: x86: introduce ISA specific SMM entry/exit callbacks Date: Thu, 14 Sep 2017 09:14:35 +0200 Message-ID: References: <20170913140628.7787-1-lprosek@redhat.com> <20170913140628.7787-2-lprosek@redhat.com> <89091967-4ffe-9e26-88aa-f6f716f0e0a8@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: KVM list , Radim Krcmar To: Paolo Bonzini Return-path: Received: from mail-wm0-f50.google.com ([74.125.82.50]:44660 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751085AbdINHOh (ORCPT ); Thu, 14 Sep 2017 03:14:37 -0400 Received: by mail-wm0-f50.google.com with SMTP id 189so3618691wmh.1 for ; Thu, 14 Sep 2017 00:14:36 -0700 (PDT) In-Reply-To: <89091967-4ffe-9e26-88aa-f6f716f0e0a8@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Sep 13, 2017 at 11:44 PM, Paolo Bonzini 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