From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53887 invoked by alias); 15 Apr 2019 21:32:13 -0000 Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org Received: (qmail 53876 invoked by uid 89); 15 Apr 2019 21:32:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=1457, frank X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 15 Apr 2019 21:32:12 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11F15C057E37; Mon, 15 Apr 2019 21:32:11 +0000 (UTC) Received: from [10.13.129.79] (dhcp129-79.rdu.redhat.com [10.13.129.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id D21B45D9CA; Mon, 15 Apr 2019 21:32:10 +0000 (UTC) Subject: Re: [PATCH] arm64: use sregs for syscall probe registers To: Frank van der Linden , systemtap@sourceware.org References: <5cb0cb1f.ROdjA4uUKaH5hT/r%fllinden@amazon.com> From: William Cohen Message-ID: Date: Mon, 15 Apr 2019 21:32:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <5cb0cb1f.ROdjA4uUKaH5hT/r%fllinden@amazon.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-q2/txt/msg00030.txt.bz2 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 > +%} > + > /* > * Return the value of function arg #argnum (1=first arg). > * If truncate=1, mask off the top 32 bits. > @@ -115,25 +145,7 @@ function u_register:long (name:string) { > * TODO: 32-bit arm code has different calling conventions than arm64 > */ > function _stp_arg:long (argnum:long, sign_extend:long, truncate:long) { > - val = 0 > - assert(!(argnum < 1 || argnum > 8), sprintf("Cannot access arg(%d)", argnum)) > - > - if (argnum == 1) > - val = u_register("x0") > - else if (argnum == 2) > - val = u_register("x1") > - else if (argnum == 3) > - val = u_register("x2") > - else if (argnum == 4) > - val = u_register("x3") > - else if (argnum == 5) > - val = u_register("x4") > - else if (argnum == 6) > - val = u_register("x5") > - else if (argnum == 7) > - val = u_register("x6") > - else if (argnum == 8) > - val = u_register("x7") > + val = _stp_arg_register(argnum) > > if (truncate) { > if (sign_extend) >