ARM: virt: Add boot-time diagnostics
[firefly-linux-kernel-4.4.55.git] / arch / arm / kernel / setup.c
index e15d83bb4ea378c1316db6a7d705eab30248a98b..04fd01feea86ed82672a406fa5343f6144023875 100644 (file)
@@ -55,6 +55,7 @@
 #include <asm/traps.h>
 #include <asm/unwind.h>
 #include <asm/memblock.h>
+#include <asm/virt.h>
 
 #if defined(CONFIG_DEPRECATED_PARAM_STRUCT)
 #include "compat.h"
@@ -508,7 +509,7 @@ void __init dump_machine_table(void)
                /* can't use cpu_relax() here as it may require MMU setup */;
 }
 
-int __init arm_add_memory(phys_addr_t start, unsigned long size)
+int __init arm_add_memory(phys_addr_t start, phys_addr_t size)
 {
        struct membank *bank = &meminfo.bank[meminfo.nr_banks];
 
@@ -538,7 +539,7 @@ int __init arm_add_memory(phys_addr_t start, unsigned long size)
        }
 #endif
 
-       bank->size = size & PAGE_MASK;
+       bank->size = size & ~(phys_addr_t)(PAGE_SIZE - 1);
 
        /*
         * Check whether this memory region has non-zero size or
@@ -558,7 +559,7 @@ int __init arm_add_memory(phys_addr_t start, unsigned long size)
 static int __init early_mem(char *p)
 {
        static int usermem __initdata = 0;
-       unsigned long size;
+       phys_addr_t size;
        phys_addr_t start;
        char *endp;
 
@@ -937,6 +938,21 @@ static int __init meminfo_cmp(const void *_a, const void *_b)
        return cmp < 0 ? -1 : cmp > 0 ? 1 : 0;
 }
 
+void __init hyp_mode_check(void)
+{
+#ifdef CONFIG_ARM_VIRT_EXT
+       if (is_hyp_mode_available()) {
+               pr_info("CPU: All CPU(s) started in HYP mode.\n");
+               pr_info("CPU: Virtualization extensions available.\n");
+       } else if (is_hyp_mode_mismatched()) {
+               pr_warn("CPU: WARNING: CPU(s) started in wrong/inconsistent modes (primary CPU mode 0x%x)\n",
+                       __boot_cpu_mode & MODE_MASK);
+               pr_warn("CPU: This may indicate a broken bootloader or firmware.\n");
+       } else
+               pr_info("CPU: All CPU(s) started in SVC mode.\n");
+#endif
+}
+
 void __init setup_arch(char **cmdline_p)
 {
        struct machine_desc *mdesc;
@@ -980,6 +996,10 @@ void __init setup_arch(char **cmdline_p)
        if (is_smp())
                smp_init_cpus();
 #endif
+
+       if (!is_smp())
+               hyp_mode_check();
+
        reserve_crashkernel();
 
        tcm_init();