From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agzyl-0007Wk-44 for qemu-devel@nongnu.org; Fri, 18 Mar 2016 15:22:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agzyi-0004TA-Ax for qemu-devel@nongnu.org; Fri, 18 Mar 2016 15:22:35 -0400 Received: from ulysses.noc.ntua.gr ([2001:648:2000:de::230]:39098) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agzyh-0004SU-Lr for qemu-devel@nongnu.org; Fri, 18 Mar 2016 15:22:32 -0400 From: Stefanos Gerangelos Message-ID: <56EC484E.8070200@cslab.ece.ntua.gr> Date: Fri, 18 Mar 2016 20:26:22 +0200 MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="n8s7OhhXjqpoHRtKXkN6Ucn8hPbjW7l95" Subject: [Qemu-devel] kvm ept fault BUG_ON() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: kvm@vger.kernel.org Cc: qemu-devel@nongnu.org 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--