aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64/kernel/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/kernel/setup.c')
-rw-r--r--arch/x86_64/kernel/setup.c118
1 files changed, 56 insertions, 62 deletions
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index 238f73e1a834..750e01dcbdf4 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -60,6 +60,7 @@
60#include <asm/setup.h> 60#include <asm/setup.h>
61#include <asm/mach_apic.h> 61#include <asm/mach_apic.h>
62#include <asm/numa.h> 62#include <asm/numa.h>
63#include <asm/sections.h>
63 64
64/* 65/*
65 * Machine setup.. 66 * Machine setup..
@@ -103,7 +104,6 @@ struct edid_info edid_info;
103struct e820map e820; 104struct e820map e820;
104 105
105extern int root_mountflags; 106extern int root_mountflags;
106extern char _text, _etext, _edata, _end;
107 107
108char command_line[COMMAND_LINE_SIZE]; 108char command_line[COMMAND_LINE_SIZE];
109 109
@@ -412,7 +412,6 @@ contig_initmem_init(unsigned long start_pfn, unsigned long end_pfn)
412{ 412{
413 unsigned long bootmap_size, bootmap; 413 unsigned long bootmap_size, bootmap;
414 414
415 memory_present(0, start_pfn, end_pfn);
416 bootmap_size = bootmem_bootmap_pages(end_pfn)<<PAGE_SHIFT; 415 bootmap_size = bootmem_bootmap_pages(end_pfn)<<PAGE_SHIFT;
417 bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT, bootmap_size); 416 bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT, bootmap_size);
418 if (bootmap == -1L) 417 if (bootmap == -1L)
@@ -571,6 +570,8 @@ void __init setup_arch(char **cmdline_p)
571 570
572 init_memory_mapping(0, (end_pfn_map << PAGE_SHIFT)); 571 init_memory_mapping(0, (end_pfn_map << PAGE_SHIFT));
573 572
573 zap_low_mappings(0);
574
574#ifdef CONFIG_ACPI 575#ifdef CONFIG_ACPI
575 /* 576 /*
576 * Initialize the ACPI boot-time table parser (gets the RSDP and SDT). 577 * Initialize the ACPI boot-time table parser (gets the RSDP and SDT).
@@ -657,8 +658,6 @@ void __init setup_arch(char **cmdline_p)
657 } 658 }
658#endif 659#endif
659 660
660 sparse_init();
661
662 paging_init(); 661 paging_init();
663 662
664 check_ioapic(); 663 check_ioapic();
@@ -793,7 +792,7 @@ static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
793#endif 792#endif
794 793
795 bits = 0; 794 bits = 0;
796 while ((1 << bits) < c->x86_num_cores) 795 while ((1 << bits) < c->x86_max_cores)
797 bits++; 796 bits++;
798 797
799 /* Low order bits define the core id (index of core in socket) */ 798 /* Low order bits define the core id (index of core in socket) */
@@ -823,16 +822,14 @@ static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
823 if (!node_online(node)) 822 if (!node_online(node))
824 node = nearby_node(apicid); 823 node = nearby_node(apicid);
825 } 824 }
826 cpu_to_node[cpu] = node; 825 numa_set_node(cpu, node);
827 826
828 printk(KERN_INFO "CPU %d(%d) -> Node %d -> Core %d\n", 827 printk(KERN_INFO "CPU %d(%d) -> Node %d -> Core %d\n",
829 cpu, c->x86_num_cores, node, cpu_core_id[cpu]); 828 cpu, c->x86_max_cores, node, cpu_core_id[cpu]);
830#endif 829#endif
831#endif 830#endif
832} 831}
833 832
834#define HWCR 0xc0010015
835
836static int __init init_amd(struct cpuinfo_x86 *c) 833static int __init init_amd(struct cpuinfo_x86 *c)
837{ 834{
838 int r; 835 int r;
@@ -841,14 +838,18 @@ static int __init init_amd(struct cpuinfo_x86 *c)
841#ifdef CONFIG_SMP 838#ifdef CONFIG_SMP
842 unsigned long value; 839 unsigned long value;
843 840
844 // Disable TLB flush filter by setting HWCR.FFDIS: 841 /*
845 // bit 6 of msr C001_0015 842 * Disable TLB flush filter by setting HWCR.FFDIS on K8
846 // 843 * bit 6 of msr C001_0015
847 // Errata 63 for SH-B3 steppings 844 *
848 // Errata 122 for all(?) steppings 845 * Errata 63 for SH-B3 steppings
849 rdmsrl(HWCR, value); 846 * Errata 122 for all steppings (F+ have it disabled by default)
850 value |= 1 << 6; 847 */
851 wrmsrl(HWCR, value); 848 if (c->x86 == 15) {
849 rdmsrl(MSR_K8_HWCR, value);
850 value |= 1 << 6;
851 wrmsrl(MSR_K8_HWCR, value);
852 }
852#endif 853#endif
853 854
854 /* Bit 31 in normal CPUID used for nonstandard 3DNow ID; 855 /* Bit 31 in normal CPUID used for nonstandard 3DNow ID;
@@ -873,9 +874,9 @@ static int __init init_amd(struct cpuinfo_x86 *c)
873 display_cacheinfo(c); 874 display_cacheinfo(c);
874 875
875 if (c->extended_cpuid_level >= 0x80000008) { 876 if (c->extended_cpuid_level >= 0x80000008) {
876 c->x86_num_cores = (cpuid_ecx(0x80000008) & 0xff) + 1; 877 c->x86_max_cores = (cpuid_ecx(0x80000008) & 0xff) + 1;
877 if (c->x86_num_cores & (c->x86_num_cores - 1)) 878 if (c->x86_max_cores & (c->x86_max_cores - 1))
878 c->x86_num_cores = 1; 879 c->x86_max_cores = 1;
879 880
880 amd_detect_cmp(c); 881 amd_detect_cmp(c);
881 } 882 }
@@ -887,54 +888,44 @@ static void __cpuinit detect_ht(struct cpuinfo_x86 *c)
887{ 888{
888#ifdef CONFIG_SMP 889#ifdef CONFIG_SMP
889 u32 eax, ebx, ecx, edx; 890 u32 eax, ebx, ecx, edx;
890 int index_msb, tmp; 891 int index_msb, core_bits;
891 int cpu = smp_processor_id(); 892 int cpu = smp_processor_id();
892 893
894 cpuid(1, &eax, &ebx, &ecx, &edx);
895
896 c->apicid = phys_pkg_id(0);
897
893 if (!cpu_has(c, X86_FEATURE_HT) || cpu_has(c, X86_FEATURE_CMP_LEGACY)) 898 if (!cpu_has(c, X86_FEATURE_HT) || cpu_has(c, X86_FEATURE_CMP_LEGACY))
894 return; 899 return;
895 900
896 cpuid(1, &eax, &ebx, &ecx, &edx);
897 smp_num_siblings = (ebx & 0xff0000) >> 16; 901 smp_num_siblings = (ebx & 0xff0000) >> 16;
898 902
899 if (smp_num_siblings == 1) { 903 if (smp_num_siblings == 1) {
900 printk(KERN_INFO "CPU: Hyper-Threading is disabled\n"); 904 printk(KERN_INFO "CPU: Hyper-Threading is disabled\n");
901 } else if (smp_num_siblings > 1) { 905 } else if (smp_num_siblings > 1 ) {
902 index_msb = 31; 906
903 /*
904 * At this point we only support two siblings per
905 * processor package.
906 */
907 if (smp_num_siblings > NR_CPUS) { 907 if (smp_num_siblings > NR_CPUS) {
908 printk(KERN_WARNING "CPU: Unsupported number of the siblings %d", smp_num_siblings); 908 printk(KERN_WARNING "CPU: Unsupported number of the siblings %d", smp_num_siblings);
909 smp_num_siblings = 1; 909 smp_num_siblings = 1;
910 return; 910 return;
911 } 911 }
912 tmp = smp_num_siblings; 912
913 while ((tmp & 0x80000000 ) == 0) { 913 index_msb = get_count_order(smp_num_siblings);
914 tmp <<=1 ;
915 index_msb--;
916 }
917 if (smp_num_siblings & (smp_num_siblings - 1))
918 index_msb++;
919 phys_proc_id[cpu] = phys_pkg_id(index_msb); 914 phys_proc_id[cpu] = phys_pkg_id(index_msb);
920 915
921 printk(KERN_INFO "CPU: Physical Processor ID: %d\n", 916 printk(KERN_INFO "CPU: Physical Processor ID: %d\n",
922 phys_proc_id[cpu]); 917 phys_proc_id[cpu]);
923 918
924 smp_num_siblings = smp_num_siblings / c->x86_num_cores; 919 smp_num_siblings = smp_num_siblings / c->x86_max_cores;
925 920
926 tmp = smp_num_siblings; 921 index_msb = get_count_order(smp_num_siblings) ;
927 index_msb = 31; 922
928 while ((tmp & 0x80000000) == 0) { 923 core_bits = get_count_order(c->x86_max_cores);
929 tmp <<=1 ;
930 index_msb--;
931 }
932 if (smp_num_siblings & (smp_num_siblings - 1))
933 index_msb++;
934 924
935 cpu_core_id[cpu] = phys_pkg_id(index_msb); 925 cpu_core_id[cpu] = phys_pkg_id(index_msb) &
926 ((1 << core_bits) - 1);
936 927
937 if (c->x86_num_cores > 1) 928 if (c->x86_max_cores > 1)
938 printk(KERN_INFO "CPU: Processor Core ID: %d\n", 929 printk(KERN_INFO "CPU: Processor Core ID: %d\n",
939 cpu_core_id[cpu]); 930 cpu_core_id[cpu]);
940 } 931 }
@@ -965,16 +956,15 @@ static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c)
965static void srat_detect_node(void) 956static void srat_detect_node(void)
966{ 957{
967#ifdef CONFIG_NUMA 958#ifdef CONFIG_NUMA
968 unsigned apicid, node; 959 unsigned node;
969 int cpu = smp_processor_id(); 960 int cpu = smp_processor_id();
970 961
971 /* Don't do the funky fallback heuristics the AMD version employs 962 /* Don't do the funky fallback heuristics the AMD version employs
972 for now. */ 963 for now. */
973 apicid = phys_proc_id[cpu]; 964 node = apicid_to_node[hard_smp_processor_id()];
974 node = apicid_to_node[apicid];
975 if (node == NUMA_NO_NODE) 965 if (node == NUMA_NO_NODE)
976 node = 0; 966 node = 0;
977 cpu_to_node[cpu] = node; 967 numa_set_node(cpu, node);
978 968
979 if (acpi_numa > 0) 969 if (acpi_numa > 0)
980 printk(KERN_INFO "CPU %d -> Node %d\n", cpu, node); 970 printk(KERN_INFO "CPU %d -> Node %d\n", cpu, node);
@@ -992,13 +982,18 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
992 unsigned eax = cpuid_eax(0x80000008); 982 unsigned eax = cpuid_eax(0x80000008);
993 c->x86_virt_bits = (eax >> 8) & 0xff; 983 c->x86_virt_bits = (eax >> 8) & 0xff;
994 c->x86_phys_bits = eax & 0xff; 984 c->x86_phys_bits = eax & 0xff;
985 /* CPUID workaround for Intel 0F34 CPU */
986 if (c->x86_vendor == X86_VENDOR_INTEL &&
987 c->x86 == 0xF && c->x86_model == 0x3 &&
988 c->x86_mask == 0x4)
989 c->x86_phys_bits = 36;
995 } 990 }
996 991
997 if (c->x86 == 15) 992 if (c->x86 == 15)
998 c->x86_cache_alignment = c->x86_clflush_size * 2; 993 c->x86_cache_alignment = c->x86_clflush_size * 2;
999 if (c->x86 >= 15) 994 if (c->x86 >= 15)
1000 set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability); 995 set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability);
1001 c->x86_num_cores = intel_num_cpu_cores(c); 996 c->x86_max_cores = intel_num_cpu_cores(c);
1002 997
1003 srat_detect_node(); 998 srat_detect_node();
1004} 999}
@@ -1036,7 +1031,7 @@ void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c)
1036 c->x86_model_id[0] = '\0'; /* Unset */ 1031 c->x86_model_id[0] = '\0'; /* Unset */
1037 c->x86_clflush_size = 64; 1032 c->x86_clflush_size = 64;
1038 c->x86_cache_alignment = c->x86_clflush_size; 1033 c->x86_cache_alignment = c->x86_clflush_size;
1039 c->x86_num_cores = 1; 1034 c->x86_max_cores = 1;
1040 c->extended_cpuid_level = 0; 1035 c->extended_cpuid_level = 0;
1041 memset(&c->x86_capability, 0, sizeof c->x86_capability); 1036 memset(&c->x86_capability, 0, sizeof c->x86_capability);
1042 1037
@@ -1059,10 +1054,10 @@ void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c)
1059 c->x86 = (tfms >> 8) & 0xf; 1054 c->x86 = (tfms >> 8) & 0xf;
1060 c->x86_model = (tfms >> 4) & 0xf; 1055 c->x86_model = (tfms >> 4) & 0xf;
1061 c->x86_mask = tfms & 0xf; 1056 c->x86_mask = tfms & 0xf;
1062 if (c->x86 == 0xf) { 1057 if (c->x86 == 0xf)
1063 c->x86 += (tfms >> 20) & 0xff; 1058 c->x86 += (tfms >> 20) & 0xff;
1059 if (c->x86 >= 0x6)
1064 c->x86_model += ((tfms >> 16) & 0xF) << 4; 1060 c->x86_model += ((tfms >> 16) & 0xF) << 4;
1065 }
1066 if (c->x86_capability[0] & (1<<19)) 1061 if (c->x86_capability[0] & (1<<19))
1067 c->x86_clflush_size = ((misc >> 8) & 0xff) * 8; 1062 c->x86_clflush_size = ((misc >> 8) & 0xff) * 8;
1068 } else { 1063 } else {
@@ -1212,7 +1207,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
1212 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1207 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1213 1208
1214 /* Intel-defined (#2) */ 1209 /* Intel-defined (#2) */
1215 "pni", NULL, NULL, "monitor", "ds_cpl", NULL, NULL, "est", 1210 "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", NULL, "est",
1216 "tm2", NULL, "cid", NULL, NULL, "cx16", "xtpr", NULL, 1211 "tm2", NULL, "cid", NULL, NULL, "cx16", "xtpr", NULL,
1217 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1212 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1218 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1213 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -1270,13 +1265,12 @@ static int show_cpuinfo(struct seq_file *m, void *v)
1270 seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size); 1265 seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
1271 1266
1272#ifdef CONFIG_SMP 1267#ifdef CONFIG_SMP
1273 if (smp_num_siblings * c->x86_num_cores > 1) { 1268 if (smp_num_siblings * c->x86_max_cores > 1) {
1274 int cpu = c - cpu_data; 1269 int cpu = c - cpu_data;
1275 seq_printf(m, "physical id\t: %d\n", phys_proc_id[cpu]); 1270 seq_printf(m, "physical id\t: %d\n", phys_proc_id[cpu]);
1276 seq_printf(m, "siblings\t: %d\n", 1271 seq_printf(m, "siblings\t: %d\n", cpus_weight(cpu_core_map[cpu]));
1277 c->x86_num_cores * smp_num_siblings);
1278 seq_printf(m, "core id\t\t: %d\n", cpu_core_id[cpu]); 1272 seq_printf(m, "core id\t\t: %d\n", cpu_core_id[cpu]);
1279 seq_printf(m, "cpu cores\t: %d\n", c->x86_num_cores); 1273 seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
1280 } 1274 }
1281#endif 1275#endif
1282 1276