Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp794766lqt; Fri, 19 Apr 2024 10:33:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXNyMDJi09ovFRQgX4FvCf31kEjxR3ORJLqNrS+gUkI0noHhndiRlwCImBAd6JTnotmYSZmU6lpZyjC4wseklG5Z7tOPIlj9feVraIWWQ== X-Google-Smtp-Source: AGHT+IGtJ9BJtyX1mSO7qWtwb1n72BqyvbDVLxozEYgdr7+C6iPc7xHjfn68RCohGR9rhq2lQa5D X-Received: by 2002:a05:6a20:948a:b0:1ac:dead:68 with SMTP id hs10-20020a056a20948a00b001acdead0068mr359348pzb.24.1713547995868; Fri, 19 Apr 2024 10:33:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713547995; cv=pass; d=google.com; s=arc-20160816; b=HWanqQKgPOfxc9xkiN/f8cDmRnyT0B79/jkEXiulv3BmtOv/CfhZJ6eAy8IHHxkT+Y TbcRo/jcJKkZSdu6P69OFi1n5WW21i5E1oed7WOPO6wSzZH6NWDBEiS0h5N8Q05yUS0L nTX6k7Hj3qjd3R4wzOglZQyGIEOYhBsuHZP89TUDpkjFWAR9TR43nBUAxZHM3F/lNsyS XG+fyNCLfSLBV1vSNLv2RnOHxv3ubcsxhSIRZ4p74qg+nF3oZxvgYl+vbZqiI6fUxlKC I0eq1yqJZTZxi4KjrhkBqi2NISGkEyhYWq651wZVsKl8FuKBXX35HL/v3RdOWrs3F4OM T8qw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=thIwesszatYaJ6sctPtDKM7mmBtwkWZpjuK7ZWkjfTQ=; fh=okKEKEW+WpyoF3ioEIyXK2OGxCLF9X4BoOZpnP/mISM=; b=g13bF9hRnFHUNg7Zqtt/D4sf9C/68euzLFqFtWaXltuLSeyQj9rCDkMtp0LZbgIGW8 WCEngI27YEtUfacWLHlTULhSF6nLq3A/NYxD02+bMFAAvYnvLMaYLVlJIRO4UiwUyo0L 0la+l8x1gTf7+RMMG/9ZqTBRLa7xchbVeEvH5Qd5/KPoQ8jrVADZ8D7nD+qFtRjclkml Du2izVMthpiH7WOqLb+iVcT+k/Uo49PKowDJcBwS3fjZOXLr5NaXcvTLItNpUW2QyQ5f UQySpx1uTNAfjm4/04nt3RpOFI/5F4u+/pWYLjae+KL0M1m0bODa8uOVGYXtZYCxrIve EW9A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mLeMJbhX; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-151824-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151824-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id f21-20020a631015000000b005dc81a6b2absi3434775pgl.792.2024.04.19.10.33.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 10:33:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151824-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mLeMJbhX; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-151824-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151824-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 54A25B227BD for ; Fri, 19 Apr 2024 17:33:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0AF6F13B5A1; Fri, 19 Apr 2024 17:32:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mLeMJbhX" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5024130E20; Fri, 19 Apr 2024 17:32:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713547973; cv=none; b=CE+2DkWXpbfGDao3u2gA2paG7uTS1sQcksfoIX6eNxKfTQam6U6SupQ0Q5if9vKTIKaIs90iLzl4OFy2qYeUe7XQSyIB4IYMrbCs713p8I7uBePp4+OLjIO1T5g31O1Lvfqr9ij1JfKXr/n0pST45jnVT2/ESC1YDfR8iP5jziw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713547973; c=relaxed/simple; bh=sVegppIF/niXLnTLCcBWzkxa2L1ow1Dt9dF+ATN6lsk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=CVBM7NZ9h1xg0Zz7LdIsYP0XSr5eioYrSpAtIYT1A+gbQivejKix41i2I0QZQRuHX0yysA3jEuV5XWVoW7zQP6hkA/hpyIphhSq0U3S3jVI/JMm/SMcNiHNRB5U9yzr4HM+COQ5XV56ArWCvnnxvHV++lxmTNs0cMIJ1Bk0rgiA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mLeMJbhX; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 556FAC32782; Fri, 19 Apr 2024 17:32:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713547972; bh=sVegppIF/niXLnTLCcBWzkxa2L1ow1Dt9dF+ATN6lsk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=mLeMJbhXL1USdyI1VBlZR/GBg1BEz0cjgWcP3SXE7vHv+TaAQSyfRtJFvknWhZNwF EWgJr5kC1w4O/75kkwCllehB+XaQxw0W39Vheh4H91moRz4zIACCdx+7jJEfpx6lZO x8q/xw1DFD+2x4Fti4C0rP5hLs/xqJFqj4UHRxR8PvHiGzZtkZ6mLr1kr1XSdfdIiB YE3donqw1Gm0GoL/3qzEWlzTvLIfaL/IRhRD7q9EWCzscK8abqIPsxDOM48gzlIU75 UnQWol+B94cwBhV5l/AV7J/1aE3nJoEBRBO1u2qhUn/t9zYuQvrWaz871VWxdPhsum QvkU90GBu4LBA== Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-516d1ecaf25so2984590e87.2; Fri, 19 Apr 2024 10:32:52 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCX8YgCfyt2ijOYD3jCucwuP0qHnEeZz0uMsZX5YKcmpJ7KA8e6ZYRe9mcr+51/60f0/uNyStDto5eSUR4vQqhogWeq5xOuWECH0+i5VuutxrxkGH0e65GTsOodX0s/9npXpwmMYHpGeGTvhHhVi4lr1qM9TaqUodlQJLEql8CY9NbuNzd23Nhlq6OeF2Z00aIUYclB1TLQuV+i5xSn7/pSD0rOSKm1NlFySerHfLMIXf76xPN4oi33ICOOCRVM75u0G1je5V3ygHtQuaO5cudhAi+HbA+PInUlg7DWEFiH2O54K6yIoaJ6i5LBXyEeFcEROi9VPLnzJQlpKnnpp2GdgKeKN/EFqSWzUO2ZtRzsyWvcNmF3iJrAKto+yKUzn3tWAy98Ubvx2KbCtzE9Aaic3C7eoQL8DakahD5fK9S0VchZjqebZ8fDd8h4= X-Gm-Message-State: AOJu0Yy3YzKXSgWYvVlKluT8ebaVPxkFUs9f61nP6uSKxHfMuUcDNz2L i/EgqF9IgUoce6Nz/+w+IbFZ7qUMNNBYGmAeqgSYZuwaFbtfQCnaqEcx6e/vS6BcQA16+BaoYs0 uSbRVEwMQlAYSmpnOhEjK4eZufKI= X-Received: by 2002:ac2:5a1e:0:b0:519:296e:2c80 with SMTP id q30-20020ac25a1e000000b00519296e2c80mr1475078lfn.15.1713547970497; Fri, 19 Apr 2024 10:32:50 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240415075241.GF40213@noisy.programming.kicks-ass.net> In-Reply-To: From: Song Liu Date: Fri, 19 Apr 2024 10:32:39 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 05/15] mm: introduce execmem_alloc() and execmem_free() To: Mike Rapoport Cc: Mark Rutland , Peter Zijlstra , linux-kernel@vger.kernel.org, Alexandre Ghiti , Andrew Morton , Bjorn Topel , Catalin Marinas , Christophe Leroy , "David S. Miller" , Dinh Nguyen , Donald Dutile , Eric Chanudet , Heiko Carstens , Helge Deller , Huacai Chen , Kent Overstreet , Luis Chamberlain , Michael Ellerman , Nadav Amit , Palmer Dabbelt , Puranjay Mohan , Rick Edgecombe , Russell King , Steven Rostedt , Thomas Bogendoerfer , Thomas Gleixner , Will Deacon , bpf@vger.kernel.org, linux-arch@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, x86@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Apr 19, 2024 at 10:03=E2=80=AFAM Mike Rapoport wr= ote: [...] > > > > > > [1] https://lore.kernel.org/all/20240411160526.2093408-1-rppt@kernel.= org > > > > For the ROX to work, we need different users (module text, kprobe, etc.= ) to have > > the same execmem_range. From [1]: > > > > static void *execmem_cache_alloc(struct execmem_range *range, size_t si= ze) > > { > > ... > > p =3D __execmem_cache_alloc(size); > > if (p) > > return p; > > err =3D execmem_cache_populate(range, size); > > ... > > } > > > > We are calling __execmem_cache_alloc() without range. For this to work, > > we can only call execmem_cache_alloc() with one execmem_range. > > Actually, on x86 this will "just work" because everything shares the same > address space :) > > The 2M pages in the cache will be in the modules space, so > __execmem_cache_alloc() will always return memory from that address space= . > > For other architectures this indeed needs to be fixed with passing the > range to __execmem_cache_alloc() and limiting search in the cache for tha= t > range. I think we at least need the "map to" concept (initially proposed by Thomas= ) to get this work. For example, EXECMEM_BPF and EXECMEM_KPROBE maps to EXECMEM_MODULE_TEXT, so that all these actually share the same range. Does this make sense? Song