[PATCH v6 11/22] powerpc/book3s64/pkeys: Inherit correctly on fork.
Aneesh Kumar K.V
aneesh.kumar at linux.ibm.com
Thu Nov 26 00:56:57 AEDT 2020
On 11/25/20 7:24 PM, Christophe Leroy wrote:
>
>
> Le 25/11/2020 à 06:16, Aneesh Kumar K.V a écrit :
>> Child thread.kuap value is inherited from the parent in
>> copy_thread_tls. We still
>> need to make sure when the child returns from a fork in the kernel we
>> start with the kernel
>> default AMR value.
>>
>> Reviewed-by: Sandipan Das <sandipan at linux.ibm.com>
>> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.ibm.com>
>> ---
>> arch/powerpc/kernel/process.c | 11 +++++++++++
>> 1 file changed, 11 insertions(+)
>>
>> diff --git a/arch/powerpc/kernel/process.c
>> b/arch/powerpc/kernel/process.c
>> index b6b8a845e454..733680de0ba4 100644
>> --- a/arch/powerpc/kernel/process.c
>> +++ b/arch/powerpc/kernel/process.c
>> @@ -1768,6 +1768,17 @@ int copy_thread(unsigned long clone_flags,
>> unsigned long usp,
>> childregs->ppr = DEFAULT_PPR;
>> p->thread.tidr = 0;
>> +#endif
>> + /*
>> + * Run with the current AMR value of the kernel
>> + */
>> +#ifdef CONFIG_PPC_KUAP
>> + if (mmu_has_feature(MMU_FTR_KUAP))
>> + kregs->kuap = AMR_KUAP_BLOCKED;
>> +#endif
>
> Do we need that ifdef at all ?
>
> Shouldn't mmu_has_feature(MMU_FTR_KUAP) be always false and get
> optimised out when CONFIG_PPC_KUAP is not defined ?
>
>> +#ifdef CONFIG_PPC_KUEP
>> + if (mmu_has_feature(MMU_FTR_KUEP))
>> + kregs->iamr = AMR_KUEP_BLOCKED;
>
> Same ?
>
>> #endif
>> kregs->nip = ppc_function_entry(f);
>> return 0;
>>
Not really. I did hit a compile error with this patch on
mpc885_ads_defconfig and that required me to do
modified arch/powerpc/kernel/process.c
@@ -1772,11 +1772,10 @@ int copy_thread(unsigned long clone_flags,
unsigned long usp,
/*
* Run with the current AMR value of the kernel
*/
-#ifdef CONFIG_PPC_KUAP
+#ifdef CONFIG_PPC_PKEY
if (mmu_has_feature(MMU_FTR_KUAP))
- kregs->kuap = AMR_KUAP_BLOCKED;
-#endif
-#ifdef CONFIG_PPC_KUEP
+ kregs->amr = AMR_KUAP_BLOCKED;
+
if (mmu_has_feature(MMU_FTR_KUEP))
kregs->iamr = AMR_KUEP_BLOCKED;
#endif
More information about the Linuxppc-dev
mailing list