From patchwork Mon Apr 29 12:16:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13646780 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B132C04FFE for ; Mon, 29 Apr 2024 12:18:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E2096B0095; Mon, 29 Apr 2024 08:18:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 091DF6B0096; Mon, 29 Apr 2024 08:18:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9B8E6B0098; Mon, 29 Apr 2024 08:18:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C7D996B0095 for ; Mon, 29 Apr 2024 08:18:38 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 513861C22CB for ; Mon, 29 Apr 2024 12:18:38 +0000 (UTC) X-FDA: 82062472716.28.3C96ACA Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf25.hostedemail.com (Postfix) with ESMTP id 29A3FA0040 for ; Mon, 29 Apr 2024 12:18:35 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jmX0JiUm; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714393116; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VpbkUxuadtAaKX6Fnq0w2CEcga3ignfuLmYWKso72/Y=; b=zyrlww24I0YBSyyqLiO5JLoOgtjCdOi2mNwMJ26mPYnMbs+FMeWy5f+1TIuS+Z4wY5B+a9 9LAErpISlFEpFGfUMzF/3RP5UFX1fr7PX6jK3KHnEvDr/kkJ9LpLRzeTo6qSydfw/CUvkK fgobgMkhw5IWekGsaduUVHhbChaRePA= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jmX0JiUm; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714393116; a=rsa-sha256; cv=none; b=MZn3FPnFXvBYUjdZnI1JTzvndJOMiNEot+J7z/O/PIO3KmA4CHYlt4ewQZbwVf4B2X8yp1 ssP7aTrMW0xrtOyTsULQbstfkWT9abrm0nOix2IvNr/zs7sUtyIe4TYXEWqriSzao9b2z0 tiy1qFz8Mpr+Apv7yKfupfbpQO35n9I= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 86E33CE0B5C; Mon, 29 Apr 2024 12:18:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C696C116B1; Mon, 29 Apr 2024 12:18:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714393112; bh=baelIo5gqQ6dNoONu464d37hHX6/MoaALRFlqjsyJfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jmX0JiUmaBDUp0oWoV7cqdMMmCUIf7j2Hg4K5AdCS0nTCzFuIEYi/B9WpZ/CoFzB4 eBqJp/nULn8xBvVhXpBysR5txHkYVQUdpEmmv7RGWVFWcpLbsP39WW8OohcRlxH2rB whODPWry/PCsvxMoP+HVvLOzwacZwc4x1jNz1DMsaJ0ZfVkqLhKOAXzQEZpurdg7+u EmwUHDs15VEBISsNMHlMRmicXj1UGKL8K9BujbVqC3deNf798PQtF33lPqtyyNybUN Kbd8EFMFNuE1fWRAWKLgqSiV90kEGfWZRz/Q2iTw5nCnoXS6RowtW70V04qzZioBrJ ScvmZlU6Y9ADA== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexandre Ghiti , Andrew Morton , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Catalin Marinas , Christophe Leroy , "David S. Miller" , Dinh Nguyen , Donald Dutile , Eric Chanudet , Heiko Carstens , Helge Deller , Huacai Chen , Kent Overstreet , Luis Chamberlain , Mark Rutland , Masami Hiramatsu , Michael Ellerman , Mike Rapoport , Nadav Amit , Palmer Dabbelt , Peter Zijlstra , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Rick Edgecombe , Russell King , Sam Ravnborg , Song Liu , 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: [PATCH v7 10/16] arm64: extend execmem_info for generated code allocations Date: Mon, 29 Apr 2024 15:16:14 +0300 Message-ID: <20240429121620.1186447-11-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240429121620.1186447-1-rppt@kernel.org> References: <20240429121620.1186447-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 29A3FA0040 X-Stat-Signature: 8yicf68p74cxztfo7upqp94amjp5m9ts X-Rspam-User: X-HE-Tag: 1714393115-939913 X-HE-Meta: U2FsdGVkX1/57q85h/Dr4RyH0H5L/TsCBbPq7mPvikUPMMqhfKNgWD5PY/yFV+vn8h/0dp/V3sntm9qenkHu5cpTBQYf3M+U964LquLKO7/pIv/4IJ63BngFQ4VKRP8m5a4L5YxlgVSW6o6ZK9ycyxEWqhL6oHXTMMGwB0JuEexmQ7Ymy6NxsUUD5AY6l6hHyVhOsvy40smrioK3Hq38e5vWgz4dXjWgEr6aSXjC6fpHQXJFD+IG1+pYLXXlgRCf/p7OVf+NaKtH0nkKhWRPL69qWDn/kNggO/EddC2wPUmlILv/u4jeVVRFgdKgGvgnbrLNw/YfikYuEjW1lS9T9zr0oJUGRUOLSPMf5AyapX1CrlVkA2CohD+8bphHegBo8Dkzy1Ds5oFC6rED9zI3PeT2vKzOYrkyeTMR2Ij+v+AVOHoE/oY33RLB0fzVhQxkh2JJr1AmO0hLRY3nT4hBXqUKKwHoSqGL2x8AB1gPQ06q4bQRv6DPE8+BTYGdBjPe7GuikYZEouByi19HzZ9AUFB7KZAUtRStv+sWmIE7UFyEmMtdxAvyRYR4Hgh38ai3VWKM8QZk98BifJJmGKk4oU2cT5z5SrftlpnBtjf/znPJyl31MkLyh1UcsxrRaoVDH9Jm0Jc2cum9w5zSIk4wzsLpY548j9qg5a23R9uG1WrM9p9p1RRr9FINKWN7wB+8gtdIirrosaQ1SMSVZe5VQ6h8qvTLo6oD1Vn7/MkxmaFghkkIeHB5q1KDEBemTHUws8zGJqCM32lzxVN+LqKvBLrvqz1vIY7JqjgV7EPQ9Q5k8R54vDyQj18WUp4n6HvirMpHel9h5TnDiBUkMghAL4c4qO4eUfNpoeNm/b82E5KxrefWej3+7DpMyznxswswRYR6ta1otPwkdppsdBSWD4t8yt33o5BZ1bPfPbfzyYPmkWvhXdDeBi+yqyZgy93QtMnh1anfTdqTRRCDW9P WTXpZHP+ JPVcvd5eN5yLmA9MzvvuhJWi4UXclYXtL/MbOGdowTpv3TOYgkoD3zlQhCIm0f1AAreogv7t0/cz2jJ4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: "Mike Rapoport (IBM)" The memory allocations for kprobes and BPF on arm64 can be placed anywhere in vmalloc address space and currently this is implemented with overrides of alloc_insn_page() and bpf_jit_alloc_exec() in arm64. Define EXECMEM_KPROBES and EXECMEM_BPF ranges in arm64::execmem_info and drop overrides of alloc_insn_page() and bpf_jit_alloc_exec(). Signed-off-by: Mike Rapoport (IBM) Acked-by: Will Deacon --- arch/arm64/kernel/module.c | 12 ++++++++++++ arch/arm64/kernel/probes/kprobes.c | 7 ------- arch/arm64/net/bpf_jit_comp.c | 11 ----------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/arch/arm64/kernel/module.c b/arch/arm64/kernel/module.c index b7a7a23f9f8f..a52240ea084b 100644 --- a/arch/arm64/kernel/module.c +++ b/arch/arm64/kernel/module.c @@ -146,6 +146,18 @@ struct execmem_info __init *execmem_arch_setup(void) .fallback_start = fallback_start, .fallback_end = fallback_end, }, + [EXECMEM_KPROBES] = { + .start = VMALLOC_START, + .end = VMALLOC_END, + .pgprot = PAGE_KERNEL_ROX, + .alignment = 1, + }, + [EXECMEM_BPF] = { + .start = VMALLOC_START, + .end = VMALLOC_END, + .pgprot = PAGE_KERNEL, + .alignment = 1, + }, }, }; diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c index 327855a11df2..4268678d0e86 100644 --- a/arch/arm64/kernel/probes/kprobes.c +++ b/arch/arm64/kernel/probes/kprobes.c @@ -129,13 +129,6 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) return 0; } -void *alloc_insn_page(void) -{ - return __vmalloc_node_range(PAGE_SIZE, 1, VMALLOC_START, VMALLOC_END, - GFP_KERNEL, PAGE_KERNEL_ROX, VM_FLUSH_RESET_PERMS, - NUMA_NO_NODE, __builtin_return_address(0)); -} - /* arm kprobe: install breakpoint in text */ void __kprobes arch_arm_kprobe(struct kprobe *p) { diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c index 122021f9bdfc..456f5af239fc 100644 --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c @@ -1793,17 +1793,6 @@ u64 bpf_jit_alloc_exec_limit(void) return VMALLOC_END - VMALLOC_START; } -void *bpf_jit_alloc_exec(unsigned long size) -{ - /* Memory is intended to be executable, reset the pointer tag. */ - return kasan_reset_tag(vmalloc(size)); -} - -void bpf_jit_free_exec(void *addr) -{ - return vfree(addr); -} - /* Indicate the JIT backend supports mixing bpf2bpf and tailcalls. */ bool bpf_jit_supports_subprog_tailcalls(void) {