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>,
	stefano.stabellini@eu.citrix.com, julien.grall@linaro.org,
	tim@xen.org, Roy Franz <roy.franz@linaro.org>,
	Jan Beulich <jbeulich@suse.com>, Fu Wei <fu.wei@linaro.org>
Subject: [PATCH for-4.5 v3 2/3] xen: add helpers for PDX mask initialisation calculations
Date: Wed, 17 Sep 2014 22:21:02 +0100	[thread overview]
Message-ID: <1410988863-15238-2-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1410988836.23505.65.camel@citrix.com>

I wanted to make fill_mask a public function so I could use it on ARM, but it
was actually easier to think of a (semi) reasonable public name for the users
of it, so that is what I have done.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
---
v3: New patch
---
 xen/arch/x86/srat.c   |   16 +++-------------
 xen/common/pdx.c      |   18 ++++++++++++++++++
 xen/include/xen/pdx.h |    3 +++
 3 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c
index 2b05272..29fc724 100644
--- a/xen/arch/x86/srat.c
+++ b/xen/arch/x86/srat.c
@@ -339,13 +339,6 @@ void __init acpi_numa_arch_fixup(void) {}
 
 static u64 __initdata srat_region_mask;
 
-static u64 __init fill_mask(u64 mask)
-{
-	while (mask & (mask + 1))
-		mask |= mask + 1;
-	return mask;
-}
-
 static int __init srat_parse_region(struct acpi_subtable_header *header,
 				    const unsigned long end)
 {
@@ -366,8 +359,7 @@ static int __init srat_parse_region(struct acpi_subtable_header *header,
 		       ma->base_address, ma->base_address + ma->length - 1);
 
 	srat_region_mask |= ma->base_address |
-			    fill_mask(ma->base_address ^
-				      (ma->base_address + ma->length - 1));
+			    pdx_region_mask(ma->base_address, ma->length);
 
 	return 0;
 }
@@ -381,7 +373,7 @@ void __init srat_parse_regions(u64 addr)
 	    acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat))
 		return;
 
-	srat_region_mask = fill_mask(addr - 1);
+	srat_region_mask = pdx_init_mask(addr);
 	acpi_table_parse_srat(ACPI_SRAT_TYPE_MEMORY_AFFINITY,
 			      srat_parse_region, 0);
 
@@ -389,9 +381,7 @@ void __init srat_parse_regions(u64 addr)
 		if (e820.map[i].type != E820_RAM)
 			continue;
 
-		if (~mask &
-		    fill_mask(e820.map[i].addr ^
-			      (e820.map[i].addr + e820.map[i].size - 1)))
+		if (~mask & pdx_region_mask(e820.map[i].addr, e820.map[i].size))
 			mask = 0;
 	}
 
diff --git a/xen/common/pdx.c b/xen/common/pdx.c
index 11349a7..a9c326f 100644
--- a/xen/common/pdx.c
+++ b/xen/common/pdx.c
@@ -41,6 +41,24 @@ int __mfn_valid(unsigned long mfn)
                            pdx_group_valid));
 }
 
+/* Sets all bits from the most-significant 1-bit down to the LSB */
+static u64 __init fill_mask(u64 mask)
+{
+        while (mask & (mask + 1))
+                mask |= mask + 1;
+        return mask;
+}
+
+u64 pdx_init_mask(u64 base_addr)
+{
+	return fill_mask(base_addr - 1);
+}
+
+u64 pdx_region_mask(u64 base, u64 len)
+{
+	return fill_mask(base ^ (base + len - 1));
+}
+
 void set_pdx_range(unsigned long smfn, unsigned long emfn)
 {
     unsigned long idx, eidx;
diff --git a/xen/include/xen/pdx.h b/xen/include/xen/pdx.h
index 624f04f..18fe8e5 100644
--- a/xen/include/xen/pdx.h
+++ b/xen/include/xen/pdx.h
@@ -13,6 +13,9 @@ extern unsigned long pfn_top_mask, ma_top_mask;
                          (sizeof(*frame_table) & -sizeof(*frame_table)))
 extern unsigned long pdx_group_valid[];
 
+extern u64 pdx_init_mask(u64 base_addr);
+extern u64 pdx_region_mask(u64 base, u64 len);
+
 extern void set_pdx_range(unsigned long smfn, unsigned long emfn);
 
 #define page_to_pdx(pg)  ((pg) - frame_table)
-- 
1.7.10.4

  parent reply	other threads:[~2014-09-17 21:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-17 21:20 [PATCH for-4.5 v3 0/3] Support for sparse physical address space on ARM Ian Campbell
2014-09-17 21:21 ` [PATCH for-4.5 v3 1/3] xen: refactor physical address space compression support into common code Ian Campbell
2014-09-17 21:21 ` Ian Campbell [this message]
2014-09-18 10:03   ` [PATCH for-4.5 v3 2/3] xen: add helpers for PDX mask initialisation calculations Jan Beulich
2014-09-18 19:16   ` Julien Grall
2014-09-22 15:42     ` Ian Campbell
2014-09-22 15:55       ` Julien Grall
2014-09-22 16:28         ` Ian Campbell
2014-09-17 21:21 ` [PATCH for-4.5 v3 3/3] xen: arm: Enable physical address space compression (PDX) on arm Ian Campbell
2014-09-18 19:21   ` Julien Grall
2014-09-18 18:22 ` [PATCH for-4.5 v3 0/3] Support for sparse physical address space on ARM Roy Franz

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=1410988863-15238-2-git-send-email-ian.campbell@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=fu.wei@linaro.org \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@linaro.org \
    --cc=roy.franz@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 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).