diff options
-rw-r--r-- | arch/x86/kernel/cpu/mtrr/main.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c index 1e27b69a7a0e..b6e136f23d3d 100644 --- a/arch/x86/kernel/cpu/mtrr/main.c +++ b/arch/x86/kernel/cpu/mtrr/main.c | |||
@@ -659,7 +659,7 @@ static __init int amd_special_default_mtrr(void) | |||
659 | */ | 659 | */ |
660 | int __init mtrr_trim_uncached_memory(unsigned long end_pfn) | 660 | int __init mtrr_trim_uncached_memory(unsigned long end_pfn) |
661 | { | 661 | { |
662 | unsigned long i, base, size, highest_addr = 0, def, dummy; | 662 | unsigned long i, base, size, highest_pfn = 0, def, dummy; |
663 | mtrr_type type; | 663 | mtrr_type type; |
664 | u64 trim_start, trim_size; | 664 | u64 trim_start, trim_size; |
665 | 665 | ||
@@ -682,28 +682,27 @@ int __init mtrr_trim_uncached_memory(unsigned long end_pfn) | |||
682 | mtrr_if->get(i, &base, &size, &type); | 682 | mtrr_if->get(i, &base, &size, &type); |
683 | if (type != MTRR_TYPE_WRBACK) | 683 | if (type != MTRR_TYPE_WRBACK) |
684 | continue; | 684 | continue; |
685 | base <<= PAGE_SHIFT; | 685 | if (highest_pfn < base + size) |
686 | size <<= PAGE_SHIFT; | 686 | highest_pfn = base + size; |
687 | if (highest_addr < base + size) | ||
688 | highest_addr = base + size; | ||
689 | } | 687 | } |
690 | 688 | ||
691 | /* kvm/qemu doesn't have mtrr set right, don't trim them all */ | 689 | /* kvm/qemu doesn't have mtrr set right, don't trim them all */ |
692 | if (!highest_addr) { | 690 | if (!highest_pfn) { |
693 | printk(KERN_WARNING "WARNING: strange, CPU MTRRs all blank?\n"); | 691 | printk(KERN_WARNING "WARNING: strange, CPU MTRRs all blank?\n"); |
694 | WARN_ON(1); | 692 | WARN_ON(1); |
695 | return 0; | 693 | return 0; |
696 | } | 694 | } |
697 | 695 | ||
698 | if ((highest_addr >> PAGE_SHIFT) < end_pfn) { | 696 | if (highest_pfn < end_pfn) { |
699 | printk(KERN_WARNING "WARNING: BIOS bug: CPU MTRRs don't cover" | 697 | printk(KERN_WARNING "WARNING: BIOS bug: CPU MTRRs don't cover" |
700 | " all of memory, losing %LdMB of RAM.\n", | 698 | " all of memory, losing %luMB of RAM.\n", |
701 | (((u64)end_pfn << PAGE_SHIFT) - highest_addr) >> 20); | 699 | (end_pfn - highest_pfn) >> (20 - PAGE_SHIFT)); |
702 | 700 | ||
703 | WARN_ON(1); | 701 | WARN_ON(1); |
704 | 702 | ||
705 | printk(KERN_INFO "update e820 for mtrr\n"); | 703 | printk(KERN_INFO "update e820 for mtrr\n"); |
706 | trim_start = highest_addr; | 704 | trim_start = highest_pfn; |
705 | trim_start <<= PAGE_SHIFT; | ||
707 | trim_size = end_pfn; | 706 | trim_size = end_pfn; |
708 | trim_size <<= PAGE_SHIFT; | 707 | trim_size <<= PAGE_SHIFT; |
709 | trim_size -= trim_start; | 708 | trim_size -= trim_start; |