* [PATCH AUTOSEL 6.6 4/6] ARM: 9420/1: smp: Fix SMP for xip kernels
[not found] <20241120140647.1768984-1-sashal@kernel.org>
@ 2024-11-20 14:06 ` Sasha Levin
2024-11-20 14:06 ` [PATCH AUTOSEL 6.6 5/6] ARM: 9434/1: cfi: Fix compilation corner case Sasha Levin
1 sibling, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2024-11-20 14:06 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Harith G, Linus Walleij, Russell King, Sasha Levin, linux,
linux-arm-kernel
From: Harith G <harith.g@alifsemi.com>
[ Upstream commit 9e9b0cf9319b4db143014477b0bc4b39894248f1 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/arm/kernel/head.S | 4 ++++
arch/arm/kernel/psci_smp.c | 7 +++++++
arch/arm/mm/idmap.c | 7 +++++++
3 files changed, 18 insertions(+)
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 1ec35f065617e..e573adfe73b28 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -407,7 +407,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:
diff --git a/arch/arm/kernel/psci_smp.c b/arch/arm/kernel/psci_smp.c
index d4392e1774848..3bb0c4dcfc5c9 100644
--- a/arch/arm/kernel/psci_smp.c
+++ b/arch/arm/kernel/psci_smp.c
@@ -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;
}
diff --git a/arch/arm/mm/idmap.c b/arch/arm/mm/idmap.c
index 448e57c6f6534..4a833e89782aa 100644
--- a/arch/arm/mm/idmap.c
+++ b/arch/arm/mm/idmap.c
@@ -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;
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH AUTOSEL 6.6 5/6] ARM: 9434/1: cfi: Fix compilation corner case
[not found] <20241120140647.1768984-1-sashal@kernel.org>
2024-11-20 14:06 ` [PATCH AUTOSEL 6.6 4/6] ARM: 9420/1: smp: Fix SMP for xip kernels Sasha Levin
@ 2024-11-20 14:06 ` Sasha Levin
2024-11-20 15:13 ` Nathan Chancellor
1 sibling, 1 reply; 4+ messages in thread
From: Sasha Levin @ 2024-11-20 14:06 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Linus Walleij, kernel test robot, Nathan Chancellor, Russell King,
Sasha Levin, linux, arnd, samitolvanen, linux-arm-kernel, llvm
From: Linus Walleij <linus.walleij@linaro.org>
[ Upstream commit 4aea16b7cfb76bd3361858ceee6893ef5c9b5570 ]
When enabling expert mode CONFIG_EXPERT and using that power
user mode to disable the branch prediction hardening
!CONFIG_HARDEN_BRANCH_PREDICTOR, the assembly linker
in CLANG notices that some assembly in proc-v7.S does
not have corresponding C call sites, i.e. the prototypes
in proc-v7-bugs.c are enclosed in ifdef
CONFIG_HARDEN_BRANCH_PREDICTOR so this assembly:
SYM_TYPED_FUNC_START(cpu_v7_smc_switch_mm)
SYM_TYPED_FUNC_START(cpu_v7_hvc_switch_mm)
Results in:
ld.lld: error: undefined symbol: __kcfi_typeid_cpu_v7_smc_switch_mm
>>> referenced by proc-v7.S:94 (.../arch/arm/mm/proc-v7.S:94)
>>> arch/arm/mm/proc-v7.o:(.text+0x108) in archive vmlinux.a
ld.lld: error: undefined symbol: __kcfi_typeid_cpu_v7_hvc_switch_mm
>>> referenced by proc-v7.S:105 (.../arch/arm/mm/proc-v7.S:105)
>>> arch/arm/mm/proc-v7.o:(.text+0x124) in archive vmlinux.a
Fix this by adding an additional requirement that
CONFIG_HARDEN_BRANCH_PREDICTOR has to be enabled to compile
these assembly calls.
Closes: https://lore.kernel.org/oe-kbuild-all/202411041456.ZsoEiD7T-lkp@intel.com/
Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/arm/mm/proc-v7.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
index 193c7aeb67039..bea11f9bfe856 100644
--- a/arch/arm/mm/proc-v7.S
+++ b/arch/arm/mm/proc-v7.S
@@ -93,7 +93,7 @@ ENTRY(cpu_v7_dcache_clean_area)
ret lr
ENDPROC(cpu_v7_dcache_clean_area)
-#ifdef CONFIG_ARM_PSCI
+#if defined(CONFIG_ARM_PSCI) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR)
.arch_extension sec
ENTRY(cpu_v7_smc_switch_mm)
stmfd sp!, {r0 - r3}
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH AUTOSEL 6.6 5/6] ARM: 9434/1: cfi: Fix compilation corner case
2024-11-20 14:06 ` [PATCH AUTOSEL 6.6 5/6] ARM: 9434/1: cfi: Fix compilation corner case Sasha Levin
@ 2024-11-20 15:13 ` Nathan Chancellor
2024-11-22 15:21 ` Sasha Levin
0 siblings, 1 reply; 4+ messages in thread
From: Nathan Chancellor @ 2024-11-20 15:13 UTC (permalink / raw)
To: Sasha Levin
Cc: linux-kernel, stable, Linus Walleij, kernel test robot,
Russell King, linux, arnd, samitolvanen, linux-arm-kernel, llvm
Hi Sasha,
On Wed, Nov 20, 2024 at 09:06:35AM -0500, Sasha Levin wrote:
> From: Linus Walleij <linus.walleij@linaro.org>
>
> [ Upstream commit 4aea16b7cfb76bd3361858ceee6893ef5c9b5570 ]
>
> When enabling expert mode CONFIG_EXPERT and using that power
> user mode to disable the branch prediction hardening
> !CONFIG_HARDEN_BRANCH_PREDICTOR, the assembly linker
> in CLANG notices that some assembly in proc-v7.S does
> not have corresponding C call sites, i.e. the prototypes
> in proc-v7-bugs.c are enclosed in ifdef
> CONFIG_HARDEN_BRANCH_PREDICTOR so this assembly:
>
> SYM_TYPED_FUNC_START(cpu_v7_smc_switch_mm)
> SYM_TYPED_FUNC_START(cpu_v7_hvc_switch_mm)
>
> Results in:
>
> ld.lld: error: undefined symbol: __kcfi_typeid_cpu_v7_smc_switch_mm
> >>> referenced by proc-v7.S:94 (.../arch/arm/mm/proc-v7.S:94)
> >>> arch/arm/mm/proc-v7.o:(.text+0x108) in archive vmlinux.a
>
> ld.lld: error: undefined symbol: __kcfi_typeid_cpu_v7_hvc_switch_mm
> >>> referenced by proc-v7.S:105 (.../arch/arm/mm/proc-v7.S:105)
> >>> arch/arm/mm/proc-v7.o:(.text+0x124) in archive vmlinux.a
>
> Fix this by adding an additional requirement that
> CONFIG_HARDEN_BRANCH_PREDICTOR has to be enabled to compile
> these assembly calls.
>
> Closes: https://lore.kernel.org/oe-kbuild-all/202411041456.ZsoEiD7T-lkp@intel.com/
>
> Reported-by: kernel test robot <lkp@intel.com>
> Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
> arch/arm/mm/proc-v7.S | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
> index 193c7aeb67039..bea11f9bfe856 100644
> --- a/arch/arm/mm/proc-v7.S
> +++ b/arch/arm/mm/proc-v7.S
> @@ -93,7 +93,7 @@ ENTRY(cpu_v7_dcache_clean_area)
> ret lr
> ENDPROC(cpu_v7_dcache_clean_area)
>
> -#ifdef CONFIG_ARM_PSCI
> +#if defined(CONFIG_ARM_PSCI) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR)
> .arch_extension sec
> ENTRY(cpu_v7_smc_switch_mm)
This patch is unnecessary in branches prior to 6.10 (when ARM started
supporting kCFI) because SYM_TYPED_FUNC_START() is not used here. I
would just drop it for 6.6 and earlier.
> stmfd sp!, {r0 - r3}
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH AUTOSEL 6.6 5/6] ARM: 9434/1: cfi: Fix compilation corner case
2024-11-20 15:13 ` Nathan Chancellor
@ 2024-11-22 15:21 ` Sasha Levin
0 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2024-11-22 15:21 UTC (permalink / raw)
To: Nathan Chancellor
Cc: linux-kernel, stable, Linus Walleij, kernel test robot,
Russell King, linux, arnd, samitolvanen, linux-arm-kernel, llvm
On Wed, Nov 20, 2024 at 08:13:38AM -0700, Nathan Chancellor wrote:
>Hi Sasha,
>
>On Wed, Nov 20, 2024 at 09:06:35AM -0500, Sasha Levin wrote:
>> From: Linus Walleij <linus.walleij@linaro.org>
>>
>> [ Upstream commit 4aea16b7cfb76bd3361858ceee6893ef5c9b5570 ]
>>
>> When enabling expert mode CONFIG_EXPERT and using that power
>> user mode to disable the branch prediction hardening
>> !CONFIG_HARDEN_BRANCH_PREDICTOR, the assembly linker
>> in CLANG notices that some assembly in proc-v7.S does
>> not have corresponding C call sites, i.e. the prototypes
>> in proc-v7-bugs.c are enclosed in ifdef
>> CONFIG_HARDEN_BRANCH_PREDICTOR so this assembly:
>>
>> SYM_TYPED_FUNC_START(cpu_v7_smc_switch_mm)
>> SYM_TYPED_FUNC_START(cpu_v7_hvc_switch_mm)
>>
>> Results in:
>>
>> ld.lld: error: undefined symbol: __kcfi_typeid_cpu_v7_smc_switch_mm
>> >>> referenced by proc-v7.S:94 (.../arch/arm/mm/proc-v7.S:94)
>> >>> arch/arm/mm/proc-v7.o:(.text+0x108) in archive vmlinux.a
>>
>> ld.lld: error: undefined symbol: __kcfi_typeid_cpu_v7_hvc_switch_mm
>> >>> referenced by proc-v7.S:105 (.../arch/arm/mm/proc-v7.S:105)
>> >>> arch/arm/mm/proc-v7.o:(.text+0x124) in archive vmlinux.a
>>
>> Fix this by adding an additional requirement that
>> CONFIG_HARDEN_BRANCH_PREDICTOR has to be enabled to compile
>> these assembly calls.
>>
>> Closes: https://lore.kernel.org/oe-kbuild-all/202411041456.ZsoEiD7T-lkp@intel.com/
>>
>> Reported-by: kernel test robot <lkp@intel.com>
>> Reviewed-by: Nathan Chancellor <nathan@kernel.org>
>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
>> Signed-off-by: Sasha Levin <sashal@kernel.org>
>> ---
>> arch/arm/mm/proc-v7.S | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
>> index 193c7aeb67039..bea11f9bfe856 100644
>> --- a/arch/arm/mm/proc-v7.S
>> +++ b/arch/arm/mm/proc-v7.S
>> @@ -93,7 +93,7 @@ ENTRY(cpu_v7_dcache_clean_area)
>> ret lr
>> ENDPROC(cpu_v7_dcache_clean_area)
>>
>> -#ifdef CONFIG_ARM_PSCI
>> +#if defined(CONFIG_ARM_PSCI) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR)
>> .arch_extension sec
>> ENTRY(cpu_v7_smc_switch_mm)
>
>This patch is unnecessary in branches prior to 6.10 (when ARM started
>supporting kCFI) because SYM_TYPED_FUNC_START() is not used here. I
>would just drop it for 6.6 and earlier.
Ack, will do.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-11-22 15:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20241120140647.1768984-1-sashal@kernel.org>
2024-11-20 14:06 ` [PATCH AUTOSEL 6.6 4/6] ARM: 9420/1: smp: Fix SMP for xip kernels Sasha Levin
2024-11-20 14:06 ` [PATCH AUTOSEL 6.6 5/6] ARM: 9434/1: cfi: Fix compilation corner case Sasha Levin
2024-11-20 15:13 ` Nathan Chancellor
2024-11-22 15:21 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).