Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2312296rwb; Fri, 2 Dec 2022 08:09:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf5ABaj/3ny1uOqrDbuS9SqH/DO9wwwAgcbwq6Mj0mrTFHaU8XcZFJqN9USyZ655PHidE/qr X-Received: by 2002:a17:906:aec1:b0:7c0:a04b:6795 with SMTP id me1-20020a170906aec100b007c0a04b6795mr10918576ejb.16.1669997344436; Fri, 02 Dec 2022 08:09:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669997344; cv=none; d=google.com; s=arc-20160816; b=E9Vz2z4ThoIVMpjzsKiIs3o3/ZGD8rCA8Uyh7hISeMIpFgin2oYSE4Wiai7zcImCfa IJ3Z8zivgjlEasztte0qs59Y6iuYrBLyG3qv2TXje1cqVQj27GgX0jz/OP7KGCfu+b5o E89KsHqb4bamiRj1NWJ4aEJ3wUSxnzXpAsbeNcdphwOwHxTAh6dVLX9iKmP76Qk0VwMT A7S0S7Tef5zNiSSjqzYG7s+nl8HnlwvwTw518lMsQSXVeAiuW0tupOT0XcaBOc4XM6Ek xhCFaJpzGJzgifOk21wat5+bWn0Ho3//z8tWIlnrNRcCC9UXkWTgH0lzEZDBJtdqaU5E 0F/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=hoR7uvi0XdiIPnCPebp3Oixalbt12i38d+rsZe6QRv4=; b=F3zaMKlZA2W/ag2YN71zeGXtoVUKnETN89IC/XZ60PkHo0kKfm93THsauGaBCPuVdo ETLMd31jqXUv+NUwrM0PBycT/3HCOq80ma1/OFYL7l4srnUX1f/iZcy93O26613X/VBV 3rTHn6lojY+mVhbDw3QI8wm/+rxbUsDfN1j16a42TZ+dGnuNHjL3JBsrkYuWarTYRM6Y N5sZ9AxM5sw6GRepHu5DTcZixGI/Yki5AN6Br9AUKgUAGJ+QOjbTAWVxNiZUsWAJuBcG lRbWDaBUWlIlWh+XZjn5Vaad7MQIIaYfazwMK+Qd67aIVgbow0NVDg4iQPn+ndec95Um jx8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.ch header.s=s31663417 header.b=FwbQ27KZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.ch Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m9-20020a056402430900b0046ab1d20ca2si6513056edc.439.2022.12.02.08.08.43; Fri, 02 Dec 2022 08:09:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.ch header.s=s31663417 header.b=FwbQ27KZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.ch Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233758AbiLBPjJ (ORCPT + 82 others); Fri, 2 Dec 2022 10:39:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233765AbiLBPjH (ORCPT ); Fri, 2 Dec 2022 10:39:07 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A609BE6B3; Fri, 2 Dec 2022 07:39:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.ch; s=s31663417; t=1669995523; bh=ldG0fzm6Qem0Pfa6GXvE+somhuAXUV/Lz5s/EE/u7EU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=FwbQ27KZcoVQ67aMcSqdAPD+8ALJiPA+vNIE2krhZB0EuucO6VfV7+wVGMkq0Oq2M Y9esfsDr91p3srfVAQ0/3eYQ5q98qsfnbrWJ0HsGPKvnGruvcLFq1ZEqN6nlgv97OM 2pDTzcDdpD5eLvbKl9Odlt5ccqVW7znk4ZLSyfFR4KNTh9VI85kNZMnBmnQLbCVFWh qp+A65OmvVhRktZ9mEXvsF0ug3naIJ8iJ7jxHs3Xl5Jaq96joqyLuvAT9eC6dKQQ5s +MbIvrYuU9rK0jNpsGwVgmFLeirudl6IzxesHH6a8dlnvej2RoYrNpE49pu9hOLVSP s2hvlEGy/d4SQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from x1c6.fritz.box ([185.76.96.75]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mqs4f-1ofYxe2J61-00muzS; Fri, 02 Dec 2022 16:38:43 +0100 From: Timo Hunziker To: bpf@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@google.com, linux-kernel@vger.kernel.org, Timo Hunziker Subject: [PATCH bpf-next] libbpf: parse usdt args without offset on x86 (e.g. 8@(%rsp)) Date: Fri, 2 Dec 2022 16:38:16 +0100 Message-Id: <20221202153816.1180450-1-timo.hunziker@gmx.ch> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:iHEIR/r7nBpuEQBqpUIq+/Y5by8Fmo14yoHvLmB2k7rtJJNeMIx glfIQ9h8LYddQqnoX/WTe9YZ6H+lQxxKrpgBoEa/GfneQK2Nw+bgm8ZUIWUwQzY/YKfgDe+ 2xD2Gd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obFfl2j73qkfQcEjplEhxfrz54mA1 WbPgnJX98ljEa233twKCCxforig= X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Parse USDT arguments like "8@(%rsp)" on x86. These are emmited by systemtap. The syntax is a mixture between the "memory dereference case" and the "register read case" as the offset is zero but the register is wrapped in parentheses. We treat them the same as the the "register read case". I've tested that this fixes the "unrecognized arg #N spec: 8@(%rsp).." error I've run into when attaching to a probe with such an argument. Attaching and reading the arguments works. Something similar might be needed for the other supported architectures. ref: https://github.com/libbpf/libbpf/issues/559 Signed-off-by: Timo Hunziker =2D-- tools/lib/bpf/usdt.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/lib/bpf/usdt.c b/tools/lib/bpf/usdt.c index b8daae265f99..5e7ec7ad8ad7 100644 =2D-- a/tools/lib/bpf/usdt.c +++ b/tools/lib/bpf/usdt.c @@ -1233,6 +1233,14 @@ static int parse_usdt_arg(const char *arg_str, int = arg_num, struct usdt_arg_spec if (reg_off < 0) return reg_off; arg->reg_off =3D reg_off; + } else if (sscanf(arg_str, " %d @ ( %%%15[^)] ) %n", &arg_sz, reg_name, = &len) =3D=3D 2) { + /* Register read case with parentheses, e.g., 8@(%rsp) */ + arg->arg_type =3D USDT_ARG_REG; + arg->val_off =3D 0; + reg_off =3D calc_pt_regs_off(reg_name); + if (reg_off < 0) + return reg_off; + arg->reg_off =3D reg_off; } else if (sscanf(arg_str, " %d @ %%%15s %n", &arg_sz, reg_name, &len) = =3D=3D 2) { /* Register read case, e.g., -4@%eax */ arg->arg_type =3D USDT_ARG_REG; =2D- 2.36.2