提交 b684664f 编写于 作者: K Keith Mannthey 提交者: Linus Torvalds

[PATCH] x86_64: Fix overflow in NUMA hash function setup

Signed-off-by: NAndi Kleen <ak@suse.de>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 17158d17
...@@ -36,11 +36,18 @@ int numa_off __initdata; ...@@ -36,11 +36,18 @@ int numa_off __initdata;
int __init compute_hash_shift(struct node *nodes, int numnodes) int __init compute_hash_shift(struct node *nodes, int numnodes)
{ {
int i; int i;
int shift = 24; int shift = 20;
u64 addr; unsigned long addr,maxend=0;
/* When in doubt use brute force. */ for (i = 0; i < numnodes; i++)
while (shift < 48) { if ((nodes[i].start != nodes[i].end) && (nodes[i].end > maxend))
maxend = nodes[i].end;
while ((1UL << shift) < (maxend / NODEMAPSIZE))
shift++;
printk (KERN_DEBUG"Using %d for the hash shift. Max adder is %lx \n",
shift,maxend);
memset(memnodemap,0xff,sizeof(*memnodemap) * NODEMAPSIZE); memset(memnodemap,0xff,sizeof(*memnodemap) * NODEMAPSIZE);
for (i = 0; i < numnodes; i++) { for (i = 0; i < numnodes; i++) {
if (nodes[i].start == nodes[i].end) if (nodes[i].start == nodes[i].end)
...@@ -48,22 +55,17 @@ int __init compute_hash_shift(struct node *nodes, int numnodes) ...@@ -48,22 +55,17 @@ int __init compute_hash_shift(struct node *nodes, int numnodes)
for (addr = nodes[i].start; for (addr = nodes[i].start;
addr < nodes[i].end; addr < nodes[i].end;
addr += (1UL << shift)) { addr += (1UL << shift)) {
if (memnodemap[addr >> shift] != 0xff && if (memnodemap[addr >> shift] != 0xff) {
memnodemap[addr >> shift] != i) {
printk(KERN_INFO printk(KERN_INFO
"node %d shift %d addr %Lx conflict %d\n", "Your memory is not aligned you need to rebuild your kernel "
i, shift, addr, memnodemap[addr>>shift]); "with a bigger NODEMAPSIZE shift=%d adder=%lu\n",
goto next; shift,addr);
return -1;
} }
memnodemap[addr >> shift] = i; memnodemap[addr >> shift] = i;
} }
} }
return shift; return shift;
next:
shift++;
}
memset(memnodemap,0,sizeof(*memnodemap) * NODEMAPSIZE);
return -1;
} }
#ifdef CONFIG_SPARSEMEM #ifdef CONFIG_SPARSEMEM
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册