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.2 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,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham 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 9D0CDC433B4 for ; Mon, 3 May 2021 06:32:42 +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 0084561185 for ; Mon, 3 May 2021 06:32:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0084561185 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 4FYY7D4TYlz30Gb for ; Mon, 3 May 2021 16:32:40 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=csgroup.eu (client-ip=93.17.235.10; helo=pegase2.c-s.fr; envelope-from=christophe.leroy@csgroup.eu; receiver=) Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4FYY6r4f7Pz2xb8 for ; Mon, 3 May 2021 16:32:17 +1000 (AEST) Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4FYY6k52ksz9sTQ; Mon, 3 May 2021 08:32:14 +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 0Bss0bVgFYKE; Mon, 3 May 2021 08:32:14 +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 4FYY6k41kMz9sSL; Mon, 3 May 2021 08:32:14 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 59FF98B775; Mon, 3 May 2021 08:32:14 +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 heZpRwhL8hUI; Mon, 3 May 2021 08:32:14 +0200 (CEST) Received: from [172.25.230.103] (po15451.idsi0.si.c-s.fr [172.25.230.103]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2450F8B763; Mon, 3 May 2021 08:32:14 +0200 (CEST) Subject: Re: [PATCH v11 3/9] powerpc: Always define MODULES_{VADDR,END} To: Jordan Niethe References: <20210429031602.2606654-1-jniethe5@gmail.com> <20210429031602.2606654-4-jniethe5@gmail.com> <111c8736-fff9-ba0a-4749-f9388b32c9bf@csgroup.eu> <6fa81d25-4313-5f15-23d9-06b314bb7d02@csgroup.eu> From: Christophe Leroy Message-ID: <426ad3d8-a71b-5fc5-e936-0908ed923838@csgroup.eu> Date: Mon, 3 May 2021 08:32:13 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: 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: ajd@linux.ibm.com, Nicholas Piggin , cmr@codefail.de, "Aneesh Kumar K.V" , naveen.n.rao@linux.ibm.com, linuxppc-dev , Daniel Axtens Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Le 03/05/2021 à 08:26, Jordan Niethe a écrit : > On Mon, May 3, 2021 at 4:22 PM Christophe Leroy > wrote: >> >> >> >> Le 03/05/2021 à 08:16, Jordan Niethe a écrit : >>> On Mon, May 3, 2021 at 3:57 PM Christophe Leroy >>> wrote: >>>> >>>> >>>> >>>> Le 03/05/2021 à 07:39, Jordan Niethe a écrit : >>>>> On Thu, Apr 29, 2021 at 3:04 PM Christophe Leroy >>>>> wrote: >>>>>> >>>>>> >>>>>> >>>>>> Le 29/04/2021 à 05:15, Jordan Niethe a écrit : >>>>>>> If MODULES_{VADDR,END} are not defined set them to VMALLOC_START and >>>>>>> VMALLOC_END respectively. This reduces the need for special cases. For >>>>>>> example, powerpc's module_alloc() was previously predicated on >>>>>>> MODULES_VADDR being defined but now is unconditionally defined. >>>>>>> >>>>>>> This will be useful reducing conditional code in other places that need >>>>>>> to allocate from the module region (i.e., kprobes). >>>>>>> >>>>>>> Signed-off-by: Jordan Niethe >>>>>>> --- >>>>>>> v10: New to series >>>>>>> v11: - Consider more places MODULES_VADDR was being used >>>>>>> --- >>>>>>> arch/powerpc/include/asm/pgtable.h | 11 +++++++++++ >>>>>>> arch/powerpc/kernel/module.c | 5 +---- >>>>>>> arch/powerpc/mm/kasan/kasan_init_32.c | 10 +++++----- >>>>>>> arch/powerpc/mm/ptdump/ptdump.c | 4 ++-- >>>>>>> 4 files changed, 19 insertions(+), 11 deletions(-) >>>>>>> >>>>>>> diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h >>>>>>> index c6a676714f04..882fda779648 100644 >>>>>>> --- a/arch/powerpc/include/asm/pgtable.h >>>>>>> +++ b/arch/powerpc/include/asm/pgtable.h >>>>>>> @@ -39,6 +39,17 @@ struct mm_struct; >>>>>>> #define __S110 PAGE_SHARED_X >>>>>>> #define __S111 PAGE_SHARED_X >>>>>>> >>>>>>> +#ifndef MODULES_VADDR >>>>>>> +#define MODULES_VADDR VMALLOC_START >>>>>>> +#define MODULES_END VMALLOC_END >>>>>>> +#endif >>>>>>> + >>>>>>> +#if defined(CONFIG_PPC_BOOK3S_32) && defined(CONFIG_STRICT_KERNEL_RWX) >>>>>> >>>>>> No no. >>>>>> >>>>>> TASK_SIZE > MODULES_VADDR is ALWAYS wrong, for any target, in any configuration. >>>>>> >>>>>> Why is it a problem to leave the test as a BUILD_BUG_ON() in module_alloc() ? >>>>> On ppc64s, MODULES_VADDR is __vmalloc_start (a variable) and >>>>> TASK_SIZE depends on current. >>>>> Also for nohash like 44x, MODULES_VADDR is defined based on high_memory. >>>>> If I put it back in module_alloc() and wrap it with #ifdef >>>>> CONFIG_PPC_BOOK3S_32 will that be fine? >>>> >>>> Thinking about it once more, I think the best approach is the one taken by Nick in >>>> https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20210502110050.324953-1-npiggin@gmail.com/ >>>> >>>> Use MODULES_VADDR/MODULES_END when it exists, use VMALLOC_START/VMALLOC_END otherwise. >>>> >>>> I know I suggested to always define MODULES_VADDR, but maybe that's not the best solution at the end. >>> Sure, let's do it like that. >>>> >>>> For kprobes, is there a way to re-use functions from modules.c in alloc_insn_page() ? >>> Probably we can use module_alloc() then the set_memory_ functions to >>> get the permissions right. >>> Something like we had in v9: >>> https://lore.kernel.org/linuxppc-dev/20210316031741.1004850-3-jniethe5@gmail.com/ >> >> Yes, more or less, but using module_alloc() instead of vmalloc(). >> And module_alloc() implies EXEC, so only the set_memory_ro() will be required. > Yep. >> >> I see no point in doing any set_memory_xxx() in free_insn_page(), because as soon as you do a >> vfree() the page is not mapped anymore so any access will lead to a fault. > Yeah, I'd not realised we had VM_FLUSH_RESET_PERMS when I added that. > I agree it's pointless. At the end if should be quite similar to what S390 architecture does.