From patchwork Sun Feb 25 15:15:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 206042 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1619592dyb; Sun, 25 Feb 2024 07:15:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVjHPNrhA8gO0m+gWwajkDgfFN7G0/ywG2IpB2Fn3J1fsm9YtdNejlDAPBWfJRAKkMSIYxWF0Q7z4a9TXAXUwoGfg+AyQ== X-Google-Smtp-Source: AGHT+IFDICahZSYMDdhkuBOjeAwsUhLbKfMAvvem4A80q3p+g4bPJH5Eblk9aJiq12aXjURLkrAN X-Received: by 2002:a05:620a:13c3:b0:787:2a72:c2ec with SMTP id g3-20020a05620a13c300b007872a72c2ecmr5446181qkl.56.1708874139095; Sun, 25 Feb 2024 07:15:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708874139; cv=pass; d=google.com; s=arc-20160816; b=M4q5WxeVln0slTTvsICCR1ruGCvp0TmElAq895FdylgciFz5QnIzcVADLOFQ7WqaQy /dWWVsLanjKqLIfXzffU66MDi31siTlyISA2mKzuC0O8gK1vaZa6beAQOPjTSIgLQAUL 6HJx4fp8snRVY9JkP3NY6riLzTXHMLfynMbEPF5k9S8gWGM1xM3wVhlssxuaDUTSg7Vq A80lyn5p3WEWwwvjAXhrDYIu5J8a3NLIJeGJ4RzbtgbXeRb+jjrjJKHXfaz8Ja9lKmd5 AFq245FZxyQElHYllloeRMO7AT94xReMnc2hgA4IpZbmGh/+/YwhkaiojjPB4oqvKao9 kBCA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=+z/tAvga4hlPa661E6tKc6JC4M5rDFp8ROasCwIqTtc=; fh=SIgps5XdV0XNwjZfT2uAI7g3mrspDldK9Qs8qQAfoa4=; b=kTddv4MXvjsBoG85pIt5tcV0bqThkdOD5Ow7nLxIShrwaNtM0X5J5UpFWBTu1xkfui YFnh78aNwlmgE/bjMKwJ8gNcQzfIR947kyZLcSPE+GeM8XwL+Mx8zSbD+xgjnnZUdJKN 2dQeWUkJnNYuRUsoSSyHY7wNjXRIIpjPA9d8s8yY3dEAgsCdp3UhTzmgJ15WSHetHdbk v0N42c3gAVJYNc9lV+Y1i/ZonauNjqFzcZQjnG5GoZNn79UBOvKSo0csNDsOXOHyq7Vk uAFhCMXQETvzwvhpi5TAPMPB7wMLyIiXBLUC3Exulqw4t8zRWD4Tl+Ya4eRz5vTOiCV8 zr7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="nDitAo/t"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80129-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80129-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id s9-20020a05620a030900b007871d8752f6si3017574qkm.275.2024.02.25.07.15.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 07:15:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80129-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="nDitAo/t"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80129-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80129-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DE6CD1C20850 for ; Sun, 25 Feb 2024 15:15:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9515414AB7; Sun, 25 Feb 2024 15:15:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nDitAo/t" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DADD913FFC; Sun, 25 Feb 2024 15:15:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708874121; cv=none; b=cw29WHyx52z2T+e4nvzo4yAlrPg1Zc16pYpuzEvgrslgpVC4HX9kDJQHiWFvAIXY8mSIFrK2XWocXeKwH9H7Cw9uRKtQIhIlQa20vf6nqU2EIpGuL598drarMoosm44LEoCVJNQTliCQdK38aRt5j60DOft0w9HKr3O/ZOFoOeY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708874121; c=relaxed/simple; bh=/LCEyj6otVE7dq9ACr3DTrEgnCp5zvLBAVKQj9AXdic=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ppfDtOBSQdd5UmtArt5KQmI6PkQLudcajzg1UvXiJG5kkwj6SKLF6A0rtJAI691k++hEHlmR7A8rqgAwdq2tqsV3Jcy30YbH5X2hkcJ6rp6BmcDWD7BUjDtjj/IjSYMcrPmCBGFpkwelflrik6I5SkjLjpjby6AvCT8az4zCKBs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nDitAo/t; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73A26C433C7; Sun, 25 Feb 2024 15:15:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708874120; bh=/LCEyj6otVE7dq9ACr3DTrEgnCp5zvLBAVKQj9AXdic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nDitAo/tgwu6ieBekmscRmccn9BJnVGSRD6JS5b/thivAdvOatEFC6ngH90PUNWvY irmyOSFnKuwoE1FHbrAqrNZCWmRmOlkVo9j8qiR2F3qEI9ISjeOu+7T7b8hyA7LKjn 5G8Okj7ljRKD6F53d4CFHsd4L9Eu34kAaRYhwhhht0N3fb3/eRywE+Lj66cVd/UEQW K3EXGdCRaANZ5c7OcdpeliShyfBfhYsDwse0XK5bHAWbLX1VhXqhWS7sSYcgJxu6Tw l2BGOjH0wN3CfGZ6zjPFttbONOpbP6pgxxhAwIMvyVqCvMix8ntQUvY4cj0zGBdweY MIsKoRAG1/pkQ== From: "Masami Hiramatsu (Google)" To: Alexei Starovoitov , Steven Rostedt , Florent Revest Cc: linux-trace-kernel@vger.kernel.org, LKML , Martin KaFai Lau , bpf , Sven Schnelle , Alexei Starovoitov , Jiri Olsa , Arnaldo Carvalho de Melo , Daniel Borkmann , Alan Maguire , Mark Rutland , Peter Zijlstra , Thomas Gleixner , Guo Ren Subject: [PATCH v8 01/35] tracing: Add a comment about ftrace_regs definition Date: Mon, 26 Feb 2024 00:15:15 +0900 Message-Id: <170887411542.564249.13176701341524156433.stgit@devnote2> X-Mailer: git-send-email 2.34.1 In-Reply-To: <170887410337.564249.6360118840946697039.stgit@devnote2> References: <170887410337.564249.6360118840946697039.stgit@devnote2> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791884409264170669 X-GMAIL-MSGID: 1791884409264170669 From: Masami Hiramatsu (Google) To clarify what will be expected on ftrace_regs, add a comment to the architecture independent definition of the ftrace_regs. Signed-off-by: Masami Hiramatsu (Google) Acked-by: Mark Rutland --- Changes in v8: - Update that the saved registers depends on the context. Changes in v3: - Add instruction pointer Changes in v2: - newly added. --- include/linux/ftrace.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index e8921871ef9a..8b48fc621ea0 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -118,6 +118,32 @@ extern int ftrace_enabled; #ifndef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS +/** + * ftrace_regs - ftrace partial/optimal register set + * + * ftrace_regs represents a group of registers which is used at the + * function entry and exit. There are three types of registers. + * + * - Registers for passing the parameters to callee, including the stack + * pointer. (e.g. rcx, rdx, rdi, rsi, r8, r9 and rsp on x86_64) + * - Registers for passing the return values to caller. + * (e.g. rax and rdx on x86_64) + * - Registers for hooking the function call and return including the + * frame pointer (the frame pointer is architecture/config dependent) + * (e.g. rip, rbp and rsp for x86_64) + * + * Also, architecture dependent fields can be used for internal process. + * (e.g. orig_ax on x86_64) + * + * On the function entry, those registers will be restored except for + * the stack pointer, so that user can change the function parameters + * and instruction pointer (e.g. live patching.) + * On the function exit, only registers which is used for return values + * are restored. + * + * NOTE: user *must not* access regs directly, only do it via APIs, because + * the member can be changed according to the architecture. + */ struct ftrace_regs { struct pt_regs regs; };