Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp213903lqb; Thu, 23 May 2024 16:09:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXQKdYCHCyK85DEuuAx4L5/vIEOaRjJ3aK01OFiXCnhtboInluWDFF/veixyA6YqTyN3W53kzFPI0pf2XfyS555XuC8TrN4DOPanbGDcQ== X-Google-Smtp-Source: AGHT+IH2Iur+tlUfNWmwFnGr+sGJEb4eRSvE2BODdwW8G4iK3Ch8fsfQVPwZv7W8+ruoZTkwhdPl X-Received: by 2002:a17:902:e5cb:b0:1ec:3c71:eae7 with SMTP id d9443c01a7336-1f44902a744mr7992925ad.47.1716505798282; Thu, 23 May 2024 16:09:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716505798; cv=pass; d=google.com; s=arc-20160816; b=ffKDO5gKeZ4ui5kKmniIj/9zidoCv+w/iKD1LcCmfr2JlcGrqMDDteW/riKvYY1bSj PW2SY5jF7gItkU/peNFbsf/71kuu1eq/fU0Ff9Q6f5W8sUu6BpmB6/cAOXA7HawyY2XI XF0GlobXKJryKt/Ow9KR3634p8Tq/xDSh4LnAeSoLHr0/9Y5SC4WYPjY5KQX3ez7gxVJ ysE5//eXyWQkgV7TqkWtm3DFZMLQbnrVxCllOPpceEFdrMKqdYrPQyn22mY0BHHwDCdo iV7/rtyA/l2akd5+750gsotl0QE2mK57F75OJwvO3Z4XOY6TEcMXSzwjDZ92pcHYBq6N XlDw== 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:references:in-reply-to:message-id :subject:cc:to:from:date; bh=gU1nLJzsSqUQUqPqaQTIxt3xuL8J4sXYMFsOIkHcLuE=; fh=VaF/w+FGpk/prTFLJfCoV+GJDmV0Sd6dt8EMZrBTbz0=; b=F9fdjJdTYW26sBA6j+3ye3pctv+o7GiEouQN6IRj2glro0lOVMJNeJAn1s32Fr3Xvl 8ae1wo//elikA/RSPGb7AWajl2z48TdI+hNKN7isIeYFYBPUqDd8kXJjj3hCWWJYpXiK dx6Zy9kVlhLP3Gpy7B71MqK4qi7lwDlY/Ye8b9HjRkov5ZRAukG6HgRX/BeiwwW4ssTU efKaB/tqh+cxWcRnf6bbKzStPkpR6aD1pUIHtukqSIBRPmwcuG1ZFqUdbsMxEBOUgKcZ XHT6rBZ00ieQkxh94YlkCabQYddNQm8+v8YMwwuxEVcwJ1NoxWsobgIVBOVS9vZEPuzY IwRg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-188096-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188096-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f44ca14ab8si1661115ad.637.2024.05.23.16.09.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 16:09:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-188096-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-188096-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188096-linux.lists.archive=gmail.com@vger.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 81CEEB20D5A for ; Thu, 23 May 2024 23:09:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 28FBC128812; Thu, 23 May 2024 23:09:49 +0000 (UTC) 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 98A4E126F27; Thu, 23 May 2024 23:09:48 +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=1716505788; cv=none; b=T8t9JR+uCzcKDooinb26oOYuRXz70jmKQRb88vMousMPp38+N4sRPNziUkOaxbJ2Q355SuQhO1HEgnojJFEmzdd+uSn7TUCvNPItXmh+olffYzWK6aUPOBk1Aa3bbnBlS4Xbq+p8Fd0zBhi+YZ/1pWyGEdr+QNJvf7V5ZKcvpZk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716505788; c=relaxed/simple; bh=1ZerqhZiEm0bGWbV+jNKn+Dq0L+J1awgxyJkbjTBq+g=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PRgePn3SU12vAWHevKZ3rBZ0w6wdx4WWSYcfGU//IBiFWfOf0F5QUGxQW/eCJ5wRZwidAACEZHjTy88yEZkgpImL2ymP8fjqvwyHSyYpYfvKfzD8ieBMnPU0a5Ih7czDZvXqEnA7SAD/GsDhdzvuwUOrj94sUexlXiSfqmc3aEA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED0A8C2BD10; Thu, 23 May 2024 23:09:45 +0000 (UTC) Date: Thu, 23 May 2024 19:10:31 -0400 From: Steven Rostedt To: "Masami Hiramatsu (Google)" Cc: Alexei Starovoitov , Florent Revest , 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: Re: [PATCH v10 01/36] tracing: Add a comment about ftrace_regs definition Message-ID: <20240523191031.7574d944@gandalf.local.home> In-Reply-To: <171509089214.162236.6201493898649663823.stgit@devnote2> References: <171509088006.162236.7227326999861366050.stgit@devnote2> <171509089214.162236.6201493898649663823.stgit@devnote2> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 7 May 2024 23:08:12 +0900 "Masami Hiramatsu (Google)" wrote: > 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 54d53f345d14..b81f1afa82a1 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. I wonder if we should also add a note about some architectures in some circumstances may store all pt_regs in ftrace_regs. For example, if an architecture supports FTRACE_WITH_REGS, it may pass the pt_regs within the ftrace_regs. If that is the case, then ftrace_get_regs() called on it will return a pointer to a valid pt_regs, or NULL if it is not supported or the ftrace_regs does not have a all the registers. -- Steve > + * > + * 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; > };