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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA0A9C433EF for ; Thu, 19 May 2022 06:53:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230434AbiESGxJ (ORCPT ); Thu, 19 May 2022 02:53:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231277AbiESGxH (ORCPT ); Thu, 19 May 2022 02:53:07 -0400 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 513C58722F for ; Wed, 18 May 2022 23:53:06 -0700 (PDT) Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4L3gXw4b57z9skh; Thu, 19 May 2022 08:53:04 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0Zp5zHGe4S4c; Thu, 19 May 2022 08:53:04 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4L3gXw3sCpz9skW; Thu, 19 May 2022 08:53:04 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 763C48B77D; Thu, 19 May 2022 08:53:04 +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 o-bL4ISsPQ1F; Thu, 19 May 2022 08:53:04 +0200 (CEST) Received: from [192.168.203.71] (unknown [192.168.203.71]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 11FBE8B763; Thu, 19 May 2022 08:53:04 +0200 (CEST) Message-ID: Date: Thu, 19 May 2022 08:53:04 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v1 3/4] powerpc/code-patching: Use jump_label for testing freed initmem Content-Language: fr-FR From: Christophe Leroy To: Guenter Roeck Cc: "linuxppc-dev@lists.ozlabs.org" , Paul Mackerras , "linux-kernel@vger.kernel.org" References: <0aee964721cab7316cffde21a2ca223cee14d373.1647962456.git.christophe.leroy@csgroup.eu> <20220519021706.GA3526833@roeck-us.net> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 19/05/2022 à 08:27, Christophe Leroy a écrit : > > > Le 19/05/2022 à 04:17, Guenter Roeck a écrit : >> On Tue, Mar 22, 2022 at 04:40:20PM +0100, Christophe Leroy wrote: >>> Once init is done, initmem is freed forever so no need to >>> test system_state at every call to patch_instruction(). >>> >>> Use jump_label. >>> >>> This reduces by 2% the time needed to activate ftrace on an 8xx. >>> >> >> It also causes the qemu mpc8544ds emulation to crash. >> >> BUG: Unable to handle kernel data access on write at 0xc122eb34 >> Faulting instruction address: 0xc001b580 >> Oops: Kernel access of bad area, sig: 11 [#1] >> BE PAGE_SIZE=4K MPC8544 DS >> Modules linked in: >> CPU: 0 PID: 1 Comm: swapper Not tainted 5.18.0-rc7-next-20220518 #1 >> NIP: c001b580 LR: c001b560 CTR: 00000003 >> REGS: c5107dd0 TRAP: 0300 Not tainted (5.18.0-rc7-next-20220518) >> MSR: 00009000 CR: 24000882 XER: 00000000 >> DEAR: c122eb34 ESR: 00800000 >> GPR00: c001b560 c5107ec0 c5120020 10000000 00000000 00000078 0c000000 cfffffff >> GPR08: c001e9ec 00000001 00000007 00000000 44000882 00000000 c0005178 00000000 >> GPR16: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 >> GPR24: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 c1230000 >> NIP [c001b580] free_initmem+0x48/0xa8 >> LR [c001b560] free_initmem+0x28/0xa8 >> Call Trace: >> [c5107ec0] [c001b560] free_initmem+0x28/0xa8 (unreliable) >> [c5107ee0] [c00051b0] kernel_init+0x38/0x150 >> [c5107f00] [c001626c] ret_from_kernel_thread+0x5c/0x64 >> Instruction dump: >> 3fe0c123 912a00dc 90010024 48000665 3d20c218 8929fa65 2c090000 41820058 >> 813feb34 2c090000 4082003c 39200001 <913feb34> 80010024 3cc0c114 83e1001c >> >> Reverting this patch fixes the problem. >> > > That's strange. > > I was able to reproduce the problem. > > Removing the __ro_after_init in front of > DEFINE_STATIC_KEY_FALSE(init_mem_is_free) fixes the problem. > > I can't understand why, mark_readonly() is called after free_initmem(). > Moving static_branch_enable(&init_mem_is_free) before mark_initmem_nx() also solves the problem. There must be something wrong with mark_initmem_nx(). Christophe