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

[Xen-changelog] [xen master] xen/arm: p2m: Restrict usage of get_page_from_gva to the current vCPU



commit 74412ede07a756678f4c3324154a023cdcaf8f52
Author:     Julien Grall <julien.grall@xxxxxxx>
AuthorDate: Wed Jul 20 17:10:45 2016 +0100
Commit:     Stefano Stabellini <sstabellini@xxxxxxxxxx>
CommitDate: Thu Jul 21 18:27:06 2016 -0700

    xen/arm: p2m: Restrict usage of get_page_from_gva to the current vCPU
    
    The function get_page_from_gva translates a guest virtual address to a
    machine address. The translation involves the register VTTBR_EL2,
    TTBR0_EL1, TTBR1_EL1 and SCTLR_EL1.
    
    Currently, only the first register is context switch is the current
    domain is not the same. This will result to use the wrong TTBR*_EL1 and
    SCTLR_EL1 for the translation.
    
    To fix the code properly, we would have to context switch all the
    registers mentioned above when the vCPU in parameter is not the current
    one. Similar things would need to be done in the callee
    p2m_mem_check_and_get_page.
    
    Given that the only caller of this function with the vCPU that may not
    be current is a guest debugging function (show_guest_stack), restrict
    the usage to the current vCPU for the time being.
    
    Signed-off-by: Julien Grall <julien.grall@xxxxxxx>
    Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
---
 xen/arch/arm/p2m.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 1111d6f..64d84cc 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1530,24 +1530,16 @@ struct page_info *get_page_from_gva(struct vcpu *v, 
vaddr_t va,
     paddr_t maddr = 0;
     int rc;
 
-    spin_lock(&p2m->lock);
-
-    if ( unlikely(d != current->domain) )
-    {
-        unsigned long irq_flags;
-
-        local_irq_save(irq_flags);
-        p2m_load_VTTBR(d);
+    /*
+     * XXX: To support a different vCPU, we would need to load the
+     * VTTBR_EL2, TTBR0_EL1, TTBR1_EL1 and SCTLR_EL1
+     */
+    if ( v != current )
+        return NULL;
 
-        rc = gvirt_to_maddr(va, &maddr, flags);
+    spin_lock(&p2m->lock);
 
-        p2m_load_VTTBR(current->domain);
-        local_irq_restore(irq_flags);
-    }
-    else
-    {
-        rc = gvirt_to_maddr(va, &maddr, flags);
-    }
+    rc = gvirt_to_maddr(va, &maddr, flags);
 
     if ( rc )
         goto err;
--
generated by git-patchbot for /home/xen/git/xen.git#master

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

 


Rackspace

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