public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Mihai Donțu" <mdontu@bitdefender.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
	"Jan Kiszka" <jan.kiszka@siemens.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Adalbert Lazar" <alazar@bitdefender.com>,
	kvm@vger.kernel.org,
	"Tamas K Lengyel" <tamas.k.lengyel@gmail.com>
Subject: Re: [RFC PATCH v2 1/1] kvm: Add documentation and ABI/API header for VM introspection
Date: Wed, 02 Aug 2017 16:53:13 +0300	[thread overview]
Message-ID: <1501681993.15747.329.camel@bitdefender.com> (raw)
In-Reply-To: <1501680749.15747.319.camel@bitdefender.com>

On Wed, 2017-08-02 at 16:32 +0300, Mihai Donțu wrote:
> On Wed, 2017-08-02 at 14:27 +0200, Paolo Bonzini wrote:
> > On 02/08/2017 13:52, Mihai Donțu wrote:
> > > I think it might help to distinguish two situations in which we require
> > > the guest _or_ a single vCPU to be paused. Our initial KVMI_PAUSE_GUEST
> > > command can be translated into a qemu pause. In our particular usecase
> > > we made special arrangements to call it as few times as possible
> > > assuming it's very costly. The other is needed only by the internal KVM
> > > code for situations similar to:
> > > 
> > >   kvm_pause_vcpu(vcpu);
> > >   vcpu_load(vcpu);
> > >   kvm_arch_vcpu_ioctl_get_regs(vcpu, regs);
> > >   vcpu_put(vcpu);
> > >   kvm_unpause_vcpu(vcpu);
> > > 
> > > or more generally put, for accesses that involve the vCPU state
> > > (registers, MSR-s, exceptions etc.), no guest memory involved.
> > > 
> > > Here kvm_pause_vcpu() will only pull the vCPU out of the guest and, if
> > > so, make it somehow available for quick re-entry with
> > > kvm_unpause_vcpu(). If said vCPU is already out, then the function will
> > > be a no-op. Obviously, kvm_{pause,unpause}_vcpu() will do nothing if
> > > we're currently handling an event or one is pending.
> > 
> > Understood.  The issue is that there is an inherent race between
> > anything userspace is doing and get_regs.  What are the cases where you
> > need to get regs or similar outside an event?
> 
> We have currently identified three cases:
> 
>  * initial hooking of a guest
>  * periodically checking the integrity of data that is not properly
>    placed into a page and thus cannot be efficiently tracked via SPT
>  * injecting processes

A few more details are required here, taken from our current
application: cases (a) and (c) involve poking the vCPU-s a couple of
times before doing KVMI_PAUSE_GUEST() after which everything should be
OK, though we should make sure qemu sync-s the states before entering
the paused state.

Case (b), as far as I can see, is implemented only via memory maps (eg.
the IDT is mapped and kept around for quick checking), but a need
_might_ arrise to poke the vCPU a few times before concluding that an
area has really been corrupted.

> > > One exception that might have a better solution is:
> > > 
> > >   kvm_pause_all_vcpus(kvm);
> > >   kvm_set_page_access(kvm, gfn); /* pause for get too? */
> > >   kvm_unpause_all_vcpus(kvm);
> > > 
> > > There might be a way to make the change and then IPI all vCPU-s without
> > > pulling them out of the guest.
> > 
> > For that I think KVMI should define a VM-wide "mask" layered over the
> > actual memory map permissions.  Such a command can be implemented
> > relatively easily by hooking into the callers of __gfn_to_pfn_memslot
> > and kvm_vcpu_gfn_to_hva_prot.

-- 
Mihai Donțu

  parent reply	other threads:[~2017-08-02 13:53 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-07 14:34 [RFC PATCH v2 0/1] VM introspection Adalbert Lazar
2017-07-07 14:34 ` [RFC PATCH v2 1/1] kvm: Add documentation and ABI/API header for " Adalbert Lazar
2017-07-07 16:52   ` Paolo Bonzini
2017-07-10 15:32     ` alazar
2017-07-10 17:03       ` Paolo Bonzini
2017-07-11 16:48         ` Adalbert Lazar
2017-07-11 16:51           ` Paolo Bonzini
2017-07-13  5:57             ` Mihai Donțu
2017-07-13  7:32               ` Paolo Bonzini
2017-07-18 11:51                 ` Mihai Donțu
2017-07-18 12:02                   ` Mihai Donțu
2017-07-23 13:02                   ` Paolo Bonzini
2017-07-26 17:04                     ` Mihai Donțu
2017-07-26 17:25                       ` Tamas K Lengyel
2017-07-27 14:41                         ` Mihai Donțu
2017-07-27 13:33                       ` Paolo Bonzini
2017-07-27 14:46                         ` Mihai Donțu
2017-07-13  8:36     ` Mihai Donțu
2017-07-13  9:15       ` Paolo Bonzini
2017-07-27 16:23         ` Mihai Donțu
2017-07-27 16:52           ` Paolo Bonzini
2017-07-27 17:19             ` Mihai Donțu
2017-08-01 10:40               ` Paolo Bonzini
2017-08-01 16:33                 ` Tamas K Lengyel
2017-08-01 20:47                   ` Paolo Bonzini
2017-08-02 11:52                     ` Mihai Donțu
2017-08-02 12:27                       ` Paolo Bonzini
2017-08-02 13:32                         ` Mihai Donțu
2017-08-02 13:51                           ` Paolo Bonzini
2017-08-02 14:17                             ` Mihai Donțu
2017-08-04  8:35                               ` Paolo Bonzini
2017-08-04 15:29                                 ` Mihai Donțu
2017-08-04 15:37                                   ` Paolo Bonzini
2017-08-05  8:00                                   ` Andrei Vlad LUTAS
2017-08-07 12:18                                     ` Paolo Bonzini
2017-08-07 13:25                                       ` Mihai Donțu
2017-08-07 13:49                                         ` Paolo Bonzini
2017-08-07 14:12                                           ` Mihai Donțu
2017-08-07 15:56                                             ` Paolo Bonzini
2017-08-07 16:44                                               ` Mihai Donțu
2017-08-02 13:53                           ` Mihai Donțu [this message]
2017-07-27 17:06     ` Mihai Donțu
2017-07-27 17:18       ` Paolo Bonzini
2017-07-07 17:29 ` [RFC PATCH v2 0/1] " Paolo Bonzini
2017-08-07 15:28   ` Mihai Donțu
2017-08-07 15:44     ` Paolo Bonzini
2017-07-12 14:09 ` Konrad Rzeszutek Wilk
2017-07-13  5:37   ` Mihai Donțu
2017-07-14 16:13     ` Konrad Rzeszutek Wilk
2017-07-18  8:55       ` Mihai Donțu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1501681993.15747.329.camel@bitdefender.com \
    --to=mdontu@bitdefender.com \
    --cc=alazar@bitdefender.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=tamas.k.lengyel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox