xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: xen-devel@lists.xen.org
Cc: Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH 11/38] arm: implement p2m lookup
Date: Fri, 1 Jun 2012 15:39:40 +0000	[thread overview]
Message-ID: <1338565207-2888-11-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1338565207-2888-1-git-send-email-ian.campbell@citrix.com>

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
 xen/arch/arm/p2m.c        |   71 ++++++++++++++++++++++++++++++++++++++++++--
 xen/include/asm-arm/p2m.h |    3 ++
 2 files changed, 70 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 095e608..9b40e93 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -10,10 +10,20 @@ void dump_p2m_lookup(struct domain *d, paddr_t addr)
     struct p2m_domain *p2m = &d->arch.p2m;
     lpae_t *first = NULL, *second = NULL, *third = NULL;
 
-    printk("dom%d IPA %#016llx\n", d->domain_id, addr);
+    printk("dom%d IPA %#"PRIpaddr"\n", d->domain_id, addr);
+
+    printk("P2M @ %p mfn:%#lx (%#03llx,%#03llx,%#03llx)\n",
+           p2m->first_level,
+           page_to_mfn(p2m->first_level),
+           first_table_offset(addr),
+           second_table_offset(addr),
+           third_table_offset(addr));
+
+    if ( first_table_offset(addr) >= LPAE_ENTRIES )
+        goto done;
 
     first = __map_domain_page(p2m->first_level);
