From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 717563858C5E for ; Mon, 24 Jul 2023 15:57:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 717563858C5E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36OFOOfG022044; Mon, 24 Jul 2023 15:57:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=message-id : date : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2023-03-30; bh=kfHuZjFjIOt4gTEKyec0MwVMjgkhhSs0Eos5+v++ZmM=; b=nCpMF/YEvIK/HiLlj5VW6PJoL3erWFqPW+q0Geu4YNZjQ1HVEBBN8ByzPW4HFcP309zR 9OUXDv4LtNfyAOF25vRRmNieEaluU5S2yez5lbLb3FWVeYSjGK/bRGl5Dpw9MRTP9XpQ DWqnaBt3XM0wwMecQtTtL2I90wCe3i6f8kvmH0hmKzaU//GL2zXxWvCGwO0hCfWJ0y0L L5yAgSQwuXiM0r9Av4YimBMB6oI73aYv8uz1Dr5lDDhNVSQ9yTbsb9St0aR8Ogo8MZCq Ah9dfkWMNFbWtySEhxW76rEPrsKGu4/fL+PXI8ncqu/8A5Ht2uc9HGnabJZB52KdMcQ8 JQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s070au2k5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 15:57:01 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36OFBLFw028878; Mon, 24 Jul 2023 15:57:00 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2176.outbound.protection.outlook.com [104.47.57.176]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j3v3xn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 15:57:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FMjesdUcjFaWM5AgD/xiIOZYWUI0kNDgUYpNoVcgavYRrUk2rPW7sxdb4cN9pLj3aAZtSKVdDISZPr3dWIE2LC65KWbik9QUnH1Ni+nOqMTMJX9Eiq+TpQ+oQERfTz/lOLCxK7vLpC17NXeHWeQaa6pW4r7W2SGqZsRstDJf44bLOWHQ9oJxREdOYglyUqv2X9l02VoPfq2TMJ+EvLwD4MFFl/XRbOI0TnHikwR7o21eqB0BVvTJE+XN1ZS+51wa4rxhucO3QQhMPIWqLmqNe60s7/rSyuVFH52I4fXkhuRoqiqVT1FVRnzKB13PdEitVzmtPMI+2D9O0QA+oOqMYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kfHuZjFjIOt4gTEKyec0MwVMjgkhhSs0Eos5+v++ZmM=; b=e/3PK08S1d6VIsWBstmAffCh8cgwIoedUZ49RtjZWHfjC5NJP+0/nUWwI+IE8lwlx98m6sbPLux4jtMyWRDr6HTCA9sHmQ79Qpvh+/Xlx58dAd+RgtkDhEmKmfL7QNrjE2lUY2OyE3r44nuWOcMCV+PJOjAzThUF3/MV21sR7HaB6hiYq+yGFF668qnt9VXcoAtnOPGN0HIRn1B6u4nMp1lfEsS6DXVqvZ7v1tY7UmP6MRYJEjLTA31jJxpWo/7jJdNm8dxG8+sPb50R4R3IY2A94oZhTdOufXIHR2diwD4ttcF6lYkMDCTrNBsRBUxIakLyXBnFG+/5O1bifpE7EQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kfHuZjFjIOt4gTEKyec0MwVMjgkhhSs0Eos5+v++ZmM=; b=Cr5GcgSWaJazWsoHcZEV+V2RvjMwhnMa+yEW4YLI/sh5o+SMrnqQmyG3Um1N4sgFz7TeppEffzz/9MSca/+xWiWP9K6/jdWfRCg5kI/En3tawqmUYi3zELbRj0vq8TxQ8oLCYP6GgrEFFUmMWuJaCEjoH84X2ywIHjz9mid+xLk= Received: from MN2PR10MB3213.namprd10.prod.outlook.com (2603:10b6:208:131::33) by DM4PR10MB6013.namprd10.prod.outlook.com (2603:10b6:8:ae::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 15:56:58 +0000 Received: from MN2PR10MB3213.namprd10.prod.outlook.com ([fe80::827f:8665:2052:16c5]) by MN2PR10MB3213.namprd10.prod.outlook.com ([fe80::827f:8665:2052:16c5%4]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 15:56:58 +0000 Message-ID: Date: Mon, 24 Jul 2023 08:56:54 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH 0/9] Add btf_decl_tag C attribute To: gcc-patches@gcc.gnu.org Cc: jose.marchesi@oracle.com, yhs@meta.com References: <20230711215716.12980-1-david.faust@oracle.com> Content-Language: en-US From: David Faust In-Reply-To: <20230711215716.12980-1-david.faust@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SN7PR04CA0170.namprd04.prod.outlook.com (2603:10b6:806:125::25) To MN2PR10MB3213.namprd10.prod.outlook.com (2603:10b6:208:131::33) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR10MB3213:EE_|DM4PR10MB6013:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e4499ff-f8fd-41ca-0b08-08db8c5e9c3e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jMj0h8C+O1YEylWFxw+2JT6wYMkOSMtGYD5jHbaP9te7ogG2dX7jVS1Ga5Ob/TSkdFfSVQ1Yf/eDXW+JeVZa8t/Lo9XSB7WsO3o8DME+lHMrKmj3hX7l0ilhfm0DnO8mp1c8aUakwfuSq4D24/i7R4cQa/KzQiJoadXpy4Yy/79y0eSbuepD7FLRKmhvOHbqpl+mazOt72DNjx12p0dFf9iGD0QQ+uCOcSyL8/7gqXrY6+IR4OJY2ZOSb03MuEgevlIb0qGr0P3ayZHvThPnExUwUvfhsibGWF0zprT8VtMznKjvndnq51z9TXU9SiCd6WqWho+yZIXBHLIOxki9DcSNlNKhRRFZTOTXAIaU19gdnY8TZWG/2kC1HU5n2YIHnuKvJwY41HDiuKrwhTwhJVX5nNu4zoNNRK4yzQUKK0GtTSosV+hDBpqdsBVlDW1fX+V7ncyGCIpTUSiPDY2bEQg/ZYO4Lz5OF0uaiLb3imXAto5l1F3AZ9SFULHAwYbtr8abNvxahxA2IAVaUOcJ0maETJLtJ/1fpL/5sw5Xc3jxh9txTAhVcIRNU+16yegByKDdlvz/QXebLzcbgUZIhvirx5DssgTjey7pc4R5qlSLW/Wc7dUwLtQm+lmrTUTV80QTQwk6RJK7TbzBkH9Epg3PMB5ugnsezz6v+eWf8Q0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR10MB3213.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(396003)(39860400002)(366004)(136003)(376002)(451199021)(6512007)(966005)(38100700002)(83380400001)(6506007)(53546011)(2616005)(186003)(26005)(44832011)(5660300002)(8676002)(8936002)(2906002)(41300700001)(66556008)(36756003)(6486002)(6666004)(66476007)(66946007)(6916009)(4326008)(31696002)(478600001)(316002)(86362001)(31686004)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?d2xtakl2U01lUHNOWHNSaU5vSHRJNm56aTlsNjBhQ0J4aXA0ZzlrV2F6MlA2?= =?utf-8?B?d3h6ajkxNEJnUWhxZzBVYjVQd3ZtT3RtV3BsRjBKZ200RkZJWGwvY3BzQ3F3?= =?utf-8?B?bVJiam1xd1IzcGFnYW84TUtmcDJMdEdOS0tUaUVnWW5VWitGQVd2TmNvazVE?= =?utf-8?B?SGF2QjlZaUIzRSs2TUV0QVAvdy91RDFPVXRnV0h6Zy82MzRTWGg0UTZFMUJF?= =?utf-8?B?eUNzWEtmSWNSWU1CNHJySFFreC9paFBGVjVsT1E3b3EvTklMSkM1bCs4NE9Q?= =?utf-8?B?TndQL1EzQ3l3T211Tlp6NkNlSzU5QjYvMzdCMnN2d1lSeUFEa2RaTDQ3OHRn?= =?utf-8?B?d0t2b290ZWdGRGs2R1ZqbWNpSExGbDZWcXBoVXoxM25OYTB3YXNxTHZBNm1l?= =?utf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Hop-MessageData-0: Ef/+WFCyFqbmRLSsp9ruqh9s10cZimA49e+6KPSF/2nxbd0pzvdDmg4QJnRqLCZg0QwdoY4jAyomDny3Y5zy/aq9xFnyioiWUIDO4Fnmm3Z5+fTDqtNaLYE7Dp2Od1TrCRk6O6mMqxDrptu1AEj533GkJJpXmunt9VhWDA9BRrlpNHhkuSCcXuSE85Xnw8xm3wMPQA/mRCSQL5zNediNTFwftn8N44Ccy2WrViAj9KVxhWzziivsl5hl9ypmrgvmPc75dJpcf2gyje41dt4GEBCM+GnGLBWONv+jnV5RPoFUX1lgsKd1h8nN7P0cjAAacDcnuR8QuqqJMP4YJw2usUCjqqyMdxR/fmI4WgYCPp6mgXS4Izs88jomLHrfwh03qnn0oDu7IeTsFHXjJ2CUwOU8ScIrnA5a+QFAV8V4AbDa8y+NFWq1HYAP0OxhReSMYYuCbdHXXC4LJLSg7GGb0E+Rh46c2jX2YX2H/S6HRTZTjlyob/QyN8n05NmHaksqKIgFlXlgbtS3Wj2rjs0yC4lN2HNSqscAashprwPhKAOcw9s+gef9kWq57oi9CkpWIrWAYwsvZ63sywPE+IXG3Eai9b58jYQQjNxzmCteDbMh25nPgayPbBG/zcI/CY45zAk/TpyGlVZheCodhJU5jyuWPHgjEJNFGfTZdc2j4iJQDSK2pN0D3zCAMz/q7OCRi6nsVZfp8QcRhheaP8nyAJJBzvlRu7+Mth/UELqgKgS9V96Ufe9OtCaKyhfFgOHr4eufiyt+ogwrmL+hzNTSfA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e4499ff-f8fd-41ca-0b08-08db8c5e9c3e X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB3213.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 15:56:58.1208 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fXLt+BAlCcWiUCyKlMF8LovoPwX91hn8bORWZmP78LFqehFT2xUNt69zzwoqDDg3iuWwOKgYWMQ29zLA0RgAWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB6013 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_12,2023-07-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240142 X-Proofpoint-GUID: WqACX8JxkKgrdS6wvHTnERVxqrl9mLZT X-Proofpoint-ORIG-GUID: WqACX8JxkKgrdS6wvHTnERVxqrl9mLZT X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Gentle ping. https://gcc.gnu.org/pipermail/gcc-patches/2023-July/624156.html On 7/11/23 14:57, David Faust via Gcc-patches wrote: > Hello, > > This series adds support for a new attribute, "btf_decl_tag" in GCC. > The same attribute is already supported in clang, and is used by various > components of the BPF ecosystem. > > The purpose of the attribute is to allow to associate (to "tag") > declarations with arbitrary string annotations, which are emitted into > debugging information (DWARF and/or BTF) to facilitate post-compilation > analysis (the motivating use case being the Linux kernel BPF verifier). > Multiple tags are allowed on the same declaration. > > These strings are not interpreted by the compiler, and the attribute > itself has no effect on generated code, other than to produce additional > DWARF DIEs and/or BTF records conveying the annotations. > > This entails: > > - A new C-language-level attribute which allows to associate (to "tag") > particular declarations with arbitrary strings. > > - The conveyance of that information in DWARF in the form of a new DIE, > DW_TAG_GNU_annotation, with tag number (0x6000) and format matching > that of the DW_TAG_LLVM_annotation extension supported in LLVM for > the same purpose. These DIEs are already supported by BPF tooling, > such as pahole. > > - The conveyance of that information in BTF debug info in the form of > BTF_KIND_DECL_TAG records. These records are already supported by > LLVM and other tools in the eBPF ecosystem, such as the Linux kernel > eBPF verifier. > > > Background > ========== > > The purpose of these tags is to convey additional semantic information > to post-compilation consumers, in particular the Linux kernel eBPF > verifier. The verifier can make use of that information while analyzing > a BPF program to aid in determining whether to allow or reject the > program to be run. More background on these tags can be found in the > early support for them in the kernel here [1] and [2]. > > The "btf_decl_tag" attribute is half the story; the other half is a > sibling attribute "btf_type_tag" which serves the same purpose but > applies to types. Support for btf_type_tag will come in a separate > patch series, since it is impaced by GCC bug 110439 which needs to be > addressed first. > > I submitted an initial version of this work (including btf_type_tag) > last spring [3], however at the time there were some open questions > about the behavior of the btf_type_tag attribute and issues with its > implementation. Since then we have clarified these details and agreed > to solutions with the BPF community and LLVM BPF folks. > > The main motivation for emitting the tags in DWARF is that the Linux > kernel generates its BTF information via pahole, using DWARF as a source: > > +--------+ BTF BTF +----------+ > | pahole |-------> vmlinux.btf ------->| verifier | > +--------+ +----------+ > ^ ^ > | | > DWARF | BTF | > | | > vmlinux +-------------+ > module1.ko | BPF program | > module2.ko +-------------+ > ... > > This is because: > > a) pahole adds additional kernel-specific information into the > produced BTF based on additional analysis of kernel objects. > > b) Unlike GCC, LLVM will only generate BTF for BPF programs. > > b) GCC can generate BTF for whatever target with -gbtf, but there is no > support for linking/deduplicating BTF in the linker. > > In the scenario above, the verifier needs access to the pointer tags of > both the kernel types/declarations (conveyed in the DWARF and translated > to BTF by pahole) and those of the BPF program (available directly in BTF). > > > DWARF Representation > ==================== > > As noted above, btf_decl_tag is represented in DWARF via a new DIE > DW_TAG_GNU_annotation, with identical format to the LLVM DWARF > extension DW_TAG_LLVM_annotation serving the same purpose. The DIE has > the following format: > > DW_TAG_GNU_annotation (0x6000) > DW_AT_name: "btf_decl_tag" > DW_AT_const_value: > > These DIEs are placed in the DWARF tree as children of the DIE for the > appropriate declaration, and one such DIE is created for each occurrence > of the btf_decl_tag attribute on a declaration. > > For example: > > const int * c __attribute__((btf_decl_tag ("__c"), btf_decl_tag ("devicemem"))); > > This declaration produces the following DWARF: > > <1><1e>: Abbrev Number: 2 (DW_TAG_variable) > <1f> DW_AT_name : c > <24> DW_AT_type : <0x49> > ... > <2><36>: Abbrev Number: 3 (User TAG value: 0x6000) > <37> DW_AT_name : (indirect string, offset: 0x4c): btf_decl_tag > <3b> DW_AT_const_value : (indirect string, offset: 0): devicemem > <2><3f>: Abbrev Number: 4 (User TAG value: 0x6000) > <40> DW_AT_name : (indirect string, offset: 0x4c): btf_decl_tag > <44> DW_AT_const_value : __c > <2><48>: Abbrev Number: 0 > <1><49>: Abbrev Number: 5 (DW_TAG_pointer_type) > ... > > The DIEs for btf_decl_tag are placed as children of the DIE for > variable "c". > > BTF Representation > ================== > > In BTF, BTF_KIND_DECL_TAG records convey the annotations. These records refer > to the annotated object by BTF type ID, as well as a component index which is > used for btf_decl_tags placed on struct/union members or function arguments. > > For example, the BTF for the above declaration is: > > [1] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED > [2] CONST '(anon)' type_id=1 > [3] PTR '(anon)' type_id=2 > [4] DECL_TAG '__c' type_id=6 component_idx=-1 > [5] DECL_TAG 'devicemem' type_id=6 component_idx=-1 > [6] VAR 'c' type_id=3, linkage=global > ... > > The BTF format is documented here [4]. > > > References > ========== > > [1] https://lore.kernel.org/bpf/20210914223004.244411-1-yhs@fb.com/ > [2] https://lore.kernel.org/bpf/20211011040608.3031468-1-yhs@fb.com/ > [3] https://gcc.gnu.org/pipermail/gcc-patches/2022-May/593936.html > [4] https://www.kernel.org/doc/Documentation/bpf/btf.rst > > > David Faust (9): > c-family: add btf_decl_tag attribute > include: add BTF decl tag defines > dwarf: create annotation DIEs for decl tags > dwarf: expose get_die_parent > ctf: add support to pass through BTF tags > dwarf2ctf: convert annotation DIEs to CTF types > btf: create and output BTF_KIND_DECL_TAG types > testsuite: add tests for BTF decl tags > doc: document btf_decl_tag attribute > > gcc/btfout.cc | 81 ++++++++++++++++++- > gcc/c-family/c-attribs.cc | 23 ++++++ > gcc/ctf-int.h | 28 +++++++ > gcc/ctfc.cc | 10 ++- > gcc/ctfc.h | 17 +++- > gcc/doc/extend.texi | 47 +++++++++++ > gcc/dwarf2ctf.cc | 73 ++++++++++++++++- > gcc/dwarf2out.cc | 37 ++++++++- > gcc/dwarf2out.h | 1 + > .../gcc.dg/debug/btf/btf-decltag-func.c | 21 +++++ > .../gcc.dg/debug/btf/btf-decltag-sou.c | 33 ++++++++ > .../gcc.dg/debug/btf/btf-decltag-var.c | 19 +++++ > .../gcc.dg/debug/dwarf2/annotation-decl-1.c | 9 +++ > .../gcc.dg/debug/dwarf2/annotation-decl-2.c | 18 +++++ > .../gcc.dg/debug/dwarf2/annotation-decl-3.c | 17 ++++ > include/btf.h | 14 +++- > include/dwarf2.def | 4 + > 17 files changed, 437 insertions(+), 15 deletions(-) > create mode 100644 gcc/ctf-int.h > create mode 100644 gcc/testsuite/gcc.dg/debug/btf/btf-decltag-func.c > create mode 100644 gcc/testsuite/gcc.dg/debug/btf/btf-decltag-sou.c > create mode 100644 gcc/testsuite/gcc.dg/debug/btf/btf-decltag-var.c > create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/annotation-decl-1.c > create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/annotation-decl-2.c > create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/annotation-decl-3.c >