ARM: v7 setup function should invalidate L1 cache
Subsystems (14)
PATCH 1/1 ARM: v7 setup function should invalidate L1 cache
All ARMv5 and older CPUs invalidate their caches in the early assembly setup function, prior to enabling the MMU. This is because the L1 cache should not contain any data relevant to the execution of the kernel at this point; all data should have been flushed out to memory.
This requirement should also be true for ARMv6 and ARMv7 CPUs - indeed, these typically do not search their caches when caching is disabled (as it needs to be when the MMU is disabled) so this change should be safe.
ARMv7 allows there to be CPUs which search their caches while caching is disabled, and it's permitted that the cache is uninitialised at boot; for these, the architecture reference manual requires that an implementation specific code sequence is used immediately after reset to ensure that the cache is placed into a sane state. Such functionality is definitely outside the remit of the Linux kernel, and must be done by the SoC's firmware before _any_ CPU gets to the Linux kernel.
Changing the data cache clean+invalidate to a mere invalidate allows us to get rid of a lot of platform specific hacks around this issue for their secondary CPU bringup paths - some of which were buggy.
--- arch/arm/mach-bcm/Makefile | 2 +- arch/arm/mach-bcm/brcmstb.h | 19 ------------------- arch/arm/mach-bcm/headsmp-brcmstb.S | 33 --------------------------------- arch/arm/mach-bcm/platsmp-brcmstb.c | 4 +--- arch/arm/mach-berlin/headsmp.S | 6 ------ arch/arm/mach-berlin/platsmp.c | 3 +-- arch/arm/mach-hisi/Makefile | 2 +- arch/arm/mach-hisi/core.h | 1 - arch/arm/mach-hisi/headsmp.S | 16 ---------------- arch/arm/mach-hisi/platsmp.c | 4 ++-- arch/arm/mach-imx/headsmp.S | 1 - arch/arm/mach-mvebu/headsmp-a9.S | 1 - arch/arm/mach-prima2/headsmp.S | 1 - arch/arm/mach-rockchip/core.h | 1 - arch/arm/mach-rockchip/headsmp.S | 8 -------- arch/arm/mach-rockchip/platsmp.c | 5 ++--- arch/arm/mach-shmobile/common.h | 1 - arch/arm/mach-shmobile/headsmp-scu.S | 4 ++-- arch/arm/mach-shmobile/headsmp.S | 7 ------- arch/arm/mach-shmobile/platsmp-apmu.c | 2 +- arch/arm/mach-socfpga/core.h | 1 - arch/arm/mach-socfpga/headsmp.S | 5 ----- arch/arm/mach-socfpga/platsmp.c | 2 +- arch/arm/mach-tegra/Makefile | 2 +- arch/arm/mach-tegra/headsmp.S | 12 ------------ arch/arm/mach-tegra/reset.c | 2 +- arch/arm/mach-tegra/reset.h | 1 - arch/arm/mach-zynq/common.h | 2 -- arch/arm/mach-zynq/headsmp.S | 5 ----- arch/arm/mach-zynq/platsmp.c | 5 ++--- arch/arm/mm/proc-v7.S | 2 +- 31 files changed, 17 insertions(+), 143 deletions(-) delete mode 100644 arch/arm/mach-bcm/brcmstb.h delete mode 100644 arch/arm/mach-bcm/headsmp-brcmstb.S delete mode 100644 arch/arm/mach-hisi/headsmp.S delete mode 100644 arch/arm/mach-tegra/headsmp.S
arch/arm/mach-bcm/Makefile +1 -1
@@ -43,5 +43,5 @@ obj-$(CONFIG_ARCH_BCM_63XX) := bcm63xx.o ifeq ($(CONFIG_ARCH_BRCMSTB),y) CFLAGS_platsmp-brcmstb.o += -march=armv7-a obj-y += brcmstb.o -obj-$(CONFIG_SMP) += headsmp-brcmstb.o platsmp-brcmstb.o +obj-$(CONFIG_SMP) += platsmp-brcmstb.o endif
arch/arm/mach-bcm/brcmstb.h deleted +0 -19
@@ -1,19 +0,0 @@ -/* -* Copyright (C) 2013-2014 Broadcom Corporation -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License as -* published by the Free Software Foundation version 2. -* -* This program is distributed "as is" WITHOUT ANY WARRANTY of any -* kind, whether express or implied; without even the implied warranty -* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -*/ - -#ifndef __BRCMSTB_H__ -#define __BRCMSTB_H__ - -void brcmstb_secondary_startup (void ); - -#endif /* __BRCMSTB_H__ */
arch/arm/mach-bcm/headsmp-brcmstb.S deleted +0 -33
@@ -1,33 +0,0 @@ -/* - * SMP boot code for secondary CPUs - * Based on arch/arm/mach-tegra/headsmp.S - * - * Copyright (C) 2010 NVIDIA, Inc. - * Copyright (C) 2013-2014 Broadcom Corporation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation version 2. - * - * This program is distributed "as is" WITHOUT ANY WARRANTY of any - * kind, whether express or implied; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include <asm/assembler.h> -#include <linux/linkage.h> -#include <linux/init.h> - - .section ".text.head", "ax" - -ENTRY(brcmstb_secondary_startup) - /* - * Ensure CPU is in a sane state by disabling all IRQs and switching - * into SVC mode. - */ - setmode PSR_I_BIT | PSR_F_BIT | SVC_MODE, r0 - - bl v7_invalidate_l1 - b secondary_startup -ENDPROC(brcmstb_secondary_startup)
arch/arm/mach-bcm/platsmp-brcmstb.c +1 -3
@@ -30,8 +30,6 @@#include <asm/mach-types.h> #include <asm/smp_plat.h> -#include "brcmstb.h" -enum {ZONE_MAN_CLKEN_MASK =BIT (0 ),ZONE_MAN_RESET_CNTL_MASK =BIT (1 ),
@@ -153,7 +151,7 @@ static void brcmstb_cpu_boot(u32 cpu)* Set the reset vector to point to the secondary_startup * routine */ -cpu_set_boot_addr (cpu,virt_to_phys (brcmstb_secondary_startup)); +cpu_set_boot_addr (cpu,virt_to_phys (secondary_startup));/* Unhalt the cpu */ cpu_rst_cfg_set (cpu,0 );
arch/arm/mach-berlin/headsmp.S +0 -6
@@ -12,12 +12,6 @@ #include <linux/init.h> #include <asm/assembler.h> -ENTRY(berlin_secondary_startup) - ARM_BE8(setend be) - bl v7_invalidate_l1 - b secondary_startup -ENDPROC(berlin_secondary_startup) - /* * If the following instruction is set in the reset exception vector, CPUs * will fetch the value of the software reset address vector when being
arch/arm/mach-berlin/platsmp.c +1 -2
@@ -22,7 +22,6 @@#define RESET_VECT 0x00#define SW_RESET_ADDR 0x94 -extern void berlin_secondary_startup (void );extern u32 boot_inst;static void __iomem *cpu_ctrl;
@@ -85,7 +84,7 @@ static void __init berlin_smp_prepare_cpus(unsigned int max_cpus)* Write the secondary startup address into the SW reset address * vector. This is used by boot_inst. */ -writel (virt_to_phys (berlin_secondary_startup), vectors_base +SW_RESET_ADDR ); +writel (virt_to_phys (secondary_startup), vectors_base +SW_RESET_ADDR );iounmap (vectors_base); unmap_scu:
arch/arm/mach-hisi/Makefile +1 -1
@@ -6,4 +6,4 @@ CFLAGS_platmcpm.o := -march=armv7-a obj-y += hisilicon.o obj-$(CONFIG_MCPM) += platmcpm.o -obj-$(CONFIG_SMP) += platsmp.o hotplug.o headsmp.o +obj-$(CONFIG_SMP) += platsmp.o hotplug.o
arch/arm/mach-hisi/core.h +0 -1
@@ -12,7 +12,6 @@ extern void hi3xxx_cpu_die(unsigned int cpu);extern int hi3xxx_cpu_kill (unsigned int cpu);extern void hi3xxx_set_cpu (int cpu,bool enable); -extern void hisi_secondary_startup (void );extern struct smp_operations hix5hd2_smp_ops;extern void hix5hd2_set_cpu (int cpu,bool enable);extern void hix5hd2_cpu_die (unsigned int cpu);
arch/arm/mach-hisi/headsmp.S deleted +0 -16
@@ -1,16 +0,0 @@ -/* - * Copyright (c) 2014 Hisilicon Limited. - * Copyright (c) 2014 Linaro Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ -#include <linux/linkage.h> -#include <linux/init.h> - - __CPUINIT - -ENTRY(hisi_secondary_startup) - bl v7_invalidate_l1 - b secondary_startup
arch/arm/mach-hisi/platsmp.c +2 -2
@@ -118,7 +118,7 @@ static int hix5hd2_boot_secondary(unsigned int cpu, struct task_struct *idle) {phys_addr_t jumpaddr; - jumpaddr =virt_to_phys (hisi_secondary_startup); + jumpaddr =virt_to_phys (secondary_startup);hix5hd2_set_scu_boot_addr (HIX5HD2_BOOT_ADDRESS , jumpaddr);hix5hd2_set_cpu (cpu, true);arch_send_wakeup_ipi_mask (cpumask_of (cpu));
@@ -156,7 +156,7 @@ static int hip01_boot_secondary(unsigned int cpu, struct task_struct *idle)struct device_node *node; - jumpaddr =virt_to_phys (hisi_secondary_startup); + jumpaddr =virt_to_phys (secondary_startup);hip01_set_boot_addr (HIP01_BOOT_ADDRESS , jumpaddr); node =of_find_compatible_node (NULL ,NULL ,"hisilicon,hip01-sysctrl" );
arch/arm/mach-imx/headsmp.S +0 -1
@@ -25,7 +25,6 @@ diag_reg_offset: .endm ENTRY(v7_secondary_startup) - bl v7_invalidate_l1 set_diag_reg b secondary_startup ENDPROC(v7_secondary_startup)
arch/arm/mach-mvebu/headsmp-a9.S +0 -1
@@ -21,7 +21,6 @@ ENTRY(mvebu_cortex_a9_secondary_startup) ARM_BE8(setend be) - bl v7_invalidate_l1 bl armada_38x_scu_power_up b secondary_startup ENDPROC(mvebu_cortex_a9_secondary_startup)
arch/arm/mach-prima2/headsmp.S +0 -1
@@ -15,7 +15,6 @@ * ready for them to initialise. */ ENTRY(sirfsoc_secondary_startup) - bl v7_invalidate_l1 mrc p15, 0, r0, c0, c0, 5 and r0, r0, #15 adr r4, 1f
arch/arm/mach-rockchip/core.h +0 -1
@@ -17,4 +17,3 @@ extern char rockchip_secondary_trampoline;extern char rockchip_secondary_trampoline_end;extern unsigned long rockchip_boot_fn; -extern void rockchip_secondary_startup (void );
arch/arm/mach-rockchip/headsmp.S +0 -8
@@ -15,14 +15,6 @@ #include <linux/linkage.h> #include <linux/init.h> -ENTRY(rockchip_secondary_startup) - mrc p15, 0, r0, c0, c0, 0 @ read main ID register - ldr r1, =0x00000c09 @ Cortex-A9 primary part number - teq r0, r1 - beq v7_invalidate_l1 - b secondary_startup -ENDPROC(rockchip_secondary_startup) - ENTRY(rockchip_secondary_trampoline) ldr pc, 1f ENDPROC(rockchip_secondary_trampoline)
arch/arm/mach-rockchip/platsmp.c +2 -3
@@ -149,8 +149,7 @@ static int __cpuinit rockchip_boot_secondary(unsigned int cpu,* sram_base_addr + 8: start address for pc * */ udelay (10 ); -writel (virt_to_phys (rockchip_secondary_startup), - sram_base_addr +8 ); +writel (virt_to_phys (secondary_startup), sram_base_addr +8 );writel (0xDEADBEAF , sram_base_addr +4 );dsb_sev (); }
@@ -189,7 +188,7 @@ static int __init rockchip_smp_prepare_sram(struct device_node *node) }/* set the boot function for the sram code */ - rockchip_boot_fn =virt_to_phys (rockchip_secondary_startup); + rockchip_boot_fn =virt_to_phys (secondary_startup);/* copy the trampoline to sram, that runs during startup of the core */ memcpy (sram_base_addr, &rockchip_secondary_trampoline, trampoline_sz);
arch/arm/mach-shmobile/common.h +0 -1
@@ -14,7 +14,6 @@ extern void shmobile_smp_sleep(void);extern void shmobile_smp_hook (unsigned int cpu,unsigned long fn,unsigned long arg);extern int shmobile_smp_cpu_disable (unsigned int cpu); -extern void shmobile_invalidate_start (void );extern void shmobile_boot_scu (void );extern void shmobile_smp_scu_prepare_cpus (unsigned int max_cpus);extern void shmobile_smp_scu_cpu_die (unsigned int cpu);
arch/arm/mach-shmobile/headsmp-scu.S +2 -2
@@ -22,7 +22,7 @@ * Boot code for secondary CPUs. * * First we turn on L1 cache coherency for our CPU. Then we jump to - * shmobile_invalidate_start that invalidates the cache and hands over control + * secondary_startup that invalidates the cache and hands over control * to the common ARM startup code. */ ENTRY(shmobile_boot_scu)
@@ -36,7 +36,7 @@ ENTRY(shmobile_boot_scu) bic r2, r2, r3 @ Clear bits of our CPU (Run Mode) str r2, [r0, #8] @ write back - b shmobile_invalidate_start + b secondary_startup ENDPROC(shmobile_boot_scu) .text
arch/arm/mach-shmobile/headsmp.S +0 -7
@@ -16,13 +16,6 @@ #include <asm/assembler.h> #include <asm/memory.h> -#ifdef CONFIG_SMP -ENTRY(shmobile_invalidate_start) - bl v7_invalidate_l1 - b secondary_startup -ENDPROC(shmobile_invalidate_start) -#endif - /* * Reset vector for secondary CPUs. * This will be mapped at address 0 by SBAR register.
arch/arm/mach-shmobile/platsmp-apmu.c +1 -1
@@ -133,7 +133,7 @@ void __init shmobile_smp_apmu_prepare_cpus(unsigned int max_cpus,int shmobile_smp_apmu_boot_secondary (unsigned int cpu,struct task_struct *idle) {/* For this particular CPU register boot vector */ -shmobile_smp_hook (cpu,virt_to_phys (shmobile_invalidate_start),0 ); +shmobile_smp_hook (cpu,virt_to_phys (secondary_startup),0 );return apmu_wrap (cpu, apmu_power_on); }
arch/arm/mach-socfpga/core.h +0 -1
@@ -31,7 +31,6 @@#define RSTMGR_MPUMODRST_CPU1 0x2/* CPU1 Reset */ -extern void socfpga_secondary_startup (void );extern void __iomem *socfpga_scu_base_addr;extern void socfpga_init_clocks (void );
arch/arm/mach-socfpga/headsmp.S +0 -5
@@ -30,8 +30,3 @@ ENTRY(secondary_trampoline) 1: .long . .long socfpga_cpu1start_addr ENTRY(secondary_trampoline_end) - -ENTRY(socfpga_secondary_startup) - bl v7_invalidate_l1 - b secondary_startup -ENDPROC(socfpga_secondary_startup)
arch/arm/mach-socfpga/platsmp.c +1 -1
@@ -40,7 +40,7 @@ static int socfpga_boot_secondary(unsigned int cpu, struct task_struct *idle)memcpy (phys_to_virt (0 ), &secondary_trampoline, trampoline_size); -writel (virt_to_phys (socfpga_secondary_startup), +writel (virt_to_phys (secondary_startup), sys_manager_base_addr + (socfpga_cpu1start_addr &0x000000ff ));flush_cache_all ();
arch/arm/mach-tegra/Makefile +1 -1
@@ -19,7 +19,7 @@ obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += pm-tegra30.o ifeq ($(CONFIG_CPU_IDLE),y) obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += cpuidle-tegra30.o endif -obj-$(CONFIG_SMP) += platsmp.o headsmp.o +obj-$(CONFIG_SMP) += platsmp.o obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o obj-$(CONFIG_ARCH_TEGRA_114_SOC) += sleep-tegra30.o
arch/arm/mach-tegra/headsmp.S deleted +0 -12
@@ -1,12 +0,0 @@ -#include <linux/linkage.h> -#include <linux/init.h> - -#include "sleep.h" - - .section ".text.head", "ax" - -ENTRY(tegra_secondary_startup) - check_cpu_part_num 0xc09, r8, r9 - bleq v7_invalidate_l1 - b secondary_startup -ENDPROC(tegra_secondary_startup)
arch/arm/mach-tegra/reset.c +1 -1
@@ -94,7 +94,7 @@ void __init tegra_cpu_reset_handler_init(void) __tegra_cpu_reset_handler_data[TEGRA_RESET_MASK_PRESENT ] = *((u32 *)cpu_possible_mask); __tegra_cpu_reset_handler_data[TEGRA_RESET_STARTUP_SECONDARY ] = -virt_to_phys ((void *)tegra_secondary_startup); +virt_to_phys ((void *)secondary_startup);#endif #ifdef CONFIG_PM_SLEEP
arch/arm/mach-tegra/reset.h +0 -1
@@ -36,7 +36,6 @@ extern unsigned long __tegra_cpu_reset_handler_data[TEGRA_RESET_DATA_SIZE];void __tegra_cpu_reset_handler_start (void );void __tegra_cpu_reset_handler (void );void __tegra_cpu_reset_handler_end (void ); -void tegra_secondary_startup (void );#ifdef CONFIG_PM_SLEEP #define tegra_cpu_lp1_mask \
arch/arm/mach-zynq/common.h +0 -2
@@ -17,8 +17,6 @@#ifndef __MACH_ZYNQ_COMMON_H__#define __MACH_ZYNQ_COMMON_H__ -void zynq_secondary_startup (void ); -extern int zynq_slcr_init (void );extern int zynq_early_slcr_init (void );extern void zynq_slcr_system_reset (void );
arch/arm/mach-zynq/headsmp.S +0 -5
@@ -22,8 +22,3 @@ zynq_secondary_trampoline_jump: .globl zynq_secondary_trampoline_end zynq_secondary_trampoline_end: ENDPROC(zynq_secondary_trampoline) - -ENTRY(zynq_secondary_startup) - bl v7_invalidate_l1 - b secondary_startup -ENDPROC(zynq_secondary_startup)
arch/arm/mach-zynq/platsmp.c +2 -3
@@ -87,10 +87,9 @@ int zynq_cpun_start(u32 address, int cpu) }EXPORT_SYMBOL (zynq_cpun_start); -static int zynq_boot_secondary (unsigned int cpu, -struct task_struct *idle) +static int zynq_boot_secondary (unsigned int cpu,struct task_struct *idle) { -return zynq_cpun_start (virt_to_phys (zynq_secondary_startup), cpu); +return zynq_cpun_start (virt_to_phys (secondary_startup), cpu); }/*
arch/arm/mm/proc-v7.S +1 -1
@@ -414,7 +414,7 @@ __v7_pj4b_setup: __v7_setup: adr r12, __v7_setup_stack @ the local stack stmia r12, {r0-r5, r7, r9, r11, lr} - bl v7_flush_dcache_louis + bl v7_invalidate_l1 ldmia r12, {r0-r5, r7, r9, r11, lr} and r0, r9, #0xff000000 @ ARM?
Signature · 1 line
2.1.0
Heiko Stuebner
maintainerPATCH 1/1 ARM: v7 setup function should invalidate L1 cache
Hi Russell,
Am Dienstag, 19. Mai 2015, 17:12:56 schrieb Russell King:
Quoted 18 lines
All ARMv5 and older CPUs invalidate their caches in the early assembly setup function, prior to enabling the MMU. This is because the L1 cache should not contain any data relevant to the execution of the kernel at this point; all data should have been flushed out to memory.
This requirement should also be true for ARMv6 and ARMv7 CPUs - indeed, these typically do not search their caches when caching is disabled (as it needs to be when the MMU is disabled) so this change should be safe.
ARMv7 allows there to be CPUs which search their caches while caching is disabled, and it's permitted that the cache is uninitialised at boot; for these, the architecture reference manual requires that an implementation specific code sequence is used immediately after reset to ensure that the cache is placed into a sane state. Such functionality is definitely outside the remit of the Linux kernel, and must be done by the SoC's firmware before _any_ CPU gets to the Linux kernel.
Quoted 5 lines
Changing the data cache clean+invalidate to a mere invalidate allows us to get rid of a lot of platform specific hacks around this issue for their secondary CPU bringup paths - some of which were buggy.
Signed-off-by Russell King <[email protected]>
Michael Niewoehner tested this on a rk3188 (Cortex-A9) and wrote in [0]
Quoted 5 lines
Tested-by Michael Niewoehner <[email protected]>Tested on Radxa Rock Pro with RK3188.
The kernel panics on reboot I had before and also a kernel BUG when running "memtester 1900M" went away and the rock seems to run stable now.
I've also tested the patch on a rk3288-based board, so both supported Rockchip ARM-cores (A9 and A12/A17) seem to run fine with this change.
Rockchip-specific changes
Thanks Heiko
[0] http://lists.infradead.org/pipermail/linux-rockchip/2015-May/003046.html
PATCH 1/1 ARM: v7 setup function should invalidate L1 cache
Quoted 8 lines · On Tuesday 19 May 2015 23:44:58 Heiko Stuebner wrote:
Michael Niewoehner tested this on a rk3188 (Cortex-A9) and wrote in [0]
Quoted 5 lines
Tested-by Michael Niewoehner <[email protected]>Tested on Radxa Rock Pro with RK3188.
The kernel panics on reboot I had before and also a kernel BUG when running "memtester 1900M" went away and the rock seems to run stable now.
We should probably create a separate fix for that and add it to the stable kernels then. I would suggest something like the untested patch below, which takes advantage of the fact that we already have separate assignments for the start_secondary function pointer for A9 and A17.
Arnd
arch/arm/mach-rockchip/headsmp.S +0 -3
@@ -16,9 +16,6 @@ #include <linux/init.h> ENTRY(rockchip_secondary_startup) - mrc p15, 0, r0, c0, c0, 0 @ read main ID register - ldr r1, =0x00000c09 @ Cortex-A9 primary part number - teq r0, r1 beq v7_invalidate_l1 b secondary_startup ENDPROC(rockchip_secondary_startup)
arch/arm/mach-rockchip/platsmp.c +1 -2
@@ -149,8 +149,7 @@ static int __cpuinit rockchip_boot_secondary(unsigned int cpu,* sram_base_addr + 8: start address for pc * */ udelay (10 ); -writel (virt_to_phys (rockchip_secondary_startup), - sram_base_addr +8 ); +writel (virt_to_phys (secondary_startup), sram_base_addr +8 );writel (0xDEADBEAF , sram_base_addr +4 );dsb_sev (); }
PATCH 1/1 ARM: v7 setup function should invalidate L1 cache
Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · On Tuesday 19 May 2015 23:44:58 Heiko Stuebner wrote:
Michael Niewoehner tested this on a rk3188 (Cortex-A9) and wrote in [0]
Quoted 5 lines
Tested-by Michael Niewoehner <[email protected]>Tested on Radxa Rock Pro with RK3188.
The kernel panics on reboot I had before and also a kernel BUG when running "memtester 1900M" went away and the rock seems to run stable now.
Quoted 4 lines
We should probably create a separate fix for that and add it to the stable kernels then. I would suggest something like the untested patch below, which takes advantage of the fact that we already have separate assignments for the
start_secondaryfunction pointer for A9 and A17.
Your patch is also continuing the pattern with this code...
arch/arm/mach-rockchip/headsmp.S line 20
Quoted 13 lines
arch/arm/mach-rockchip/headsmp.S +0
-3@@ -16,9 +16,6 @@ #include <linux/init.h> ENTRY(rockchip_secondary_startup) - mrc p15, 0, r0, c0, c0, 0 @ read main ID register - ldr r1, =0x00000c09 @ Cortex-A9 primary part number - teq r0, r1 beq v7_invalidate_l1 b secondary_startup
If you look carefully at this, you'll notice that it's utter crap. (Sorry, but it is.) It has two problems:
1. It'll never match a Cortex-A9 CPU. Cortex-A9 has a MIDR value of 0x412fc09a, not 0x00000c09. The bit position of the part number field isn't even right.
2. If it does match, then we branch to "v7_invalidate_l1" without setting the link register: we'll never return back here (we'll return to whatever random value the link register contains) and so we'll never make it to secondary_startup. *Thankfully*, because of (1), this branch will never be taken - this is it's saving grace.
Your patch introduces a /third/ form of crapiness:
3. If the PSR happens to have Z=1, the "beq" instruction will be taken, thereby crashing the system because of (2).
The /simplest/ change which would fix this problem is to just change proc-v7.S. The remainder is effectively a cleanup removing redundant code.
Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up according to speedtest.net.
PATCH 1/1 ARM: v7 setup function should invalidate L1 cache
Quoted 7 lines · On Tuesday 19 May 2015 23:07:21 Russell King - ARM Linux wrote:
If you look carefully at this, you'll notice that it's utter crap. (Sorry, but it is.) It has two problems:
1. It'll never match a Cortex-A9 CPU. Cortex-A9 has a MIDR value of
0x412fc09a, not0x00000c09. The bit position of the part number field isn't even right.
Quoted 5 lines
2. If it does match, then we branch to "
v7_invalidate_l1" without setting the link register: we'll never return back here (we'll return to whatever random value the link register contains) and so we'll never make it tosecondary_startup. *Thankfully*, because of (1), this branch will never be taken - this is it's saving grace.
Yes, I've understood both before.
Quoted 4 lines
Your patch introduces a /third/ form of crapiness:
3. If the PSR happens to have Z=1, the "beq" instruction will be taken, thereby crashing the system because of (2).
Right, this was the result of sloppiness on my side when fat-fingering a patch for illustration.
Quoted 3 lines
The /simplest/ change which would fix this problem is to just change
proc-v7.S. The remainder is effectively a cleanup removing redundant code.
Fair enough. I wasn't sure if we're confident enough about that change already to put it into stable backports. If the risk is low enough, that's fine.
Arnd
PATCH 1/1 ARM: v7 setup function should invalidate L1 cache
Quoted 8 lines · Arnd Bergmann
Quoted 3 lines · On Tuesday 19 May 2015 23:07:21 Russell King - ARM Linux wrote:
The /simplest/ change which would fix this problem is to just change
proc-v7.S. The remainder is effectively a cleanup removing redundant code.Fair enough. I wasn't sure if we're confident enough about that change already to put it into stable backports. If the risk is low enough, that's fine.
When the kernel is entered from the decompressor, the last steps just before calling the kernel is to clean and invalidate the caches, then turn them off, and then jump to the kernel.
So, there _should_ be no dirty cache lines which we rely upon at this point - if there was dirty data in the cache, then it hasn't been flushed to memory, and we're potentially going to crash because some part of the decompressed kernel image hasn't been flushed out to memory.
So I'll put a confidence value of 99.999% on this.
The case which might bite people is if they bypass the decompressor. Even then, leaving bits of the kernel image in the caches is really dodgy.
Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up according to speedtest.net.
PATCH 1/1 ARM: v7 setup function should invalidate L1 cache
In reply to Russell KingQuoted 18 lines · Russell King
All ARMv5 and older CPUs invalidate their caches in the early assembly setup function, prior to enabling the MMU. This is because the L1 cache should not contain any data relevant to the execution of the kernel at this point; all data should have been flushed out to memory.
This requirement should also be true for ARMv6 and ARMv7 CPUs - indeed, these typically do not search their caches when caching is disabled (as it needs to be when the MMU is disabled) so this change should be safe.
ARMv7 allows there to be CPUs which search their caches while caching is disabled, and it's permitted that the cache is uninitialised at boot; for these, the architecture reference manual requires that an implementation specific code sequence is used immediately after reset to ensure that the cache is placed into a sane state. Such functionality is definitely outside the remit of the Linux kernel, and must be done by the SoC's firmware before _any_ CPU gets to the Linux kernel.
Quoted 3 lines
Changing the data cache clean+invalidate to a mere invalidate allows us to get rid of a lot of platform specific hacks around this issue for their secondary CPU bringup paths - some of which were buggy.
For brcmstb:
Signature · 1 line
Florian
PATCH 1/1 ARM: v7 setup function should invalidate L1 cache
In reply to Russell KingQuoted 18 lines · Russell King
All ARMv5 and older CPUs invalidate their caches in the early assembly setup function, prior to enabling the MMU. This is because the L1 cache should not contain any data relevant to the execution of the kernel at this point; all data should have been flushed out to memory.
This requirement should also be true for ARMv6 and ARMv7 CPUs - indeed, these typically do not search their caches when caching is disabled (as it needs to be when the MMU is disabled) so this change should be safe.
ARMv7 allows there to be CPUs which search their caches while caching is disabled, and it's permitted that the cache is uninitialised at boot; for these, the architecture reference manual requires that an implementation specific code sequence is used immediately after reset to ensure that the cache is placed into a sane state. Such functionality is definitely outside the remit of the Linux kernel, and must be done by the SoC's firmware before _any_ CPU gets to the Linux kernel.
Quoted 5 lines
Changing the data cache clean+invalidate to a mere invalidate allows us to get rid of a lot of platform specific hacks around this issue for their secondary CPU bringup paths - some of which were buggy.
Signed-off-by Russell King <[email protected]>
For socfpga:
Thanks,
Dinh
Sebastian Hesselbarth
maintainerPATCH 1/1 ARM: v7 setup function should invalidate L1 cache
In reply to Russell KingQuoted 24 lines · Russell King
All ARMv5 and older CPUs invalidate their caches in the early assembly setup function, prior to enabling the MMU. This is because the L1 cache should not contain any data relevant to the execution of the kernel at this point; all data should have been flushed out to memory.
This requirement should also be true for ARMv6 and ARMv7 CPUs - indeed, these typically do not search their caches when caching is disabled (as it needs to be when the MMU is disabled) so this change should be safe.
ARMv7 allows there to be CPUs which search their caches while caching is disabled, and it's permitted that the cache is uninitialised at boot; for these, the architecture reference manual requires that an implementation specific code sequence is used immediately after reset to ensure that the cache is placed into a sane state. Such functionality is definitely outside the remit of the Linux kernel, and must be done by the SoC's firmware before _any_ CPU gets to the Linux kernel.
Changing the data cache clean+invalidate to a mere invalidate allows us to get rid of a lot of platform specific hacks around this issue for their secondary CPU bringup paths - some of which were buggy.
Signed-off-by Russell King <[email protected]>---
[...]
Quoted 2 lines
arch/arm/mach-berlin/headsmp.S | 6 ------ arch/arm/mach-berlin/platsmp.c | 3 +--
For berlin,
Thanks!
PATCH 1/1 ARM: v7 setup function should invalidate L1 cache
In reply to Russell KingQuoted 24 lines · Russell King
All ARMv5 and older CPUs invalidate their caches in the early assembly setup function, prior to enabling the MMU. This is because the L1 cache should not contain any data relevant to the execution of the kernel at this point; all data should have been flushed out to memory.
This requirement should also be true for ARMv6 and ARMv7 CPUs - indeed, these typically do not search their caches when caching is disabled (as it needs to be when the MMU is disabled) so this change should be safe.
ARMv7 allows there to be CPUs which search their caches while caching is disabled, and it's permitted that the cache is uninitialised at boot; for these, the architecture reference manual requires that an implementation specific code sequence is used immediately after reset to ensure that the cache is placed into a sane state. Such functionality is definitely outside the remit of the Linux kernel, and must be done by the SoC's firmware before _any_ CPU gets to the Linux kernel.
Changing the data cache clean+invalidate to a mere invalidate allows us to get rid of a lot of platform specific hacks around this issue for their secondary CPU bringup paths - some of which were buggy.
Signed-off-by Russell King <[email protected]>---
...
Quoted 1 line
arch/arm/mach-imx/headsmp.S | 1 -
PATCH 1/1 ARM: v7 setup function should invalidate L1 cache
In reply to Russell KingQuoted 24 lines · Russell King
All ARMv5 and older CPUs invalidate their caches in the early assembly setup function, prior to enabling the MMU. This is because the L1 cache should not contain any data relevant to the execution of the kernel at this point; all data should have been flushed out to memory.
This requirement should also be true for ARMv6 and ARMv7 CPUs - indeed, these typically do not search their caches when caching is disabled (as it needs to be when the MMU is disabled) so this change should be safe.
ARMv7 allows there to be CPUs which search their caches while caching is disabled, and it's permitted that the cache is uninitialised at boot; for these, the architecture reference manual requires that an implementation specific code sequence is used immediately after reset to ensure that the cache is placed into a sane state. Such functionality is definitely outside the remit of the Linux kernel, and must be done by the SoC's firmware before _any_ CPU gets to the Linux kernel.
Changing the data cache clean+invalidate to a mere invalidate allows us to get rid of a lot of platform specific hacks around this issue for their secondary CPU bringup paths - some of which were buggy.
Signed-off-by Russell King <[email protected]>---
[...]
Quoted 4 lines
arch/arm/mach-tegra/Makefile | 2 +- arch/arm/mach-tegra/headsmp.S | 12 ------------ arch/arm/mach-tegra/reset.c | 2 +- arch/arm/mach-tegra/reset.h | 1 -
[...]
Russell,
I saw a couple of conflicts trying to apply this to v4.1-rc1..v4.1-rc4 or any of recent linux-next versions. I ended up applying this on top of your for-next branch and tested using that. The conflicts seem very minor and a test merge of Tegra's for-next branch resolved this fine. A test merge of next-20150520 shows one conflict in mach-socfpga/core.h, but it's a trivial one to resolve.
Anyway, the patch seems to work fine on TrimSlice (Tegra20), Beaver (Tegra30), Dalmore (Tegra114) and Jetson TK1 (Tegra124). Tested on Paul's boot farm:
Paul, thanks for setting up the boot test infrastructure, this saved me a lot of time.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150521/a52aa9be/attachment-0001.sig>
PATCH 1/1 ARM: v7 setup function should invalidate L1 cache
In reply to Russell KingQuoted 18 lines · Russell King
All ARMv5 and older CPUs invalidate their caches in the early assembly setup function, prior to enabling the MMU. This is because the L1 cache should not contain any data relevant to the execution of the kernel at this point; all data should have been flushed out to memory.
This requirement should also be true for ARMv6 and ARMv7 CPUs - indeed, these typically do not search their caches when caching is disabled (as it needs to be when the MMU is disabled) so this change should be safe.
ARMv7 allows there to be CPUs which search their caches while caching is disabled, and it's permitted that the cache is uninitialised at boot; for these, the architecture reference manual requires that an implementation specific code sequence is used immediately after reset to ensure that the cache is placed into a sane state. Such functionality is definitely outside the remit of the Linux kernel, and must be done by the SoC's firmware before _any_ CPU gets to the Linux kernel.
Quoted 5 lines
Changing the data cache clean+invalidate to a mere invalidate allows us to get rid of a lot of platform specific hacks around this issue for their secondary CPU bringup paths - some of which were buggy.
Signed-off-by Russell King <[email protected]>
For various shmobile:
- sh73a0/kzm9g
- r8a7740/armadillo
- r8a73a4/ape6evm
- r8a7791/koelsch
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
PATCH 1/1 ARM: v7 setup function should invalidate L1 cache
Quoted 26 lines · Geert Uytterhoeven
Quoted 18 lines · Russell King
All ARMv5 and older CPUs invalidate their caches in the early assembly setup function, prior to enabling the MMU. This is because the L1 cache should not contain any data relevant to the execution of the kernel at this point; all data should have been flushed out to memory.
This requirement should also be true for ARMv6 and ARMv7 CPUs - indeed, these typically do not search their caches when caching is disabled (as it needs to be when the MMU is disabled) so this change should be safe.
ARMv7 allows there to be CPUs which search their caches while caching is disabled, and it's permitted that the cache is uninitialised at boot; for these, the architecture reference manual requires that an implementation specific code sequence is used immediately after reset to ensure that the cache is placed into a sane state. Such functionality is definitely outside the remit of the Linux kernel, and must be done by the SoC's firmware before _any_ CPU gets to the Linux kernel.
Quoted 5 lines
Changing the data cache clean+invalidate to a mere invalidate allows us to get rid of a lot of platform specific hacks around this issue for their secondary CPU bringup paths - some of which were buggy.
Signed-off-by Russell King <[email protected]>
Quoted 7 lines
For various shmobile:
- sh73a0/kzm9g
- r8a7740/armadillo
- r8a73a4/ape6evm
- r8a7791/koelschTested-by Geert Uytterhoeven <[email protected]>
FWIW, I have the feeling this has a slight influence on boot reliability on two of my boards:
- r8a7740/armadillo, which is known to suffer from a cache-related bug in its bootloader, seems to have a higher change of booting successfully on cold boot,
- sh73a0/kzm9g, which has known cache-issues with secondary CPU boot up, seems to have a lower chance of booting successfully.
No time to spend all week turning this into a statistical significant test project... The reset button is my friend...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
PATCH 1/1 ARM: v7 setup function should invalidate L1 cache
Quoted 10 lines · Geert Uytterhoeven
FWIW, I have the feeling this has a slight influence on boot reliability on two of my boards:
- r8a7740/armadillo, which is known to suffer from a cache-related bug in its bootloader, seems to have a higher change of booting successfully on cold boot,
- sh73a0/kzm9g, which has known cache-issues with secondary CPU boot up, seems to have a lower chance of booting successfully.No time to spend all week turning this into a statistical significant test project... The reset button is my friend...
Damn it, you sent this right after I merged and pushed out this change in my for-arm-soc branch, and was just about to send it to the arm-soc people. What excellent timing you have. :)
What happens on the kzm9g if you revert the mach-shmobile changes?
For armadillo, do you use the decompressor? That should be doing all the cache cleaning already, prior to the kernel being entered.
Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up according to speedtest.net.
PATCH 1/1 ARM: v7 setup function should invalidate L1 cache
Hi Russell,
Quoted 9 lines · Russell King - ARM Linux
Quoted 8 lines · Geert Uytterhoeven
FWIW, I have the feeling this has a slight influence on boot reliability on two of my boards:
- r8a7740/armadillo, which is known to suffer from a cache-related bug in its bootloader, seems to have a higher change of booting successfully on cold boot,
- sh73a0/kzm9g, which has known cache-issues with secondary CPU boot up, seems to have a lower chance of booting successfully.
Quoted 6 lines
Quoted 2 lines
No time to spend all week turning this into a statistical significant test project... The reset button is my friend...
Damn it, you sent this right after I merged and pushed out this change in my for-arm-soc branch, and was just about to send it to the arm-soc people. What excellent timing you have. :)
Don't worry, I didn't send that email to make you postpone this change. Giving the fuzziness of reproduction, and the flakiness (esp. on Armadillo) of the boot loader, and these are old SoCs, please go ahead.
Quoted 1 line
What happens on the kzm9g if you revert the mach-shmobile changes?
Seems to make no difference.
Quoted 2 lines
For armadillo, do you use the decompressor? That should be doing all the cache cleaning already, prior to the kernel being entered.
I think so.
Corruption pattern ranges from lock up, over "Error: unrecognized/unsupported machine ID", to booting almost completely, but lacking a few devices due to a corrupted DTB. Been like that as long as I remember, i.e. since I got the board ca. 1 year ago. Boots fine (100%) with kexec.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
PATCH 1/1 ARM: v7 setup function should invalidate L1 cache
Quoted 31 lines · Geert Uytterhoeven
Hi Russell,
Quoted 9 lines · Russell King - ARM Linux
Quoted 8 lines · Geert Uytterhoeven
FWIW, I have the feeling this has a slight influence on boot reliability on two of my boards:
- r8a7740/armadillo, which is known to suffer from a cache-related bug in its bootloader, seems to have a higher change of booting successfully on cold boot,
- sh73a0/kzm9g, which has known cache-issues with secondary CPU boot up, seems to have a lower chance of booting successfully.Quoted 6 lines
Quoted 2 lines
No time to spend all week turning this into a statistical significant test project... The reset button is my friend...
Damn it, you sent this right after I merged and pushed out this change in my for-arm-soc branch, and was just about to send it to the arm-soc people. What excellent timing you have. :)
Don't worry, I didn't send that email to make you postpone this change. Giving the fuzziness of reproduction, and the flakiness (esp. on Armadillo) of the boot loader, and these are old SoCs, please go ahead.
Quoted 1 line
What happens on the kzm9g if you revert the mach-shmobile changes?
Seems to make no difference.
Quoted 2 lines
For armadillo, do you use the decompressor? That should be doing all the cache cleaning already, prior to the kernel being entered.
Quoted 7 lines
I think so.
Corruption pattern ranges from lock up, over "Error: unrecognized/unsupported machine ID", to booting almost completely, but lacking a few devices due to a corrupted DTB. Been like that as long as I remember, i.e. since I got the board ca. 1 year ago. Boots fine (100%) with kexec.
It seems like this patch is causing the SoCFPGA to not boot with SMP reliably. About 1 out of every 10 reboots, I'm seeing the boot failure below. The error seems to only happen when I do a cold or warm reboot, but never occurs during a power-up. If I revert this patch, or put back the call to v7_invalidate_l1 in socfpga_secondary_startup , then its able to boot 100% of the time.
Just wondering if anyone else is seeing something similar?
I am testing this on both linux-next and arm-soc/rmk/for-arm-soc. When the failure happens, here's the log:
Booting Linux on physical CPU 0x0
Initializing cgroup subsys cpuset
Linux version 4.1.0-rc8-next-20150617-00002-gdd1f624
(dinguyen at linux-builds1) (gcc version 4.7.3 20130226 (prerelease) (crosstool-NG linaro-1.13.1-4.7-2013.03-20130313 - Linaro GCC 2013.03) ) #1 SMP Wed Jun 17 14:22:59 CDT 2015
CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=10c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache Machine model: Altera SOCFPGA Cyclone V SoC Development Kit Truncating RAM at 0x00000000-0x40000000 to -0x2f800000
Memory policy: Data cache writealloc
On node 0 totalpages: 194560free_area_init_node: node 0, pgdat c0692640, node_mem_map ef20b000
Normal zone: 1520 pages used for memmap
Normal zone: 0 pages reserved
Normal zone: 194560 pages, LIFO batch:31
PERCPU: Embedded 12 pages/cpu @ef1e1000 s19648 r8192 d21312 u49152
pcpu-alloc: s19648 r8192 d21312 u49152 alloc=12*4096
pcpu-alloc: [0] 0 [0] 1
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 193040 Kernel command line: console=ttyS0,115200 root=/dev/mmcblk0p2 rw rootwait ip=dhcp earlyprintk
PID hash table entries: 4096 (order: 2, 16384 bytes)
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes) Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
Memory: 764288K/778240K available (4782K kernel code, 286K rwdata, 1344K rodata, 304K init, 135K bss, 13952K reserved, 0K cma-reserved) Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
vmalloc : 0xf0000000 - 0xff000000 ( 240 MB)
lowmem : 0xc0000000 - 0xef800000 ( 760 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.text : 0xc0008000 - 0xc0603e78 (6128 kB)
.init : 0xc0604000 - 0xc0650000 ( 304 kB)
.data : 0xc0650000 - 0xc0697920 ( 287 kB)
.bss : 0xc0697920 - 0xc06b976c ( 136 kB)SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1 Hierarchical RCU implementation.
Additional per-CPU info printed with stalls.
Build-time adjustment of leaf fanout to 32.
NR_IRQS:16 nr_irqs:16 16
L2C-310 enabling early BRESP for Cortex-A9
L2C-310 full line of zeros enabled for Cortex-A9
L2C-310 dynamic clock gating enabled, standby mode enabled L2C-310 cache controller enabled, 8 ways, 512 kB
L2C-310: CACHE_ID 0x410030c9, AUX_CTRL 0x46060001
clocksource: timer1: mask: 0xffffffff max_cycles: 0xffffffff,max_idle_ns: 19112604467 nssched_clock: 32 bits at 100MHz, resolution 10ns, wraps every 21474836475ns
Console: colour dummy device 80x30
Calibrating delay loop... 1836.64 BogoMIPS (lpj=9183232)pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 2048 (order: 1, 8192 bytes) Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
CPU: Testing write buffer coherency: ok
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x8280 - 0x82d8
CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
Internal error: Oops - undefined instruction: 0 [#1] SMP ARM Modules linked in: CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.1.0-rc8-next-20150617-00002-gdd1f624 #1 Hardware name: Altera SOCFPGA task: eecaeac0 ti: eecce000 task.ti: eecce000 PC is at vfp_notifier+0x58/0x12c LR is at notifier_call_chain+0x44/0x84 pc : [<c000a6bc>] lr : [<c003d134>] psr: 80000193
sp : eeccff48 ip : c06563c8 fp : eeccffd4
r10: eecaef80 r9 : ef1f1300 r8 : 00000002
r7 : eecd0000 r6 : c0656bc0 r5 : 00000000 r4 : eecd0000 r3 : c000a664 r2 : eecd0000 r1 : 00000002 r0 : c06563c8
Flags: Nzcv IRQs off FIQs on Mode SVC_32 ISA ARM Segment kernel
Control: 10c5387d Table: 0000404a DAC: 00000015
Process swapper/1 (pid: 0, stack limit = 0xeecce218)
Stack: (0xeeccff48 to 0xeecd0000)
ff40: c000a664 ffffffff 00000000 c003d134 eecd0018 eecaeac0
ff60: c06648e0 0b52d2f9 c048cfa8 c003d18c 00000000 f0002100 00000001 c003d1ac
ff80: 00000000 eecaeac0 c064f300 c001369c c064b304 c0013140 00000000 ef1ed328
ffa0: eeccffe8 c001e760 c0486ec4 2eba2000 c06957c0 c06524dc 00000015 c06957c0
ffc0: c048c778 c064b304 c06957c0 00000000 eeccffdc c0486ec4 eeccffe4 c0487138
ffe0: 00000001 c00544e8 c0009494 c0697bc0 00000000 000094ac 7ef5bffd 3f39b3f8 [<c000a6bc>] (vfp_notifier) from [<c003d134>] (notifier_call_chain+0x44/0x84) [<c003d134>] (notifier_call_chain) from [<c003d18c>] (__atomic_notifier_call_chain+0x18/0x20)
[<c003d18c>] (__atomic_notifier_call_chain) from [<c003d1ac>] (atomic_notifier_call_chain+0x18/0x20)
[<c003d1ac>] (atomic_notifier_call_chain) from [<c001369c>] (__switch_to+0x34/0x58)
Code: e3a03002 e5843208 e3a00000 e8bd8038 (eef85a10) ---[ end trace 9eaea9661b3b550a ]--- Kernel panic - not syncing: Attempted to kill the idle task! SMP: failed to stop secondary CPUs ---[ end Kernel panic - not syncing: Attempted to kill the idle task!
Dinh
PATCH 1/1 ARM: v7 setup function should invalidate L1 cache
Quoted 40 lines · Dinh Nguyen
Quoted 31 lines · Geert Uytterhoeven
Hi Russell,
Quoted 9 lines · Russell King - ARM Linux
Quoted 8 lines · Geert Uytterhoeven
FWIW, I have the feeling this has a slight influence on boot reliability on two of my boards:
- r8a7740/armadillo, which is known to suffer from a cache-related bug in its bootloader, seems to have a higher change of booting successfully on cold boot,
- sh73a0/kzm9g, which has known cache-issues with secondary CPU boot up, seems to have a lower chance of booting successfully.Quoted 6 lines
Quoted 2 lines
No time to spend all week turning this into a statistical significant test project... The reset button is my friend...
Damn it, you sent this right after I merged and pushed out this change in my for-arm-soc branch, and was just about to send it to the arm-soc people. What excellent timing you have. :)
Don't worry, I didn't send that email to make you postpone this change. Giving the fuzziness of reproduction, and the flakiness (esp. on Armadillo) of the boot loader, and these are old SoCs, please go ahead.
Quoted 1 line
What happens on the kzm9g if you revert the mach-shmobile changes?
Seems to make no difference.
Quoted 2 lines
For armadillo, do you use the decompressor? That should be doing all the cache cleaning already, prior to the kernel being entered.
Quoted 7 lines
I think so.
Corruption pattern ranges from lock up, over "Error: unrecognized/unsupported machine ID", to booting almost completely, but lacking a few devices due to a corrupted DTB. Been like that as long as I remember, i.e. since I got the board ca. 1 year ago. Boots fine (100%) with kexec.
Quoted 6 lines
It seems like this patch is causing the SoCFPGA to not boot with SMP reliably. About 1 out of every 10 reboots, I'm seeing the boot failure below. The error seems to only happen when I do a cold or warm reboot, but never occurs during a power-up. If I revert this patch, or put back the call to
v7_invalidate_l1insocfpga_secondary_startup, then its able to boot 100% of the time.
It really sucks that you're only just testing this change now, because I've frozen my tree, and removing it for the next merge window is going to be an entirely non-trivial matter. You were copied on the original patch, which you failed to test... I can't say I have _much_ sympathy for a bug report at this point in time.
Quoted 8 lines
Internal error: Oops - undefined instruction: 0 [#1] SMP ARM Modules linked in: CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.1.0-rc8-next-20150617-00002-gdd1f624 #1 Hardware name: Altera SOCFPGA task: eecaeac0 ti: eecce000 task.ti: eecce000 PC is at vfp_notifier+0x58/0x12c LR is at notifier_call_chain+0x44/0x84
This suggests that access to the VFP coprocessor is still disabled. However, vfp_hotplug() should have been called for CPU1 before it gets here, which should call vfp_enable(), which should enable access.
However, what I'm wondering is...
Quoted 7 lines
[<
c000a6bc>] (vfp_notifier) from [<c003d134>] (notifier_call_chain+0x44/0x84) [<c003d134>] (notifier_call_chain) from [<c003d18c>] (__atomic_notifier_call_chain+0x18/0x20)
[<c003d18c>] (__atomic_notifier_call_chain) from [<c003d1ac>] (atomic_notifier_call_chain+0x18/0x20)
[<c003d1ac>] (atomic_notifier_call_chain) from [<c001369c>] (__switch_to+0x34/0x58)
what the rest of the trace is. Unfortunately, we mark __switch_to() as "cantunwind" which means the unwinder always stops here. It would be really good to know what is responsible for this scheduling event, whether it's due to a lock which is tried to be taken but is found to be locked, but I don't think we can modify __switch_to() to allow it to unwind (and I don't have the unwinder knowledge to hand to hack something together.)
In order to see what's going on here, we do need to see the rest of the trace... right now I don't have the time to be able to sort out __switch_to() to achieve that.
As I say, you should have tested this earlier. About the only thing I can do now is to revert the entire original patch, which is going to be extremely disruptive as it'll cause yet more conflicts between trees - again, something that we want to be avoiding at this stage in the game.
Please test patches earlier.
Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up according to speedtest.net.
PATCH 1/1 ARM: v7 setup function should invalidate L1 cache
Quoted 48 lines · Russell King - ARM Linux
Quoted 40 lines · Dinh Nguyen
Quoted 31 lines · Geert Uytterhoeven
Hi Russell,
Quoted 9 lines · Russell King - ARM Linux
Quoted 8 lines · Geert Uytterhoeven
FWIW, I have the feeling this has a slight influence on boot reliability on two of my boards:
- r8a7740/armadillo, which is known to suffer from a cache-related bug in its bootloader, seems to have a higher change of booting successfully on cold boot,
- sh73a0/kzm9g, which has known cache-issues with secondary CPU boot up, seems to have a lower chance of booting successfully.Quoted 6 lines
Quoted 2 lines
No time to spend all week turning this into a statistical significant test project... The reset button is my friend...
Damn it, you sent this right after I merged and pushed out this change in my for-arm-soc branch, and was just about to send it to the arm-soc people. What excellent timing you have. :)
Don't worry, I didn't send that email to make you postpone this change. Giving the fuzziness of reproduction, and the flakiness (esp. on Armadillo) of the boot loader, and these are old SoCs, please go ahead.
Quoted 1 line
What happens on the kzm9g if you revert the mach-shmobile changes?
Seems to make no difference.
Quoted 2 lines
For armadillo, do you use the decompressor? That should be doing all the cache cleaning already, prior to the kernel being entered.
Quoted 7 lines
I think so.
Corruption pattern ranges from lock up, over "Error: unrecognized/unsupported machine ID", to booting almost completely, but lacking a few devices due to a corrupted DTB. Been like that as long as I remember, i.e. since I got the board ca. 1 year ago. Boots fine (100%) with kexec.
Quoted 6 lines
It seems like this patch is causing the SoCFPGA to not boot with SMP reliably. About 1 out of every 10 reboots, I'm seeing the boot failure below. The error seems to only happen when I do a cold or warm reboot, but never occurs during a power-up. If I revert this patch, or put back the call to
v7_invalidate_l1insocfpga_secondary_startup, then its able to boot 100% of the time.
Quoted 6 lines
It really sucks that you're only just testing this change now, because I've frozen my tree, and removing it for the next merge window is going to be an entirely non-trivial matter. You were copied on the original patch, which you failed to test... I can't say I have _much_ sympathy for a bug report at this point in time.
I apologize for not catching this error while testing this patch. But I did test it when you first sent it out..I probably didn't do a stress test. Sometimes the reboot fails in the 1st attempt, sometimes it fails in the 9th attempt.
I only caught this error when I was testing my recent changes to use CPU_METHOD_OF_DECLARE.
For me, I don't think you need to revert this patch or anything, but a fix can go in for a -rcX?
Dinh
PATCH 1/1 ARM: v7 setup function should invalidate L1 cache
Quoted 61 lines · Dinh Nguyen
Quoted 48 lines · Russell King - ARM Linux
Quoted 40 lines · Dinh Nguyen
Quoted 31 lines · Geert Uytterhoeven
Hi Russell,
Quoted 9 lines · Russell King - ARM Linux
Quoted 8 lines · Geert Uytterhoeven
FWIW, I have the feeling this has a slight influence on boot reliability on two of my boards:
- r8a7740/armadillo, which is known to suffer from a cache-related bug in its bootloader, seems to have a higher change of booting successfully on cold boot,
- sh73a0/kzm9g, which has known cache-issues with secondary CPU boot up, seems to have a lower chance of booting successfully.Quoted 6 lines
Quoted 2 lines
No time to spend all week turning this into a statistical significant test project... The reset button is my friend...
Damn it, you sent this right after I merged and pushed out this change in my for-arm-soc branch, and was just about to send it to the arm-soc people. What excellent timing you have. :)
Don't worry, I didn't send that email to make you postpone this change. Giving the fuzziness of reproduction, and the flakiness (esp. on Armadillo) of the boot loader, and these are old SoCs, please go ahead.
Quoted 1 line
What happens on the kzm9g if you revert the mach-shmobile changes?
Seems to make no difference.
Quoted 2 lines
For armadillo, do you use the decompressor? That should be doing all the cache cleaning already, prior to the kernel being entered.
Quoted 7 lines
I think so.
Corruption pattern ranges from lock up, over "Error: unrecognized/unsupported machine ID", to booting almost completely, but lacking a few devices due to a corrupted DTB. Been like that as long as I remember, i.e. since I got the board ca. 1 year ago. Boots fine (100%) with kexec.
Quoted 6 lines
It seems like this patch is causing the SoCFPGA to not boot with SMP reliably. About 1 out of every 10 reboots, I'm seeing the boot failure below. The error seems to only happen when I do a cold or warm reboot, but never occurs during a power-up. If I revert this patch, or put back the call to
v7_invalidate_l1insocfpga_secondary_startup, then its able to boot 100% of the time.Quoted 6 lines
It really sucks that you're only just testing this change now, because I've frozen my tree, and removing it for the next merge window is going to be an entirely non-trivial matter. You were copied on the original patch, which you failed to test... I can't say I have _much_ sympathy for a bug report at this point in time.
I apologize for not catching this error while testing this patch. But I did test it when you first sent it out..I probably didn't do a stress test. Sometimes the reboot fails in the 1st attempt, sometimes it fails in the 9th attempt.
Quoted 6 lines
I only caught this error when I was testing my recent changes to use
CPU_METHOD_OF_DECLARE.For me, I don't think you need to revert this patch or anything, but a fix can go in for a -rcX?
Also, I am not seeing the error on the SoCFPGA Arria 10 platform at all. This Arria10 platform is running a different version of bootloader than the Cyclone5. Although, I also did test with the latest version of U-Boot on the Cyclone5.
Dinh
PATCH 1/1 ARM: v7 setup function should invalidate L1 cache
Quoted 4 lines · Dinh Nguyen
Also, I am not seeing the error on the SoCFPGA Arria 10 platform at all. This Arria10 platform is running a different version of bootloader than the Cyclone5. Although, I also did test with the latest version of U-Boot on the Cyclone5.
It _shouldn't_ cause any issue, unless secondary_startup is called with caches already enabled (which it shouldn't.)
If caches are enabled, that's incredibly dodgy even with the old code - cache lines could be migrated to the incoming CPU which v7_invalidate_l1() would then invalidate, resulting in the loss of data in those migrated cache lines.
If caches are not enabled, this change should have no effect: caches should not be searched if the C bit is clear, and we still end up invalidating the local L1 cache later in the normal boot sequence.
(If caches are searched with the C bit clear, and the caches initialise in an unpredictable state, the ARM ARM requires an implementation specific routine to be executed immediately on CPU startup. The idea is that if this option were to be chosen, the vendor must guarantee a certain code sequence can't be disrupted by the uninitialised state in the caches, which, if you're searching the caches for instruction fetches, is pretty much impossible to guarantee no matter what kind of code sequence you
specify: even the first instruction fetched from the CPU reset vector could ultimately be sourced from the instruction cache if the i-cache reports that it thinks it has valid data.)
Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up according to speedtest.net.
PATCH 1/1 ARM: v7 setup function should invalidate L1 cache
In reply to Russell KingQuoted 24 lines · Russell King
All ARMv5 and older CPUs invalidate their caches in the early assembly setup function, prior to enabling the MMU. This is because the L1 cache should not contain any data relevant to the execution of the kernel at this point; all data should have been flushed out to memory.
This requirement should also be true for ARMv6 and ARMv7 CPUs - indeed, these typically do not search their caches when caching is disabled (as it needs to be when the MMU is disabled) so this change should be safe.
ARMv7 allows there to be CPUs which search their caches while caching is disabled, and it's permitted that the cache is uninitialised at boot; for these, the architecture reference manual requires that an implementation specific code sequence is used immediately after reset to ensure that the cache is placed into a sane state. Such functionality is definitely outside the remit of the Linux kernel, and must be done by the SoC's firmware before _any_ CPU gets to the Linux kernel.
Changing the data cache clean+invalidate to a mere invalidate allows us to get rid of a lot of platform specific hacks around this issue for their secondary CPU bringup paths - some of which were buggy.
Signed-off-by Russell King <[email protected]>---
...
Quoted 3 lines
arch/arm/mach-zynq/common.h | 2 -- arch/arm/mach-zynq/headsmp.S | 5 ----- arch/arm/mach-zynq/platsmp.c | 5 ++---
For Zynq:
Thanks,
Michal
Wei Xu
maintainerPATCH 1/1 ARM: v7 setup function should invalidate L1 cache
In reply to Russell KingQuoted 18 lines · Russell King
All ARMv5 and older CPUs invalidate their caches in the early assembly setup function, prior to enabling the MMU. This is because the L1 cache should not contain any data relevant to the execution of the kernel at this point; all data should have been flushed out to memory.
This requirement should also be true for ARMv6 and ARMv7 CPUs - indeed, these typically do not search their caches when caching is disabled (as it needs to be when the MMU is disabled) so this change should be safe.
ARMv7 allows there to be CPUs which search their caches while caching is disabled, and it's permitted that the cache is uninitialised at boot; for these, the architecture reference manual requires that an implementation specific code sequence is used immediately after reset to ensure that the cache is placed into a sane state. Such functionality is definitely outside the remit of the Linux kernel, and must be done by the SoC's firmware before _any_ CPU gets to the Linux kernel.
Quoted 6 lines
Changing the data cache clean+invalidate to a mere invalidate allows us to get rid of a lot of platform specific hacks around this issue for their secondary CPU bringup paths - some of which were buggy.
Signed-off-by Russell King <[email protected]>---
Hi Russell,
[...]
Quoted 4 lines
arch/arm/mach-hisi/Makefile | 2 +- arch/arm/mach-hisi/core.h | 1 - arch/arm/mach-hisi/headsmp.S | 16 ---------------- arch/arm/mach-hisi/platsmp.c | 4 ++--
[...]
Sorry for the late reply.
For Hisilicon:
- hip01/ca9x2
- hix5hd2/dkb
Thanks!
Best Regards,
Wei
PATCH 1/1 ARM: BCM63xx: Remove custom secondary_startup function
In reply to Russell KingWith commit 02b4e2756e01c623cc4dbceae4b07be75252db5b ("ARM: v7 setup function should invalidate L1 cache"), the default secondary_startup function for ARMv7 CPUs does invalidate the L1 cache, which was the sole reason why BCM63xx had to have its own secondary_startup implementation.
Now that the secondary_startup takes care of this, we can completely remove that code.
---
Russell,
Will queue this up for 4.3, BCM63138 SMP support happened at the same time as your changes to cache-v7.S.
Thanks
arch/arm/mach-bcm/Makefile | 4 +--- arch/arm/mach-bcm/bcm63xx_headsmp.S | 23 ----------------------- arch/arm/mach-bcm/bcm63xx_smp.c | 2 +- arch/arm/mach-bcm/bcm63xx_smp.h | 1 - 4 files changed, 2 insertions(+), 28 deletions(-) delete mode 100644 arch/arm/mach-bcm/bcm63xx_headsmp.S
arch/arm/mach-bcm/Makefile +1 -3
@@ -39,10 +39,8 @@ obj-$(CONFIG_ARCH_BCM_5301X) += bcm_5301x.o # BCM63XXx ifeq ($(CONFIG_ARCH_BCM_63XX),y) -CFLAGS_bcm63xx_headsmp.o += -march=armv7-a obj-y += bcm63xx.o -obj-$(CONFIG_SMP) += bcm63xx_smp.o bcm63xx_headsmp.o \ - bcm63xx_pmb.o +obj-$(CONFIG_SMP) += bcm63xx_smp.o bcm63xx_pmb.o endif ifeq ($(CONFIG_ARCH_BRCMSTB),y)
arch/arm/mach-bcm/bcm63xx_headsmp.S deleted +0 -23
@@ -1,23 +0,0 @@ -/* - * Copyright (C) 2015, Broadcom Corporation - * All Rights Reserved - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ -#include <linux/linkage.h> -#include <linux/init.h> -#include <asm/assembler.h> - -ENTRY(bcm63138_secondary_startup) - ARM_BE8(setend be) - /* - * L1 cache does have unpredictable contents at power-up clean its - * contents without flushing - */ - bl v7_invalidate_l1 - nop - - b secondary_startup -ENDPROC(bcm63138_secondary_startup)
arch/arm/mach-bcm/bcm63xx_smp.c +1 -1
@@ -135,7 +135,7 @@ static int bcm63138_smp_boot_secondary(unsigned int cpu, }/* Write the secondary init routine to the BootLUT reset vector */ - val =virt_to_phys (bcm63138_secondary_startup); + val =virt_to_phys (secondary_startup);writel_relaxed (val, bootlut_base +BOOTLUT_RESET_VECT );/* Power up the core, will jump straight to its reset vector when we
arch/arm/mach-bcm/bcm63xx_smp.h +0 -1
@@ -3,7 +3,6 @@struct device_node ; -extern void bcm63138_secondary_startup (void );extern int bcm63xx_pmb_power_on_cpu (struct device_node *dn);#endif /* __BCM63XX_SMP_H */
Signature · 1 line
2.1.0
Florian Fainelli
AppliedPATCH 1/1 ARM: BCM63xx: Remove custom secondary_startup function
Le 07/07/15 18:17, Florian Fainelli a ?crit :
Quoted 9 lines
With commit
02b4e2756e01c623cc4dbceae4b07be75252db5b("ARM: v7 setup function should invalidate L1 cache"), the defaultsecondary_startupfunction for ARMv7 CPUs does invalidate the L1 cache, which was the sole reason why BCM63xx had to have its ownsecondary_startupimplementation.Now that the
secondary_startuptakes care of this, we can completely remove that code.Signed-off-by Florian Fainelli <[email protected]>
Applied to soc/next.
Signature · 1 line
Florian