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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 935B6C04FDF for ; Mon, 17 Jul 2023 17:24:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EF846B0072; Mon, 17 Jul 2023 13:24:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 278D78D0001; Mon, 17 Jul 2023 13:24:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F1C76B0075; Mon, 17 Jul 2023 13:24:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id F09EC6B0072 for ; Mon, 17 Jul 2023 13:24:30 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C9C8180447 for ; Mon, 17 Jul 2023 17:24:30 +0000 (UTC) X-FDA: 81021777900.19.2D98817 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id 316A9140021 for ; Mon, 17 Jul 2023 17:24:26 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=U55TcGyi; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of luto@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=luto@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689614667; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nfJBbCTXPolvdJK/+Xqw0USoVndNwWvCJcH4Qcb4wug=; b=u7OGxa2ZKNTTc1zgc4KZxrFTbn1cUQPYvA+AyR3c8RskiU13Z75wGtj0DNWasufRBI6+cN /9huQxiqHTDwPL0Yzlo29Vx0Rw4T7/DRdOIfVjtsNXTDOyTxr2BLJGXFk0++f+RACQtBee aO8FsVC6ivdTPCXCBL2YHkTP3QtsCtA= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=U55TcGyi; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of luto@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=luto@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689614667; a=rsa-sha256; cv=none; b=52gdZg+0pwV7OYN9FIUB07MXvyPKz0a/JF8WMzQtPUsF+iRigFvL2KMhEjlOvqsqoIpwTW Yl/xLsktVPHIaRS2jvFUyoC/QT9dCt/uGI6HZKFD8PcPBAyDPPHB1bPlYKZQahO+B8jeJZ Ysqx+kVykkCokrxX18S9ZoAJtSd5zvI= 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 1E24B61018; Mon, 17 Jul 2023 17:24:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26824C433C9; 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-Rspamd-Queue-Id: 316A9140021 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 5a3kh1ak4ym7fxc41ryq8bqzy1x5thdg X-HE-Tag: 1689614666-778125 X-HE-Meta: U2FsdGVkX18RDLgVwTmq5YiJGxUY9B2Sbnrut/A6GjmrB/fpndkhMgcz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iVV7QakUG+UnJTT35oSZ0FczphgtBukAnkGT9HIiFqNs25Ey4l1lAEjiP7d6rb/cI/GB3GVLv6/7IGVgY9eHrfZ6O1hDPlmGTsJDTDX/u8l5vHE4j3VznSFjKBOPM/kGvUyUGfaGUL3r04zts4CVA8+8fvyu/x0vmyCpT5ixBTUhMj7LD5ZCjGzX70jkb+o02Vi75YgTbaX9ev3L6c9WeGMvQsjwXCeGp8PtH5JcG8mr01zfBxqlDx2gOvvn+ojX88X1BuDXkh5tveUdwLLcKHOrqtuPvA2j3zyJGn8gjG1CB7EuE76ZJ2aygU+ByFfCG3Cisy3DXqtesCCTHdsmncyVu5Ihj71Wgf0knnkSvBs6DcgtOGWtTo8pMd8l61GW8ZwYd5 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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