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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 5B1ADC433DF for ; Fri, 9 Oct 2020 19:32:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13AEE222BA for ; Fri, 9 Oct 2020 19:32:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mXoZsVlE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390623AbgJITcc (ORCPT ); Fri, 9 Oct 2020 15:32:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388639AbgJITcb (ORCPT ); Fri, 9 Oct 2020 15:32:31 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EDB4C0613D2 for ; Fri, 9 Oct 2020 12:32:31 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id p15so14700624ejm.7 for ; Fri, 09 Oct 2020 12:32:31 -0700 (PDT) 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:content-transfer-encoding; bh=Z8tzmW3tEEl4LWjCU0NlhQ1/o6AqbQ7QB2eHzwb4ewI=; b=mXoZsVlEbAwitEGSly25LeLBYDk3t1WiBY/jPNrK+Xxm9YfSL+an0CmjwxyOVjJ8HV 9bsV0gJ40GEa7HNQESSPXfo8lu/FTQeQF/rmHHdYQ4VhCQKmInSx653/dV+ypH5yjj/y Ax2fhRv6tzBBYUxdF9Y+qkcHzr716B6OlOPPvIoBUrLrdqKKyWHDJYmJ792yVy0psK5v ISvMiqkyVW4vc9+xNX1inTr7OtE4PJZZ672OOWtMUPrH6wwSbu+nSvKnN4uFBDlRzpWA d7V/vAzLwj0LWa9yNRTeo64arKqW40fNf6zc6Q7C/VAkPHuBGNZhpOS0jB++fhMkSOQX aiKA== 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:content-transfer-encoding; bh=Z8tzmW3tEEl4LWjCU0NlhQ1/o6AqbQ7QB2eHzwb4ewI=; b=S/hulRLIbqZniO0uSACXRLOPpkBNgWt2xLHB9YvOhdxj/ZA/z+OS6qz5uL+Aq2snnb oGaonaH1itDTriSqKoIk3QVl+8btv+6Ef/8XvDC36+THvFzKQieoNzyR16AEo0G2+s8e 4JVvAD5QzMSFjUT8B1mPikkOdQH0hlF0xpSoJ4eB4KKnAcXnWbIipy0aCP4sGHuUKW6K hO7DHCi5tFjlCs0SRz5x73/uqyW3vJUm6BmfWHj1FllSukssme+JM3f9RABaWr/DqAvO H65SggGdkjvgbXFMS4Jfw/Q0esMuVqamnTfCrUtUbC8ZbDs5r3t5p6ckP9GIq2kmInaA kayg== X-Gm-Message-State: AOAM530DklXDkvFNWCkfeAqsHOyM+MCXLQIkuYVBXKg8JWvUlV24+azn FRm6SV9NJeCPOAficRczrd58X2dl3tDLrV2yca8= X-Google-Smtp-Source: ABdhPJwG7kN0Sf4uWTSRNGomshyNmcRfxtBNBEHb1ZZ53DRiheqlw22ZoPeXfm5gQpRWhfzoq8fQxYl8lxmA1w2/ksI= X-Received: by 2002:a17:906:6d89:: with SMTP id h9mr15378987ejt.152.1602271947764; Fri, 09 Oct 2020 12:32:27 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Yaniv Agman Date: Fri, 9 Oct 2020 22:32:16 +0300 Message-ID: Subject: Re: libbpf error: unknown register name 'r0' in asm To: Andrii Nakryiko Cc: Daniel Borkmann , bpf , Yonghong Song Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org =E2=80=AB=D7=91=D7=AA=D7=90=D7=A8=D7=99=D7=9A =D7=99=D7=95=D7=9D =D7=95=D7= =B3, 9 =D7=91=D7=90=D7=95=D7=A7=D7=B3 2020 =D7=91-21:39 =D7=9E=D7=90=D7=AA = =E2=80=AAAndrii Nakryiko=E2=80=AC=E2=80=8F <=E2=80=AAandrii.nakryiko@gmail.com=E2=80=AC=E2=80=8F>:=E2=80=AC > > On Fri, Oct 9, 2020 at 11:33 AM Yaniv Agman wrote: > > > > =E2=80=AB=D7=91=D7=AA=D7=90=D7=A8=D7=99=D7=9A =D7=99=D7=95=D7=9D =D7=95= =D7=B3, 9 =D7=91=D7=90=D7=95=D7=A7=D7=B3 2020 =D7=91-21:21 =D7=9E=D7=90=D7= =AA =E2=80=AADaniel Borkmann=E2=80=AC=E2=80=8F > > <=E2=80=AAdaniel@iogearbox.net=E2=80=AC=E2=80=8F>:=E2=80=AC > > > > > > On 10/9/20 8:09 PM, Yaniv Agman wrote: > > > > =E2=80=AB=D7=91=D7=AA=D7=90=D7=A8=D7=99=D7=9A =D7=99=D7=95=D7=9D = =D7=95=D7=B3, 9 =D7=91=D7=90=D7=95=D7=A7=D7=B3 2020 =D7=91-20:39 =D7=9E=D7= =90=D7=AA =E2=80=AADaniel Borkmann=E2=80=AC=E2=80=8F > > > > <=E2=80=AAdaniel@iogearbox.net=E2=80=AC=E2=80=8F>:=E2=80=AC > > > >> > > > >> On 10/9/20 6:56 PM, Yaniv Agman wrote: > > > >>> =E2=80=AB=D7=91=D7=AA=D7=90=D7=A8=D7=99=D7=9A =D7=99=D7=95=D7=9D = =D7=95=D7=B3, 9 =D7=91=D7=90=D7=95=D7=A7=D7=B3 2020 =D7=91-19:27 =D7=9E=D7= =90=D7=AA =E2=80=AADaniel Borkmann=E2=80=AC=E2=80=8F > > > >>> <=E2=80=AAdaniel@iogearbox.net=E2=80=AC=E2=80=8F>:=E2=80=AC > > > >>>> > > > >>>> [ Cc +Yonghong ] > > > >>>> > > > >>>> On 10/9/20 6:05 PM, Yaniv Agman wrote: > > > >>>>> Pulling the latest changes of libbpf and compiling my applicati= on with it, > > > >>>>> I see the following error: > > > >>>>> > > > >>>>> ../libbpf/src//root/usr/include/bpf/bpf_helpers.h:99:10: error: > > > >>>>> unknown register name 'r0' in asm > > > >>>>> : "r0", "r1", "r2", "r3", "r4", "r5"); > > > >>>>> > > > >>>>> The commit which introduced this change is: > > > >>>>> 80c7838600d39891f274e2f7508b95a75e4227c1 > > > >>>>> > > > >>>>> I'm not sure if I'm doing something wrong (missing include?), o= r this > > > >>>>> is a genuine error > > > >>>> > > > >>>> Seems like your clang/llvm version might be too old. > > > >>> > > > >>> I'm using clang 10.0.1 > > > >> > > > >> Ah, okay, I see. Would this diff do the trick for you? > > > > > > > > Yes! Now it compiles without any problems! > > > > > > Great, thx, I'll cook proper fix and check with clang6 as Yonghong me= ntioned. > > > > > > > Thanks! > > Does this happen because I'm first compiling using "emit-llvm" and > > then using llc? > > So this must be the reason, but I'll wait for Yonghong to confirm. > > > I wish I could use bpf target directly, but I'm then having problems > > with includes of asm code (like pt_regs and other stuff) > > Are you developing for a 32-bit platform? Or what exactly is the > problem? I've been trying to solve problems for 32-bit arches recently > by making libbpf smarter, that relies on CO-RE though. Is CO-RE an > option for you? > Examples for the errors I'm getting: /lib/modules/4.14.199-1-MANJARO/build/arch/x86/include/asm/atomic.h:177:9: error: invalid output constraint '+q' in asm return xadd(&v->counter, i); ^ /lib/modules/4.14.199-1-MANJARO/build/arch/x86/include/asm/cmpxchg.h:234:25= : note: expanded from macro 'xadd' #define xadd(ptr, inc) __xadd((ptr), (inc), LOCK_PREFIX) ... >From What I understood, this is a known issue for tracing programs (like the one I'm developing) Unfortunately, CO-RE is not (yet) an option. I'm currently making the move from bcc to libbpf, and our application needs to support kernel 4.14, and work on all environments. > [...]