From: "van der Linden, Frank" <fllinden@amazon.com>
To: William Cohen <wcohen@redhat.com>,
"systemtap@sourceware.org" <systemtap@sourceware.org>
Subject: Re: [PATCH] arm64: use sregs for syscall probe registers
Date: Mon, 15 Apr 2019 21:40:00 -0000 [thread overview]
Message-ID: <F89C61CE-3EE8-436A-84A8-26BF6E232697@amazon.com> (raw)
In-Reply-To: <d50a95eb-2798-a53c-a95a-a03780f650c0@redhat.com>
On 4/15/19, 2:32 PM, "William Cohen" <wcohen@redhat.com> wrote:
On 4/12/19 1:30 PM, Frank van der Linden wrote:
> Since syscall wrappers are now active on arm64 (4.19+), arguments need to
> be retrieved the right way, by checking if there is a saved set of system
> call registers, and using them if there are.
> ---
> tapset/arm64/registers.stp | 50 ++++++++++++++++++++++++++++------------------
> 1 file changed, 31 insertions(+), 19 deletions(-)
>
> diff --git a/tapset/arm64/registers.stp b/tapset/arm64/registers.stp
> index b2e56495d..b001b8efe 100644
> --- a/tapset/arm64/registers.stp
> +++ b/tapset/arm64/registers.stp
> @@ -107,6 +107,36 @@ function u_register:long (name:string) {
> return _stp_register(name, 0)
> }
>
> +function _stp_arg_register:long (argnum:long) %{ /* pure */
> + long val;
> + struct pt_regs *regs;
> +
> + if (STAP_ARG_argnum < 1 || STAP_ARG_argnum > 8) {
> + snprintf(CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer),
> + "Cannot access arg(%lld)",
> + (long long)STAP_ARG_argnum);
> + CONTEXT->last_error = CONTEXT->error_buffer;
> + return;
> + }
> +
> + /* syscall-in-pt_regs mode, 4.19+ */
> + if (CONTEXT->sregs) {
> + regs = CONTEXT->sregs;
> + } else {
> + regs = (CONTEXT->user_mode_p ? CONTEXT->uregs : CONTEXT->kregs);
> + }
> +
> + if (!regs) {
> + CONTEXT->last_error = "No registers available in this context";
> + return;
> + }
> +
> + memcpy(&val, ((char *)regs) + ((STAP_ARG_argnum - 1) * sizeof (long)),
> + sizeof (long));
> +
> + STAP_RETVALUE = val;
> Could the memcpy be eliminated and STAP_RETVALUE statements be simplified to something like:
>
> STAP_RETVALUE = regs->regs[STAP_ARG_argnum-1];
>
>-Will
Probably. I was following existing practice and used memcpy. See also _stp_get_register_by_offset() for various architectures: they all use memcpy. I am not sure why. Alignment paranoia?
Frank
next prev parent reply other threads:[~2019-04-15 21:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-12 17:30 Frank van der Linden
2019-04-15 21:32 ` William Cohen
2019-04-15 21:40 ` van der Linden, Frank [this message]
2019-04-16 15:33 ` Frank Ch. Eigler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=F89C61CE-3EE8-436A-84A8-26BF6E232697@amazon.com \
--to=fllinden@amazon.com \
--cc=systemtap@sourceware.org \
--cc=wcohen@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).