Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp16534501rwd; Mon, 26 Jun 2023 11:15:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6lllluG02amUIl5mwQ1ell3aBswcr2pmdbNE+zu05Q+9JtRXBOC0xevujpF7M8gem6YTLD X-Received: by 2002:a05:6830:1399:b0:6b7:20ce:c4fc with SMTP id d25-20020a056830139900b006b720cec4fcmr11940665otq.12.1687803334387; Mon, 26 Jun 2023 11:15:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687803334; cv=none; d=google.com; s=arc-20160816; b=eE47XMTqJ1m8/WayO7UKBxSEbT3doErmb/bEVYht3A3XaK1nCHVvv93rXGXVH+RSL6 TLf5O1rbkDIIU2evRTgUqkJyuusSww4miWsreArOXrpE/cLGOvs5dgLk28JLtQ8MMzhN Wqw/QhrRRGh5gq+zuvzXf8KMoWJnax4gEb9hWc3g/41INd45FwXX4+lB++DWDDp/bpM7 243Hq2s60q899KsglHMSuQZ9xrBIjzzW6aNeX/ekjFBU2u7qvvmnvoLy5LpZP/1wtnh2 J9F7pDoidf1VYdbVbWLLJyRTy+ktSkSUErGBxN8XD0im4mKt1lWuNruMoZNkWji2Q+ab nawA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=fFWuzhLLiGkinhaWeToFLkDX/dcx5OWER83aW8VgRow=; fh=12+wRB/5XHKCdj2TIMIgS5y5kQHfIXe657Ikl1okOGc=; b=iTND/TdVmooL47MPYfpUN2qtek0VEkOL3AbstbxF6aMA5VpSbagDcPyIpBQMiPCLTP 4YgIhDF7O5ya9k+RvjdDuN8JMzFY5gLa/EOkRrvJe0gBzhDDK0HWHuzoO4v9KYfUORkh VNV4wGdjYqjATSPRW6t47mQ/WSfW8xqdpXyf7Aed8dsTESDZ+PdeCmcuVnK57xc4Z8Cq 8BryaWceznaIhxRxy8Zd7UotnYs1eQUYn3vcvFpyKPjzQ4gJJ835v9xx71tkGUeDGL2Z xjZSkY1mpTsi9OQ5WICXjMtbrCdFppdhUccfcN8qsJ+nIWUMzgrUrs/AJEa9rFkyDWem xF/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Qn7TSH5f; 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 m129-20020a632687000000b005537e4e7d59si5731839pgm.84.2023.06.26.11.15.22; Mon, 26 Jun 2023 11:15:34 -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=Qn7TSH5f; 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 S230223AbjFZRtZ (ORCPT + 99 others); Mon, 26 Jun 2023 13:49:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230377AbjFZRtK (ORCPT ); Mon, 26 Jun 2023 13:49:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 942EB26B3; Mon, 26 Jun 2023 10:48:52 -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 3025360F18; Mon, 26 Jun 2023 17:48:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86401C43397; Mon, 26 Jun 2023 17:48:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687801731; bh=fFWuzhLLiGkinhaWeToFLkDX/dcx5OWER83aW8VgRow=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Qn7TSH5fBy879Kn45s8a/YCOEx1oTS+0VCd/Q+kNmCB7uRTTg7TK3CW2K5FgKL5SO RoBVKuhnNkjoWxoU5K2xmCMLOL3TePePVRvun87gj3KrTnQpXgAMXLWOX/L2U+vGMb wy6CqBDWmWhCmphC6Q8EiBNziTaMXriaczMp6DJiN1Ej/WUjTzJ6N+lvXogj4eiJcj PJKRTqLP+Zecd+1KGIrC38/JsFePpZ84jlJVtuUPeUpe+0KdJssjei1KlWQsAb8xqI wX+VWs0F7zWSqHLgR+NZLp09+VOq+k1qPrGR83NuByW+4SQgicdeCKOv73ZNgnYywR IXCdgqJe6fP2Q== Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-4f8689fbf59so5765332e87.0; Mon, 26 Jun 2023 10:48:51 -0700 (PDT) X-Gm-Message-State: AC+VfDwHOCXBDBdGd9b4lMdSKT8qVBasv78TzKVknxYGcI7OVT7Ygd8R 4MKUxER8LP9Ic52vOMgwJgoERu5KyoiNGxxH/7k= X-Received: by 2002:a19:5f5d:0:b0:4f8:5e62:b94b with SMTP id a29-20020a195f5d000000b004f85e62b94bmr8655403lfj.9.1687801729333; Mon, 26 Jun 2023 10:48:49 -0700 (PDT) MIME-Version: 1.0 References: <20230616085038.4121892-1-rppt@kernel.org> <20230616085038.4121892-3-rppt@kernel.org> <20230618080027.GA52412@kernel.org> <20230625161417.GK52412@kernel.org> In-Reply-To: From: Song Liu Date: Mon, 26 Jun 2023 10:48:37 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 02/12] mm: introduce execmem_text_alloc() and jit_text_alloc() To: Mark Rutland Cc: Mike Rapoport , Andy Lutomirski , 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" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 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 pages > > 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 page = will > > be "invalidated" by filling it with breakpoint instructions (e.g int3 o= n > > x86) > > Does that work on x86? > > That is in no way gauranteed for other architectures; on arm64 you need > explicit cache maintenance (with I-cache maintenance at the VA to be exec= uted > from) followed by context-synchronization-events (e.g. via ISB instructio= ns, 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 torn rea= d? Thanks, Song