From patchwork Sun May 5 16:06:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13654472 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 53C4CC04FFE for ; Sun, 5 May 2024 16:08:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DBFE76B0085; Sun, 5 May 2024 12:08:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D70A56B009F; Sun, 5 May 2024 12:08:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C10DF6B00A0; Sun, 5 May 2024 12:08:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A0A156B0085 for ; Sun, 5 May 2024 12:08:49 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 605481A04B5 for ; Sun, 5 May 2024 16:08:49 +0000 (UTC) X-FDA: 82084825578.06.324FD82 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf05.hostedemail.com (Postfix) with ESMTP id BF018100002 for ; Sun, 5 May 2024 16:08:47 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=o8jiLvcf; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf05.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 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=1714925327; 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=63MyeCe5WWYF+fCbgXkmpB/FpAPoiWTepDiwIPLSU8PNff4/aYUHLrdkDzkc9AaIyHvP9e jBMdaTW/akqLwlQPOXIWumdjKe98a6TLJkJeFWKBmJtMqS0jZe5QrwYlf5YHy3zufRlzo/ IXI0v/yW1uZpnRX2TGL5AhY9BFjIk8g= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=o8jiLvcf; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf05.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714925327; a=rsa-sha256; cv=none; b=yeIJDrp+WMjak+hLeP2+JSPoz7MnTp2ZOYGqNm15LU5e1DHFciZKmMvvfpiTesi2MTetAM INYWy8iYyYuF8f52T5Jv03dxp3h0TU8TZg4p+FDnErpLcyM66fQU5aIAUeVBbrzDthKdRq jZnQIBYZEi0MPzYYVDEcyxHQ1u7bxtU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E9BF360CBB; Sun, 5 May 2024 16:08:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C2B7C4AF66; Sun, 5 May 2024 16:08:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714925326; bh=baelIo5gqQ6dNoONu464d37hHX6/MoaALRFlqjsyJfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o8jiLvcfyNXB2iKxVuJHVMVEodBkbD1zblOEpItf8uhQXKQxqKdCGY7s0UctSKPri k3As8VAahDJ4NZSDJZmP61b1qd29PgNi4/WY8gt8pcKwe+U4mL0gWKr6G0c0l3jpEh lALY/R8NgYRkr74Dq4kIvOKK9Z8fxbuOpiw8GpmS2/XpjxcCx/Vu0WjnQ947IN3TrW v+f+OWtztPnMo6X5MTTu0wTYyR/w4hxiWyvDCgQheibsLdCYKyF8k/C/97DxOoCjPL DXuwU6qdfZL8+QFtJj1eo0qsbPEa5DTL9c098i09INCdxXLQTtnFDA8FsMheRTKOOZ 98lqdYyVWEYLg== 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 , Liviu Dudau , 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 RESEND v8 10/16] arm64: extend execmem_info for generated code allocations Date: Sun, 5 May 2024 19:06:22 +0300 Message-ID: <20240505160628.2323363-11-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240505160628.2323363-1-rppt@kernel.org> References: <20240505160628.2323363-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Stat-Signature: g8jrnosx8nwguweii9e19jwb6tzuk3cy X-Rspam-User: X-Rspamd-Queue-Id: BF018100002 X-HE-Tag: 1714925327-434999 X-HE-Meta: U2FsdGVkX1/kpTqZzk3kJrqLgJtogi9RtDUJXbrhZh67roh6vqqPpURgJ0pF8nQlL+RswFpHI1voRLhQXJlU78BuaKEWQMLIyC9XL4wafmvQnHhbpokQkSyXjilzm+I5NIV/YE8SgIgy0JGYtjeHEzKf2JOGc0LxR+gbwqkaw8xSJPf6yf6Xl1r/HIfYd8XbP+HoHlh2oOoIovKbUkqTQgmenHs7EgxYOekNoEKquUI9eRnwxEr9O5+o48Tbc0JlwZtPSrrXUpv9f5bmHgDboLeNJMAlwgaYcpfxNgfLOvGWpp/pYysB+F0GTs6Ukt9huKSbcrB0U5DI4P80lu2Nsjdl2g2/xOVQUUaPVnivlMdsXF7kW0zYd524/ssx9yhqg9USSM3wTF2pdhTtscoM8KYGGb5E7mwS/YXhruvNFU322zjQPHMKJhzDAMstAPZzli9flPvC5AiIfiBboCh4a/OXIXua++KrjC62ioNWhn15bOuJDdGhboIRzCy7vT7iAdvnnjbBAQ4z35muR398gd+ILEZSNYJzpsS3aonPxJRSVlrZJXqpup9NnvIbuzItByKT1O97rtVkIqeahVdRYAdzqgIqwOTwHk2kBqhGM4cmgSud/z7YrlEmE/B6fHbk5RCqWaAlxEFy10uyPCVZzliIajhltcQQn58Yo3N6xZlrKflRUneQBJjifM6iSj37IkJYaSoF2MwgSQxGcdDnHOfGLz5wZYLoRtEcKgfcf3qqU6Vzslc4DOWUZ3jEIa0BxnHAX+wx6jP/4zQMuK3fgaJRYICsXHoj3QHcitCtUP+HYZ+/PVcDtkEEqDXUhVrguo1VoXTq0mo49s/YJmgFiV5tfZNXJTgG9hefMLAias5gR6H6glTHI4J+0zkkbii0GCYSKkIm3OeouL3wnSgWBQYkEmcWN0Xgj5jjecjU0/FOKVGKPSVQ3LtK7Q0vxUk5TFuibkkForWLtHd6lPu FAF5PPsh kZpJ0idAL6n3JPcNOG9JgG8JJVwImBimCuJXVLpv0SSNa+4GkBZA9U7jZa6LDica4rLV9CpxHPFoKnh7oxOR74Zvot48mvhNLdnXj0r/AJ2KrNyr8fA2eVA86ynvMFDENiH7eZNXxPsk2V57cc1fCOvJplNZaqbE68PKRc6Z1qUJnvdd9NBNgMQ4okK1RPcWFZiMmNwkxlCnGpLCPReO9T29XIAEnLs8rDZ6r8s6sZA0Qq7+etvniv6AsG9yatuBSBwXynXz2xIQMHAL3t3YLm+c4yms3RQzCwwVT+/LijBVa85AUtlnb8BoFRNym4I9b4OIUCBdCtlpmHCkkkFxSBhboQorcYwlpJRiH5vrESA317BefBHni69CPh990z3hVKj02J48IddE3rItdg3P9BYZF1j2M7OH6c5y+EOCW68zZwrLsqX9ztTsf9Q== 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) {