Consolidate the mtrr sanity checking, add a dump_stack(). Signed-off-by: Andrew Morton --- 25-akpm/arch/i386/kernel/cpu/mtrr/main.c | 23 +++++++++++++++-------- 1 files changed, 15 insertions(+), 8 deletions(-) diff -puN arch/i386/kernel/cpu/mtrr/main.c~mtrr-size-and-base-debug arch/i386/kernel/cpu/mtrr/main.c --- 25/arch/i386/kernel/cpu/mtrr/main.c~mtrr-size-and-base-debug 2005-03-10 19:09:04.000000000 -0800 +++ 25-akpm/arch/i386/kernel/cpu/mtrr/main.c 2005-03-10 19:09:04.000000000 -0800 @@ -371,6 +371,19 @@ int mtrr_add_page(unsigned long base, un 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 * @base: Physical base address of region @@ -411,11 +424,8 @@ int mtrr_add(unsigned long base, unsigned long size, unsigned int type, char increment) { - 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); + if (mtrr_check(base, size)) return -EINVAL; - } return mtrr_add_page(base >> PAGE_SHIFT, size >> PAGE_SHIFT, type, increment); } @@ -507,11 +517,8 @@ int mtrr_del_page(int reg, unsigned long int mtrr_del(int reg, unsigned long base, unsigned long size) { - if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) { - 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); + if (mtrr_check(base, size)) return -EINVAL; - } return mtrr_del_page(reg, base >> PAGE_SHIFT, size >> PAGE_SHIFT); } _