kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tamas K Lengyel <tamas.k.lengyel@gmail.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Mihai Donțu" <mdontu@bitdefender.com>,
	"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
Subject: Re: [RFC PATCH v2 1/1] kvm: Add documentation and ABI/API header for VM introspection
Date: Tue, 1 Aug 2017 10:33:04 -0600	[thread overview]
Message-ID: <CABfawh=nSA13MoSYtrnY21tp07kvsMe1wo8TYwEs5nFVUNJssQ@mail.gmail.com> (raw)
In-Reply-To: <f9eeaea1-1fc2-0298-a4f8-77eed8c587d3@redhat.com>

On Tue, Aug 1, 2017 at 4:40 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> On 27/07/2017 19:19, Mihai Donțu wrote:
>> On Thu, 2017-07-27 at 18:52 +0200, Paolo Bonzini wrote:
>>> On 27/07/2017 18:23, Mihai Donțu wrote:
>>>> On Thu, 2017-07-13 at 11:15 +0200, Paolo Bonzini wrote:
>>>>> On 13/07/2017 10:36, Mihai Donțu wrote:
>>>>>> On Fri, 2017-07-07 at 18:52 +0200, Paolo Bonzini wrote:
>>>>>>> Worse, KVM is not able to distinguish userspace that has paused the VM
>>>>>>> from userspace that is doing MMIO or userspace that has a bug and hung
>>>>>>> somewhere.  And even worse, there are cases where userspace wants to
>>>>>>> modify registers while doing port I/O (the awful VMware RPCI port).  So
>>>>>>> I'd rather avoid this.
>>>>>>
>>>>>> I should give more details here: we don't need to pause the vCPU-s in
>>>>>> the sense widely understood but just prevent them from entering the
>>>>>> guest for a short period of time. In our particular case, we need this
>>>>>> when we start introspecting a VM that's already running. For this we
>>>>>> kick the vCPU-s out of the guest so that our scan of the memory does
>>>>>> not race with the guest kernel/applications.
>>>>>>
>>>>>> Another use case is when we inject applications into a running guest.
>>>>>> We also kick the vCPU-s out while we atomically make changes to kernel
>>>>>> specific structures.
>>>>>
>>>>> This is not possible to do in KVM, because KVM doesn't control what
>>>>> happens to the memory outside KVM_RUN (and of course it doesn't control
>>>>> devices doing DMA).  You need to talk to QEMU in order to do this.
>>>>
>>>> Maybe add a new exit reason (eg. KVM_EXIT_PAUSE) and have qemu wait on
>>>> the already opened file descriptor to /dev/kvm for an event?
>>>
>>> Nope.  QEMU might be running and writing to memory in another thread.  I
>>> don't see how this can be reliable on other hypervisors too, actually.
>>
>> I assume it largely depends on knowing what's possible to do and what
>> not with the guest memory even while the vCPU-s are suspended. The
>> price of breaking this rule will be something any KVMI user will have
>> to be very aware of.
>
> If you actually pause the whole VM (through QEMU's monitor commands
> "stop" and "cont") everything should be safe.  Of course there can be
> bugs and PCI passthrough devices should be problematic, but in general
> the device emulation is quiescent.  This however is not the case when
> only the VCPUs are paused.

IMHO for some use-cases it is sufficient to have the guest itself be
limited in the modifications it makes to memory. So for example if
just a vCPU is paused there are areas of memory that you can interact
with without having to worry about it changing underneath the
introspecting application (ie. thread-specific datastructures like the
KPCR, etc..). If the introspecting application needs access to areas
that non-paused vCPUs may touch, or QEMU, or a pass-through device,
then it should be a decision for the introspecting app whether to
pause the VM completely. It may still choose to instead do some
error-detection on reads/writes to detect inconsistent accesses and
perhaps just re-try the operation till it succeeds. This may have less
of an impact on the performance of the VM as no full VM pause had to
be performed. It is all very application specific, so having options
is always a good thing.

Tamas

  reply	other threads:[~2017-08-01 16:33 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 [this message]
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
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='CABfawh=nSA13MoSYtrnY21tp07kvsMe1wo8TYwEs5nFVUNJssQ@mail.gmail.com' \
    --to=tamas.k.lengyel@gmail.com \
    --cc=alazar@bitdefender.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kvm@vger.kernel.org \
    --cc=mdontu@bitdefender.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=stefanha@redhat.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;
as well as URLs for NNTP newsgroup(s).