-    printk("1ST[%#03llx] = %#016llx\n",
+    printk("1ST[%#03llx] = %#"PRIpaddr"\n",
            first_table_offset(addr),
            first[first_table_offset(addr)].bits);
     if ( !first[first_table_offset(addr)].p2m.valid ||
@@ -21,7 +31,7 @@ void dump_p2m_lookup(struct domain *d, paddr_t addr)
         goto done;
 
     second = map_domain_page(first[first_table_offset(addr)].p2m.base);
-    printk("2ND[%#03llx] = %#016llx\n",
+    printk("2ND[%#03llx] = %#"PRIpaddr"\n",
            second_table_offset(addr),
            second[second_table_offset(addr)].bits);
     if ( !second[second_table_offset(addr)].p2m.valid ||
@@ -29,7 +39,7 @@ void dump_p2m_lookup(struct domain *d, paddr_t addr)
         goto done;
 
     third = map_domain_page(second[second_table_offset(addr)].p2m.base);
-    printk("3RD[%#03llx] = %#016llx\n",
+    printk("3RD[%#03llx] = %#"PRIpaddr"\n",
            third_table_offset(addr),
            third[third_table_offset(addr)].bits);
 
@@ -51,6 +61,59 @@ void p2m_load_VTTBR(struct domain *d)
     isb(); /* Ensure update is visible */
 }
 
+/*
+ * Lookup the MFN corresponding to a domain's PFN.
+ *
+ * There are no processor functions to do a stage 2 only lookup therefore we
+ * do a a software walk.
+ */
+paddr_t p2m_lookup(struct domain *d, paddr_t paddr)
+{
+    struct p2m_domain *p2m = &d->arch.p2m;
+    lpae_t pte, *first = NULL, *second = NULL, *third = NULL;
+    paddr_t maddr = INVALID_PADDR;
+
+    spin_lock(&p2m->lock);
+
+    first = __map_domain_page(p2m->first_level);
+    if ( !first[first_table_offset(paddr)].p2m.valid )
+        goto done_err;
+    if ( !first[first_table_offset(paddr)].p2m.table )
+    {
+        pte = first[first_table_offset(paddr)];
+        goto done;
+    }
+
+    second = map_domain_page(first[first_table_offset(paddr)].p2m.base);
+    if ( !second[second_table_offset(paddr)].p2m.valid )
+        goto done_err;
+    if ( !second[second_table_offset(paddr)].p2m.table )
+    {
+        pte = second[second_table_offset(paddr)];
+        goto done;
+    }
+
+    third = map_domain_page(second[second_table_offset(paddr)].p2m.base);
+    if ( !third[third_table_offset(paddr)].p2m.valid )
+        goto done_err;
+    if ( !third[third_table_offset(paddr)].p2m.table )
+        goto done_err;
+
+    pte = third[third_table_offset(paddr)];
+
+done:
+
+    maddr = (pte.bits & PADDR_MASK & PAGE_MASK) | (paddr & ~PAGE_MASK);
+done_err:
+    if (third) unmap_domain_page(third);
+    if (second) unmap_domain_page(second);
+    if (first) unmap_domain_page(first);
+
+    spin_unlock(&p2m->lock);
+
+    return maddr;
+}
+
 int guest_physmap_mark_populate_on_demand(struct domain *d,
                                           unsigned long gfn,
                                           unsigned int order)
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index 349923a..1afd5cb 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -32,6 +32,9 @@ int p2m_alloc_table(struct domain *d);
 /* */
 void p2m_load_VTTBR(struct domain *d);
 
+/* */
+paddr_t p2m_lookup(struct domain *d, paddr_t gpfn);
+
 /* Setup p2m RAM mapping for domain d from start-end. */
 int p2m_populate_ram(struct domain *d, paddr_t start, paddr_t end);
 /* Map MMIO regions in the p2m: start_gaddr and end_gaddr is the range
-- 
1.7.9.1

  parent reply	other threads:[~2012-06-01 15:39 UTC|newest]

Thread overview: 136+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-01 15:38 [PATCH 0/38] arm: boot a dom1 to "Calibrating delay loop" then hang Ian Campbell
2012-06-01 15:39 ` [PATCH 01/38] arm: allocate top level p2m page for all non-idle domains Ian Campbell
2012-06-01 15:39   ` [PATCH 02/38] arm: handy function to print a walk of the hypervisor page tables Ian Campbell
2012-06-07  8:45     ` Tim Deegan
2012-06-07 11:57       ` Ian Campbell
2012-06-07 12:39         ` Tim Deegan
2012-06-01 15:39   ` [PATCH 03/38] arm: handy function to print a walk of a domain's p2m Ian Campbell
2012-06-07  8:49     ` Tim Deegan
2012-06-07 12:26       ` Ian Campbell
2012-06-07 12:40         ` Tim Deegan
2012-06-07 13:54           ` Ian Campbell
2012-06-07 16:34             ` Ian Campbell
2012-06-07 16:39               ` Ian Campbell
2012-06-07 19:10               ` Tim Deegan
2012-06-01 15:39   ` [PATCH 04/38] arm: correct and expand TLB flush CP15 registers Ian Campbell
2012-06-06 12:45     ` Stefano Stabellini
2012-06-01 15:39   ` [PATCH 05/38] arm: restore stack on return from trap Ian Campbell
2012-06-06 13:03     ` Stefano Stabellini
2012-06-01 15:39   ` [PATCH 06/38] arm: enable interrupts while handling traps Ian Campbell
2012-06-06 13:38     ` Stefano Stabellini
2012-06-01 15:39   ` [PATCH 07/38] arm: hook up domctl and memory_op Ian Campbell
2012-06-06 13:39     ` Stefano Stabellini
2012-06-01 15:39   ` [PATCH 08/38] arm: allocate and setup a guest vcpu Ian Campbell
2012-06-06 13:46     ` Stefano Stabellini
2012-06-06 13:55       ` Ian Campbell
2012-06-07  9:40         ` Ian Campbell
2012-06-07 17:02           ` Ian Campbell
2012-06-08 10:00             ` Stefano Stabellini
2012-06-01 15:39   ` [PATCH 09/38] arm: print domid as part of debug trap Ian Campbell
2012-06-06 13:47     ` Stefano Stabellini
2012-06-01 15:39   ` [PATCH 10/38] arm: remove unnecessarily verbose print from p2m_load_VTTBR Ian Campbell
2012-06-06 13:47     ` Stefano Stabellini
2012-06-01 15:39   ` Ian Campbell [this message]
2012-06-06 14:01     ` [PATCH 11/38] arm: implement p2m lookup Stefano Stabellini
2012-06-06 14:30       ` Ian Campbell
2012-06-13 13:40         ` Ian Campbell
2012-06-07  9:03     ` Tim Deegan
2012-06-13 15:13       ` Ian Campbell
2012-06-14  8:47         ` Tim Deegan
2012-06-19  9:43           ` Ian Campbell
2012-06-01 15:39   ` [PATCH 12/38] arm: remove hard tabs from init_idle_domain Ian Campbell
2012-06-06 15:13     ` Stefano Stabellini
2012-06-01 15:39   ` [PATCH 13/38] arm: stub out sync_vcpu_execstate Ian Campbell
2012-06-06 15:15     ` Stefano Stabellini
2012-06-01 15:39   ` [PATCH 14/38] arm: do not set max_vcpus = 8 in arch_domain_create Ian Campbell
2012-06-06 15:26     ` Stefano Stabellini
2012-06-06 15:29       ` Ian Campbell
2012-06-07 16:57       ` Ian Campbell
2012-06-07 16:59         ` Stefano Stabellini
2012-06-01 15:39   ` [PATCH 15/38] arm: implement stub version of flush_tlb_mask Ian Campbell
2012-06-06 15:27     ` Stefano Stabellini
2012-06-01 15:39   ` [PATCH 16/38] arm: Add simple cpu_{sibling,core}_mask Ian Campbell
2012-06-06 16:13     ` [PATCH 16/38] arm: Add simple cpu_{sibling, core}_mask Stefano Stabellini
2012-06-07  9:08     ` Tim Deegan
2012-06-07 11:35       ` Ian Campbell
2012-06-07 11:42         ` Tim Deegan
2012-06-13 15:18         ` Ian Campbell
2012-06-01 15:39   ` [PATCH 17/38] arm: allow p2m to be created with specific MATTR Ian Campbell
2012-06-06 16:27     ` Stefano Stabellini
2012-06-13 15:33       ` Ian Campbell
2012-06-01 15:39   ` [PATCH 18/38] arm: implement vpl011 (UART) emulator Ian Campbell
2012-06-06 16:57     ` Stefano Stabellini
2012-06-07  9:29     ` Tim Deegan
2012-06-07  9:34       ` Ian Campbell
2012-06-07 10:18         ` Tim Deegan
2012-06-20 13:37           ` Ian Campbell
2012-06-01 15:39   ` [PATCH 19/38] arm: context switch a bunch of guest state Ian Campbell
2012-06-05 17:11     ` Stefano Stabellini
2012-06-06 15:19       ` Ian Campbell
2012-06-06 15:20         ` Stefano Stabellini
2012-06-01 15:39   ` [PATCH 20/38] arm: dump a page table walk when va_to_par fails Ian Campbell
2012-06-07  9:32     ` Tim Deegan
2012-06-01 15:39   ` [PATCH 21/38] arm: dump guest s1 walk on data abort which is not a stage 2 issue Ian Campbell
2012-06-07  9:41     ` Tim Deegan
2012-06-20 13:48       ` Ian Campbell
2012-06-01 15:39   ` [PATCH 22/38] arm: implement vcpu_show_execution_state Ian Campbell
2012-06-06 17:26     ` Stefano Stabellini
2012-06-20 13:53       ` Ian Campbell
2012-06-20 13:56         ` Ian Campbell
2012-06-01 15:39   ` [PATCH 23/38] arm: use correct attributes for mappings in copy_from_paddr() Ian Campbell
2012-06-01 16:20     ` David Vrabel
2012-06-06 17:38     ` Stefano Stabellini
2012-06-20 15:38       ` Ian Campbell
2012-06-01 15:39   ` [PATCH 24/38] arm: map fixmaps non-executable Ian Campbell
2012-06-06 17:40     ` Stefano Stabellini
2012-06-01 15:39   ` [PATCH 25/38] arm: remove old identity map of boot paddr when we are done with it Ian Campbell
2012-06-06 18:04     ` Stefano Stabellini
2012-06-06 18:18       ` Tim Deegan
2012-06-21  8:15         ` Ian Campbell
2012-06-21  9:26           ` Ian Campbell
2012-06-01 15:39   ` [PATCH 26/38] arm: fix locking in create_p2m_entries Ian Campbell
2012-06-07  9:48     ` Tim Deegan
2012-06-07 10:26     ` Stefano Stabellini
2012-06-01 15:39   ` [PATCH 27/38] arm: split pending SPIs (global) out from pending PPIs and SGIs (per CPU) Ian Campbell
2012-06-07 10:35     ` Stefano Stabellini
2012-06-26  9:03       ` Ian Campbell
2012-06-01 15:39   ` [PATCH 28/38] arm: map GICV in all domains, not just dom0 Ian Campbell
2012-06-07  9:51     ` Tim Deegan
2012-06-26  9:25       ` Ian Campbell
2012-06-07 10:39     ` Stefano Stabellini
2012-06-26 10:18     ` Ian Campbell
2012-06-01 15:39   ` [PATCH 29/38] arm: delay enabling data-cache until paging enabled Ian Campbell
2012-06-01 17:05     ` Tim Deegan
2012-06-01 19:04       ` Ian Campbell
2012-06-07 13:59         ` Tim Deegan
2012-06-26  9:30           ` Ian Campbell
2012-06-07 10:41     ` Stefano Stabellini
2012-06-01 15:39   ` [PATCH 30/38] arm: Upgrade guest barriers to Outer-Shareable. Enable Protected Table Walk Ian Campbell
2012-06-07 10:20     ` Tim Deegan
2012-06-01 15:40   ` [PATCH 31/38] arm: gic.lock can be taken in interrupt context, so lock appropriately Ian Campbell
2012-06-07 10:20     ` Tim Deegan
2012-06-07 10:49     ` Stefano Stabellini
2012-06-26  9:35       ` Ian Campbell
2012-06-26 11:41         ` Stefano Stabellini
2012-06-26 12:25           ` Ian Campbell
2012-06-26 13:45             ` Ian Campbell
2012-06-01 15:40   ` [PATCH 32/38] arm: context switch virtual timer registers Ian Campbell
2012-06-07 10:21     ` Tim Deegan
2012-06-01 15:40   ` [PATCH 33/38] arm: the hyp timer seems to work now, default to using it Ian Campbell
2012-06-07 10:22     ` Tim Deegan
2012-06-01 15:40   ` [PATCH 34/38] HACK: arm: initial XENMAPSPACE_gmfn_foreign Ian Campbell
2012-06-07 10:56     ` Stefano Stabellini
2012-06-01 15:40   ` [PATCH 35/38] arm: move PSR flag definitions into interface, for tools use Ian Campbell
2012-06-07 10:23     ` Tim Deegan
2012-06-01 15:40   ` [PATCH 36/38] libxc: add ARM support to xc_dom (PV domain building) Ian Campbell
2012-06-07 11:38     ` Stefano Stabellini
2012-07-23 13:57       ` Ian Campbell
2012-07-23 14:11         ` Ian Campbell
2012-07-23 14:37           ` David Vrabel
2012-07-23 14:47             ` Ian Campbell
2012-06-01 15:40   ` [PATCH 37/38] HACK: add simple xcbuild Ian Campbell
2012-06-07 11:42     ` Stefano Stabellini
2012-06-07 12:06       ` Ian Campbell
2012-06-01 15:40   ` [PATCH 38/38] HACK: arm: disable hypercall continuations Ian Campbell
2012-06-07 11:00     ` Stefano Stabellini
2012-06-01 16:46 ` [PATCH 0/38] arm: boot a dom1 to "Calibrating delay loop" then hang Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1338565207-2888-11-git-send-email-ian.campbell@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).