Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3476081lqp; Tue, 26 Mar 2024 10:04:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5KFK0uMXN2nFu/amaYzBMJhCmKtTciSFh7SPREhiNx6IpUVv5Gf7kJ6tVcy7iAKTvS+tl45ZyGdWClyv7wFbqeW4REg0+TbYwyqNknQ== X-Google-Smtp-Source: AGHT+IH0ZZUAKTVseO87jXR5ZVVPN/9H//mfOm7WawBK68WIC4Sbzt5xAfXy5cdLCuQ6SsWNYwrD X-Received: by 2002:a05:6a00:1808:b0:6e6:b320:5567 with SMTP id y8-20020a056a00180800b006e6b3205567mr2032784pfa.24.1711472681699; Tue, 26 Mar 2024 10:04:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711472681; cv=pass; d=google.com; s=arc-20160816; b=uFSAruSaUh0AKmJCQVlJHDmWFKmlmL0MveQ68N+LJm+gtwcan1dq6411uzbgLX/drK S6wuZIeTpRFEZvjAS+/ZqrkGciqh20JBhymQLeO40s+7gdCb9Fj/MB7YMv5YSPSjsonB tb1pzA/z+NbK9II5vDA9NOuNOVnTbTCp2HgJaqMgGNEwLjPyn+rgGUwCT5sbIM+VYOoU zTW55dhSb0yrcsaAAEXWXrYpl5kwN+CO3xVVnH24R6igDaqlDmfm4WrzprHgtuxrc+rQ at5Fu6Sp2zgr3Aa29X5sKn+VIWuOUSGzBoMfoEG169H/3tKsGZaZMcku5tiWwhFD0Bup Xbbg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=mkDAsk9N6MYomVPnQx3qbVx9seQvCicRbPMWiKbGqKA=; fh=3Igtva66iLFF+yhYxQZqIVp7ObLMgfBm1n7Bav6SjRU=; b=TrQD1o+MXoJGvykhO5Vbz7XH9DB/00Oov46PdlfpRvY7ormrXaYsa+ffRCMHKon8QG LgnpRxNqvvqqLNQ1ontEbXX2UBnY/euZlDQX0htGOc0QcBzsbFumnMcNuU0ZKTipVGSp 064zIjVyINdRWhzzGm8EDnXhmihcxyOTUsggFAF3XGg0/t+tYvjJzTkkRkeoabY5rCGl mDGDNNVZncWoEpfE7N+23AbSIO3HTtyy7eq2GsNioQX8mqqrvlltW5ZWTYd3dOSYUGX1 R2xYz9UuJswcRrTeytCEM0HSKaD8X8aUMmkCbvsUrHnvF2QShpwSmNpVYGDgtO3WRF2J UIyw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-119482-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119482-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id p13-20020a62ab0d000000b006e69b4fa6e3si7422054pff.357.2024.03.26.10.04.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 10:04:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119482-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-119482-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119482-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 53DE5B22009 for ; Tue, 26 Mar 2024 16:38:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 21C4612E75; Tue, 26 Mar 2024 16:38:14 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 489173DAC0F; Tue, 26 Mar 2024 16:38:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711471093; cv=none; b=OQ4H8oXosRQ66njrzRAMQACwG2mt2LjiYmN8tGDi1cz2/vIgMHRi6fkMYffmKlXId+ONiojOUY01cOpioZQagichW1GV2sJEPEQeth0yo1nBfV4kk2bBI9Vj5+Hty38CRnKMh9rVLBb7KSXDJqRtLHL6YUpn6asgy64x8SoNicY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711471093; c=relaxed/simple; bh=1VUl5T3Hy9/wKjGM7Ekj16noT58ordY8L5XY+CsT5wE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OAMvyH0vVZDZ4ABlXPwhZ3fvIZAhEdf/MLjS7QFO4H47WGd1u6WwpskeHxpcC5/+8m6cmfbOX6z3GihZOBP73WOa3Fb4RjW472PawNKnkUBiejljHQZabbB+DxPRErE5ERhzvZGhVQn3X5h4YEET84q4AxjkgyELNcXm+3lV24A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6E6452F4; Tue, 26 Mar 2024 09:38:45 -0700 (PDT) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.35.184]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2A34C3F694; Tue, 26 Mar 2024 09:38:10 -0700 (PDT) Date: Tue, 26 Mar 2024 16:38:07 +0000 From: Mark Rutland To: Masami Hiramatsu Cc: Jarkko Sakkinen , linux-riscv@lists.infradead.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-kernel@vger.kernel.org, "Naveen N . Rao" , Anil S Keshavamurthy , "David S . Miller" , linux-trace-kernel@vger.kernel.org, Calvin Owens Subject: Re: [PATCH v2] arch/riscv: Enable kprobes when CONFIG_MODULES=n Message-ID: References: <20240323232908.13261-1-jarkko@kernel.org> <20240325115632.04e37297491cadfbbf382767@kernel.org> <20240327002403.62649aee45508b7a16caedba@kernel.org> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240327002403.62649aee45508b7a16caedba@kernel.org> On Wed, Mar 27, 2024 at 12:24:03AM +0900, Masami Hiramatsu wrote: > On Tue, 26 Mar 2024 14:46:10 +0000 > Mark Rutland wrote: > > > > On Mon, Mar 25, 2024 at 11:56:32AM +0900, Masami Hiramatsu wrote: > > > I think, we'd better to introduce `alloc_execmem()`, > > > CONFIG_HAVE_ALLOC_EXECMEM and CONFIG_ALLOC_EXECMEM at first > > > > > > config HAVE_ALLOC_EXECMEM > > > bool > > > > > > config ALLOC_EXECMEM > > > bool "Executable trampline memory allocation" > > > depends on MODULES || HAVE_ALLOC_EXECMEM > > > > > > And define fallback macro to module_alloc() like this. > > > > > > #ifndef CONFIG_HAVE_ALLOC_EXECMEM > > > #define alloc_execmem(size, gfp) module_alloc(size) > > > #endif > > > > Please can we *not* do this? I think this is abstracting at the wrong level (as > > I mentioned on the prior execmem proposals). > > > > Different exectuable allocations can have different requirements. For example, > > on arm64 modules need to be within 2G of the kernel image, but the kprobes XOL > > areas can be anywhere in the kernel VA space. > > > > Forcing those behind the same interface makes things *harder* for architectures > > and/or makes the common code more complicated (if that ends up having to track > > all those different requirements). From my PoV it'd be much better to have > > separate kprobes_alloc_*() functions for kprobes which an architecture can then > > choose to implement using a common library if it wants to. > > > > I took a look at doing that using the core ifdeffery fixups from Jarkko's v6, > > and it looks pretty clean to me (and works in testing on arm64): > > > > https://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git/log/?h=kprobes/without-modules > > > > Could we please start with that approach, with kprobe-specific alloc/free code > > provided by the architecture? > > OK, as far as I can read the code, this method also works and neat! > (and minimum intrusion). I actually found that exposing CONFIG_ALLOC_EXECMEM > to user does not help, it should be an internal change. So hiding this change > from user is better choice. Then there is no reason to introduce the new > alloc_execmem, but just expand kprobe_alloc_insn_page() is reasonable. > > Mark, can you send this series here, so that others can review/test it? I've written up a cover letter and sent that out: https://lore.kernel.org/lkml/20240326163624.3253157-1-mark.rutland@arm.com/ Mark.