Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1416457rwb; Wed, 16 Nov 2022 17:41:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf6PwG6JXe96R+R44dSCTlWkTUAt9t/C/rZ4R/+jTXJHXj5fjUQyP/cI3RGEyXOzgGSbKItX X-Received: by 2002:a17:90a:19cb:b0:205:fa0b:798c with SMTP id 11-20020a17090a19cb00b00205fa0b798cmr6405553pjj.179.1668649273416; Wed, 16 Nov 2022 17:41:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668649273; cv=none; d=google.com; s=arc-20160816; b=Luy3mjJCyyA9ishJVNPIsWh42eud4eA5QnD0p8TWwMkTF2NZVkekzJuJ6oHuNJiaSs 6AuALT6qhRwLp1FrazNB9A5Rd7q+53BY+N6YX8edz/kaKEiu9pEURn/FltlqRrzcGyTp 70OFh/4dG9kzSrMnl7zlu50b6KDDRtw4OL/tTHy5HLge+sN3P1pMLjEahIYlS/Yi9b/I wreUzAJMvlYsNU4E376ZeIeVbIB0gBKRs0u4LuGxtirRefnln4hY2dl4LNvBfkuffwiH HQgVvU8kp7x9CMzgcZH4uUwFmBOsYS0JuHAZQu4LXpt8u7jhvFm7inu0wKFutEAwbZBb htIQ== 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:subject:cc:to:from:date; bh=n8ATK5zpmJdO9k9rP/Ajte0cXnSiGqYTUTuTl7cSldE=; b=MYYKHSTd4phiPru6Bnym/fnWMLJWgXVWTRlklotm2tTy6GunQ6VEv11ipZTw45Flrw FFr2DaUusNUTlTAHg6wgiNukD5ZONV6HJoRDp9ADQ8LCW/02I4EE+D5u5Qjdr4N74eex TUlHBmBlI8+fEjiLHBHiIco6Bslz2sBVGnYLDd43fjwmt7kF9fnJI7nLIMd0STmuV55k O5ZdcQsgdlN+hGkuUjFjVPRFXT1pXgUaMjykWkDbvWvJkhroCum1VwkUE4+av+9ZjXnM 1f00DflcmUEHVp2YIBYqmSZY5VL9eRKMrFDTJ/geDUhNdgSds/BYpCajYKgdl6MFwI2W gRmQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o16-20020a056a0015d000b0054d5253e7d7si17812893pfu.190.2022.11.16.17.41.02; Wed, 16 Nov 2022 17:41:13 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232548AbiKQBZh (ORCPT + 90 others); Wed, 16 Nov 2022 20:25:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233519AbiKQBZ2 (ORCPT ); Wed, 16 Nov 2022 20:25:28 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FF553134D for ; Wed, 16 Nov 2022 17:25:27 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CFD296205E for ; Thu, 17 Nov 2022 01:25:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 115AEC433D7; Thu, 17 Nov 2022 01:25:24 +0000 (UTC) Date: Wed, 16 Nov 2022 20:25:21 -0500 From: Steven Rostedt To: Chen Guokai Cc: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, mingo@redhat.com, sfr@canb.auug.org.au, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, liaochang1@huawei.com, Peter Zijlstra , Linus Torvalds Subject: Re: [PATCH v4 2/8] riscv/kprobe: Allocate detour buffer from module area Message-ID: <20221116202521.6c528955@gandalf.local.home> In-Reply-To: <20221106100316.2803176-3-chenguokai17@mails.ucas.ac.cn> References: <20221106100316.2803176-1-chenguokai17@mails.ucas.ac.cn> <20221106100316.2803176-3-chenguokai17@mails.ucas.ac.cn> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS 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 On Sun, 6 Nov 2022 18:03:10 +0800 Chen Guokai wrote: > @@ -84,6 +85,30 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) > } > > #ifdef CONFIG_MMU > +#if defined(CONFIG_OPTPROBES) && defined(CONFIG_64BIT) > +void *alloc_optinsn_page(void) > +{ > + void *page; > + > + page = __vmalloc_node_range(PAGE_SIZE, 1, MODULES_VADDR, > + MODULES_END, GFP_KERNEL, > + PAGE_KERNEL, 0, NUMA_NO_NODE, > + __builtin_return_address(0)); > + if (!page) > + return NULL; > + > + set_vm_flush_reset_perms(page); > + /* > + * First make the page read-only, and only then make it executable to > + * prevent it from being W+X in between. > + */ > + set_memory_ro((unsigned long)page, 1); > + set_memory_x((unsigned long)page, 1); FYI, the above combination is going to be going away: https://lore.kernel.org/all/Y10OyLCLAAS6rsZv@hirez.programming.kicks-ass.net/ -- Steve > + > + return page; > +} > +#endif > +