Date: Tue, 23 Jul 2013 05:04:29 +0000 (UTC) From: Neel Natu <neel@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r253561 - in projects/bhyve_npt_pmap/sys/amd64: include vmm/intel Message-ID: <201307230504.r6N54THe067219@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: neel Date: Tue Jul 23 05:04:28 2013 New Revision: 253561 URL: http://svnweb.freebsd.org/changeset/base/253561 Log: Populate the guest physical address's protection bits in the vmexit collateral. Modified: projects/bhyve_npt_pmap/sys/amd64/include/vmm.h projects/bhyve_npt_pmap/sys/amd64/vmm/intel/vmcs.h projects/bhyve_npt_pmap/sys/amd64/vmm/intel/vmx.c Modified: projects/bhyve_npt_pmap/sys/amd64/include/vmm.h ============================================================================== --- projects/bhyve_npt_pmap/sys/amd64/include/vmm.h Tue Jul 23 03:03:17 2013 (r253560) +++ projects/bhyve_npt_pmap/sys/amd64/include/vmm.h Tue Jul 23 05:04:28 2013 (r253561) @@ -275,6 +275,7 @@ struct vm_exit { struct { uint64_t gpa; int fault_type; + int protection; } paging; struct { uint64_t gpa; Modified: projects/bhyve_npt_pmap/sys/amd64/vmm/intel/vmcs.h ============================================================================== --- projects/bhyve_npt_pmap/sys/amd64/vmm/intel/vmcs.h Tue Jul 23 03:03:17 2013 (r253560) +++ projects/bhyve_npt_pmap/sys/amd64/vmm/intel/vmcs.h Tue Jul 23 05:04:28 2013 (r253561) @@ -332,6 +332,9 @@ uint64_t vmcs_read(uint32_t encoding); #define EPT_VIOLATION_DATA_READ (1UL << 0) #define EPT_VIOLATION_DATA_WRITE (1UL << 1) #define EPT_VIOLATION_INST_FETCH (1UL << 2) +#define EPT_VIOLATION_GPA_READABLE (1UL << 3) +#define EPT_VIOLATION_GPA_WRITEABLE (1UL << 4) +#define EPT_VIOLATION_GPA_EXECUTABLE (1UL << 5) #define EPT_VIOLATION_GLA_VALID (1UL << 7) #define EPT_VIOLATION_XLAT_VALID (1UL << 8) Modified: projects/bhyve_npt_pmap/sys/amd64/vmm/intel/vmx.c ============================================================================== --- projects/bhyve_npt_pmap/sys/amd64/vmm/intel/vmx.c Tue Jul 23 03:03:17 2013 (r253560) +++ projects/bhyve_npt_pmap/sys/amd64/vmm/intel/vmx.c Tue Jul 23 05:04:28 2013 (r253561) @@ -1178,18 +1178,33 @@ vmx_emulate_cr_access(struct vmx *vmx, i static int ept_fault_type(uint64_t ept_qual) { - int fault_type = 0; + int fault_type; - if (ept_qual & EPT_VIOLATION_INST_FETCH) - fault_type |= VM_PROT_EXECUTE; - if (ept_qual & EPT_VIOLATION_DATA_READ) - fault_type |= VM_PROT_READ; if (ept_qual & EPT_VIOLATION_DATA_WRITE) - fault_type |= VM_PROT_WRITE; + fault_type = VM_PROT_WRITE; + else if (ept_qual & EPT_VIOLATION_INST_FETCH) + fault_type = VM_PROT_EXECUTE; + else + fault_type= VM_PROT_READ; return (fault_type); } +static int +ept_protection(uint64_t ept_qual) +{ + int prot = 0; + + if (ept_qual & EPT_VIOLATION_GPA_READABLE) + prot |= VM_PROT_READ; + if (ept_qual & EPT_VIOLATION_GPA_WRITEABLE) + prot |= VM_PROT_WRITE; + if (ept_qual & EPT_VIOLATION_GPA_EXECUTABLE) + prot |= VM_PROT_EXECUTE; + + return (prot); +} + static boolean_t ept_emulation_fault(uint64_t ept_qual) { @@ -1342,6 +1357,7 @@ vmx_exit_process(struct vmx *vmx, int vc vmexit->exitcode = VM_EXITCODE_PAGING; vmexit->u.paging.gpa = gpa; vmexit->u.paging.fault_type = ept_fault_type(qual); + vmexit->u.paging.protection = ept_protection(qual); } else if (ept_emulation_fault(qual)) { vmexit->exitcode = VM_EXITCODE_INST_EMUL; vmexit->u.inst_emul.gpa = gpa;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307230504.r6N54THe067219>