提交 c92c6ffd 编写于 作者: A Andrew Morton 提交者: Linus Torvalds

[PATCH] mtrr size-and-base debugging

Consolidate the mtrr sanity checking, add a dump_stack().
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 a3a255e7
...@@ -375,6 +375,19 @@ int mtrr_add_page(unsigned long base, unsigned long size, ...@@ -375,6 +375,19 @@ int mtrr_add_page(unsigned long base, unsigned long size,
return error; return error;
} }
static int mtrr_check(unsigned long base, unsigned long size)
{
if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) {
printk(KERN_WARNING
"mtrr: size and base must be multiples of 4 kiB\n");
printk(KERN_DEBUG
"mtrr: size: 0x%lx base: 0x%lx\n", size, base);
dump_stack();
return -1;
}
return 0;
}
/** /**
* mtrr_add - Add a memory type region * mtrr_add - Add a memory type region
* @base: Physical base address of region * @base: Physical base address of region
...@@ -415,11 +428,8 @@ int ...@@ -415,11 +428,8 @@ int
mtrr_add(unsigned long base, unsigned long size, unsigned int type, mtrr_add(unsigned long base, unsigned long size, unsigned int type,
char increment) char increment)
{ {
if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) { if (mtrr_check(base, size))
printk(KERN_WARNING "mtrr: size and base must be multiples of 4 kiB\n");
printk(KERN_DEBUG "mtrr: size: 0x%lx base: 0x%lx\n", size, base);
return -EINVAL; return -EINVAL;
}
return mtrr_add_page(base >> PAGE_SHIFT, size >> PAGE_SHIFT, type, return mtrr_add_page(base >> PAGE_SHIFT, size >> PAGE_SHIFT, type,
increment); increment);
} }
...@@ -511,11 +521,8 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size) ...@@ -511,11 +521,8 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
int int
mtrr_del(int reg, unsigned long base, unsigned long size) mtrr_del(int reg, unsigned long base, unsigned long size)
{ {
if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) { if (mtrr_check(base, size))
printk(KERN_INFO "mtrr: size and base must be multiples of 4 kiB\n");
printk(KERN_DEBUG "mtrr: size: 0x%lx base: 0x%lx\n", size, base);
return -EINVAL; return -EINVAL;
}
return mtrr_del_page(reg, base >> PAGE_SHIFT, size >> PAGE_SHIFT); return mtrr_del_page(reg, base >> PAGE_SHIFT, size >> PAGE_SHIFT);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册