Merge tag 'v3.10.69' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm64 / kernel / setup.c
index 268f504664fb2143601e2414435c7084a0d7c592..21ad76b0495f99895e3f111022f2e52dba373121 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/memblock.h>
 #include <linux/of_fdt.h>
 #include <linux/of_platform.h>
+#include <linux/personality.h>
 
 #include <asm/cputype.h>
 #include <asm/elf.h>
@@ -109,7 +110,20 @@ void __init early_print(const char *str, ...)
        printk("%s", buf);
 }
 
-void __init smp_setup_processor_id(void)
+struct cpuinfo_arm64 {
+       struct cpu      cpu;
+       u32             reg_midr;
+};
+
+static DEFINE_PER_CPU(struct cpuinfo_arm64, cpu_data);
+
+void cpuinfo_store_cpu(void)
+{
+       struct cpuinfo_arm64 *info = this_cpu_ptr(&cpu_data);
+       info->reg_midr = read_cpuid_id();
+}
+
+static void __init setup_processor(void)
 {
        /*
         * clear __my_cpu_offset on boot CPU to avoid hang caused by
@@ -250,6 +264,8 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys)
        struct boot_param_header *devtree;
        unsigned long dt_root;
 
+       cpuinfo_store_cpu();
+
        /* Check we have a non-NULL DT pointer */
        if (!dt_phys) {
                early_print("\n"
@@ -416,14 +432,12 @@ static int __init arm64_device_init(void)
 }
 arch_initcall_sync(arm64_device_init);
 
-static DEFINE_PER_CPU(struct cpu, cpu_data);
-
 static int __init topology_init(void)
 {
        int i;
 
        for_each_possible_cpu(i) {
-               struct cpu *cpu = &per_cpu(cpu_data, i);
+               struct cpu *cpu = &per_cpu(cpu_data.cpu, i);
                cpu->hotpluggable = 1;
                register_cpu(cpu, i);
        }
@@ -444,14 +458,41 @@ static const char *hwcap_str[] = {
        NULL
 };
 
+#ifdef CONFIG_COMPAT
+static const char *compat_hwcap_str[] = {
+       "swp",
+       "half",
+       "thumb",
+       "26bit",
+       "fastmult",
+       "fpa",
+       "vfp",
+       "edsp",
+       "java",
+       "iwmmxt",
+       "crunch",
+       "thumbee",
+       "neon",
+       "vfpv3",
+       "vfpv3d16",
+       "tls",
+       "vfpv4",
+       "idiva",
+       "idivt",
+       "vfpd32",
+       "lpae",
+       "evtstrm"
+};
+#endif /* CONFIG_COMPAT */
+
 static int c_show(struct seq_file *m, void *v)
 {
-       int i;
-
-       seq_printf(m, "Processor\t: %s rev %d (%s)\n",
-                  cpu_name, read_cpuid_id() & 15, ELF_PLATFORM);
+       int i, j;
 
        for_each_online_cpu(i) {
+               struct cpuinfo_arm64 *cpuinfo = &per_cpu(cpu_data, i);
+               u32 midr = cpuinfo->reg_midr;
+
                /*
                 * glibc reads /proc/cpuinfo to determine the number of
                 * online processors, looking for lines beginning with
@@ -460,38 +501,36 @@ static int c_show(struct seq_file *m, void *v)
 #ifdef CONFIG_SMP
                seq_printf(m, "processor\t: %d\n", i);
 #endif
-               seq_printf(m, "BogoMIPS\t: %lu.%02lu\n\n",
+               seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
                           loops_per_jiffy / (500000UL/HZ),
                           loops_per_jiffy / (5000UL/HZ) % 100);
-       }
 
-       /* dump out the processor features */
-       seq_puts(m, "Features\t: ");
-
-       for (i = 0; hwcap_str[i]; i++)
-               if (elf_hwcap & (1 << i))
-                       seq_printf(m, "%s ", hwcap_str[i]);
-#ifdef CONFIG_ARMV7_COMPAT_CPUINFO
-       if (is_compat_task()) {
-               /* Print out the non-optional ARMv8 HW capabilities */
-               seq_printf(m, "wp half thumb fastmult vfp edsp neon vfpv3 tlsi ");
-               seq_printf(m, "vfpv4 idiva idivt ");
-       }
-#endif
-
-       seq_printf(m, "\nCPU implementer\t: 0x%02x\n", read_cpuid_id() >> 24);
-       seq_printf(m, "CPU architecture: %s\n",
-#if IS_ENABLED(CONFIG_ARMV7_COMPAT_CPUINFO)
-                       is_compat_task() ? "8" :
-#endif
-                       "AArch64");
-       seq_printf(m, "CPU variant\t: 0x%x\n", (read_cpuid_id() >> 20) & 15);
-       seq_printf(m, "CPU part\t: 0x%03x\n", (read_cpuid_id() >> 4) & 0xfff);
-       seq_printf(m, "CPU revision\t: %d\n", read_cpuid_id() & 15);
-
-       seq_puts(m, "\n");
+               /*
+                * Dump out the common processor features in a single line.
+                * Userspace should read the hwcaps with getauxval(AT_HWCAP)
+                * rather than attempting to parse this, but there's a body of
+                * software which does already (at least for 32-bit).
+                */
+               seq_puts(m, "Features\t:");
+               if (personality(current->personality) == PER_LINUX32) {
+#ifdef CONFIG_COMPAT
+                       for (j = 0; compat_hwcap_str[j]; j++)
+                               if (COMPAT_ELF_HWCAP & (1 << j))
+                                       seq_printf(m, " %s", compat_hwcap_str[j]);
+#endif /* CONFIG_COMPAT */
+               } else {
+                       for (j = 0; hwcap_str[j]; j++)
+                               if (elf_hwcap & (1 << j))
+                                       seq_printf(m, " %s", hwcap_str[j]);
+               }
+               seq_puts(m, "\n");
 
-       seq_printf(m, "Hardware\t: %s\n", machine_name);
+               seq_printf(m, "CPU implementer\t: 0x%02x\n", (midr >> 24));
+               seq_printf(m, "CPU architecture: 8\n");
+               seq_printf(m, "CPU variant\t: 0x%x\n", ((midr >> 20) & 0xf));
+               seq_printf(m, "CPU part\t: 0x%03x\n", ((midr >> 4) & 0xfff));
+               seq_printf(m, "CPU revision\t: %d\n\n", (midr & 0xf));
+       }
 
        return 0;
 }