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 X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9A35C433DB for ; Wed, 3 Mar 2021 03:56:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90A5264E12 for ; Wed, 3 Mar 2021 03:56:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352532AbhCCDuy (ORCPT ); Tue, 2 Mar 2021 22:50:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1580980AbhCBScd (ORCPT ); Tue, 2 Mar 2021 13:32:33 -0500 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39F7DC061788; Tue, 2 Mar 2021 10:31:53 -0800 (PST) Received: by mail-yb1-xb2f.google.com with SMTP id h82so7935504ybc.13; Tue, 02 Mar 2021 10:31:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=p5mQjzoE3xnTJG7PmrlFzhti+trlvTo1ic3oTokLMMc=; b=Y0Ubm2IqkOgR4zN9cLivDAIzbZ8wOHHcMayKC/hM/QadVWehA+GemhY0JUtHmknVRP P5qxmjvvlFInrnpkvhgz5nblA+JxhGj08gDDAAEf+lIJdyxnqGuU/uIP4S5VRAwtrDUT kfTSKtx7Xd8w80NX+fKfmMYXr8kIIa3wM2eO0YkNLc2pvzO9EZiqO3gj4nRju61xDhfn JlWE7hhdAhqMOmCIPKProsDfA5CBuY1/Ld7N6i02FJht5O164WylrME3yBVecxR6KlCm UYltiOjb6YrG968ul1LANwtnfL9Yojbk+2/slh5LuIrFcr7nKGkyGLFwGGR02ceZou8x Xnsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=p5mQjzoE3xnTJG7PmrlFzhti+trlvTo1ic3oTokLMMc=; b=c0qkr8ozzeogxHlqxr0XeAGKh+cq4W5cgkgxET3SCUUJ8bOFlo+K+0rvQUrNaqg42+ omU68XF+S1riTKk+WxZVWOFkNTgdiEaicB4oAmc+p5T6XpDf4d89+BVwqaKEtvHDuzx/ cJWQxMMVQwH3a3/lpqRSLed4s4zFS6OUlUBJE4RlO3lXgQkF3qsrAMd6eykY8jHU5/GO XI2HsSxGUaVFRxrKmQtrbKecNJXI5is0yZtRU3TnsxCz3j9s028qx/SIIkk/2wr+cg+F 5+mFbmjyCkt9fhVF9CEcUd8qj49oFsucZfqHkd86u1/h1fiqLdGt8K1zHo2THGlscHty hs6A== X-Gm-Message-State: AOAM533697R9JPyMLBLIIcpb1a5mGLI2Q3euXU+iCHZcEC56564AVCS9 AKhq6ZjIi4rD3+XVYPGD18MJ0th1+UkzhamB+M/DfBmYA84= X-Google-Smtp-Source: ABdhPJyQwwgASrpAqh0D+gy2eaMl5TSk+tWWgM0z9Yq8pKwMSkIRx55hvjrAWYBTJUmIDgK1d+EgiI9R2qZlD4PSn2Y= X-Received: by 2002:a25:c6cb:: with SMTP id k194mr32076441ybf.27.1614709912374; Tue, 02 Mar 2021 10:31:52 -0800 (PST) MIME-Version: 1.0 References: <20210301190416.90694-1-jolsa@kernel.org> In-Reply-To: From: Andrii Nakryiko Date: Tue, 2 Mar 2021 10:31:41 -0800 Message-ID: Subject: Re: [PATCH bpf-next] selftests/bpf: Fix test_attach_probe for powerpc uprobes To: Jiri Olsa Cc: Jiri Olsa , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Networking , bpf , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= , Yauheni Kaliuta Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Tue, Mar 2, 2021 at 3:14 AM Jiri Olsa wrote: > > On Mon, Mar 01, 2021 at 04:34:24PM -0800, Andrii Nakryiko wrote: > > On Mon, Mar 1, 2021 at 11:11 AM Jiri Olsa wrote: > > > > > > When testing uprobes we the test gets GEP (Global Entry Point) > > > address from kallsyms, but then the function is called locally > > > so the uprobe is not triggered. > > > > > > Fixing this by adjusting the address to LEP (Local Entry Point) > > > for powerpc arch. > > > > > > Signed-off-by: Jiri Olsa > > > --- > > > .../selftests/bpf/prog_tests/attach_probe.c | 18 +++++++++++++++++- > > > 1 file changed, 17 insertions(+), 1 deletion(-) > > > > > > diff --git a/tools/testing/selftests/bpf/prog_tests/attach_probe.c b/tools/testing/selftests/bpf/prog_tests/attach_probe.c > > > index a0ee87c8e1ea..c3cfb48d3ed0 100644 > > > --- a/tools/testing/selftests/bpf/prog_tests/attach_probe.c > > > +++ b/tools/testing/selftests/bpf/prog_tests/attach_probe.c > > > @@ -2,6 +2,22 @@ > > > #include > > > #include "test_attach_probe.skel.h" > > > > > > +#if defined(__powerpc64__) > > > +/* > > > + * We get the GEP (Global Entry Point) address from kallsyms, > > > + * but then the function is called locally, so we need to adjust > > > + * the address to get LEP (Local Entry Point). > > > + */ > > > +#define LEP_OFFSET 8 > > > + > > > +static ssize_t get_offset(ssize_t offset) > > > > if we mark this function __weak global, would it work as is? Would it > > get an address of a global entry point? I know nothing about this GEP > > vs LEP stuff, interesting :) > > you mean get_base_addr? it's already global > > all the calls to get_base_addr within the object are made > to get_base_addr+0x8 > > 00000000100350c0 : > ... > 100350e0: 59 fd ff 4b bl 10034e38 > ... > 100358a8: 91 f5 ff 4b bl 10034e38 > > > I'm following perf fix we had for similar issue: > 7b6ff0bdbf4f perf probe ppc64le: Fixup function entry if using kallsyms lookup > > I'll get more info on that My thinking was that if you mark the function as __weak, then the compiler is not allowed to assume that the actual implementation of that function will come from the same object (because it might be replaced by the linker later), so it has to be pessimistic and use global entry, no? Totally theoritizing here, of course. > > jirka > > > > > > +{ > > > + return offset + LEP_OFFSET; > > > +} > > > +#else > > > +#define get_offset(offset) (offset) > > > +#endif > > > + > > > ssize_t get_base_addr() { > > > size_t start, offset; > > > char buf[256]; > > > @@ -36,7 +52,7 @@ void test_attach_probe(void) > > > if (CHECK(base_addr < 0, "get_base_addr", > > > "failed to find base addr: %zd", base_addr)) > > > return; > > > - uprobe_offset = (size_t)&get_base_addr - base_addr; > > > + uprobe_offset = get_offset((size_t)&get_base_addr - base_addr); > > > > > > skel = test_attach_probe__open_and_load(); > > > if (CHECK(!skel, "skel_open", "failed to open skeleton\n")) > > > -- > > > 2.29.2 > > > > > >