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=-4.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 56B6FC433E3 for ; Tue, 14 Jul 2020 12:26:09 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 213AF22453 for ; Tue, 14 Jul 2020 12:26:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pztaI5rq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 213AF22453 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=T8EDrXpzzb60JjomIPNOLq+onxA2xih9FHl6wlPq0Zo=; b=pztaI5rq+CXoLCGt1cgS0IVie u6jtY9w4hOY9v+cLMfvSgDNumUrC4kD9vbaoEdx9wtUs+ODsBZJEa8M3KjHQLx3tnYFocnDWBI9iE 82Lh7Ck7qGPENU9WM3CtZ/lXEve+QyCW1NiEy7w9cR8KBZ8H/moaMH7jark1grVJRvrW6m1w3kNjC 6MLwvpcCIE4iIpSOr1w34Q1xYQPE36M1ZpvKGhjsGi9Sb9vWadd3HwoeI7rlc0ChIBfOUJQzo2qsf zp06bsuRBzw3PCWHkhSzmMSJ9cdeJQcO8qs8hLHC8pk6nEbyps0VU6iVQP51zabKUOwqiQsuxY3zk zxARf1ocg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvK0V-0000Yb-FY; Tue, 14 Jul 2020 12:25:59 +0000 Received: from mga07.intel.com ([134.134.136.100]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvK0T-0000XO-4m; Tue, 14 Jul 2020 12:25:58 +0000 IronPort-SDR: uHRmKfaCM7RuKxaMxSXb8Re9pvM/3xAJ8SFkfASDkqJNs0GDxEAil+XfmQL1MEiy87k+yHGjyq JQEN99WwlyRg== X-IronPort-AV: E=McAfee;i="6000,8403,9681"; a="213681519" X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="213681519" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2020 05:25:53 -0700 IronPort-SDR: TVIaMKQPYPdjGFZZbI3WQ9ns1+0Iskz9REpvCKvlTFGqhFJ9NUL6fPtyjLnMsU2L3jtH6/uf5d oLaIYQihVZaw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="268639830" Received: from pipper-mobl1.ger.corp.intel.com (HELO localhost) ([10.249.46.185]) by fmsmga007.fm.intel.com with ESMTP; 14 Jul 2020 05:25:20 -0700 Date: Tue, 14 Jul 2020 15:25:18 +0300 From: Jarkko Sakkinen To: Peter Zijlstra Subject: Re: [PATCH v2 1/3] module: Rename module_alloc() to text_alloc() and move to kernel proper Message-ID: <20200714122518.GE1463346@linux.intel.com> References: <20200714094625.1443261-1-jarkko.sakkinen@linux.intel.com> <20200714094625.1443261-2-jarkko.sakkinen@linux.intel.com> <20200714102826.GB4756@willie-the-truck> <20200714112927.GV10769@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200714112927.GV10769@hirez.programming.kicks-ass.net> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200714_082557_337953_78F0D6C6 X-CRM114-Status: GOOD ( 23.94 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Catalin Marinas , Kefeng Wang , Paul Mackerras , Zong Li , Andi Kleen , Paul Burton , Michael Ellerman , Vincent Whitchurch , Benjamin Herrenschmidt , Petr Mladek , Brian Gerst , Andy Lutomirski , Thomas Gleixner , Jiri Kosina , Anup Patel , linux-kernel@vger.kernel.org, Philipp Rudo , Torsten Duwe , Masami Hiramatsu , Andrew Morton , Mark Rutland , "James E.J. Bottomley" , Vincent Chen , Omar Sandoval , "open list:S390" , Joe Lawrence , Helge Deller , John Fastabend , Anil S Keshavamurthy , Yonghong Song , Iurii Zaikin , Andrii Nakryiko , Thomas Huth , Vasily Gorbik , "moderated list:ARM PORT" , Daniel Axtens , Damien Le Moal , Martin KaFai Lau , Song Liu , Paul Walmsley , Heiko Carstens , Alexei Starovoitov , Atish Patra , Will Deacon , Daniel Borkmann , Masahiro Yamada , Nayna Jain , Ley Foon Tan , Christian Borntraeger , Sami Tolvanen , "Naveen N. Rao" , Mao Han , Marco Elver , Steven Rostedt , Babu Moger , Borislav Petkov , Greentime Hu , Ben Dooks , Guan Xuetao , Thomas Bogendoerfer , "open list:PARISC ARCHITECTURE" , Jessica Yu , "open list:BPF JIT for MIPS \(32-BIT AND 64-BIT\)" , "David S. Miller" , Thiago Jung Bauermann , David Howells , "open list:SPARC + UltraSPARC \(sparc/sparc64\)" , Sandipan Das , "H. Peter Anvin" , Amit Daniel Kachhap , Tiezhu Yang , Miroslav Benes , Jiri Olsa , Ard Biesheuvel , Vincenzo Frascino , Anders Roxell , Sven Schnelle , "maintainer:X86 ARCHITECTURE \(32-BIT AND 64-BIT\)" , Russell King , "open list:RISC-V ARCHITECTURE" , Mike Rapoport , Ingo Molnar , Albert Ou , "Paul E. McKenney" , Josh Poimboeuf , KP Singh , Dmitry Vyukov , Nick Hu , "open list:BPF JIT for MIPS \(32-BIT AND 64-BIT\)" , "open list:MIPS" , Palmer Dabbelt , "open list:LINUX FOR POWERPC \(32-BIT AND 64-BIT\)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Tue, Jul 14, 2020 at 01:29:27PM +0200, Peter Zijlstra wrote: > On Tue, Jul 14, 2020 at 11:28:27AM +0100, Will Deacon wrote: > > > As Ard says, module_alloc() _is_ special, in the sense that the virtual > > memory it allocates wants to be close to the kernel text, whereas the > > concept of allocating executable memory is broader and doesn't have these > > restrictions. So, while I'm in favour of having a text_alloc() interface > > that can be used by callers which only require an executable mapping, I'd > > much prefer for the module_alloc() code to remain for, err, modules. > > So on x86 all those things (kprobes, bpf, ftrace) require that same > closeness. > > An interface like the late vmalloc_exec() will simply not work for us. > > We recently talked about arm64-kprobes and how you're not doing any of > the optimizations and fully rely on the exception return. And I see > you're one of the few archs that has bpf_jit_alloc_exec() (also, > shouldn't you be using PAGE_KERNEL_EXEC there?). But the BPF core seems > to use module_alloc() as a default means of allocating text. > > > So what should this look like? Have a text_alloc() with an argument that > indicates where? But then I suppose we also need a means to manage PLT > entries. Otherwise I don't exactly see how you're going to call BPF > code, or how that BPF stuff is going to call back into its helpers. To make this less of a havoc to arch maintainers what if: void * __weak module_alloc(unsigned long size) { if (IS_ENABLED(HAS_TEXT_ALLOC)) return text_alloc(size); return __vmalloc_node_range(size, 1, VMALLOC_START, VMALLOC_END, GFP_KERNEL, PAGE_KERNEL_EXEC, VM_FLUSH_RESET_PERMS, NUMA_NO_NODE, __builtin_return_address(0)); } Then in arch/x86/Kconfig I could put: config HAS_TEXT_ALLOC def_bool y This would scale down the patch set just to add kernel/text.c and arch/x86/kernel/text.c, and allows gradual migration to other arch's. /Jarkko _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv