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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7AD9BC433EF for ; Tue, 10 May 2022 14:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Qs0w+5tLJCYNS1vYu2maQov7h1nbrdtj9BlYK9Cm3Z0=; b=QzaCqE7Jc+H1g6 i/Eukhn8ZS/xYcKhwsjbu1OOc/b6z8xm0h/V2a9ALS+U/GIYsypcuST0p0A6VCieexvtJyshDBHZ2 Yq4oUZn+ykf9FVtCh5pljqhA8xKBD0BrnqcM2hRNUEmp9N3D9/6zzOa9fWoq5P4it4RXdOSDoOm3p jm+RzHvMtqYUTU8ZZlEUHQS1PC8ZkhirbV3538D+qBCHt33b+lPhRJtGIQk4b1uFnAywgVhPE6LrF 1wXxwvhoNgfv22mdD0zVnDSUL0flyhtZao07RcCMNU/p9MTuzSu/Roon0KOtRhtzyl88UJsY48pVP 2n4cQS4sv3uZZtWZmcQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1noR6c-002aBn-O5; Tue, 10 May 2022 14:44:54 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1noR6Y-002aAh-I4 for linux-arm-kernel@lists.infradead.org; Tue, 10 May 2022 14:44:52 +0000 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 E2E7661943; Tue, 10 May 2022 14:44:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DF37C385C2; Tue, 10 May 2022 14:44:47 +0000 (UTC) Date: Tue, 10 May 2022 10:44:46 -0400 From: Steven Rostedt To: Masami Hiramatsu Cc: Mark Rutland , Wang ShaoBo , cj.chengjian@huawei.com, huawei.libin@huawei.com, xiexiuqi@huawei.com, liwei391@huawei.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, zengshun.wu@outlook.com, Jiri Olsa Subject: Re: [RFC PATCH -next v2 3/4] arm64/ftrace: support dynamically allocated trampolines Message-ID: <20220510104446.6d23b596@gandalf.local.home> In-Reply-To: <20220510181012.d5cba23a2547f14d14f016b9@kernel.org> References: <20220421100639.03c0d123@gandalf.local.home> <20220421114201.21228eeb@gandalf.local.home> <20220421130648.56b21951@gandalf.local.home> <20220422114541.34d71ad9@gandalf.local.home> <20220426174749.b5372c5769af7bf901649a05@kernel.org> <20220505121538.04773ac98e2a8ba17f675d39@kernel.org> <20220509142203.6c4f2913@gandalf.local.home> <20220510181012.d5cba23a2547f14d14f016b9@kernel.org> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220510_074450_686335_F1DE174E X-CRM114-Status: GOOD ( 26.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 10 May 2022 18:10:12 +0900 Masami Hiramatsu wrote: > > > > This was suggested by both Peter Zijlstra and Thomas Gleixner when I > > introduced FTRACE_WITH_ARGS, where all functions can now get the arguments > > from fregs, but not the full pt_regs. > > Hmm, I thought the ftrace_get_regs() is the all-or-nothing interface, or > is there any way to get the arguments from fregs? Not yet generically. But that can easily be added. If you look at x86 live patching, since it is arch specific, it just took the regs parameter directly, knowing that the args were already set up. That is, ftrace_regs is just a wrapper around pt_regs with just the regs for the arguments and stack initialized. If you get regs from ftrace_get_regs(fregs) it will return NULL if it wasn't full set of regs. But we can add generic functions to get the parameters. That is, we can create a ftrace_get_kernel_argument() function that takes fregs instead of pt_regs, and produce the same thing as regs_get_kernel_argument(). x86 live kernel patching has this: arch/x86/include/asm/ftrace.h: #define ftrace_instruction_pointer_set(fregs, _ip) \ do { (fregs)->regs.ip = (_ip); } while (0) arch/x86/include/asm/livepatch.h: static inline void klp_arch_set_pc(struct ftrace_regs *fregs, unsigned long ip) { ftrace_instruction_pointer_set(fregs, ip); } Where fregs is not a full set of regs. > > > If a ftrace_ops has the REGS flag set > > (using ftrace_regs_caller), the ftrace_get_regs(fregs) will return the > > pt_regs, or it will return NULL if ftrace_regs_caller was not used. > > > > This way the same parameter can provide full pt_regs or a subset, and have > > an generic interface to tell the difference. > > If it can provide a partial (subset of) pt_regs, that could be good for me > too, since at least kprobe-events on ftrace can check the traced register > is in the subset or not and reject it if it doesn't saved. That's exactly the use case for ftrace_regs. -- Steve _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel