Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp872350lqt; Fri, 19 Apr 2024 13:04:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXIyhlzUo+ueD9d2Tl9JgHS8sjRcWHO+e7BhIgvAdr6crx60IEleTVnJH6Vxpdtbn9CpHU0KGayCizZumf/k8gEHnlPiwxhSq3dlGlCtg== X-Google-Smtp-Source: AGHT+IFwKtcdXZ1ehv0fdRPpVeuFrUGvsaBuP/qc1+a212rFVw4yYmWdSGwQ4QMLnqUKZRTaGr// X-Received: by 2002:a05:6a20:9794:b0:1a9:c843:6f37 with SMTP id hx20-20020a056a20979400b001a9c8436f37mr3558253pzc.19.1713557067125; Fri, 19 Apr 2024 13:04:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713557067; cv=pass; d=google.com; s=arc-20160816; b=AVF3JwyzHZ35IiDhz8ujRfsUUX0mfJjnKmJoBoSn8uyy9yybn0ps/9MiO+AqJyHNBT E/UT8eKeH1pwJK5WV70g5NPeAPEcDGLS+NlQQbJ88RhpG/UcgKtMZFY38BrKR64ZxEWC t1XOheZp1hqq2uWZAFdy+TmRxIXc312nojhoEAcp+tDW0Kf4iaaZBY4am1oCsW/Utu3H TpJJz2il5rw2hVH46+i9WOI5j2R9nI9a88lO7nltq8bwlUQyRKUvssTxj89ndW0JbNO5 2jdaWhVXBEXVddhUUo53/05iOGFZx1qDv/itp3UAA/motXAbQ9uQfNgx89asyGU6hdy0 AYjg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Z7FmTSDL0DsiTFkA903ZicdtUlw/HmenLkxicgXNje0=; fh=7CWc0oMXKDuCd1dK8m8iSHqZvuyVE5zY2SjGNC+50Rw=; b=gRI/hBco3YwnHuMNUJ09BLPnuPSfUf/7Jsc5Sn1n5XQhccJh0acX8eZBamtYEDKQhr aLTp6C7KPumNmewc3jQof7xoUm5g0thzaLk/YuYEPwuJg4dhqouDAn58GGpwItMPq+DR Nln+uheK8a1EyMC1KLVCb1teS1pavK8Iy1zJehnNxBwuyXy9zeTqICKU09sTgKfmVjqo fDVo5ppM9xiTNcsb1R/MbveWGY+3OQ3sscAUZl+N4Fo3bE4az0Rxq029VREO/5PPV+oP ARfmrOtUT1QFghbmhl0fbMZywezQo7H775zuREWg64oqeAtjzNS7Odk+oEYpA7Iv9OSf r33w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hePROBT+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-151923-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151923-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 ge2-20020a056a00838200b006ea83747d2bsi3671711pfb.244.2024.04.19.13.04.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 13:04:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151923-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=hePROBT+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-151923-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151923-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 3DACFB211CB for ; Fri, 19 Apr 2024 20:01:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A929E13D267; Fri, 19 Apr 2024 20:00:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hePROBT+" 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 9651513C9CB; Fri, 19 Apr 2024 20:00:42 +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=1713556842; cv=none; b=SE3wbmV8qDwQjD/+g32s18FwXpNNAg5Ib0NchlqfXCnmEXss6Cs3CiXoNHbFRyKXK+domDfSOGJ7j5ykMKrX8r+i5mrl7Y6gfD/EnC28zLh5+A/TvgaSxsQXm0ZaPnR0Yjc4kI0/84iN3OASp9gZWIuq5AJbekUxLqLPxpsF8qw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713556842; c=relaxed/simple; bh=1irIlRUcjlhAgXQYQkJd/oGHdCUHLQFxqqgY1XfLhP4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rpQ5GM0/X29Fn+zEyr17iQ0OjGTs8i2rF3WHCXqGpT98PL8igV4sIjBIBCngaK3AtR8lA8RQJXMxqa7GFcyuW1PX1kdBIuIMpi3/3z+hlG9Kz+BzjTClkm52stIqCZ44Qa4JkQY1Ea0y9lZljmporMsntjtjEbYAILm/NXe3dJQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hePROBT+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36E93C116B1; Fri, 19 Apr 2024 20:00:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713556842; bh=1irIlRUcjlhAgXQYQkJd/oGHdCUHLQFxqqgY1XfLhP4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hePROBT+glizGF2HhWjQfOISipAvaDLeIwoPfB6eB/130EUaYxI8C9JiOZ0p4IuPP wJr3uvJ18Qdtvzvp+1EN21A1wIYXV57CwgYBWxwwSTpuZVC3Y+zaCK4bAzWjqyz19x of4ezj0xR0KrcZGKrma2TwE1tPaK9aqfe2f5ZULEd8dNouln7cfqCdOX1Qzu+4TMk8 WLbPp6C0rIz8BNuB+lG6UD/vpJZsyvT1zRcqUNkcRP+vw16ocKGnhDqx8/KxOoGcQD fvWWbiJ1tqrYnX18IQfVwbrFy6dcbjd61pDUGP6pZkbtq0sqUsgCyvD6UjOkfp09sG phC1jK7//sNkA== Date: Fri, 19 Apr 2024 22:59:22 +0300 From: Mike Rapoport To: Song Liu 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 Subject: Re: [PATCH v4 05/15] mm: introduce execmem_alloc() and execmem_free() Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Apr 19, 2024 at 10:32:39AM -0700, Song Liu wrote: > On Fri, Apr 19, 2024 at 10:03 AM Mike Rapoport wrote: > [...] > > > > > > > > [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 size) > > > { > > > ... > > > p = __execmem_cache_alloc(size); > > > if (p) > > > return p; > > > err = 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 that > > 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. Why? > Does this make sense? > > Song -- Sincerely yours, Mike.