Date: Tue, 25 Jun 2013 03:57:28 +0000 (UTC) From: Neel Natu <neel@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r252192 - projects/bhyve_npt_pmap/sys/amd64/amd64 Message-ID: <201306250357.r5P3vS9A053484@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: neel Date: Tue Jun 25 03:57:27 2013 New Revision: 252192 URL: http://svnweb.freebsd.org/changeset/base/252192 Log: vtopte()/vtopde() can never be used to lookup the PTE/PDE associated with a guest physical address since the page tables pointed to by the nested pmap are never installed in the host %cr3. The recursive mapping used by these functions will end up using the page tables associated with the host thread that provides the execution context for the vcpu - which is clearly wrong! Since the user virtual address space is numerically identical to the guest physical address space this restriction can be expressed in terms of VM_MAXUSER_ADDRESS. This is safe because the amd64/pmap code never uses vtopte()/vtopde() for user virtual addresses. Modified: projects/bhyve_npt_pmap/sys/amd64/amd64/pmap.c Modified: projects/bhyve_npt_pmap/sys/amd64/amd64/pmap.c ============================================================================== --- projects/bhyve_npt_pmap/sys/amd64/amd64/pmap.c Tue Jun 25 02:48:36 2013 (r252191) +++ projects/bhyve_npt_pmap/sys/amd64/amd64/pmap.c Tue Jun 25 03:57:27 2013 (r252192) @@ -473,6 +473,8 @@ vtopte(vm_offset_t va) { u_int64_t mask = ((1ul << (NPTEPGSHIFT + NPDEPGSHIFT + NPDPEPGSHIFT + NPML4EPGSHIFT)) - 1); + KASSERT(va >= VM_MAXUSER_ADDRESS, ("vtopte on a uva/gpa 0x%0lx", va)); + return (PTmap + ((va >> PAGE_SHIFT) & mask)); } @@ -481,6 +483,8 @@ vtopde(vm_offset_t va) { u_int64_t mask = ((1ul << (NPDEPGSHIFT + NPDPEPGSHIFT + NPML4EPGSHIFT)) - 1); + KASSERT(va >= VM_MAXUSER_ADDRESS, ("vtopde on a uva/gpa 0x%0lx", va)); + return (PDmap + ((va >> PDRSHIFT) & mask)); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201306250357.r5P3vS9A053484>