* [PATCH] powerpc/4xx: Fix setup_kuep() on SMP
@ 2021-06-28 6:56 Christophe Leroy
2021-06-29 11:58 ` Michael Ellerman
0 siblings, 1 reply; 3+ messages in thread
From: Christophe Leroy @ 2021-06-28 6:56 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linux-kernel, linuxppc-dev
On SMP, setup_kuep() is also called from start_secondary() since
commit 86f46f343272 ("powerpc/32s: Initialise KUAP and KUEP in C").
start_secondary() is not an __init function.
Remove the __init marker from setup_kuep() and bail out when
not caller on the first CPU as the work is already done.
Reported-by: kernel test robot <lkp@intel.com>
Fixes: 10248dcba120 ("powerpc/44x: Implement Kernel Userspace Exec Protection (KUEP)")
Fixes: 86f46f343272 ("powerpc/32s: Initialise KUAP and KUEP in C").
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/mm/nohash/44x.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/mm/nohash/44x.c b/arch/powerpc/mm/nohash/44x.c
index 7da6d1e9fc9b..20c18bd5b9a0 100644
--- a/arch/powerpc/mm/nohash/44x.c
+++ b/arch/powerpc/mm/nohash/44x.c
@@ -241,8 +241,11 @@ void __init mmu_init_secondary(int cpu)
#endif /* CONFIG_SMP */
#ifdef CONFIG_PPC_KUEP
-void __init setup_kuep(bool disabled)
+void setup_kuep(bool disabled)
{
+ if (smp_processor_id() != boot_cpuid)
+ return;
+
if (disabled)
patch_instruction_site(&patch__tlb_44x_kuep, ppc_inst(PPC_RAW_NOP()));
else
--
2.25.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc/4xx: Fix setup_kuep() on SMP
2021-06-28 6:56 [PATCH] powerpc/4xx: Fix setup_kuep() on SMP Christophe Leroy
@ 2021-06-29 11:58 ` Michael Ellerman
2021-06-29 12:06 ` Christophe Leroy
0 siblings, 1 reply; 3+ messages in thread
From: Michael Ellerman @ 2021-06-29 11:58 UTC (permalink / raw)
To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras
Cc: linux-kernel, linuxppc-dev
Christophe Leroy <christophe.leroy@csgroup.eu> writes:
> On SMP, setup_kuep() is also called from start_secondary() since
> commit 86f46f343272 ("powerpc/32s: Initialise KUAP and KUEP in C").
>
> start_secondary() is not an __init function.
>
> Remove the __init marker from setup_kuep() and bail out when
> not caller on the first CPU as the work is already done.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Fixes: 10248dcba120 ("powerpc/44x: Implement Kernel Userspace Exec Protection (KUEP)")
> Fixes: 86f46f343272 ("powerpc/32s: Initialise KUAP and KUEP in C").
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
> arch/powerpc/mm/nohash/44x.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/mm/nohash/44x.c b/arch/powerpc/mm/nohash/44x.c
> index 7da6d1e9fc9b..20c18bd5b9a0 100644
> --- a/arch/powerpc/mm/nohash/44x.c
> +++ b/arch/powerpc/mm/nohash/44x.c
> @@ -241,8 +241,11 @@ void __init mmu_init_secondary(int cpu)
> #endif /* CONFIG_SMP */
>
> #ifdef CONFIG_PPC_KUEP
> -void __init setup_kuep(bool disabled)
> +void setup_kuep(bool disabled)
> {
> + if (smp_processor_id() != boot_cpuid)
> + return;
> +
> if (disabled)
> patch_instruction_site(&patch__tlb_44x_kuep, ppc_inst(PPC_RAW_NOP()));
> else
Building ppc44x_defconfig gives me:
/linux/arch/powerpc/mm/nohash/44x.c: In function 'setup_kuep':
/linux/arch/powerpc/mm/nohash/44x.c:246:35: error: 'boot_cpuid' undeclared (first use in this function); did you mean 'boot_cpu_init'?
246 | if (smp_processor_id() != boot_cpuid)
| ^~~~~~~~~~
| boot_cpu_init
/linux/arch/powerpc/mm/nohash/44x.c:246:35: note: each undeclared identifier is reported only once for each function it appears in
cheers
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc/4xx: Fix setup_kuep() on SMP
2021-06-29 11:58 ` Michael Ellerman
@ 2021-06-29 12:06 ` Christophe Leroy
0 siblings, 0 replies; 3+ messages in thread
From: Christophe Leroy @ 2021-06-29 12:06 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras
Cc: linux-kernel, linuxppc-dev
Le 29/06/2021 à 13:58, Michael Ellerman a écrit :
> Christophe Leroy <christophe.leroy@csgroup.eu> writes:
>> On SMP, setup_kuep() is also called from start_secondary() since
>> commit 86f46f343272 ("powerpc/32s: Initialise KUAP and KUEP in C").
>>
>> start_secondary() is not an __init function.
>>
>> Remove the __init marker from setup_kuep() and bail out when
>> not caller on the first CPU as the work is already done.
>>
>> Reported-by: kernel test robot <lkp@intel.com>
>> Fixes: 10248dcba120 ("powerpc/44x: Implement Kernel Userspace Exec Protection (KUEP)")
>> Fixes: 86f46f343272 ("powerpc/32s: Initialise KUAP and KUEP in C").
>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> ---
>> arch/powerpc/mm/nohash/44x.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/powerpc/mm/nohash/44x.c b/arch/powerpc/mm/nohash/44x.c
>> index 7da6d1e9fc9b..20c18bd5b9a0 100644
>> --- a/arch/powerpc/mm/nohash/44x.c
>> +++ b/arch/powerpc/mm/nohash/44x.c
>> @@ -241,8 +241,11 @@ void __init mmu_init_secondary(int cpu)
>> #endif /* CONFIG_SMP */
>>
>> #ifdef CONFIG_PPC_KUEP
>> -void __init setup_kuep(bool disabled)
>> +void setup_kuep(bool disabled)
>> {
>> + if (smp_processor_id() != boot_cpuid)
>> + return;
>> +
>> if (disabled)
>> patch_instruction_site(&patch__tlb_44x_kuep, ppc_inst(PPC_RAW_NOP()));
>> else
>
> Building ppc44x_defconfig gives me:
>
> /linux/arch/powerpc/mm/nohash/44x.c: In function 'setup_kuep':
> /linux/arch/powerpc/mm/nohash/44x.c:246:35: error: 'boot_cpuid' undeclared (first use in this function); did you mean 'boot_cpu_init'?
> 246 | if (smp_processor_id() != boot_cpuid)
> | ^~~~~~~~~~
> | boot_cpu_init
> /linux/arch/powerpc/mm/nohash/44x.c:246:35: note: each undeclared identifier is reported only once for each function it appears in
Seems like we need <asm/smp.h> when we don't have CONFIG_SMP.
I tested it with akebono_defconfig, looks like it has CONFIG_SMP.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-06-29 12:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28 6:56 [PATCH] powerpc/4xx: Fix setup_kuep() on SMP Christophe Leroy
2021-06-29 11:58 ` Michael Ellerman
2021-06-29 12:06 ` Christophe Leroy
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).