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

[Xen-devel] [PATCH] arm/mem_access: properly handle traps caused by no-longer current settings



When mem_access settings change, the active vCPUs may still cause a violation
until the TLB gets flushed. Instead of just reinjecting the violation to the
guest, in this patch we direct the vCPU to retry the access where
appropriate or we crash the domain where the mem_access settings are
corrupted.

Requested-by: Julien Grall <julien.grall@xxxxxxx>
Signed-off-by: Tamas K Lengyel <tamas.lengyel@xxxxxxxxxxxx>
---
Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>
Cc: Julien Grall <julien.grall@xxxxxxx>
---
 xen/arch/arm/p2m.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 40a0b80..a4b6b7b 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1657,8 +1657,26 @@ bool_t p2m_mem_access_check(paddr_t gpa, vaddr_t gla, 
const struct npfec npfec)
         return true;
 
     rc = p2m_get_mem_access(v->domain, _gfn(paddr_to_pfn(gpa)), &xma);
-    if ( rc )
-        return true;
+    switch (rc )
+    {
+    case -ESRCH:
+        /*
+         * If we can't find any mem_access setting for this page then the page
+         * might have just been removed and the event was triggered by no 
longer
+         * valid settings. The vCPU should just retry to get to the proper 
error
+         * path.
+         */
+        return false;
+    case -ERANGE:
+        /*
+         * The mem_access settings are corrupted. Crashing the domain is the
+         * appropriate step in this case.
+         */
+        domain_crash(v->domain);
+        return false;
+    };
+
+    ASSERT(!rc);
 
     /* Now check for mem_access violation. */
     switch ( xma )
@@ -1692,8 +1710,13 @@ bool_t p2m_mem_access_check(paddr_t gpa, vaddr_t gla, 
const struct npfec npfec)
         break;
     }
 
+    /*
+     * If there is no violation found based on the current setting this event
+     * has been triggereded by a setting that is no longer current. The vCPU
+     * should just retry the access in this case.
+     */
     if ( !violation )
-        return true;
+        return false;
 
     /* First, handle rx2rw and n2rwx conversion automatically. */
     if ( npfec.write_access && xma == XENMEM_access_rx2rw )
-- 
2.8.1


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

 


Rackspace

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