Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2298482rwd; Fri, 16 Jun 2023 01:55:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6NMxeaOzzFJWfYC5W/EWv6F3pSm8G4D9S/AhGf6MtBnrMdSipc7ApDvdSXk8tTvv2UVF04 X-Received: by 2002:a05:6a00:2d13:b0:663:f82b:c6bc with SMTP id fa19-20020a056a002d1300b00663f82bc6bcmr1565709pfb.24.1686905755262; Fri, 16 Jun 2023 01:55:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686905755; cv=none; d=google.com; s=arc-20160816; b=l51eMDw9kqyIHupR8/GYWf3+Y8W6RdJOvQWRj8fOfdA9foSRpeCdkoDDUGzc9ECLh6 49KU0pIooSy4/jP99o/4Nxblg3F5fGc4+B/8Ds1JHGhrcxZNHtv1Po6T0RFNFak70zDC 4TBdkKLMvE6BO5yIPDpOwGmbzhfHWzC4AoeIMyTCZHaNzWnSgvHEOX3PLYikr7RfPLJ2 bH2d77oTahxcFLMM9bytxyDeYLvlmxCDtvr0uAEDVaZ0LhA6310rZ54ZiboEcmC542rN dNPD+6mvVBzLBI1FxGrOKoqw2KdTaP6Sw6fiA428TBQfhwq/cgJ2HmLnaRuFYB+c3Ma5 m9Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4pr7ZKCip7Tu4MI5t1/9CsCaDYOnfaP3m5M8Al8nLKE=; b=ZxyXEpeZBI7FJD1BaL0dZRGiG6pGNK4hJ/KrCDAKb8oMz0Xcon3a1YR4Z/SVEBJkhS Daq44pHfmBjnHxmj7kxqYUjjUUsdxEsiwPCLIe2IzrcwowPB+HBXEKakHYVRE8ZJt6rF W1RUQYNqCwOZaVU37G47BCaVJhMNqOshwjSO4Mkwxnt17HZrM0I1s1fMUcVu2tMPv1rY 3aD3WmExxb3D7uwYe6OJH4X4ksLiwLiQbjoU82yRdQtSIhfkSjwIyjMGRFE76atYQIHH 0s2EsaGJui3n7sIfNvIo0zdF/nilCPKrbTEyqC3DOepixTvzrDM4H3nbTTNf96OzIKFv RmpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RXsNDUtY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o22-20020a637316000000b00543d2ba66casi4807433pgc.621.2023.06.16.01.55.40; Fri, 16 Jun 2023 01:55:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RXsNDUtY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344035AbjFPIxC (ORCPT + 99 others); Fri, 16 Jun 2023 04:53:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344017AbjFPIwc (ORCPT ); Fri, 16 Jun 2023 04:52:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58EE935AD; Fri, 16 Jun 2023 01:52:18 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id D2AAF627FC; Fri, 16 Jun 2023 08:52:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E3C5C433CD; Fri, 16 Jun 2023 08:52:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686905537; bh=QpRLaiTQjkFAZbWC8PMbwO4haV/9se+uMBjn/xjk6Eg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RXsNDUtYj249KQAhJs+wEQjCxqfjKx6/L1Un4qq+20KcffdZ1deQG8lIIT7DV+ZMq m0eHek+DKutrTD2bY61bqwx/MvyuFb7gWqbU+m6qEsiGCLCvTZ7S6qv0+x7akVCFuB hR9l1tbgw6B2t7wTqYFLvXI+KAAIhbgEWQDFcYOxbtABFlclmsFbdqgW4kmI9RoSdI zuYaQBPZBK8o2VXshwQtSE3bM0njGcW3mDpBRHQHK++MLDhg4oBdqwaVZ6MqkCYoov 3oCj/KsihjERHBpOHzrJ3ShbDZ37kQWZGW77+ZrjAOqj6IbLfSqY9c93w/m7agDClK PWUowLo8PSiqQ== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Andrew Morton , 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 v2 08/12] riscv: extend execmem_params for kprobes allocations Date: Fri, 16 Jun 2023 11:50:34 +0300 Message-Id: <20230616085038.4121892-9-rppt@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230616085038.4121892-1-rppt@kernel.org> References: <20230616085038.4121892-1-rppt@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Mike Rapoport (IBM)" RISC-V overrides kprobes::alloc_insn_range() to use the entire vmalloc area rather than limit the allocations to the modules area. Slightly reorder execmem_params initialization to support both 32 and 64 bit variantsi and add definition of jit area to execmem_params to support generic kprobes::alloc_insn_page(). Signed-off-by: Mike Rapoport (IBM) --- arch/riscv/kernel/module.c | 16 +++++++++++++++- arch/riscv/kernel/probes/kprobes.c | 10 ---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c index ee5e04cd3f21..cca6ed4e9340 100644 --- a/arch/riscv/kernel/module.c +++ b/arch/riscv/kernel/module.c @@ -436,7 +436,7 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab, return 0; } -#if defined(CONFIG_MMU) && defined(CONFIG_64BIT) +#ifdef CONFIG_MMU static struct execmem_params execmem_params = { .modules = { .text = { @@ -444,12 +444,26 @@ static struct execmem_params execmem_params = { .alignment = 1, }, }, + .jit = { + .text = { + .pgprot = PAGE_KERNEL_READ_EXEC, + .alignment = 1, + }, + }, }; struct execmem_params __init *execmem_arch_params(void) { +#ifdef CONFIG_64BIT execmem_params.modules.text.start = MODULES_VADDR; execmem_params.modules.text.end = MODULES_END; +#else + execmem_params.modules.text.start = VMALLOC_START; + execmem_params.modules.text.end = VMALLOC_END; +#endif + + execmem_params.jit.text.start = VMALLOC_START; + execmem_params.jit.text.end = VMALLOC_END; return &execmem_params; } diff --git a/arch/riscv/kernel/probes/kprobes.c b/arch/riscv/kernel/probes/kprobes.c index 2f08c14a933d..e64f2f3064eb 100644 --- a/arch/riscv/kernel/probes/kprobes.c +++ b/arch/riscv/kernel/probes/kprobes.c @@ -104,16 +104,6 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) return 0; } -#ifdef CONFIG_MMU -void *alloc_insn_page(void) -{ - return __vmalloc_node_range(PAGE_SIZE, 1, VMALLOC_START, VMALLOC_END, - GFP_KERNEL, PAGE_KERNEL_READ_EXEC, - VM_FLUSH_RESET_PERMS, NUMA_NO_NODE, - __builtin_return_address(0)); -} -#endif - /* install breakpoint in text */ void __kprobes arch_arm_kprobe(struct kprobe *p) { -- 2.35.1