Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2301760rwd; Fri, 16 Jun 2023 01:59:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6sF7ZMU+7pg8Dum6/4E5JKjcN/pQW/DUV/wFvPT4FlH3G6qmZa6NwnALveH4tpdHVjC167 X-Received: by 2002:a17:90a:7282:b0:25e:7ffb:8a5e with SMTP id e2-20020a17090a728200b0025e7ffb8a5emr1884894pjg.7.1686905991651; Fri, 16 Jun 2023 01:59:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686905991; cv=none; d=google.com; s=arc-20160816; b=BRlAHYTbumYCx/MvVX4iTW/vnsf9vtp77OYSN2K1rRabg5up3XtdVKVRXADKPEep5r tsS3gfMl4nRmXpqMCjMrq34enGSahc44PZuird6elYupE4gCWNKcpwIWeP5REMoTjRbK H3qUFoGw93Il8UwTEUoMajsZ7DObIE+xe121t/0+1kdrYm7Dtn7V72j49jLO8rDyWATR 8vXyoCahM3LkVTCrDqhK764vtAGmlKAK7yxuXo5RCFxoGGhybAwP2AHziiH9MhgAXV7N rf3rWFMyWpXBV9JoUqHdVcvLZKuLZrOqg5B3Q0Yx9mX9QqY/gFfO1HGydgfmpQq9XCr6 0ayg== 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=nsb6NlPSmkdWpmVZ3qGFMpwiCDZC/TjIozOONvPQrc0=; b=sSYNxGZ3T5ndYAPerjp3lb+d68SQnZ4hwl+JoVIClWGszmwayr2XVzIpcyp6pXu0xn lgLOkZgYEhmj9ur7oeP+R8ROosiNCPPN4X9MB3e4LJ4juG4Anx4lPl1F3Zqxl7uLmgi+ In02DviNyBaH2SmcNVxKpt/lcLS0h7m9u+6LIeXV+4zoS40KVvUcXafPB7pmCyjYlnS5 k/3RcN65XJsKFmWyoxJMFz4i4pqTy2EgeaB4xxN4p1vEC33gxZUn6TucFhLh+Ls7gE+8 L1WvA7N3P/bxt9bdsSgcdRasNEEZj77+ct+SVSEyDOLD8FjOdS0Sojtquzxw+y9NJIoK gTwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KxFrWYHe; 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 u130-20020a637988000000b00542924cbf75si14811127pgc.235.2023.06.16.01.59.37; Fri, 16 Jun 2023 01:59:51 -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=KxFrWYHe; 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 S1343908AbjFPIxK (ORCPT + 99 others); Fri, 16 Jun 2023 04:53:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243272AbjFPIwi (ORCPT ); Fri, 16 Jun 2023 04:52:38 -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 334232D77; Fri, 16 Jun 2023 01:52:28 -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 B48F163154; Fri, 16 Jun 2023 08:52:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B10D2C433C9; Fri, 16 Jun 2023 08:52:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686905546; bh=zp7Q5W5hhg/nI6mMLaPrtf/lusmFV7Z8YW7nip5II4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KxFrWYHeHpwcGUbxWkaMB83ecrjl0v+hXSJoSdevwYq1457qx+XC5pH2hwNcB7OJy BwvPt5jaXdXDVAAK8wLt3BvkhL9bFKm5ZmoUGY+wBwPfiaUq1FrMNmPitFFFnpVK4u ixA3C4gmJvX3Phwm0Cb/Ti+UGSkHwd2cn1C9JGVhNDuPjLJpERB/EawaSAnIJWgY0d 6dDF3oU5Bwj/MqxfBhEq0t0GM9GOHhDIGHOxT6E9WlvGlwMglCXID10GCfWlmI5Mxv XJJ8eW7PieCf7GdA0Y1v+oFScNl8TL9sHxqnk8aS5sDFO0f8pXzJpZGi3DtHbexORX ISfK1uW//RIDw== 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 09/12] powerpc: extend execmem_params for kprobes allocations Date: Fri, 16 Jun 2023 11:50:35 +0300 Message-Id: <20230616085038.4121892-10-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)" powerpc overrides kprobes::alloc_insn_page() to remove writable permissions when STRICT_MODULE_RWX is on. Add definition of jit area to execmem_params to allow using the generic kprobes::alloc_insn_page() with the desired permissions. As powerpc uses breakpoint instructions to inject kprobes, it does not need to constrain kprobe allocations to the modules area and can use the entire vmalloc address space. Signed-off-by: Mike Rapoport (IBM) --- arch/powerpc/kernel/kprobes.c | 14 -------------- arch/powerpc/kernel/module.c | 13 +++++++++++++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c index 5db8df5e3657..14c5ddec3056 100644 --- a/arch/powerpc/kernel/kprobes.c +++ b/arch/powerpc/kernel/kprobes.c @@ -126,20 +126,6 @@ kprobe_opcode_t *arch_adjust_kprobe_addr(unsigned long addr, unsigned long offse return (kprobe_opcode_t *)(addr + offset); } -void *alloc_insn_page(void) -{ - void *page; - - page = jit_text_alloc(PAGE_SIZE); - if (!page) - return NULL; - - if (strict_module_rwx_enabled()) - set_memory_rox((unsigned long)page, 1); - - return page; -} - int arch_prepare_kprobe(struct kprobe *p) { int ret = 0; diff --git a/arch/powerpc/kernel/module.c b/arch/powerpc/kernel/module.c index 4c6c15bf3947..8e5b379d6da1 100644 --- a/arch/powerpc/kernel/module.c +++ b/arch/powerpc/kernel/module.c @@ -96,6 +96,11 @@ static struct execmem_params execmem_params = { .alignment = 1, }, }, + .jit = { + .text = { + .alignment = 1, + }, + }, }; @@ -131,5 +136,13 @@ struct execmem_params __init *execmem_arch_params(void) execmem_params.modules.text.pgprot = prot; + execmem_params.jit.text.start = VMALLOC_START; + execmem_params.jit.text.end = VMALLOC_END; + + if (strict_module_rwx_enabled()) + execmem_params.jit.text.pgprot = PAGE_KERNEL_ROX; + else + execmem_params.jit.text.pgprot = PAGE_KERNEL_EXEC; + return &execmem_params; } -- 2.35.1