@@ -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;
}
@@ -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;
@@ -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)
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(-)