Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3053966lqp; Mon, 25 Mar 2024 19:01:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVVKOOKZ9ofAKzyIn38IOPjfPOvhtYhm6yvpOnroqhsaVi7h6qg1x6j45tjbfMfGIc4AZmnHKRAh8OEthvJYzvgu/uR3tTbkgt7B+Jh8g== X-Google-Smtp-Source: AGHT+IHEUxqN2EyvwaeixPmEhOEnH+oLvliSqgDoMZ49S6cfp65kWrJidHQu3P5+IKE/VRVunc69 X-Received: by 2002:a17:907:2683:b0:a47:5231:754f with SMTP id bn3-20020a170907268300b00a475231754fmr4825248ejc.7.1711418498939; Mon, 25 Mar 2024 19:01:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711418498; cv=pass; d=google.com; s=arc-20160816; b=ePvp/+HcC7tIynWlWte9f1rnmQtJXUt+qH7WDdr1CF54fTG22RAYz8yVEYKE1H+NE+ m5I4EW0YjWBg1dZPcB86yZR2QVJrxuM13Jym5pLk+jPtSv/eH4y2j4dtTvIxWeHnastU OA8kI5vAFokqiTNxq6E10060TwCHxOV5ylf03KdB80Lmf4UT47MrCXoIrrVHA4eqrCJI 7l+JmejE25bTN0cxxQAFadtqkUz14Ine4epw5cr8QmHAoVyhbaCVxFniIQ/0iCIQBJ4X wYRrZqzy0lz2Da/W9sBJMxgcimatFJVWzegmi6fGb7BhZdgDAk00nG7M4WHM4jNjZoE3 Fm6Q== 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=u+YioT3FqOTC40O4LsygPgqeGJJk0g7l63OSy9zO5jw=; fh=HmETeg3EB6EeHuMCK1ogWZ40gOfYquwpurWVOP7Z4y4=; b=DHJFurPI11sCdLxI+nE/eJL7GlAHxRjqZC+I21xiezTa59sbTNlqBcJXit3N5A3E+c 0gyhKNjuUDVJSRXy+oW8cgcB3i7y7PF/7xJEubCa2Tmyc6epZaGko2OoNM/ceWbQWgCr 65fKQOuC6fJr6GiXbvtKpsxHAAknXxyOS4L5ccVQ1hZjI2KPkggJMXMBDcPv8PxK0hWA UaU9E/7PRpgLp0Job9jtAXR2m/0R8TIJnUv2dx1Np85fD7cnqQXzZPXjKDZ092aN7QEt q6JuKbySZmkIFRnmV9QHDrIjRgcRJMl0w7FAepKWAhcG6SLilF0zYCdiGMR5RijGtiyc SYvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Lhw57AEB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-118277-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118277-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id e24-20020a170906c01800b00a4633a910desi3033472ejz.867.2024.03.25.19.01.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 19:01:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-118277-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Lhw57AEB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-118277-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118277-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 am.mirrors.kernel.org (Postfix) with ESMTPS id A7C221F6170D for ; Tue, 26 Mar 2024 02:01:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3EB385A4C6; Tue, 26 Mar 2024 02:01:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Lhw57AEB" 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 66C0C4E1A2; Tue, 26 Mar 2024 02:01:28 +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=1711418488; cv=none; b=mlfoy4RKRAxs4U+9P8T5Pf1WWG/DrfaAhhwrLrHvFatIoKNRO+y367y8fw4hlX2PibA9R2xufgnpZI4N3kfhuk6lNkXVgzphmHOa1Wm7n2ng8Sw4g6SrOZq6tHvZW/ATozYJ9yTrt1XOfbt6hDH8WhUDztiLX79gGTwBOTiANPY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711418488; c=relaxed/simple; bh=MF9ovmrIg6e8IQIMkwaYLFqAcxexDC3fSt0fm0vWIc4=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=b/BFF/gY99v+1+T2d4mIUbUsWitjPom1cu/Ph7PUl/Jan9WJCU8mILUA31hUSBk7lZiXQJGAj+m3+igau7kB/Kv6jOOhdZ83lv9WaujFPxjVvJUN82ddE60i+LA53+GnFfIiGcX3NgzsxZXPAO05+ffZ1ZwTZEmOqN+8AhQo9N8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Lhw57AEB; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78E47C433C7; Tue, 26 Mar 2024 02:01:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711418487; bh=MF9ovmrIg6e8IQIMkwaYLFqAcxexDC3fSt0fm0vWIc4=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=Lhw57AEBPxbjD9GL0sYfWTtjr9JPLANVwg5Yz1VhBT/S50e2etFPWxhogAEkIOW7w c4trvVg5EzC3Xng1V19j2Dm9Yvs33knBUrCaRLqlKh5lpCKfiSULRnnfK970su7Qqa W/VlNom4Hf+B+NR3A8gZ5pDfJuvrir5CEOuQVEhvMxh/DHply97ElQUI2qaCFvjXxH v69BQSz8BF6/g/XGpOUqx7Wlwxz2dSU8gNRRBmcYWDH0/acsGQLVPhwpDs0EIXacI+ n1PHMW9iMhAtQfL24uHs7U5cspXL0IC8tZrffj/YxQzXR8I/J0VlMxyYuEnr5XaqI4 tqMgvIYyYUWiQ== 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 04:01:23 +0200 Message-Id: Cc: , "Paul Walmsley" , "Palmer Dabbelt" , "Albert Ou" , , "Luis Chamberlain" , , "Naveen N . Rao" , "Anil S Keshavamurthy" , "David S . Miller" Subject: Re: [PATCH v5 1/2] kprobes: textmem API From: "Jarkko Sakkinen" To: "Jarkko Sakkinen" , "Masami Hiramatsu" X-Mailer: aerc 0.17.0 References: <20240325215502.660-1-jarkko@kernel.org> <20240326095836.f43d259b7747269a7c0b9d23@kernel.org> In-Reply-To: On Tue Mar 26, 2024 at 3:31 AM EET, Jarkko Sakkinen wrote: > > > +#endif /* _LINUX_EXECMEM_H */ > > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c > > > index 9d9095e81792..87fd8c14a938 100644 > > > --- a/kernel/kprobes.c > > > +++ b/kernel/kprobes.c > > > @@ -44,6 +44,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > =20 > > > #define KPROBE_HASH_BITS 6 > > > #define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS) > > > @@ -113,17 +114,17 @@ enum kprobe_slot_state { > > > void __weak *alloc_insn_page(void) > > > { > > > /* > > > - * Use module_alloc() so this page is within +/- 2GB of where the > > > + * Use alloc_execmem() so this page is within +/- 2GB of where the > > > * kernel image and loaded module images reside. This is required > > > * for most of the architectures. > > > * (e.g. x86-64 needs this to handle the %rip-relative fixups.) > > > */ > > > - return module_alloc(PAGE_SIZE); > > > + return alloc_execmem(PAGE_SIZE, GFP_KERNEL); > > > } > > > =20 > > > static void free_insn_page(void *page) > > > { > > > - module_memfree(page); > > > + free_execmem(page); > > > } > > > =20 > > > struct kprobe_insn_cache kprobe_insn_slots =3D { > > > @@ -1580,6 +1581,7 @@ static int check_kprobe_address_safe(struct kpr= obe *p, > > > goto out; > > > } > > > =20 > > > +#ifdef CONFIG_MODULES > > > > You don't need this block, because these APIs have dummy functions. > > Hmm... I'll verify this tomorrow. It depends on having struct module available given "(*probed_mod)->state". It is non-existent unless CONFIG_MODULES is set given how things are flagged in include/linux/module.h. BR, Jarkko