Skip to content

Commit 8cf8df8

Browse files
tmlindarndb
authored andcommitted
ARM: OMAP2+: Fix regression for smc calls for vmap stack
Commit 9c46929 ("ARM: implement THREAD_INFO_IN_TASK for uniprocessor systems") started triggering an issue with smc calls hanging on boot as VMAP_STACK is now enabled by default. Based on discussions on the #armlinux irc channel, Arnd noticed that omaps are using __pa() for stack for smc calls. This does not work with vmap stack. Let's fix the issue by changing the param arrays to use static param[5] for each function for __pa() to work. This consumes a bit more memory compared to adding a single static buffer, but avoids potential races with the smc calls initializing the shared buffer. For omap_secure_dispatcher(), we need to use a cpu specific buffer as there's nothing currently ensuring it only gets called from cpu0. Fixes: 9c46929 ("ARM: implement THREAD_INFO_IN_TASK for uniprocessor systems") Link: https://lore.kernel.org/r/20220331171737.48211-1-tony@atomide.com Suggested-by: Ard Biesheuvel <ardb@kernel.org> Suggested-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Tony Lindgren <tony@atomide.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent 6a2f0b2 commit 8cf8df8

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

arch/arm/mach-omap2/omap-secure.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,13 @@ static void __init omap_optee_init_check(void)
5959
u32 omap_secure_dispatcher(u32 idx, u32 flag, u32 nargs, u32 arg1, u32 arg2,
6060
u32 arg3, u32 arg4)
6161
{
62+
static u32 buf[NR_CPUS][5];
63+
u32 *param;
64+
int cpu;
6265
u32 ret;
63-
u32 param[5];
66+
67+
cpu = get_cpu();
68+
param = buf[cpu];
6469

6570
param[0] = nargs;
6671
param[1] = arg1;
@@ -76,6 +81,8 @@ u32 omap_secure_dispatcher(u32 idx, u32 flag, u32 nargs, u32 arg1, u32 arg2,
7681
outer_clean_range(__pa(param), __pa(param + 5));
7782
ret = omap_smc2(idx, flag, __pa(param));
7883

84+
put_cpu();
85+
7986
return ret;
8087
}
8188

@@ -119,8 +126,8 @@ phys_addr_t omap_secure_ram_mempool_base(void)
119126
#if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
120127
u32 omap3_save_secure_ram(void __iomem *addr, int size)
121128
{
129+
static u32 param[5];
122130
u32 ret;
123-
u32 param[5];
124131

125132
if (size != OMAP3_SAVE_SECURE_RAM_SZ)
126133
return OMAP3_SAVE_SECURE_RAM_SZ;
@@ -153,8 +160,8 @@ u32 omap3_save_secure_ram(void __iomem *addr, int size)
153160
u32 rx51_secure_dispatcher(u32 idx, u32 process, u32 flag, u32 nargs,
154161
u32 arg1, u32 arg2, u32 arg3, u32 arg4)
155162
{
163+
static u32 param[5];
156164
u32 ret;
157-
u32 param[5];
158165

159166
param[0] = nargs+1; /* RX-51 needs number of arguments + 1 */
160167
param[1] = arg1;

0 commit comments

Comments
 (0)