From patchwork Sun May 5 14:25:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13654321 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 85D04C4345F for ; Sun, 5 May 2024 14:28:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 221A46B008C; Sun, 5 May 2024 10:28:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1AB6D6B00A2; Sun, 5 May 2024 10:28:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F3FCB6B00A4; Sun, 5 May 2024 10:28:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D123D6B00A2 for ; Sun, 5 May 2024 10:28:28 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8A9CC1A07D8 for ; Sun, 5 May 2024 14:28:28 +0000 (UTC) X-FDA: 82084572696.16.05BF445 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf07.hostedemail.com (Postfix) with ESMTP id 50B7F4000D for ; Sun, 5 May 2024 14:28:25 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PHxXhHC8; spf=pass (imf07.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 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=1714919307; 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=VQAh3jaTm4v2IU+dxnuc3wrcYqCu724F3JNsEBCY03iZjwTHu1pmyH5fpdEAnWW3jVSk5v YzsVavMmaHP3THG3Kd6HWJVyGYH5JjEiHLMCnxT7WrmPMNXoXzgFsy+eiTLmPv4DccNBgC wf7iOtkEfzMhicduMEhD+qUqa5pfVzA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714919307; a=rsa-sha256; cv=none; b=jM+7N6wxGsI9UsMEwRKxNW0u3U2ZMIhr7wIszLuxJAb1cvEGez0jeHV/EaXDlrqOdOwCeW 0rarMotJC0VGwH3jYwFbmvOC+qpvejPVaP09mg9gcgrNvWonrk9w8uJ9uiQ1Tv5nbDfSkB xpavkzuZpqP7eUMCXF2DTQD/4Yhrw4M= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PHxXhHC8; spf=pass (imf07.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id E643FCE0A4E; Sun, 5 May 2024 14:28:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB82EC113CC; Sun, 5 May 2024 14:28:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714919302; bh=baelIo5gqQ6dNoONu464d37hHX6/MoaALRFlqjsyJfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PHxXhHC8rkUDdApsaz0Wu8zNDhjBFugtbubfQQ0OsI7aJv0fGa07Rze4oulHLDC70 0hXVV4L414t9ApdglEOcQYUxLlA0gGWTAfPMDnUy8vxloxGJFdkem+KAomkNROY6bj SRqpls8Bx2IPzB0STr3+PyHq6T4lb6f/KFacw5kTWmVKX+CC5q5y8Xt7RmwKOjE3DT +qL5znqnDQe1s96fseldOv0anL7qPAl+ESMUzOwmNVdxiK48khpyQf6+jMayxQdqo8 SH++wVZDyGRgI4c2GQAtNnKM0Usl2Ss6TPPoKhMHWvJbn8cQB2jfMCYYNuovFqjpaM vOrKLdmFZ5l0w== 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 v8 10/17] arm64: extend execmem_info for generated code allocations Date: Sun, 5 May 2024 17:25:53 +0300 Message-ID: <20240505142600.2322517-11-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240505142600.2322517-1-rppt@kernel.org> References: <20240505142600.2322517-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: iytimoc4mhod8nny9m1n7mrdhcyymgzg X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 50B7F4000D X-HE-Tag: 1714919305-768884 X-HE-Meta: U2FsdGVkX188YxGMwy5wlcy5t6tCepExHDvkZJm5P5kugpUPoS1PENZV/4ldi4UQvZ1NWQX6+pvRXYiIsG42OfWvQB1ZJzwke9YlpXO+ha8mr01Qt9uuk0ip2djEuX/YV21PMTLvkBRUarpn8xJnF3dyXzpp9pH0fil2iPuu23mh+newGXcqgYQE1iSlQkJkr+6x5qOiVNj5ZzstmEwyWsHjpHIt03fs/PAq1iyj9dB/Q1Xfiyogsz0SJW+JURTM7Y/wL0zQhfLK0aob1n23r7s0cdB1dvh0d2IbLhkPca39wNEOISTu130Roy2j2YSF97hhTUQ2E8gRu+eyTbD186Y/8NLhkZpnva6fleo9AOdu3mMGzwglbwcPAAflzCWbjzyz2qf7xROB7O7IngT8F3WYGs4MUlj5OoUSxn/7PRPIfSr4ifeq9BkRuev2dLOPZYAg9qf5lHNXkYcPW3arDeVsOs6orCuHDeOh38f8jTJgZhJaSKOyU1zpBTEaYHWfXqRfRZMs48ZCFRULcD/VcnTvIipCcHr5hGNRIt5OEpExBMtGrvi/A0iNMfqt96Iapb/nrpzq9x615tyzgG9MvDpTk2kVnh57nPmLjt1fbxc0NK73hQlrIi3nnYTwJvyKX9+pt80zgkeApyb6eLdTzZaxO+WcmveHsWuxAwYFhV4o6pcrDdfXzCQlyKTE0p+I5OTcyLFv00Acemr8erVHVB/GbfQ/QrKcdqBvn0uYZ60y5WWCCKcxtC1sGqcKUC3iN5dfJO6jSbRA+5ljotVjqQlYrJKn8mNKlqk6rUOqGzglsI4TpOKjSCFTcz/SsY4DVLkGyMzd0IHeAUsH+7THL4R+QBx3VeA7Zjrm1dL/9JAzzZ8g2R6bZ1+R0VUxvap/Ra1OUIf9ohN1+fPwpf7DWlFW4OG8DLlGlAIipN44eFafDr0t4vmZUz8Vd9zxoiEG2TOC9IUDRjizgIMSISq nhCsH6ju 2hfey/7wl6bEfTzK12d62Jm49BcwxdxPIPi1b7ZVjTJOBeIiJRkOkIwABj50NnmF1BOOOalAdzXJxjDZemPttceJU5uZcfnYGoS66nxs9cGoauew4wy6jWGjrKyRPdSGCIGwtWjWC1K4P7iADuAIi7oi6UsgqDK+qEuhITicaJQocVCtVv8mZkb3z53qVYXFMq31XVLhzf8z8O6FhQ2YjoUhBw7IxDudrW4MfHtveuhqUv4W4ZdCv2ilw1dY4CDq8OiBOYOznmys+gHT0nN3MrkdfBlHlVOlS1miTSL1bCtHNwVYiSHZ1PU6lk4vhSobCfbYqYKlOd8fTfMAUcCZTGybg2aWaZjf5CsuArQwk7fz/AwRCYZ+HoimpUPquge9ySNmPXOrUSnzbTsKKPwHbDxiZ2lyRJCyX6zJNFiBuVt2ghViVc8T8d5kFkw== 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) {