From patchwork Fri Apr 26 08:28:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13644232 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 7CC0BC4345F for ; Fri, 26 Apr 2024 08:31:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 175406B00AA; Fri, 26 Apr 2024 04:31:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 126626B00AB; Fri, 26 Apr 2024 04:31:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDFDF6B00AC; Fri, 26 Apr 2024 04:31:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D00866B00AA for ; Fri, 26 Apr 2024 04:31:08 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 86860C07C4 for ; Fri, 26 Apr 2024 08:31:08 +0000 (UTC) X-FDA: 82051013016.06.7B2D1FC Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id E9235120003 for ; Fri, 26 Apr 2024 08:31:06 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PKONgJ1Q; spf=pass (imf29.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714120267; 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=24FPA+RX7C/pb0x8VP4Q1A0oO/yWzbUUPrYE7HJMjA46XikLLRAqRUIb3051ijcfFffFUA Vz5s4ujh/BatC/xKy1xYNQ7X6gtxKjXidqXfJp/123SH3b1mMBXkpqF5kRbTqWEEYLexjs ZA/ET36w8AOBvXPA53RBi6t3UiuIFUs= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PKONgJ1Q; spf=pass (imf29.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714120267; a=rsa-sha256; cv=none; b=7cqmKzfulXksYmLVi+peXc4eXFj1Doxg2++ddny03KPgmN0n5zHWT2l4EIG5K5FVyt4ij/ IN6MkxpV0l+Qawb+vPP5YRKiDVJFOp8gDm3c0CcxpKvr9n5eq40HuW9/O+S4qC+ghpOFf9 nm2mXuI2nwJtT57Ee6W6TDZYqPNi6zs= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0E5E862009; Fri, 26 Apr 2024 08:31:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27323C113CE; Fri, 26 Apr 2024 08:30:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714120265; bh=baelIo5gqQ6dNoONu464d37hHX6/MoaALRFlqjsyJfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PKONgJ1Qdz8UWrqYN1ZX4SC/mWC6ejttaPgK34VndT+EqYH8tNZm9N5sHEIPTWNOL PeS7hUpNc3Hcxg4NFbS7e4iqg4SMFyWYqPXU297rBbMaGlPxOzaXn7G14FAQ8O1WlM FN4VoFISbQVjVGaP9hjcr2wIWVh0zoP+TSjwYlSYlvNBYFFj7HtF94z6YyELAoklq/ w/p6xes60DM4Iwm2cN4rVzoZveadaxZkTJouD0y4ZNlZXalnXiHtgBflYuf2e3NHKt ppr0urZYCzFq9rcQuln0hib9PLAzoiNM/04RP0lCGJQm0TeX1iTFt1PW6mRy4eG71Q IlXwRUKHBRVmw== 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 , 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 v6 10/16] arm64: extend execmem_info for generated code allocations Date: Fri, 26 Apr 2024 11:28:48 +0300 Message-ID: <20240426082854.7355-11-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240426082854.7355-1-rppt@kernel.org> References: <20240426082854.7355-1-rppt@kernel.org> MIME-Version: 1.0 X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KJ0OW/5RQV7D16kS2Dj Bslrn65Q SV8fRvMVpLYYev5KD/O24vT18Lps54k75/NMRVHXpvelwLLjalzcqGGpY0IgSUo44r+lLIpSlMxddvxXaqlli4V3yDjroX1NkekxmXZOCCqC1ZLCj5FD6IxBTE5aIct4qUB/7T0oZcvbgDr3VRs3JHmAGYXx9Q1acH/IGI7SNhmCWxqsSi/LC7TRZ22aPvgZbr/y/jBLTfOmhpWUWRWF05kmoc6lfLS7qTgOs1zObYZ/YswCR8l01m3M0WcDl1BNAqwAdLwUQmnLzrNmT942/j2Dfnm0HIT+OU9h4m9JDWxMyRSHyOPTVU+kMsMVK9Rjf/PdjOiWGcC6rWSVQ/fS8RbwP/0pxbWLVyZ3vSQCpmb9QTDs= 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) {