From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A74DDC11F68 for ; Tue, 29 Jun 2021 12:07:26 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 12E9961D6E for ; Tue, 29 Jun 2021 12:07:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 12E9961D6E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=csgroup.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GDjs83Kswz2yPf for ; Tue, 29 Jun 2021 22:07:24 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=csgroup.eu (client-ip=93.17.236.30; helo=pegase1.c-s.fr; envelope-from=christophe.leroy@csgroup.eu; receiver=) Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4GDjrm2mQWz2yN8 for ; Tue, 29 Jun 2021 22:07:00 +1000 (AEST) Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4GDjrb5W3wzB9jv; Tue, 29 Jun 2021 14:06:55 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zHQr_DDFz2aM; Tue, 29 Jun 2021 14:06:55 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4GDjrZ4ZgvzB9f4; Tue, 29 Jun 2021 14:06:54 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 7AD418B7C1; Tue, 29 Jun 2021 14:06:54 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id dNp7uxly07AA; Tue, 29 Jun 2021 14:06:54 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 8C9F38B7BE; Tue, 29 Jun 2021 14:06:53 +0200 (CEST) Subject: Re: [PATCH] powerpc/4xx: Fix setup_kuep() on SMP To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras References: <87tulg7uh6.fsf@mpe.ellerman.id.au> From: Christophe Leroy Message-ID: <920c4c49-5185-a0d5-0ab2-484effc307cc@csgroup.eu> Date: Tue, 29 Jun 2021 14:06:49 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <87tulg7uh6.fsf@mpe.ellerman.id.au> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Le 29/06/2021 à 13:58, Michael Ellerman a écrit : > Christophe Leroy 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 >> 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 >> --- >> 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 when we don't have CONFIG_SMP. I tested it with akebono_defconfig, looks like it has CONFIG_SMP.