From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mihai =?UTF-8?Q?Don=C8=9Bu?= Subject: Re: [RFC PATCH v2 1/1] kvm: Add documentation and ABI/API header for VM introspection Date: Thu, 13 Jul 2017 08:57:46 +0300 Message-ID: <1499925466.2110.342.camel@bitdefender.com> References: <20170707143416.11195-1-alazar@bitdefender.com> <20170707143416.11195-2-alazar@bitdefender.com> <7104167e-0747-92fe-05df-1b7e1848d65f@redhat.com> <1499700768.37E8E87C5.13190@host> <1499791729.BdcecF.28697@host> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Cc: Radim =?UTF-8?Q?Kr=C4=8Dm=C3=A1=C5=99?= , Jan Kiszka , Stefan Hajnoczi , Adalbert Lazar , kvm@vger.kernel.org To: Paolo Bonzini Return-path: Received: from mx01.bbu.dsd.mx.bitdefender.com ([91.199.104.161]:41992 "EHLO mx01.bbu.dsd.mx.bitdefender.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750857AbdGMF5y (ORCPT ); Thu, 13 Jul 2017 01:57:54 -0400 Received: from smtp03.buh.bitdefender.org (smtp.bitdefender.biz [10.17.80.77]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id B6B527FBF4 for ; Thu, 13 Jul 2017 08:57:52 +0300 (EEST) In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On Tue, 2017-07-11 at 18:51 +0200, Paolo Bonzini wrote: > On 11/07/2017 18:48, Adalbert Lazar wrote: > > On Mon, 10 Jul 2017 19:03:06 +0200, Paolo Bonzini wrote: > > > I'm not sure what you think of removing KVMI_EVENT_ACTION_SET_REGS and > > > more or less standardizing on actions SKIP/RETRY/ALLOW/CRASH. > > > > > > The main remaining issue seems to be map/unmap. > > > > Definitely, SKIP/RETRY/ALLOW/CRASH looks better, but SET_REGS helps > > performance wise. Maybe we could have it as an optional flag for ALLOW? > > Actually it makes more sense for SKIP, I think, where the introspector > is actually doing emulation? I'm afraid I don't undestand your question, however we were looking at using KVM's x86 emulator rather than putting together our own, as such software might be fun to write but they take a very long time to get right. I'd argue that KVM's emulator has already seen a lot of coverage. In the future we are looking at maybe moving away from it on Intel-s, by way of VMFUNC and #VE. > But why is KVMI_SET_REGS slower than a set regs command followed by an > action? To be honest, we just looked at the Xen implementation which gates writing back the registers to VMCS on them actually having been changed. I just figured the less VMWRITE-s, the better. I'm also looking over some older stats that show the registers being written back quite often. Allow me 1-2 days to gather new ones and followup on this thread. > > Or at least for the hot paths? > > > > Summarily, on events, besides CRASH (vs SHUTDOWN cmd) and any other > > additional flag: > > > >   * CR, MSR - ALLOW with untouched new_value will let the guest continue, > >               but with "new_value = old_value" is a "deny" > > > >   * xsetbv - ALLOW is implied > > > >   * breakpoint - SKIP means the BP is processed by the introspector, > >                  ALLOW means let the guest handle it > > > >   * hypercall - ALLOW is implied > > > >   * page_fault - ALLOW means emulate, RETRY means let guest re-trigger the PF, > >                  ALLOW with adjusted PC is a "skip" (done by the tool > >                  for the moment). > > This is more complicated than necessary.  I would just make it simple: > > - SKIP, adjust RIP to point to the next instruction and enter the guest > > - RETRY, enter the guest > > - ALLOW, emulate the instruction with information coming from the > response packet > > - CRASH, self-explanatory I see no major problem with your version. The reason we removed SKIP from the #PF description is that the RIP adjustment is done by the introspection tool after it decodes the instruction and computes its opcode length. So when the event response reaches KVM, it all looks like ALLOW was requested as the host-side code would be oblivous to the RIP change. -- Mihai Donțu