]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
xen/arm: p2m: Provide an helper to generate the VTTBR
authorJulien Grall <julien.grall@arm.com>
Mon, 28 Jan 2019 11:50:21 +0000 (11:50 +0000)
committerStefano Stabellini <sstabellini@kernel.org>
Tue, 29 Jan 2019 00:53:17 +0000 (16:53 -0800)
A follow-up patch will need to generate the VTTBR in a few places.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Andrii Anisov <andrii_anisov@epam.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/p2m.c

index 059a39157a39f109c57aa731f6e752c27b02a62b..38bfa9964f641e83e4e1f3ef7f382514f03734b1 100644 (file)
@@ -41,6 +41,11 @@ static const paddr_t level_masks[] =
 static const uint8_t level_orders[] =
     { ZEROETH_ORDER, FIRST_ORDER, SECOND_ORDER, THIRD_ORDER };
 
+static uint64_t generate_vttbr(uint16_t vmid, mfn_t root_mfn)
+{
+    return (mfn_to_maddr(root_mfn) | ((uint64_t)vmid << 48));
+}
+
 /* Unlock the flush and do a P2M TLB flush if necessary */
 void p2m_write_unlock(struct p2m_domain *p2m)
 {
@@ -1364,7 +1369,7 @@ static int p2m_alloc_table(struct domain *d)
 
     p2m->root = page;
 
-    p2m->vttbr = page_to_maddr(p2m->root) | ((uint64_t)p2m->vmid << 48);
+    p2m->vttbr = generate_vttbr(p2m->vmid, page_to_mfn(p2m->root));
 
     /*
      * Make sure that all TLBs corresponding to the new VMID are flushed