Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5864064rwp; Mon, 17 Jul 2023 10:34:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlFpjlF+An31bWhTAYKjoG4MY8oXmllYRMQtZ732sXAo95RTP1CCjf2RjPfNhMct3YQf4UF+ X-Received: by 2002:a2e:8183:0:b0:2b9:3274:dbef with SMTP id e3-20020a2e8183000000b002b93274dbefmr3621537ljg.45.1689615245417; Mon, 17 Jul 2023 10:34:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689615245; cv=none; d=google.com; s=arc-20160816; b=Go5Jw2jogN0H3i0JFMZATpUvnaW+E8Htua+iY52VKHezYue51NLYMLSkLzIcMrYXF/ mrWoyrUDfpCWrzS6k6QIGL5aYgeNbb8o1KYaMe8tPz0Hy0nNNQYzaeHmh7iyZyJ4q60v inTUr3jikVB6buO8VCkv2Opkw+HlQI5/ojjfqCORW/aC9SfQLdu9AxvDb0JfVAr83ocW ec2W5R1ohHphYOf0rfkhnur6bpf+Pk5aZTFcV86WeQ5B5PE03sbYsFAVSehPBDGa8Tt+ q35b1IzPnATTdH28yPP0D03vdyWaUZWPgrXDuGj2ttXiMZDNEildK4TsAd2BT/sDBW8E Lt3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:subject:cc:to:from :date:references:in-reply-to:message-id:mime-version:user-agent :feedback-id:dkim-signature; bh=nfJBbCTXPolvdJK/+Xqw0USoVndNwWvCJcH4Qcb4wug=; fh=8A4B9kiDwgKrQIripQ4q8oHZcoDEsbjPa9SpxpNIqSE=; b=gheF8SGn8YIHeFxJorr1y9nkPJN+3mC7zzNgue3e82L8Sh725BtFgrkRmEL2QFOaGu FJ5Y68K9n+4NpzPfe+e+UfSPHIoUyF1mrB/WGYAGHqc+F3u9aOfgIQKC5DhSY57Rb67u pmLpXMRriAA8SNj4rN9CaiDO3r410a6RxawxLplW9mN3WvytAkot8j2/jhc/UjQ8zCVk U2cH/gGV1DTt6Do6Xbd2Y3nEvxUoqFXexJ5jckj7MR34J9EG3+TPG1QthRvwoLL0OWPU DxZ/BrmsEUo9V6UxpWdW/e0nCxW5Fj2AzJFqe280kuATJ0ooFR48yzVGoJEXp/RyKagY JKtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=U55TcGyi; 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 qq15-20020a17090720cf00b0098dc18c13f4si14382051ejb.1037.2023.07.17.10.33.40; Mon, 17 Jul 2023 10:34:05 -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=U55TcGyi; 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 S230432AbjGQRY2 (ORCPT + 99 others); Mon, 17 Jul 2023 13:24:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229667AbjGQRY1 (ORCPT ); Mon, 17 Jul 2023 13:24:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87582BD; Mon, 17 Jul 2023 10:24:26 -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 1A1D161193; Mon, 17 Jul 2023 17:24:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 249E2C433C8; Mon, 17 Jul 2023 17:24:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689614665; bh=o+WgjDKzf9AD9b+kUzQGRClRYLlDB82OkTDYfv6a3Yk=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=U55TcGyi7YmJyhzLOTZnjrFVWw0H3+af918Yjk8mPHfHD/clSDnn9R44JznF10IRH Z8KK+n6r0jSrVIOFXY3K9zEUwgWJJmDl6U+xcWuKBgzWtStxy8DJ8vdgvW6lkDoW7B HjBUxuU9UxtzkC9l5ApN5DKkzBCr1VsqK7wmYWuXqa2OawFE6M2Oq9WP6fcTzeqAS1 oQr1aLD/6waYS1NoUdY5C7XFt1xXn2X7vRDexou/Ye3pmNVTURfyjeGdd/9YrFIH9l MqvAuz5uF3yGQhNR2S/bV8TY4Zn4vPj0wIo0nVHW6MMTPN4UGDgaMVOo3Hl1Lknk4t QarZtUu8s3ucw== Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id 0594A27C0054; Mon, 17 Jul 2023 13:24:22 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute3.internal (MEProxy); Mon, 17 Jul 2023 13:24:23 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrgedvgdduuddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtgfesthhqredtreerjeenucfhrhhomhepfdet nhguhicunfhuthhomhhirhhskhhifdcuoehluhhtoheskhgvrhhnvghlrdhorhhgqeenuc ggtffrrghtthgvrhhnpeduveffvdegvdefhfegjeejlefgtdffueekudfgkeduvdetvddu ieeluefgjeeggfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpegrnhguhidomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqudduiedu keehieefvddqvdeifeduieeitdekqdhluhhtoheppehkvghrnhgvlhdrohhrgheslhhinh hugidrlhhuthhordhush X-ME-Proxy: Feedback-ID: ieff94742:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id D060531A0064; Mon, 17 Jul 2023 13:24:21 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-531-gfdfa13a06d-fm-20230703.001-gfdfa13a0 Mime-Version: 1.0 Message-Id: In-Reply-To: References: <20230616085038.4121892-1-rppt@kernel.org> <20230616085038.4121892-3-rppt@kernel.org> <20230618080027.GA52412@kernel.org> <20230625161417.GK52412@kernel.org> Date: Mon, 17 Jul 2023 10:23:56 -0700 From: "Andy Lutomirski" To: "Song Liu" , "Mark Rutland" Cc: "Mike Rapoport" , "Kees Cook" , "Linux Kernel Mailing List" , "Andrew Morton" , "Catalin Marinas" , "Christophe Leroy" , "David S. Miller" , "Dinh Nguyen" , "Heiko Carstens" , "Helge Deller" , "Huacai Chen" , "Kent Overstreet" , "Luis Chamberlain" , "Michael Ellerman" , "Nadav Amit" , "Naveen N. Rao" , "Palmer Dabbelt" , "Puranjay Mohan" , "Rick P Edgecombe" , "Russell King (Oracle)" , "Steven Rostedt" , "Thomas Bogendoerfer" , "Thomas Gleixner" , "Will Deacon" , bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, sparclinux@vger.kernel.org, "the arch/x86 maintainers" Subject: Re: [PATCH v2 02/12] mm: introduce execmem_text_alloc() and jit_text_alloc() Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 Mon, Jun 26, 2023, at 10:48 AM, Song Liu wrote: > On Mon, Jun 26, 2023 at 5:31=E2=80=AFAM Mark Rutland wrote: >> > [...] >> > >> > So the idea was that jit_text_alloc() will have a cache of large pa= ges >> > mapped ROX, will allocate memory from those caches and there will be >> > jit_update() that uses text poking for writing to that memory. >> > >> > Upon allocation of a large page to increase the cache, that large p= age will >> > be "invalidated" by filling it with breakpoint instructions (e.g in= t3 on >> > x86) >> >> Does that work on x86? >> >> That is in no way gauranteed for other architectures; on arm64 you ne= ed >> explicit cache maintenance (with I-cache maintenance at the VA to be = executed >> from) followed by context-synchronization-events (e.g. via ISB instru= ctions, or >> IPIs). > > I guess we need: > 1) Invalidate unused part of the huge ROX pages; > 2) Do not put two jit users (including module text, bpf, etc.) in the > same cache line; > 3) Explicit cache maintenance; > 4) context-synchronization-events. > > Would these (or a subset of them) be sufficient to protect us from tor= n read? Maybe? #4 is sufficiently vague that I can't really interpret it. I have a half-drafted email asking for official clarification on the rul= es that might help shed light on this. I find that this type of request= works best when it's really well written :) > > Thanks, > Song