diff options
author | Yinghai Lu <Yinghai.Lu@Sun.COM> | 2008-01-30 07:33:32 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:33:32 -0500 |
commit | 093af8d7f0ba3c6be1485973508584ef081e9f93 (patch) | |
tree | 0a2db2401e09764e654efafbea60f6d5d6894dcd /arch/x86/kernel/cpu/mtrr | |
parent | 11201e603d28a1cb7a4bb1d65f39e61629c97a28 (diff) |
x86_32: trim memory by updating e820
when MTRRs are not covering the whole e820 table, we need to trim the
RAM and need to update e820.
reuse some code on 64-bit as well.
here need to add early_get_cap and use it in early_cpu_detect, and move
mtrr_bp_init early.
The code successfully trimmed the memory map on Justin's system:
from:
[ 0.000000] BIOS-e820: 0000000100000000 - 000000022c000000 (usable)
to:
[ 0.000000] modified: 0000000100000000 - 0000000228000000 (usable)
[ 0.000000] modified: 0000000228000000 - 000000022c000000 (reserved)
According to Justin it makes quite a difference:
| When I boot the box without any trimming it acts like a 286 or 386,
| takes about 10 minutes to boot (using raptor disks).
Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>
Tested-by: Justin Piszcz <jpiszcz@lucidpixels.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/cpu/mtrr')
-rw-r--r-- | arch/x86/kernel/cpu/mtrr/main.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c index ccd36ed2187b..ac4b6338f3f4 100644 --- a/arch/x86/kernel/cpu/mtrr/main.c +++ b/arch/x86/kernel/cpu/mtrr/main.c | |||
@@ -624,7 +624,6 @@ static struct sysdev_driver mtrr_sysdev_driver = { | |||
624 | .resume = mtrr_restore, | 624 | .resume = mtrr_restore, |
625 | }; | 625 | }; |
626 | 626 | ||
627 | #ifdef CONFIG_X86_64 | ||
628 | static int disable_mtrr_trim; | 627 | static int disable_mtrr_trim; |
629 | 628 | ||
630 | static int __init disable_mtrr_trim_setup(char *str) | 629 | static int __init disable_mtrr_trim_setup(char *str) |
@@ -643,13 +642,10 @@ early_param("disable_mtrr_trim", disable_mtrr_trim_setup); | |||
643 | #define Tom2Enabled (1U << 21) | 642 | #define Tom2Enabled (1U << 21) |
644 | #define Tom2ForceMemTypeWB (1U << 22) | 643 | #define Tom2ForceMemTypeWB (1U << 22) |
645 | 644 | ||
646 | static __init int amd_special_default_mtrr(unsigned long end_pfn) | 645 | static __init int amd_special_default_mtrr(void) |
647 | { | 646 | { |
648 | u32 l, h; | 647 | u32 l, h; |
649 | 648 | ||
650 | /* Doesn't apply to memory < 4GB */ | ||
651 | if (end_pfn <= (0xffffffff >> PAGE_SHIFT)) | ||
652 | return 0; | ||
653 | if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) | 649 | if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) |
654 | return 0; | 650 | return 0; |
655 | if (boot_cpu_data.x86 < 0xf || boot_cpu_data.x86 > 0x11) | 651 | if (boot_cpu_data.x86 < 0xf || boot_cpu_data.x86 > 0x11) |
@@ -687,9 +683,14 @@ int __init mtrr_trim_uncached_memory(unsigned long end_pfn) | |||
687 | * Make sure we only trim uncachable memory on machines that | 683 | * Make sure we only trim uncachable memory on machines that |
688 | * support the Intel MTRR architecture: | 684 | * support the Intel MTRR architecture: |
689 | */ | 685 | */ |
686 | if (!is_cpu(INTEL) || disable_mtrr_trim) | ||
687 | return 0; | ||
690 | rdmsr(MTRRdefType_MSR, def, dummy); | 688 | rdmsr(MTRRdefType_MSR, def, dummy); |
691 | def &= 0xff; | 689 | def &= 0xff; |
692 | if (!is_cpu(INTEL) || disable_mtrr_trim || def != MTRR_TYPE_UNCACHABLE) | 690 | if (def != MTRR_TYPE_UNCACHABLE) |
691 | return 0; | ||
692 | |||
693 | if (amd_special_default_mtrr()) | ||
693 | return 0; | 694 | return 0; |
694 | 695 | ||
695 | /* Find highest cached pfn */ | 696 | /* Find highest cached pfn */ |
@@ -703,8 +704,14 @@ int __init mtrr_trim_uncached_memory(unsigned long end_pfn) | |||
703 | highest_addr = base + size; | 704 | highest_addr = base + size; |
704 | } | 705 | } |
705 | 706 | ||
706 | if (amd_special_default_mtrr(end_pfn)) | 707 | /* kvm/qemu doesn't have mtrr set right, don't trim them all */ |
708 | if (!highest_addr) { | ||
709 | printk(KERN_WARNING "***************\n"); | ||
710 | printk(KERN_WARNING "**** WARNING: likely strange cpu\n"); | ||
711 | printk(KERN_WARNING "**** MTRRs all blank, cpu in qemu?\n"); | ||
712 | printk(KERN_WARNING "***************\n"); | ||
707 | return 0; | 713 | return 0; |
714 | } | ||
708 | 715 | ||
709 | if ((highest_addr >> PAGE_SHIFT) < end_pfn) { | 716 | if ((highest_addr >> PAGE_SHIFT) < end_pfn) { |
710 | printk(KERN_WARNING "***************\n"); | 717 | printk(KERN_WARNING "***************\n"); |
@@ -726,7 +733,6 @@ int __init mtrr_trim_uncached_memory(unsigned long end_pfn) | |||
726 | 733 | ||
727 | return 0; | 734 | return 0; |
728 | } | 735 | } |
729 | #endif | ||
730 | 736 | ||
731 | /** | 737 | /** |
732 | * mtrr_bp_init - initialize mtrrs on the boot CPU | 738 | * mtrr_bp_init - initialize mtrrs on the boot CPU |