diff options
-rw-r--r-- | arch/i386/kernel/cpu/mtrr/main.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/arch/i386/kernel/cpu/mtrr/main.c b/arch/i386/kernel/cpu/mtrr/main.c index e1c2042b9b7e..d66b09e0c820 100644 --- a/arch/i386/kernel/cpu/mtrr/main.c +++ b/arch/i386/kernel/cpu/mtrr/main.c | |||
@@ -375,6 +375,19 @@ int mtrr_add_page(unsigned long base, unsigned long size, | |||
375 | return error; | 375 | return error; |
376 | } | 376 | } |
377 | 377 | ||
378 | static int mtrr_check(unsigned long base, unsigned long size) | ||
379 | { | ||
380 | if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) { | ||
381 | printk(KERN_WARNING | ||
382 | "mtrr: size and base must be multiples of 4 kiB\n"); | ||
383 | printk(KERN_DEBUG | ||
384 | "mtrr: size: 0x%lx base: 0x%lx\n", size, base); | ||
385 | dump_stack(); | ||
386 | return -1; | ||
387 | } | ||
388 | return 0; | ||
389 | } | ||
390 | |||
378 | /** | 391 | /** |
379 | * mtrr_add - Add a memory type region | 392 | * mtrr_add - Add a memory type region |
380 | * @base: Physical base address of region | 393 | * @base: Physical base address of region |
@@ -415,11 +428,8 @@ int | |||
415 | mtrr_add(unsigned long base, unsigned long size, unsigned int type, | 428 | mtrr_add(unsigned long base, unsigned long size, unsigned int type, |
416 | char increment) | 429 | char increment) |
417 | { | 430 | { |
418 | if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) { | 431 | if (mtrr_check(base, size)) |
419 | printk(KERN_WARNING "mtrr: size and base must be multiples of 4 kiB\n"); | ||
420 | printk(KERN_DEBUG "mtrr: size: 0x%lx base: 0x%lx\n", size, base); | ||
421 | return -EINVAL; | 432 | return -EINVAL; |
422 | } | ||
423 | return mtrr_add_page(base >> PAGE_SHIFT, size >> PAGE_SHIFT, type, | 433 | return mtrr_add_page(base >> PAGE_SHIFT, size >> PAGE_SHIFT, type, |
424 | increment); | 434 | increment); |
425 | } | 435 | } |
@@ -511,11 +521,8 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size) | |||
511 | int | 521 | int |
512 | mtrr_del(int reg, unsigned long base, unsigned long size) | 522 | mtrr_del(int reg, unsigned long base, unsigned long size) |
513 | { | 523 | { |
514 | if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) { | 524 | if (mtrr_check(base, size)) |
515 | printk(KERN_INFO "mtrr: size and base must be multiples of 4 kiB\n"); | ||
516 | printk(KERN_DEBUG "mtrr: size: 0x%lx base: 0x%lx\n", size, base); | ||
517 | return -EINVAL; | 525 | return -EINVAL; |
518 | } | ||
519 | return mtrr_del_page(reg, base >> PAGE_SHIFT, size >> PAGE_SHIFT); | 526 | return mtrr_del_page(reg, base >> PAGE_SHIFT, size >> PAGE_SHIFT); |
520 | } | 527 | } |
521 | 528 | ||