ARM: 9420/1: smp: Fix SMP for xip kernels
authorHarith G <harith.g@alifsemi.com>
Wed, 18 Sep 2024 05:57:53 +0000 (06:57 +0100)
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Tue, 12 Nov 2024 16:38:47 +0000 (16:38 +0000)
Fix the physical address calculation of the following to get smp working
on xip kernels.
- secondary_data needed for secondary cpu bootup.
- secondary_startup address passed through psci.
- identity mapped code region needed for enabling mmu for secondary cpus.

Signed-off-by: Harith George <harith.g@alifsemi.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
arch/arm/kernel/head.S
arch/arm/kernel/psci_smp.c
arch/arm/mm/idmap.c

index 28873cda464f5101aa8636f87bae9b9d76afe020..f22c50d4bd4173892345f9bc3c206fbd85b38eb7 100644 (file)
@@ -411,7 +411,11 @@ ENTRY(secondary_startup)
        /*
         * Use the page tables supplied from  __cpu_up.
         */
+#ifdef CONFIG_XIP_KERNEL
+       ldr     r3, =(secondary_data + PLAT_PHYS_OFFSET - PAGE_OFFSET)
+#else
        adr_l   r3, secondary_data
+#endif
        mov_l   r12, __secondary_switched
        ldrd    r4, r5, [r3, #0]                @ get secondary_data.pgdir
 ARM_BE8(eor    r4, r4, r5)                     @ Swap r5 and r4 in BE:
index d4392e1774848d02885c18b5b3f19557392683f2..3bb0c4dcfc5c95e86f3c94f729facecce7ee25d5 100644 (file)
@@ -45,8 +45,15 @@ extern void secondary_startup(void);
 static int psci_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        if (psci_ops.cpu_on)
+#ifdef CONFIG_XIP_KERNEL
+               return psci_ops.cpu_on(cpu_logical_map(cpu),
+                       ((phys_addr_t)(&secondary_startup)
+                       - XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR)
+                       + CONFIG_XIP_PHYS_ADDR));
+#else
                return psci_ops.cpu_on(cpu_logical_map(cpu),
                                        virt_to_idmap(&secondary_startup));
+#endif
        return -ENODEV;
 }
 
index 448e57c6f65344fd79ceced8708760fa0217239b..4a833e89782aa250f07f7cc5ac273e29840c54dd 100644 (file)
@@ -84,8 +84,15 @@ static void identity_mapping_add(pgd_t *pgd, const char *text_start,
        unsigned long addr, end;
        unsigned long next;
 
+#ifdef CONFIG_XIP_KERNEL
+       addr = (phys_addr_t)(text_start) - XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR)
+               + CONFIG_XIP_PHYS_ADDR;
+       end = (phys_addr_t)(text_end) - XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR)
+               + CONFIG_XIP_PHYS_ADDR;
+#else
        addr = virt_to_idmap(text_start);
        end = virt_to_idmap(text_end);
+#endif
        pr_info("Setting up static identity map for 0x%lx - 0x%lx\n", addr, end);
 
        prot |= PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_AF;