All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Brendan Dolan-Gavitt <bdolangavitt@wesleyan.edu>
Cc: KVM list <kvm@vger.kernel.org>
Subject: Re: Monitoring access to a guest page?
Date: Thu, 06 Nov 2008 17:56:19 +0200	[thread overview]
Message-ID: <491313A3.40006@redhat.com> (raw)
In-Reply-To: <BB03DA83-82FD-423E-87E1-6AD5CE226819@wesleyan.edu>

Brendan Dolan-Gavitt wrote:
> Hi,
>
> I'm working on a patch to let me monitor reads and writes to a 
> particular guest page. The overall strategy is:
> 1. Mark the guest page as non-present.
> 2. In the PF handler, if the access is to the monitored page, log, and 
> emulate the instruction.
>
> When I asked about this in #kvm, some kind folks pointed out that this 
> is how MMIO is handled. So after looking through the MMIO code, the 
> new plan is:
> 1. Create a new MMIO handler (a kvm_io_device) that will shadow a 
> guest page.
> 2. Copy the page to be monitored from the guest and store it in the 
> private region of the new IO device. (using kvm_read_guest). 
> Basically, create a shadow copy of the page.
> 3. Mark the page as non-present.
> 4. Register the IO device, have its in_range check whether the address 
> is in the page being watched.
> 5. In the IO device's read/write handler, service reads and writes 
> from the shadow copy, and log.
>
> So I have two questions:
> 1. Does this all seem reasonably correct?
> 2. What's the best way to accomplish step 3? I can't seem to find a 
> function in mmu.c that will do this, but it seems overly complicated 
> to use kvm_guest_write to modify the PTE by hand.

It's the other way round.  All pages are not-present unless made present 
by the mmu.

All you have to do is _not_ register a memory slot that contains your 
page.  When the guest accesses this memory, the mmu will _not_ 
instantiate a present pte, and will forward all accesses to your mmio 
handler.

It's going to be slow, though.

-- 
error compiling committee.c: too many arguments to function


      reply	other threads:[~2008-11-06 15:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-03  3:03 Monitoring access to a guest page? Brendan Dolan-Gavitt
2008-11-06 15:56 ` Avi Kivity [this message]

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=491313A3.40006@redhat.com \
    --to=avi@redhat.com \
    --cc=bdolangavitt@wesleyan.edu \
    --cc=kvm@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.