Skip to content

Commit

Permalink
[PATCH] x86_64: Reject SRAT tables that don't cover all memory
Browse files Browse the repository at this point in the history
Broken BIOS on Iwill 8way systems reports these and it causes the bootmem
allocator to crash. Add a sanity check if all the PXMs in the
SRAT table cover all memory as reported by e820. If the sanity
check fails the SRAT is rejected and the code will fall back
to discover the NUMA topology using the K8 northbridge registers
when applicable.

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Andi Kleen authored and Linus Torvalds committed Jan 12, 2006
1 parent 95833c8 commit 8a6fdd3
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions arch/x86_64/mm/srat.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/topology.h>
#include <asm/proto.h>
#include <asm/numa.h>
#include <asm/e820.h>

static struct acpi_table_slit *acpi_slit;

Expand Down Expand Up @@ -196,12 +197,39 @@ acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma)
nd->start, nd->end);
}

/* Sanity check to catch more bad SRATs (they are amazingly common).
Make sure the PXMs cover all memory. */
static int nodes_cover_memory(void)
{
int i;
unsigned long pxmram, e820ram;

pxmram = 0;
for_each_node_mask(i, nodes_parsed) {
unsigned long s = nodes[i].start >> PAGE_SHIFT;
unsigned long e = nodes[i].end >> PAGE_SHIFT;
pxmram += e - s;
pxmram -= e820_hole_size(s, e);
}

e820ram = end_pfn - e820_hole_size(0, end_pfn);
if (pxmram < e820ram) {
printk(KERN_ERR
"SRAT: PXMs only cover %luMB of your %luMB e820 RAM. Not used.\n",
(pxmram << PAGE_SHIFT) >> 20,
(e820ram << PAGE_SHIFT) >> 20);
return 0;
}
return 1;
}

void __init acpi_numa_arch_fixup(void) {}

/* Use the information discovered above to actually set up the nodes. */
int __init acpi_scan_nodes(unsigned long start, unsigned long end)
{
int i;

if (acpi_numa <= 0)
return -1;

Expand All @@ -212,6 +240,11 @@ int __init acpi_scan_nodes(unsigned long start, unsigned long end)
node_clear(i, nodes_parsed);
}

if (!nodes_cover_memory()) {
bad_srat();
return -1;
}

memnode_shift = compute_hash_shift(nodes, nodes_weight(nodes_parsed));
if (memnode_shift < 0) {
printk(KERN_ERR
Expand Down

0 comments on commit 8a6fdd3

Please sign in to comment.