Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3698563rwd; Sat, 17 Jun 2023 00:11:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7YoiGIgfpDgL0vP7Y6cF8aZWstliUcsofZJhYxdvn+G1g8Tkop/+EQ/49c5mJ+5W2e8vur X-Received: by 2002:a05:6a20:4303:b0:10c:4a13:99e2 with SMTP id h3-20020a056a20430300b0010c4a1399e2mr13079139pzk.9.1686985868096; Sat, 17 Jun 2023 00:11:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686985868; cv=none; d=google.com; s=arc-20160816; b=OL8+62OjZr178sPmku5kFF1fUacXhpX5fnEhZLcd/bOmZZRmOlmZVSGaD2qEQcm61Y Df1g830ObNuI7fwYa2b4vagPKxm0rHh3mZTCGUCl1zJsutN428N1IUpfGQpiPset+/r6 ah0/z9ndO47W9sHhxi/yRe9e+XDdFjMtmrZODuYcXQnzpktyiaA6He9/jPm+8ovjKSwd maoe9cis7YSvYFB9PIDQeZ0qFecsvH7LZHo6Q3r9UsD581Yv5ZSllnhjqPFB60H2AWyF YvezSqauJqCRAYjgq2LoMZVmD8CgNQtKZZJqgby0sdpUyrcZYd6nmV9gbPLAbjV67+D1 Jlaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+jl6ZWh0CwRYihm2fzDXjbCTAFKm/fhpPehyYCaJF00=; b=Jbb/l8CykEm8OccJxYc5+Wdg6mzVjAyrSB6mpqnWpaRe8qOG0sQ5+5IC11PROIKvOh c8/SUTvfZJILOzzhaE0pCFoINsGpSeDIinOJjzJZTvOv5uxXpF7gtE18P0S86GrbZ33x CvVV5eglL3tMwmJSZVV3SZDC5d0yLon6/uPUFmAYv1KS0RzNwhT+0K0W2reiYgzTbpHj ydkC80muRu6IqipmvHdiUvWpw1G0eZZS8SGgss54fPJS2CyMggxFP+G1fdzmuKS0cEz8 l+96q+TsGgqTSsqm+pleTonj8HfNQFpHJr3kTt0NUvpMhAn9ZZbjdxuct2OFnJ5O04Mc E7yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="A0C/04zw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k131-20020a636f89000000b005347d133470si16527938pgc.385.2023.06.17.00.10.53; Sat, 17 Jun 2023 00:11:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="A0C/04zw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234172AbjFQGpL (ORCPT + 99 others); Sat, 17 Jun 2023 02:45:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229667AbjFQGpK (ORCPT ); Sat, 17 Jun 2023 02:45:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B03226B1; Fri, 16 Jun 2023 23:45:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (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 dfw.source.kernel.org (Postfix) with ESMTPS id 2D7AE61084; Sat, 17 Jun 2023 06:45:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC914C433C8; Sat, 17 Jun 2023 06:44:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686984307; bh=Uw5cw1TPn0rntsQJRbeXZU+V2i3I8bpFiME/qcflP08=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=A0C/04zwp8Svpx/hprFTuDwIwHJCnHpNRmn2tDdvfcmYt4wp3n7OAxHp5Py33C+kd 4kMHu8FACuUr1jN3jGFObWQ4Pw9NFQKQAIyO/G6pFYoVPUe76lGyVXZO3TQemSokHm VXxdoS02gSAauNcMun3iVu1Zubv2t9PebDcIDYD6cqQx8/HkOPh4X4/5bVg3dgu6dB sBHr55LVzNEboL0DRdq7gLRwtJOv/T3RNn91O3Tsgsn70wRNMkVoUNRgpMFOdo78UU n4UYOHCQfFtBs9Glr8+Avi1tBIrn2kszVYZ167A35xKrcwfLNkZs7DpMC2d48GQpfN ByDutHlpcGnYg== Date: Sat, 17 Jun 2023 09:44:21 +0300 From: Mike Rapoport To: "Edgecombe, Rick P" Cc: "linux-kernel@vger.kernel.org" , "tglx@linutronix.de" , "mcgrof@kernel.org" , "deller@gmx.de" , "davem@davemloft.net" , "nadav.amit@gmail.com" , "linux@armlinux.org.uk" , "netdev@vger.kernel.org" , "linux-mips@vger.kernel.org" , "linux-riscv@lists.infradead.org" , "hca@linux.ibm.com" , "catalin.marinas@arm.com" , "kent.overstreet@linux.dev" , "puranjay12@gmail.com" , "linux-s390@vger.kernel.org" , "palmer@dabbelt.com" , "chenhuacai@kernel.org" , "tsbogend@alpha.franken.de" , "linux-trace-kernel@vger.kernel.org" , "linux-parisc@vger.kernel.org" , "christophe.leroy@csgroup.eu" , "x86@kernel.org" , "mpe@ellerman.id.au" , "mark.rutland@arm.com" , "rostedt@goodmis.org" , "linuxppc-dev@lists.ozlabs.org" , "will@kernel.org" , "dinguyen@kernel.org" , "naveen.n.rao@linux.ibm.com" , "sparclinux@vger.kernel.org" , "linux-modules@vger.kernel.org" , "bpf@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "song@kernel.org" , "linux-mm@kvack.org" , "loongarch@lists.linux.dev" , "akpm@linux-foundation.org" Subject: Re: [PATCH v2 06/12] mm/execmem: introduce execmem_data_alloc() Message-ID: <20230617064421.GQ52412@kernel.org> References: <20230616085038.4121892-1-rppt@kernel.org> <20230616085038.4121892-7-rppt@kernel.org> <90a64b6f040491da16af0694172a6cbdaba33669.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <90a64b6f040491da16af0694172a6cbdaba33669.camel@intel.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 16, 2023 at 04:55:53PM +0000, Edgecombe, Rick P wrote: > On Fri, 2023-06-16 at 11:50 +0300, Mike Rapoport wrote: > > From: "Mike Rapoport (IBM)" > > > > Data related to code allocations, such as module data section, need > > to > > comply with architecture constraints for its placement and its > > allocation right now was done using execmem_text_alloc(). > > > > Create a dedicated API for allocating data related to code > > allocations > > and allow architectures to define address ranges for data > > allocations. > > Right now the cross-arch way to specify kernel memory permissions is > encoded in the function names of all the set_memory_foo()'s. You can't > just have unified prot names because some arch's have NX and some have > X bits, etc. CPA wouldn't know if it needs to set or unset a bit if you > pass in a PROT. The idea is that allocator never uses CPA. It allocates with the permissions defined by architecture at the first place and then the callers might use CPA to change them. Ideally, that shouldn't be needed for anything but ro_after_init, but we are far from there. > But then you end up with a new function for *each* combination (i.e. > set_memory_rox()). I wish CPA has flags like mmap() does, and I wonder > if it makes sense here instead of execmem_data_alloc(). I don't think execmem should handle all the combinations. The code is always allocated as ROX for architectures that support text poking and as RWX for those that don't. Maybe execmem_data_alloc() will need to able to handle RW and RO data differently at some point, but that's the only variant I can think of, but even then I don't expect CPA will be used by execmem. We also might move resetting the permissions to default from vmalloc to execmem, but again, we are far from there. > Maybe that is an overhaul for another day though... CPA surely needs some love :) -- Sincerely yours, Mike.