Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3482094lqp; Tue, 26 Mar 2024 10:12:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWy0vRPnPGuRCN7k5f3H3xbIfbR+HlmUG/m8rOHwP+nfGscdfhy61g/EBPmh1Rkm1j8vZb86v4YztkOBLD2giooIOOCpJaAwVqP/l04jg== X-Google-Smtp-Source: AGHT+IEi/BoZW9Gy36lpDmygqPN1O1uawp+DX2nP+T6sykXLDdxXNcTyN1FpjCd6Adn66wHjFqqi X-Received: by 2002:a05:622a:104b:b0:431:627e:e3b3 with SMTP id f11-20020a05622a104b00b00431627ee3b3mr3086406qte.26.1711473163703; Tue, 26 Mar 2024 10:12:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711473163; cv=pass; d=google.com; s=arc-20160816; b=BYI7z80m2r5ps5onVriCVx2s8rSl61WqodpPez+gUpsH5Fmmb0zG+3IMhbkqmcydS1 sRrR/byJfD2QKH4nv6q3qyb4T8KJOqT5iHCH2fKsoG/jNSloplRwEwHKjS/vEgl9BztJ zI/5NcquXeY4Ur0cOm/YniUbVNG/6AlO0360ufluNAW2a6cjQlkJnqrWbavVxMvf0tGv ydwRlA2MSTtvDIDlE9TCirZSUS5sakiTz+AjV+z1sEmxh75GKLFS/BEWgOkuv5/5ziFJ i+lh/gh6ZuF73+H/wIKjTMRQhoRFhJebqKyuohQJ/nbjkTiyTZYE8PNS7EOsY7vUcarl xblw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=yeIqY639vuTBsLeefwFtJbfXyLaAXycK2L+kcQB9jQE=; fh=imoPCXKNCzbGA+ZAHOt0+KTLKj1g/oFt/Ao8tgCXqQI=; b=erZLKj22AKnElyOTtu8O6Rf69i0awv98kdTniRRQ7U3Cw1DDCvjFMBd4ykmA0MTIBn gxFIZuw9+fMTK+XcLutKVcCeADhWql+1QspetSzViLa+KYUB04CigjZjTa/wxP9ZX3wQ 7TzSWK0szNMcg1O2ZVW9FjtPiI4oVuzM7c3Syi9Mrgk0de9S3k67nPGJ9m1N5mu3pf3n FRklawFdGdoKZIoSo1zDWCPgEBMsXVO6m6YBlBZgnTIR2e0eZe7tjO9hwC048wIhHBa+ HD4txB8pdgncwVeBK+aHswQS9l69F7BgmAKmuLxgXzKMTz1dAypfg6xSl5ZXJ57At7r6 BzOg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k9DczX69; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-119560-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119560-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id p15-20020a05622a048f00b0043174f36b4fsi1066898qtx.430.2024.03.26.10.12.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 10:12:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119560-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k9DczX69; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-119560-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119560-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 1B95D1C65DBD for ; Tue, 26 Mar 2024 17:12:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3EF9D1D555; Tue, 26 Mar 2024 17:11:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="k9DczX69" 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 6803C20B20; Tue, 26 Mar 2024 17:11:51 +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=1711473111; cv=none; b=RLgKf8+ZU1sBU0s6J7RL9l2JFJSnAfcCdQ/hOIkTkGrcifTeW3KyCOx46Kx7ErPZkq8wV27/6Rth9uG2kwhXOZXoAymKNi7xNPZzwIe5m5MAFOnFL8O75QIwJR/WN+b0L5RfNHhUVB0VV8sQu+zdwWi/UGHG/VKTnajk6xp2sKc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711473111; c=relaxed/simple; bh=SHSbPddnUrZNJUnZQETz0axiiuHhU56cJ/TyjxOm3LE=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=FVTFyClDiLqdmA8HOooMYgCGkAk6do3bl6vomI2aQ6r2/cVnx//qBuSt7PLnJGY3rqnI9yuPPCAakSxL9w4lEI/ZKrMOmBkGnuzypiyQ9QVT3tMLpe5w6IDpk9egETSzkwfs8eT8SNs9QEGAEpH4uLYNgVd+4tPEDiEk1VkSyz4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=k9DczX69; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68446C43399; Tue, 26 Mar 2024 17:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711473110; bh=SHSbPddnUrZNJUnZQETz0axiiuHhU56cJ/TyjxOm3LE=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=k9DczX69FvUQ6wdICAIJXiq1qaqYzNybKX/V+0hbSEhTZO6Q/IDyUfO+T0mZbLFoU 2JHkuWbGZdLCAZSmiLl89L9xs/BUDMV+wis1wiXB9+tw6CMioewzz6Xxg7iHfyIeer MV7OmEh/I3M8FcPpapn0tWIkyR9n0nE1+sudyLFMOdzX9z4KNEqDFHBYHa4chU9MtF ooPpKMvpI0iVPfvhZ1Gx4+7AAnNvVhp2bxMgj5z5687GC8kmpz2DOnm3nPo8qHH++t Jo5FPJqDXtzFwnMxVzuIkhqAzH9pIgUsca/G/irikJZYMdpRStUUUmdmw9PYHR3rkB SfVjRo212/Ptg== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 26 Mar 2024 19:11:46 +0200 Message-Id: Cc: , "Paul Walmsley" , "Palmer Dabbelt" , "Albert Ou" , , "Naveen N . Rao" , "Anil S Keshavamurthy" , "David S . Miller" , , "Calvin Owens" Subject: Re: [PATCH v2] arch/riscv: Enable kprobes when CONFIG_MODULES=n From: "Jarkko Sakkinen" To: "Mark Rutland" , "Masami Hiramatsu" X-Mailer: aerc 0.17.0 References: <20240323232908.13261-1-jarkko@kernel.org> <20240325115632.04e37297491cadfbbf382767@kernel.org> <20240327002403.62649aee45508b7a16caedba@kernel.org> In-Reply-To: On Tue Mar 26, 2024 at 6:38 PM EET, Mark Rutland wrote: > 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: > > >=20 > > > 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 > > > >=20 > > > > config HAVE_ALLOC_EXECMEM > > > > bool > > > >=20 > > > > config ALLOC_EXECMEM > > > > bool "Executable trampline memory allocation" > > > > depends on MODULES || HAVE_ALLOC_EXECMEM > > > >=20 > > > > And define fallback macro to module_alloc() like this. > > > >=20 > > > > #ifndef CONFIG_HAVE_ALLOC_EXECMEM > > > > #define alloc_execmem(size, gfp) module_alloc(size) > > > > #endif > > >=20 > > > Please can we *not* do this? I think this is abstracting at the wrong= level (as > > > I mentioned on the prior execmem proposals). > > >=20 > > > Different exectuable allocations can have different requirements. For= example, > > > on arm64 modules need to be within 2G of the kernel image, but the kp= robes XOL > > > areas can be anywhere in the kernel VA space. > > >=20 > > > Forcing those behind the same interface makes things *harder* for arc= hitectures > > > 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 architectur= e can then > > > choose to implement using a common library if it wants to. > > >=20 > > > I took a look at doing that using the core ifdeffery fixups from Jark= ko's v6, > > > and it looks pretty clean to me (and works in testing on arm64): > > >=20 > > > https://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git/log/= ?h=3Dkprobes/without-modules > > >=20 > > > Could we please start with that approach, with kprobe-specific alloc/= free code > > > provided by the architecture? > >=20 > > OK, as far as I can read the code, this method also works and neat!=20 > > (and minimum intrusion). I actually found that exposing CONFIG_ALLOC_EX= ECMEM > > 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 ne= w > > alloc_execmem, but just expand kprobe_alloc_insn_page() is reasonable. > >=20 > > 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: > =20 > https://lore.kernel.org/lkml/20240326163624.3253157-1-mark.rutland@arm.= com/ > > Mark. Ya, saw it thanks! BR, Jarkko