[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v4 2/3] x86/mem_event: Deliver gla fault EPT violation information



On Intel EPT the exit qualification generated by a violation also includes a 
bit (EPT_GLA_FAULT) which describes the following information:
Set if the access causing the EPT violation is to a guest-physical address that 
is the translation of a linear address. Clear if the access causing the EPT 
violation is to a paging-structure entry as part of a page walk or the update 
of an accessed or dirty bit.

For more information see Table 27-7 in the Intel SDM.

This patch extends the mem_event system to deliver this extra information, 
which could be useful for determining the cause of a violation.

v4: Use new bitmaps to pass information.
v3: Style fixes.
v2: Split gla_fault into fault_in_gpt and fault_gla to be more compatible with 
the AMD implementation.

Signed-off-by: Tamas K Lengyel <tamas.lengyel@xxxxxxxxxxxx>
---
 xen/arch/x86/hvm/vmx/vmx.c     | 5 +++++
 xen/arch/x86/mm/p2m.c          | 7 +++++++
 xen/include/public/mem_event.h | 4 +++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 907115b..45293d4 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2379,6 +2379,11 @@ static void ept_handle_violation(unsigned long 
qualification, paddr_t gpa)
     {
         __vmread(GUEST_LINEAR_ADDRESS, &gla);
         npfec.gla_valid = 1;
+        npfec.have_extra_fault_info = 1;
+        if( qualification & EPT_GLA_FAULT )
+            npfec.extra_fault_info = NPFEC_fault_with_gla;
+        else
+            npfec.extra_fault_info = NPFEC_fault_in_gpt;
     }
     else
         gla = ~0ull;
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 8104dbb..d886a10 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -1405,6 +1405,13 @@ bool_t p2m_mem_access_check(paddr_t gpa, unsigned long 
gla,
         req->offset = gpa & ((1 << PAGE_SHIFT) - 1);
         req->gla_valid = check.gla_valid;
         req->gla = gla;
+        if ( check.have_extra_fault_info )
+        {
+            if ( check.extra_fault_info == P2M_FAULT_WITH_GLA )
+                req->fault_with_gla = 1;
+            else
+                req->fault_in_gpt = 1;
+        }
         req->access_r = check.read_access;
         req->access_w = check.write_access;
         req->access_x = check.insn_fetch;
diff --git a/xen/include/public/mem_event.h b/xen/include/public/mem_event.h
index 3831b41..fc12697 100644
--- a/xen/include/public/mem_event.h
+++ b/xen/include/public/mem_event.h
@@ -62,7 +62,9 @@ typedef struct mem_event_st {
     uint16_t access_w:1;
     uint16_t access_x:1;
     uint16_t gla_valid:1;
-    uint16_t available:12;
+    uint16_t fault_with_gla:1;
+    uint16_t fault_in_gpt:1;
+    uint16_t available:10;
 
     uint16_t reason;
 } mem_event_request_t, mem_event_response_t;
-- 
2.0.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.