qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefanos Gerangelos <sgerag@cslab.ece.ntua.gr>
To: kvm@vger.kernel.org
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] kvm ept fault BUG_ON()
Date: Fri, 18 Mar 2016 20:26:22 +0200	[thread overview]
Message-ID: <56EC484E.8070200@cslab.ece.ntua.gr> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 1242 bytes --]

Hi,

apologies if I am not posting to the appropriate list(s).

I am using QEMU-KVM and try to implement a simple character device which
offers mmap() functionality of host device memory to guest userspace.
For this purpose, I have written a dummy guest driver which communicates
with a qemu backend device.

Specifically, the guest driver allocates a page and passes the
associated address to qemu, which then translates it to host virtual
address (cpu_physical_memory_map()). It then calls mmap() with MAP_FIXED
and this host virtual address, which succeeds, and sends back the
response.

The problem arises here, when guest (either in kernespace or in
userspace via remap_pfn_range()) tries to access the relevant address
and faults with EPT. The path goes to handle_ept_violation() in kvm
module and eventually BUG_ON() is triggered at:

virt/kvm/kvm_main.c:1252 (version 3.16):

-- cut here --

pfn = ((addr - vma->vm_start) >> PAGE_SHIFT) +
	vma->vm_pgoff;
BUG_ON(!kvm_is_mmio_pfn(pfn));

-- cut here --

addr == vma->vm_start and pfn is assigned the value of vma->vm_pgoff !!


What am I missing here? Is this scenario invalid? Can you please shed
some light?

Thanks in advance!


--Stefanos


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

                 reply	other threads:[~2016-03-18 19:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=56EC484E.8070200@cslab.ece.ntua.gr \
    --to=sgerag@cslab.ece.ntua.gr \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.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 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).