From: Stefanos Gerangelos Subject: kvm ept fault BUG_ON() Date: Fri, 18 Mar 2016 20:26:22 +0200 Message-ID: <56EC484E.8070200@cslab.ece.ntua.gr> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="n8s7OhhXjqpoHRtKXkN6Ucn8hPbjW7l95" Cc: qemu-devel@nongnu.org To: kvm@vger.kernel.org Return-path: Received: from ulysses.noc.ntua.gr ([147.102.222.230]:61195 "EHLO ulysses.noc.ntua.gr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755979AbcCRSgN (ORCPT ); Fri, 18 Mar 2016 14:36:13 -0400 Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --n8s7OhhXjqpoHRtKXkN6Ucn8hPbjW7l95 Content-Type: multipart/mixed; boundary="xOrvQPcbh3FdJgsSSPGu0sGd0mDJVu2fg" From: Stefanos Gerangelos To: kvm@vger.kernel.org Cc: qemu-devel@nongnu.org Message-ID: <56EC484E.8070200@cslab.ece.ntua.gr> Subject: kvm ept fault BUG_ON() --xOrvQPcbh3FdJgsSSPGu0sGd0mDJVu2fg Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 =3D ((addr - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff; BUG_ON(!kvm_is_mmio_pfn(pfn)); -- cut here -- addr =3D=3D 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 --xOrvQPcbh3FdJgsSSPGu0sGd0mDJVu2fg-- --n8s7OhhXjqpoHRtKXkN6Ucn8hPbjW7l95 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iQEcBAEBAgAGBQJW7EhOAAoJEDvFaozEhZubcxUH/3+mPkERh3YtPbw48SpDrcqq sdaGGn1KjDLnjp6+ToAlCcQB+zk+qMe2LkvAfRlIHToxR0Olo6gchLV7M0gF/NYI kbpYhRlehOxm9V0YndWe3+DKYhpgWzUplT36lbqgyX57eV6kwFz+oXB29QUM5j+y hdvfRNf/yDsk1rMTw1/u7wicn0apgzR+XQDTj0LKYoipMfUZsAfM/5yXIH3HaWES AdkABts4e47gOdWsLqGP5S4YxBdW6kNKCOf4ePbKXnexwTv4IEWep0NOgA0erfBC QZZ5g4a69gQQ9VHBIKzg3iKXKYiekUXJIKZlnL3UD7hCKZsWQqOu9b/zHsufZGQ= =B0wr -----END PGP SIGNATURE----- --n8s7OhhXjqpoHRtKXkN6Ucn8hPbjW7l95--