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=-9.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 95A2FC3F2C6 for ; Sat, 29 Feb 2020 23:11:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6AEC024672 for ; Sat, 29 Feb 2020 23:11:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="QbKhVn71" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727580AbgB2XL2 (ORCPT ); Sat, 29 Feb 2020 18:11:28 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:28854 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727508AbgB2XL1 (ORCPT ); Sat, 29 Feb 2020 18:11:27 -0500 Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 01TN6BmG029990 for ; Sat, 29 Feb 2020 15:11:26 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=3qHvc/GTY8saMSHNu4RopweqTiFYNaC1ry7FeqNCADM=; b=QbKhVn71jExjXPN/EDwHq/hRGIDo4KCgbCSLN5g/4gkovCTJ8Gef+YsNk7y7RJ+Sgqwd Wp8PoRa0EQGsUwna/Gwku57lWAncCiH/KQWEEPAZ65x6zXd3CjtKCNGZWmvcl9R6ZWKo BsYk+EOJHfncUBio4VbhiR8rnNgryT4mJGw= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 2yfmvgt5qn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Sat, 29 Feb 2020 15:11:26 -0800 Received: from intmgw004.03.ash8.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::e) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Sat, 29 Feb 2020 15:11:25 -0800 Received: by devbig012.ftw2.facebook.com (Postfix, from userid 137359) id 157182EC2C66; Sat, 29 Feb 2020 15:11:19 -0800 (PST) Smtp-Origin-Hostprefix: devbig From: Andrii Nakryiko Smtp-Origin-Hostname: devbig012.ftw2.facebook.com To: , , , CC: , , Andrii Nakryiko Smtp-Origin-Cluster: ftw2c04 Subject: [PATCH bpf-next 2/4] libbpf: fix use of PT_REGS_PARM macros with vmlinux.h Date: Sat, 29 Feb 2020 15:11:10 -0800 Message-ID: <20200229231112.1240137-3-andriin@fb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200229231112.1240137-1-andriin@fb.com> References: <20200229231112.1240137-1-andriin@fb.com> X-FB-Internal: Safe MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-02-29_09:2020-02-28,2020-02-29 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 adultscore=0 clxscore=1015 phishscore=0 malwarescore=0 mlxlogscore=588 suspectscore=8 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002290180 X-FB-Internal: deliver Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add detection of vmlinux.h to bpf_tracing.h header for PT_REGS macro. Currently, BPF applications have to define __KERNEL__ symbol to use correct definition of struct pt_regs on x86 arch. This is due to different field names under internal kernel vs UAPI conditions. To make this more transparent for users, detect vmlinux.h by checking __VMLINUX_H__ symbol. Signed-off-by: Andrii Nakryiko --- tools/lib/bpf/bpf_tracing.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h index b0dafe8b4ebc..8376f22b0e36 100644 --- a/tools/lib/bpf/bpf_tracing.h +++ b/tools/lib/bpf/bpf_tracing.h @@ -49,7 +49,7 @@ #if defined(bpf_target_x86) -#ifdef __KERNEL__ +#if defined(__KERNEL__) || defined(__VMLINUX_H__) #define PT_REGS_PARM1(x) ((x)->di) #define PT_REGS_PARM2(x) ((x)->si) #define PT_REGS_PARM3(x) ((x)->dx) -- 2.17.1