From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34F87C433E1 for ; Tue, 28 Jul 2020 13:35:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EF8B920663 for ; Tue, 28 Jul 2020 13:35:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="s7xlgTWj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF8B920663 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 77F126B002B; Tue, 28 Jul 2020 09:35:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 708056B002C; Tue, 28 Jul 2020 09:35:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D0738D0003; Tue, 28 Jul 2020 09:35:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0032.hostedemail.com [216.40.44.32]) by kanga.kvack.org (Postfix) with ESMTP id 435456B002B for ; Tue, 28 Jul 2020 09:35:53 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B7FCB181AC9B6 for ; Tue, 28 Jul 2020 13:35:52 +0000 (UTC) X-FDA: 77087582544.11.pest60_2a077bf26f6a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 1A7F2180F8B96 for ; Tue, 28 Jul 2020 13:35:52 +0000 (UTC) X-HE-Tag: pest60_2a077bf26f6a X-Filterd-Recvd-Size: 3781 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Tue, 28 Jul 2020 13:35:51 +0000 (UTC) Received: from devnote2 (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D592B20663; Tue, 28 Jul 2020 13:35:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595943350; bh=VhNW/VcN7636dhuyu/1kgMRnPEPrCnyH1NVrMnXimX0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=s7xlgTWj26GYXPVmvQPSyemnyiVNpxsfCk0lxaMxcOgC8Rag4Wh65Bi12AUpYMCT+ 3mSsI1SVIhhAfLNg5QBP+l8gDt2cQVLKYMVg2bFjTADrmQ9spnrc6ckduRG4bnr+tf KCUdnUivnqPoERNrnJrk1jW9WKUSvnlTLjVpPnOY= Date: Tue, 28 Jul 2020 22:35:45 +0900 From: Masami Hiramatsu To: Ard Biesheuvel Cc: Mike Rapoport , Jarkko Sakkinen , Ingo Molnar , Linux Kernel Mailing List , linux-mm@kvack.org, Andi Kleen , Peter Zijlstra , "Naveen N. Rao" , Anil S Keshavamurthy , "David S. Miller" , Jessica Yu Subject: Re: [PATCH v5 5/6] kprobes: Use text_alloc() and text_free() Message-Id: <20200728223545.ce4ff78cac73b571a27bb357@kernel.org> In-Reply-To: References: <20200724050553.1724168-1-jarkko.sakkinen@linux.intel.com> <20200724050553.1724168-6-jarkko.sakkinen@linux.intel.com> <20200724092746.GD517988@gmail.com> <20200725031648.GG17052@linux.intel.com> <20200726081408.GB2927915@kernel.org> <20200728171715.0800093e2226e3d72b04a3ae@kernel.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 1A7F2180F8B96 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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: On Tue, 28 Jul 2020 13:56:43 +0300 Ard Biesheuvel wrote: > On Tue, 28 Jul 2020 at 11:17, Masami Hiramatsu wrote: > > > Masami or Peter should correct me if I am wrong, but it seems to me > > > that the way kprobes uses these pages does not require them to be in > > > relative branching range of the core kernel on any architecture, given > > > that they are populated with individual instruction opcodes that are > > > executed in single step mode, and relative branches are emulated (when > > > needed) > > > > Actually, x86 and arm has the "relative branching range" requirements > > for the jump optimized kprobes. For the other architectures, I think > > we don't need it. Only executable text buffer is needed. > > > > Thanks for the explanation. Today, arm64 uses the definition below. > > 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)); > } > > Do you think we could use that as the generic implementation if we use > MODULES_START/_END as the allocation window? Yes, but for the generic implementation, we don't need to consider the relative branching range since we can override it for x86 and arm. (and that will be almost same as module_alloc() default code) BTW, is PAGE_KERNEL_ROX flag available generically? Thank you, -- Masami Hiramatsu