Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1159327rwd; Thu, 1 Jun 2023 11:14:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5wJYPKP36L6Uo6QP75cmUEqgq4L9lK2iERGiEgVu7YZKUabpM2XH9wo2DQqEs5IA2hsQbF X-Received: by 2002:a05:6a20:869a:b0:10c:c5df:8bb7 with SMTP id k26-20020a056a20869a00b0010cc5df8bb7mr6135694pze.30.1685643262361; Thu, 01 Jun 2023 11:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685643262; cv=none; d=google.com; s=arc-20160816; b=vR7STktzhyXNGi9IKTwDcBkqfjEQ/gxnqnpboUeIjB5kEbu9M9oQcvypY9HSrJPqsU +66/bE4fQFdDfWvOGLRPcBpR5tTbXznRlX+CkhxNPo15UsJMUtJGcsnlfAq3vR/auDlN /U1nLvXSKKAhg5DfG/FRtw/JvgJYV28cvCOPMa+yX7YOsbJ/XMwmfmy1lURQVIOyOiIG GFY0yabAP+Fath0297xP/ZgulUJW5ZEh5yv25ia6XMqWe/P2JEztSpAtTZveKN07RPhR lO0IIEjT5XNBDvZguRticoImfSWiVhu0y+iShQRb/ok/rn5NHkFPFm4kRFFkyaoR5V+J bp9A== 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:dkim-signature:date; bh=rikKWdy6FkJZ7TxOeuVv2no4Uvw2FbvFXrknlku2Lr0=; b=pTM9H27TFIeOpe1VhreNNg3GxgAl2r/AMA/ye7YkmsCdd/py50dkMO+IENPAadAcJE lC4qZ8TsfNBuCCge2scUzvFAMl+VLKpIrd5rL8zALZhcvu2XQ/4YpEEJm6zeu3WV68E/ av6GsyU9r11TAqm7bSFxqsK0e5Ltd7SgeHD0cWQ4E2hs1R4NWEY8Z/cF8/f51DvkAlvj lNafdJDS0kHoPrcSNueGVLRLdYNuzDamIIZtJihh3KYPGx4owJc94qjo8gj9X6A1cVtT CbYY3d+Tua4fMA+uYY8C/4dF6F1LZWboUYNmG1uPiBop+zsFy1aFvQkOOZEnko2G9GG7 vZzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=atiaOaKv; 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=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x71-20020a63864a000000b00535f192eac7si3187258pgd.211.2023.06.01.11.13.59; Thu, 01 Jun 2023 11:14:22 -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=@linux.dev header.s=key1 header.b=atiaOaKv; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231429AbjFASA2 (ORCPT + 99 others); Thu, 1 Jun 2023 14:00:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231359AbjFASA0 (ORCPT ); Thu, 1 Jun 2023 14:00:26 -0400 Received: from out-8.mta1.migadu.com (out-8.mta1.migadu.com [IPv6:2001:41d0:203:375::8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E172E198 for ; Thu, 1 Jun 2023 11:00:23 -0700 (PDT) Date: Thu, 1 Jun 2023 14:00:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1685642421; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rikKWdy6FkJZ7TxOeuVv2no4Uvw2FbvFXrknlku2Lr0=; b=atiaOaKv+uGgVWrIBgEc7yMVho95zk+yXn7HmIb/JWzdFNNRD8GsFkaCojYLUmxdGEZj8D 7Ioc6S8oiCxOeWCOlyVYprsSznLfrTEBk/hh6wsG3yyt6B+kTftpXgtdtqd4vLEbQHfUux KWvBLALHSXDpFUTZKzUX7J9eP0pgECQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: "Edgecombe, Rick P" Cc: "linux-kernel@vger.kernel.org" , "rppt@kernel.org" , "tglx@linutronix.de" , "mcgrof@kernel.org" , "deller@gmx.de" , "davem@davemloft.net" , "netdev@vger.kernel.org" , "linux@armlinux.org.uk" , "linux-mips@vger.kernel.org" , "linux-riscv@lists.infradead.org" , "linuxppc-dev@lists.ozlabs.org" , "hca@linux.ibm.com" , "catalin.marinas@arm.com" , "linux-s390@vger.kernel.org" , "christophe.leroy@csgroup.eu" , "chenhuacai@kernel.org" , "mpe@ellerman.id.au" , "linux-trace-kernel@vger.kernel.org" , "tsbogend@alpha.franken.de" , "palmer@dabbelt.com" , "x86@kernel.org" , "linux-parisc@vger.kernel.org" , "rostedt@goodmis.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 12/13] x86/jitalloc: prepare to allocate exectuatble memory as ROX Message-ID: References: <20230601101257.530867-1-rppt@kernel.org> <20230601101257.530867-13-rppt@kernel.org> <0f50ac52a5280d924beeb131e6e4717b6ad9fdf7.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0f50ac52a5280d924beeb131e6e4717b6ad9fdf7.camel@intel.com> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Thu, Jun 01, 2023 at 04:54:27PM +0000, Edgecombe, Rick P wrote: > It is just a local flush, but I wonder how much text_poke()ing is too > much. A lot of the are even inside loops. Can't it do the batch version > at least? > > The other thing, and maybe this is in paranoia category, but it's > probably at least worth noting. Before the modules were not made > executable until all of the code was finalized. Now they are made > executable in an intermediate state and then patched later. It might > weaken the CFI stuff, but also it just kind of seems a bit unbounded > for dealing with executable code. I believe bpf starts out by initializing new executable memory with illegal opcodes, maybe we should steal that and make it standard. > Preparing the modules in a separate RW mapping, and then text_poke()ing > the whole thing in when you are done would resolve both of these. text_poke() _does_ create a separate RW mapping. The thing that sucks about text_poke() is that it always does a full TLB flush, and AFAICT that's not remotely needed. What it really wants to be doing is conceptually just kmap_local() mempcy() kunmap_loca() flush_icache(); ...except that kmap_local() won't actually create a new mapping on non-highmem architectures, so text_poke() open codes it.