All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: xen-devel@lists.xen.org
Cc: julien.grall@linaro.org, tim@xen.org,
	Ian Campbell <ian.campbell@citrix.com>,
	stefano.stabellini@eu.citrix.com
Subject: [PATCH v2 6/8] xen: arm: add some helpers for assessing p2m pte
Date: Wed, 11 Jun 2014 17:40:02 +0100	[thread overview]
Message-ID: <1402504804-29173-6-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1402504640.16332.50.camel@kazak.uk.xensource.com>

Not terribly helpful right now, since they aren't widely used, but makes future
patches easier to read.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
v2: clarify common on p2m_{table,entry}
---
 xen/arch/arm/p2m.c |   21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 8a6d295..2a93ff9 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -14,6 +14,13 @@
 #define P2M_FIRST_ORDER 1
 #define P2M_FIRST_ENTRIES (LPAE_ENTRIES<<P2M_FIRST_ORDER)
 
+#define p2m_valid(pte) ((pte).p2m.valid)
+/* These two can only be used on L0..L2 ptes because L3 mappings set
+ * the table bit and therefore these would return the opposite to what
+ * you would expect. */
+#define p2m_table(pte) (p2m_valid(pte) && (pte).p2m.table)
+#define p2m_entry(pte) (p2m_valid(pte) && !(pte).p2m.table)
+
 void dump_p2m_lookup(struct domain *d, paddr_t addr)
 {
     struct p2m_domain *p2m = &d->arch.p2m;
@@ -139,13 +146,13 @@ paddr_t p2m_lookup(struct domain *d, paddr_t paddr, p2m_type_t *t)
 
     mask = FIRST_MASK;
     pte = first[first_table_offset(paddr)];
-    if ( !pte.p2m.valid || !pte.p2m.table )
+    if ( !p2m_table(pte) )
         goto done;
 
     mask = SECOND_MASK;
     second = map_domain_page(pte.p2m.base);
     pte = second[second_table_offset(paddr)];
-    if ( !pte.p2m.valid || !pte.p2m.table )
+    if ( !p2m_table(pte) )
         goto done;
 
     mask = THIRD_MASK;
@@ -156,11 +163,11 @@ paddr_t p2m_lookup(struct domain *d, paddr_t paddr, p2m_type_t *t)
     pte = third[third_table_offset(paddr)];
 
     /* This bit must be one in the level 3 entry */
-    if ( !pte.p2m.table )
+    if ( !p2m_table(pte) )
         pte.bits = 0;
 
 done:
-    if ( pte.p2m.valid )
+    if ( p2m_valid(pte) )
     {
         ASSERT(pte.p2m.type != p2m_invalid);
         maddr = (pte.bits & PADDR_MASK & mask) | (paddr & ~mask);
@@ -367,7 +374,7 @@ static int apply_p2m_changes(struct domain *d,
             cur_first_page = p2m_first_level_index(addr);
         }
 
-        if ( !first[first_table_offset(addr)].p2m.valid )
+        if ( !p2m_valid(first[first_table_offset(addr)]) )
         {
             if ( !populate )
             {
@@ -384,7 +391,7 @@ static int apply_p2m_changes(struct domain *d,
             }
         }
 
-        BUG_ON(!first[first_table_offset(addr)].p2m.valid);
+        BUG_ON(!p2m_valid(first[first_table_offset(addr)]));
 
         if ( cur_first_offset != first_table_offset(addr) )
         {
@@ -394,7 +401,7 @@ static int apply_p2m_changes(struct domain *d,
         }
         /* else: second already valid */
 
-        if ( !second[second_table_offset(addr)].p2m.valid )
+        if ( !p2m_valid(second[second_table_offset(addr)]) )
         {
             if ( !populate )
             {
-- 
1.7.10.4

  parent reply	other threads:[~2014-06-11 16:40 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-11 16:37 [PATCH v2 0/8] xen: arm: Use super pages in p2m Ian Campbell
2014-06-11 16:39 ` [PATCH v2 1/8] xen: arm: dump vcpu gic info in arch_dump_vcpu_info Ian Campbell
2014-06-11 16:39 ` [PATCH v2 2/8] tools/libxc: pull min/max_t into xc_private.h Ian Campbell
2014-06-11 21:14   ` Julien Grall
2014-06-11 16:39 ` [PATCH v2 3/8] tools: arm: allocate large pages to guests Ian Campbell
2014-06-11 21:26   ` Julien Grall
2014-06-12  7:19     ` Ian Campbell
2014-06-12  8:47       ` Julien Grall
2014-06-11 16:40 ` [PATCH v2 4/8] xen: arm: only put_page for p2m operations which require it Ian Campbell
2014-06-11 21:31   ` Julien Grall
2014-06-12  7:27     ` Ian Campbell
2014-06-11 16:40 ` [PATCH v2 5/8] xen: arm: handle superpage mappings in p2m_lookup Ian Campbell
2014-06-11 16:40 ` Ian Campbell [this message]
2014-06-11 21:39   ` [PATCH v2 6/8] xen: arm: add some helpers for assessing p2m pte Julien Grall
2014-06-12  7:27     ` Ian Campbell
2014-06-11 16:40 ` [PATCH v2 7/8] xen: arm: use superpages in p2m when pages are suitably aligned Ian Campbell
2014-06-11 22:19   ` Julien Grall
2014-06-12  7:30     ` Ian Campbell
2014-06-12  9:00       ` Julien Grall
2014-06-13 14:08         ` Ian Campbell
2014-06-13 17:45           ` Julien Grall
2014-06-16  8:26             ` Jan Beulich
2014-06-16  9:53             ` Ian Campbell
2014-06-12 13:57   ` Stefano Stabellini
2014-06-13 14:15     ` Ian Campbell
2014-06-11 16:40 ` [PATCH v2 8/8] xen: arm: allocate more than one bank for 1:1 domain 0 if needed Ian Campbell
2014-06-11 22:47   ` Julien Grall
2014-06-12  7:31     ` Ian Campbell
2014-06-17 17:58   ` Julien Grall
2014-06-18  8:27     ` Ian Campbell
2014-06-18  9:10       ` Julien Grall
2014-06-18  9:36         ` Ian Campbell
2014-06-12  7:20 ` [PATCH v2 0/8] xen: arm: Use super pages in p2m 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=1402504804-29173-6-git-send-email-ian.campbell@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=julien.grall@linaro.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.