Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp308356ybg; Tue, 28 Jul 2020 06:39:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiVHk1u1Pib9Es7xd4t1foNDWf/IN1jJ3byWLO8cRodj8hWIWIuR5q5z8ryxBCWblQLMom X-Received: by 2002:a17:906:64d7:: with SMTP id p23mr9740301ejn.185.1595943560063; Tue, 28 Jul 2020 06:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595943560; cv=none; d=google.com; s=arc-20160816; b=wqqO64r1q8sijUTIBbMuJsVTn69hHjStR6Hm1t65sAeBgcpRtdTGEDc8ZATsQMco8e 3IPJpyP9flOWqCaKsKeUCSytia5wD5UYAkIV9BvSXsWIZiDPx9wElFgdp3n8GGdwjsOL WqxSM20a2F31x2xG3kizxXNj+O6Sc4cHbXrdsmt9kmwndrv6yQnn0o/nnnguYnka3z3B RM2ccnFviAJAuDzth+eC9fiHux/PhvDVYKQDp1jMqzPMZaBHg/cAziJCRqJR56PLQNpj L7pa/D0EWPE1Pq99xzLxXZgvPBdEUd3m7bU2EgzaiMyX1DtBKDe3ntQcNs89MpFbj+Iu flSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=bm7wuKaB8lNn5CmHlwSPtw0o3e7MP5IX8Fej9kaVxLA=; b=Th3HoSUTuLHlXRjTAnt3f8F3aRXrnw5LBOjobhYz8Uvo07hB8uQUnDWFl+TxpNErzF 9qPDoOZR5Qm5R6imAdKLcy194oa0pCC0NsZnUIccc2+4Hw+C9PJB6JS6McHvov+GwsLW igoUQ3YhOM4muXxHIyVzXqKsqBO6hSUKXnCbp5JKNLGSrXWdsbl9rr9uWSRa6zWPvHQU VUHK+5HnMMidY2uJiFsR5lvGEDFSvUcEOsJA7mt+RADM0EYFQjLTd+E85rEylEZV/IwV i7foNQVk2KyRb8udzSBB8iAmv0fACaWqk/J3oQSPvhe74u6el9J8zz9/ELXwSXoeVOe0 FBpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s7xlgTWj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t15si5999948edy.289.2020.07.28.06.38.47; Tue, 28 Jul 2020 06:39:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s7xlgTWj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1730072AbgG1Nfv (ORCPT + 99 others); Tue, 28 Jul 2020 09:35:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:50170 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730021AbgG1Nfv (ORCPT ); Tue, 28 Jul 2020 09:35:51 -0400 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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