From patchwork Mon Sep 18 07:29:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13388976 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 563DAC46CA1 for ; Mon, 18 Sep 2023 07:31:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E42B16B0285; Mon, 18 Sep 2023 03:31:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DF3476B0287; Mon, 18 Sep 2023 03:31:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6EA96B0288; Mon, 18 Sep 2023 03:31:29 -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 B44FD6B0285 for ; Mon, 18 Sep 2023 03:31:29 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8F29740B7B for ; Mon, 18 Sep 2023 07:31:29 +0000 (UTC) X-FDA: 81248897898.14.974F6A6 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf26.hostedemail.com (Postfix) with ESMTP id 51C7B14001A for ; Mon, 18 Sep 2023 07:31:26 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QwbKIwCm; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf26.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=1695022288; 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=Qo37PvQ23r50OzMpHp40Xs5RSpcqAH908YBD31i86Ss=; b=XNJVkdr/UGHg+w0jGJPjb28EpmnhZAMmN7worHQPyF8a6ZFzLzCN9Hbz0QCZeAkc3d8+qa hk7mdHl42Gp2YLEFUw6zrKfJeq/PT7LR4/95a8WtGE6bqnKN9w1ogPD4cFOv28CDL3pqFc Z1/OMuVCxCv3hLvVaD2Oe9dtB6wwl0g= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QwbKIwCm; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf26.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=1695022288; a=rsa-sha256; cv=none; b=KcIGlxhMd6QiHVW6t0/cZC9z8oF+kCYdod3OIaGAp4a2H83D/TIA3DG8TfgaEX1uO3KaOp ZziGAzhJ3o+6ZhP4+387+Q5ndJCPxRYCWcF62ETfrWFsFQj7qORZl9R/StQTyMBPEpzMW2 DQ41r4nA6tIzM30O2eHj2ZlA4y4joek= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id B566CCE0BDB; Mon, 18 Sep 2023 07:31:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3F8CC433BF; Mon, 18 Sep 2023 07:31:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695022283; bh=uhUpg7LkgDj87OPKWv+2ZQQTqeXwsgqGQfVhMMOlf6I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QwbKIwCmsi/m+QIPzGWyDvn+Tk81CaEzaNlQaj1OrbfY6aH7VjNTOMfyqPjfbO3ZI IrekkL8ga776lr+J3x8Ygyh2wVMU8QELU6aweeJeBpGEbBfrtJxHf+rNjrvDsHVs7+ 6bm1TS2tPNGOkx/h7R28N2r8hennFfDFz6aE6FuiYGkO4GZPqz8JGrUJkS1iup7wLd Isg0JWVRjOAmJTjw/rUuKi838+cqznX9dO82PejgtCEzU2RQuKCDDPVyOOKasyX6kb 8fpNnivohYt0YSrYt8tzLAAtD+1zq8pRlzkl8JhZ7kRPGcY2/LRuqibiB20CPobXX4 xLjJAnEDRG4hQ== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Andrew Morton , =?utf-8?b?QmrDtnJuIFTDtnBl?= =?utf-8?b?bA==?= , Catalin Marinas , Christophe Leroy , "David S. Miller" , Dinh Nguyen , Heiko Carstens , Helge Deller , Huacai Chen , Kent Overstreet , Luis Chamberlain , Mark Rutland , Michael Ellerman , Mike Rapoport , Nadav Amit , "Naveen N. Rao" , Palmer Dabbelt , Puranjay Mohan , Rick Edgecombe , Russell King , Song Liu , Steven Rostedt , Thomas Bogendoerfer , Thomas Gleixner , Will Deacon , bpf@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 v3 07/13] arm64, execmem: extend execmem_params for generated code allocations Date: Mon, 18 Sep 2023 10:29:49 +0300 Message-Id: <20230918072955.2507221-8-rppt@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230918072955.2507221-1-rppt@kernel.org> References: <20230918072955.2507221-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 51C7B14001A X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: sb97pp5oywy4nh5tczdkknbxtj6xswy7 X-HE-Tag: 1695022286-902116 X-HE-Meta: U2FsdGVkX19G8pOuZf8irXOI2T/2UANN8zfVGz3f8154qGUjNu9ZY/BdFuwUZ3i0BBKFhAzVo+jnmzFkbF14RC/Pqjkbwv3phNte7rzkZ/YTSLlFvDJIWdTa+h73kTntfxaV5BbKiKvCoInA6rk3EnspvnttqCPcsPDYNR2TBr/r1NTCHMCLMb3JtD3XEBG2LoIJIWIPlEAS63r4QbSAG6dqJxHICRcvkkvkDImOpQWfWpmgqnBHr7mLjNgCz6SWlBHMSVesq+u/jgu2EnNW0XHIJO951fVixBCXjwr4MsK68ebE0jdwMfUDYWr81p2vIh/Wz3kR7jAZu7MtSIEOnYaffSuJ2d6zExQQ67nGVgbWfDh1EIj9kNYxR40Bs7XAPVRk/4SDtgtrQTliiwnVpDkfl1V/A6NZ9K7wX+sF5a8b2a8HULKgV+x2VdTzlXeL766pUdcmMhwemjWc07EPWxd8qyxl05sGFnW63yvnTm8TH8zO4JZC7TSef3lW5tWhzaY2lCJRk0Go/0/O85fT1CPmSMUQ/u3zo1usDtbPDlAK7fLUDMLhOh0Sikj1Y2EtcuYs95PNpg6J5tZlz56RYbS6IChXR5Y28WRVI+r3n9fehvbxpzTu91XjAw745BGAZhD07FAsuBoYdkp7gAWmb8cDR/7rB9+SJw2UFPiXAACd6vg7JoZ+oU8qT8snO2MdTvgaOpNgsIg/tXv173E+FoK5I3/v11fh6sBXidiaQJcsIzuPL+M99XOuFZqoS5sYsqWpIRUzgfz/0tA3u+hKL5oC6y/HYpFsZHvtkJ4mcLsZbEa4mZTk8959LfpWIac/YPVmJTIG76j9xORsGJU8hiMkzmlJ0xhT55/WUvcz+8QI83jvCPXmPKhz1eRhV06X4IkGtc9S2jIk9/nv3rvG30gueeQFajjfwnTe2y02XIEapDaUGb/PQkpIPqnHS5oDFXgBz7AnxNNtZ/xBikb zg1JZgB3 V43uTaxUbktwRyGxxsMghio97we1ZMFrtycnHRmfOGZrba9TRJBAoE87lxBY2J6XoutynKlhdsPh+Iw2oHS6C9NpJL3X0sofmxKRSC8DzOJ7N0AGmgEDScmjHCOnbUWux76z3888r9aZb1ORrxTRFev819DLJ4fsRYPhGrcIwwzLT1X+Ee8BahjMsLhOGS78MHnGNNeDVMeFJLliV/YKLoQbrjpVwyeDWEMjy/Vb10ARS7hFvxrY4zHN2Jvnjp2oQ0IROQJxgFpNdrRWj01qp84nkT71CkpxSwPcEPT9KWTYd/Q2BnIFpdftwiEl/ZFdNun1ILeA7XomkCuUvjzBdAYYVSQxOfZL12i4TKEqBYFSR52AHkAtwcqy29reyxL2RFITIwYF/amamg/W2uc+NNyuOCi7318M+51OgYmL6PrQ6J0TXCXLaAaYwnW/oL+DGbFP1fYNMz73x7dc= 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: 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_params 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 | 13 +++++++++++++ arch/arm64/kernel/probes/kprobes.c | 7 ------- arch/arm64/net/bpf_jit_comp.c | 11 ----------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/arch/arm64/kernel/module.c b/arch/arm64/kernel/module.c index cd6320de1c54..d27db168d2a2 100644 --- a/arch/arm64/kernel/module.c +++ b/arch/arm64/kernel/module.c @@ -116,6 +116,16 @@ static struct execmem_params execmem_params __ro_after_init = { .flags = EXECMEM_KASAN_SHADOW, .alignment = MODULE_ALIGN, }, + [EXECMEM_KPROBES] = { + .start = VMALLOC_START, + .end = VMALLOC_END, + .alignment = 1, + }, + [EXECMEM_BPF] = { + .start = VMALLOC_START, + .end = VMALLOC_END, + .alignment = 1, + }, }, }; @@ -140,6 +150,9 @@ struct execmem_params __init *execmem_arch_params(void) r->end = module_plt_base + SZ_2G; } + execmem_params.ranges[EXECMEM_KPROBES].pgprot = PAGE_KERNEL_ROX; + execmem_params.ranges[EXECMEM_BPF].pgprot = PAGE_KERNEL; + return &execmem_params; } diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c index 70b91a8c6bb3..6fccedd02b2a 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 150d1c6543f7..3a7590f828d1 100644 --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c @@ -1687,17 +1687,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) {