From: Yonghong Song Subject: [PATCH bpf-next 0/7] bpf: btf: fix struct/union/fwd types with kind_flag Date: Tue, 11 Dec 2018 16:46:30 -0800 Message-ID: <20181212004630.395424-1-yhs@fb.com> Mime-Version: 1.0 Content-Type: text/plain Cc: Alexei Starovoitov , Daniel Borkmann , , Martin KaFai Lau To: Return-path: Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:59480 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726233AbeLLAqg (ORCPT ); Tue, 11 Dec 2018 19:46:36 -0500 Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id wBC0ghpW030471 for ; Tue, 11 Dec 2018 16:46:34 -0800 Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2pappyr807-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 11 Dec 2018 16:46:34 -0800 Sender: netdev-owner@vger.kernel.org List-ID: Commit 69b693f0aefa ("bpf: btf: Introduce BPF Type Format (BTF)") introduced BTF, a debug info format for BTF. The original design has a couple of issues though. First, the bitfield size is only encoded in int type. If the struct member bitfield type is enum, pahole ([1]) or llvm is forced to replace enum with int type. As a result, the original type information gets lost. Second, the original BTF design does not envision the possibility of BTF=>header_file conversion ([2]), hence does not encode "struct" or "union" info for a forward type. Such information is necessary to convert BTF to a header file. This patch set fixed the issue by introducing kind_flag, using one bit in type->info. When kind_flag, the struct/union btf_member->offset will encode both bitfield_size and bit_offset, covering both int and enum base types. The kind_flag is also used to indicate whether the forward type is a union (when set) or a struct. Please see each individual patches for details. [1] https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=b18354f64cc215368c3bc0df4a7e5341c55c378c [2] https://lwn.net/SubscriberLink/773198/fe3074838f5c3f26/ Yonghong Song (7): bpf: btf: refactor btf_int_bits_seq_show() bpf: btf: fix struct/union/fwd types with kind_flag tools/bpf: sync btf.h header from kernel to tools tools/bpf: add test_btf unit tests for kind_flag tools/bpf: test kernel bpffs map pretty print with struct kind_flag tools: bpftool: refactor btf_dumper_int_bits() tools: bpftool: support pretty print with kind_flag set include/uapi/linux/btf.h | 15 +- kernel/bpf/btf.c | 266 +++++++++-- tools/bpf/bpftool/btf_dumper.c | 58 ++- tools/include/uapi/linux/btf.h | 15 +- tools/testing/selftests/bpf/test_btf.c | 593 ++++++++++++++++++++++++- 5 files changed, 881 insertions(+), 66 deletions(-) -- 2.17.1