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

[Xen-changelog] [xen master] xen: add helpers for PDX mask initialisation calculations



commit 333dd94230b21427c9f52fa5b9d844bff1c2ab7c
Author:     Ian Campbell <ian.campbell@xxxxxxxxxx>
AuthorDate: Tue Sep 16 21:01:41 2014 +0100
Commit:     Ian Campbell <ian.campbell@xxxxxxxxxx>
CommitDate: Mon Sep 22 17:02:30 2014 +0100

    xen: add helpers for PDX mask initialisation calculations
    
    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@xxxxxxxxxx>
    Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Julien Grall <julien.grall@xxxxxxxxxx>
---
 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..cf8b9b5 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 __init pdx_init_mask(u64 base_addr)
+{
+       return fill_mask(base_addr - 1);
+}
+
+u64 __init 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)
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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