We had this heuristic to try raw BTF if the file starts with
/sys/kernel/btf/, but if we are in that directory already then we
continue trying it as an ELF file, fix it:
Before:
$ cd /sys/kernel/btf/
$ pahole -C list_head vmlinux
pahole: vmlinux: No such device
$
After:
$ pahole -C list_head vmlinux
struct list_head {
struct list_head * next; /* 0 8 */
struct list_head * prev; /* 8 8 */
/* size: 16, cachelines: 1, members: 2 */
/* last cacheline: 16 bytes */
};
$
Works as well for modules:
$ pahole -C wmi_device vmlinux
pahole: type 'wmi_device' not found
$ pahole -C wmi_device --btf_base vmlinux wmi
struct wmi_device {
struct device dev; /* 0 752 */
/* XXX last struct has 7 bytes of padding */
/* --- cacheline 11 boundary (704 bytes) was 48 bytes ago --- */
bool setable; /* 752 1 */
/* size: 760, cachelines: 12, members: 2 */
/* padding: 7 */
/* paddings: 1, sum paddings: 7 */
/* last cacheline: 56 bytes */
};
$
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
If a .ko file has both DWARF and BTF, we were needing to use '-F btf' to
make the BTF info to be used, to make command lines more concise imply
'-F btf' if --btf_base is used.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Previously we used this just for vmlinux, now that we have kernel
modules, use it for those as well.
Now this works:
$ pahole wmi_block
pahole: type 'wmi_block' not found
$ pahole --btf_base /sys/kernel/btf/vmlinux /sys/kernel/btf/wmi -C wmi_block
struct wmi_block {
struct wmi_device dev; /* 0 760 */
/* XXX last struct has 7 bytes of padding */
/* --- cacheline 11 boundary (704 bytes) was 56 bytes ago --- */
struct list_head list; /* 760 16 */
/* --- cacheline 12 boundary (768 bytes) was 8 bytes ago --- */
struct guid_block gblock; /* 776 20 */
/* XXX 4 bytes hole, try to pack */
struct miscdevice char_dev; /* 800 80 */
/* XXX last struct has 6 bytes of padding */
/* --- cacheline 13 boundary (832 bytes) was 48 bytes ago --- */
struct mutex char_mutex; /* 880 32 */
/* --- cacheline 14 boundary (896 bytes) was 16 bytes ago --- */
struct acpi_device * acpi_device; /* 912 8 */
wmi_notify_handler handler; /* 920 8 */
void * handler_data; /* 928 8 */
u64 req_buf_size; /* 936 8 */
bool read_takes_no_args; /* 944 1 */
/* size: 952, cachelines: 15, members: 10 */
/* sum members: 941, holes: 1, sum holes: 4 */
/* padding: 7 */
/* paddings: 2, sum paddings: 13 */
/* last cacheline: 56 bytes */
};
$
I.e. it assumes /sys/kernel/btf/wmi is raw BTF, and finds in it a type
'struct wmi_block' that is not present in /sys/kernel/btf/vmlinux, i.e.
its a module specific type, that uses types that are in
/sys/kernel/btf/vmlinux, such as 'struct list_head'.
For reference, here are the sizes of those files:
$ ls -la /sys/kernel/btf/vmlinux /sys/kernel/btf/wmi
-r--r--r--. 1 root root 4241472 Nov 17 20:14 /sys/kernel/btf/vmlinux
-r--r--r--. 1 root root 2866 Nov 17 20:14 /sys/kernel/btf/wmi
$
It is also possible to use the .ko file:
$ uname -r
5.10.0-rc3.bpfsign+
$ pahole wmi_notify_handler
pahole: type 'wmi_notify_handler' not found
$ pahole -F btf --btf_base /sys/kernel/btf/vmlinux /lib/modules/5.10.0-rc3.bpfsign+/kernel/drivers/platform/x86/wmi.ko -C wmi_notify_handler
typedef void (*wmi_notify_handler)(u32, void *);
$ pahole -F btf --btf_base /sys/kernel/btf/vmlinux /lib/modules/5.10.0-rc3.bpfsign+/kernel/drivers/platform/x86/wmi.ko -C wmi_device
struct wmi_device {
struct device dev; /* 0 752 */
/* XXX last struct has 7 bytes of padding */
/* --- cacheline 11 boundary (704 bytes) was 48 bytes ago --- */
bool setable; /* 752 1 */
/* size: 760, cachelines: 12, members: 2 */
/* padding: 7 */
/* paddings: 1, sum paddings: 7 */
/* last cacheline: 56 bytes */
};
$
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Using more suitable fallback message for the case when the ftrace filter
can't be used because of missing symbols.
Committer notes:
Before:
vmlinux not detected, falling back to dwarf data
Now:
ftrace symbols not detected, falling back to DWARF data
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Requested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andriin@fb.com>
Cc: Hao Luo <haoluo@google.com>
Cc: Yonghong Song <yhs@fb.com>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
With introduction of collect_symbols function, we moved the percpu
variables code before btf_elf__verbose/btf_elf__force setup, so they
don't have any effect in that code anymore.
Also btf_elf__verbose is used in code that prepares ftrace filter for
functions generations, also called within collect_symbols function.
Moving btf_elf__verbose/btf_elf__force setup early in the cu__encode_btf
function, so we can get verbose messages and see the effect of the force
option.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andriin@fb.com>
Cc: Hao Luo <haoluo@google.com>
Cc: Yonghong Song <yhs@fb.com>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Current conditions for picking up function records break BTF data on
some gcc versions.
Some function records can appear with no arguments but with declaration
tag set, so moving the 'fn->declaration' in front of other checks.
Then checking if argument names are present and finally checking ftrace
filter if it's present. If ftrace filter is not available, using the
external tag to filter out non external functions.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andriin@fb.com>
Cc: Hao Luo <haoluo@google.com>
Cc: Yonghong Song <yhs@fb.com>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Currently we skip functions under .init* sections, Removing the .init*
section check, BTF now contains also functions from .init* sections.
Andrii's explanation from email:
> ... I think we should just drop the __init check and
> include all the __init functions into BTF. There could be cases where
> we'd need to attach BPF programs to __init functions (e.g., bpf_lsm
> security cases), so having BTFs for those FUNCs are necessary as well.
> Ftrace currently disallows that, but it's only because no user-space
> application has a way to attach probes early enough. This might change
> in the future, so there is no need to invent special mechanisms now
> for bpf_iter function preservation. Let's just include all __init
> functions in BTF.
It's over ~2000 functions on my .config:
$ bpftool btf dump file ./vmlinux | grep 'FUNC ' | wc -l
41505
$ bpftool btf dump file /sys/kernel/btf/vmlinux | grep 'FUNC ' | wc -l
39256
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andriin@fb.com>
Cc: Hao Luo <haoluo@google.com>
Cc: Yonghong Song <yhs@fb.com>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Add support for generating split BTF, in which there is a designated base
BTF, containing a base set of types, and a split BTF, which extends main BTF
with extra types, that can reference types and strings from the main BTF.
This is going to be used to generate compact BTFs for kernel modules, with
vmlinux BTF being a main BTF, which all kernel modules are based off of.
These changes rely on patch set [0] to be present in libbpf submodule.
[0] https://patchwork.kernel.org/project/netdevbpf/list/?series=377859&state=*
Committer notes:
Fixed up wrt ARGP_numeric_version and added a man page entry.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Cc: kernel-team@fb.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Rename a few local variables to reflects the purpose a bit better. Also
separate writing out BTF raw data and objcopy invocation into two
separate steps and improve error reporting for each.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Cc: kernel-team@fb.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Take into account type ID offset, accumulated from previous CUs, when
calculating a new type ID for the generated array index type.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Cc: kernel-team@fb.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
In Makefiles we want to do purely numeric comparisions, such as in the
Linux kernel Makefiles and scripts, that have things like this at the
moment:
$ grep PAHOLE */*.sh
scripts/link-vmlinux.sh: if ! [ -x "$(command -v ${PAHOLE})" ]; then
scripts/link-vmlinux.sh: echo >&2 "BTF: ${1}: pahole (${PAHOLE}) is not available"
scripts/link-vmlinux.sh: pahole_ver=$(${PAHOLE} --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/')
scripts/link-vmlinux.sh: echo >&2 "BTF: ${1}: pahole version $(${PAHOLE} --version) is too old, need at least v1.16"
scripts/link-vmlinux.sh: LLVM_OBJCOPY=${OBJCOPY} ${PAHOLE} -J ${1}
$
So just provide:
$ pahole --numeric_version
118
$
While keeping the --version output for older Makefiles and scripts.
Cc: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Nothing changes now, this continues to work just the same:
$ pahole --version
v1.18
$ pfunct --version
v1.18
$
This just paves the way for us to have a '--numeric-version' that will
do away with the dot and the leading 'v' and that can be used in
Makefiles to check if the required minimum version is available, to
avoid what we have now in the Linux kernel:
config PAHOLE_HAS_SPLIT_BTF
def_bool $(success, test `$(PAHOLE) --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'` -ge "119")
With the next cset we'll be able to do just:
test `$(PAHOLE) --numeric-version` -ge "119"
Cc: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Before we would have:
$ gcc x.c -Wall -ggdb3
$ strip -s a.out
$ pahole ./a.out
$
I.e. no types, no output.
Then when we started trying out the sole arg as a type to lookup either
on a vmlinux found via its build id in /sys/kernel/notes or
/sys/kernel/btf/vmlinux we instead showed this for a binary without type
info:
$ pahole ./a.out
pahole: type './a.out' not found
$
Now we show:
$ pahole a.out
pahole: file 'a.out' has no supported type information.
$
Reported-by: Jan Engelhardt <jengelh@inai.de>
Bugtracker: https://github.com/acmel/dwarves/issues/14
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
We need to generate just single BTF instance for the function, while
DWARF data contains multiple instances of DW_TAG_subprogram tag.
Unfortunately we can no longer rely on DW_AT_declaration tag
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97060)
Instead we apply following checks:
- argument names are defined for the function
- there's symbol and address defined for the function
- function is generated only once
Also because we want to follow kernel's ftrace traceable functions, this
patchset is adding extra check that the function is one of the ftrace's
functions.
All ftrace functions addresses are stored in vmlinux binary within
symbols:
__start_mcount_loc
__stop_mcount_loc
During object preparation code we read those addresses, sort them and
use them as filter for all detected dwarf functions.
We also filter out functions within .init section, ftrace is doing that
in runtime. At the same time we keep functions from
.init.bpf.preserve_type, because they are needed in BTF.
I can still see several differences to ftrace functions in
/sys/kernel/debug/tracing/available_filter_functions file:
- available_filter_functions includes modules
- available_filter_functions includes functions like:
__acpi_match_device.part.0.constprop.0
acpi_ns_check_sorted_list.constprop.0
acpi_os_unmap_generic_address.part.0
acpiphp_check_bridge.part.0
which are not part of dwarf data
- BTF includes multiple functions like:
__clk_register_clkdev
clk_register_clkdev
which share same code so they appear just as single function
in available_filter_functions, but dwarf keeps track of both
of them
- BTF includes iterator functions, which do not make it to
available_filter_functions
With this change I'm getting 38384 BTF functions, which when added above
functions to consideration gives same amount of functions in
available_filter_functions.
The patch still keeps the original function filter condition (that uses
current fn->declaration check) in case the object does not contain
*_mcount_loc symbol -> object is not vmlinux.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andriin@fb.com>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: Hao Luo <haoluo@google.com>
Cc: Mark Wieelard <mjw@redhat.com>
Cc: Yonghong Song <yhs@fb.com>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Move find_all_percpu_vars() under generic collect_symbols() that walks
over symbols and calls collect_percpu_var().
We will add another collect function that needs to go through all the
symbols, so it's better we go through them just once.
There's no functional change intended.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Hao Luo <haoluo@google.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: Mark Wieelard <mjw@redhat.com>
Cc: Yonghong Song <yhs@fb.com>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Commit 2e719cca66 ("btf_encoder: revamp how per-CPU variables are
encoded") adds percpu_var_exists() to filter out the symbols that are
not percpu var. However, the check comes after checking the var's type.
There can be symbols that are of zero type. If we hit that, btf_encoder
will not work without '--btf_encode_force'. So we should check
percpu_var_exists before checking var's type.
Tested:
haoluo@haoluo:~/kernel/tip$ gcc --version
gcc (GCC) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Before:
haoluo@haoluo:~/kernel/tip$ make clean -s
haoluo@haoluo:~/kernel/tip$ make -j 32 -s
LINK resolve_btfids
error: found variable in CU 'kernel/bpf/btf.c' that has void type
Encountered error while encoding BTF.
FAILED: load BTF from vmlinux: Unknown error -2make: *** [Makefile:1164: vmlinux] Error 255
After:
haoluo@haoluo:~/kernel/tip$ make clean -s
haoluo@haoluo:~/kernel/tip$ make -j 32 -s
LINK resolve_btfids
haoluo@haoluo:~/kernel/tip$
Fixes: 2e719cc ("btf_encoder: revamp how per-CPU variables are encoded")
Reported-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Reported-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Hao Luo <haoluo@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Cc: dwarves@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Now that libbpf is used to implement deduplicated strings container, all
of the binaries will need linux/btf.h header to compile properly. libbpf
is distributed with its own copies of Linux UAPI headers, so use them
during compilation.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Cc: dwarves@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
It's legal for ELF symbol to have size 0, if it's size is unknown or
unspecified. Instead of erroring out, just ignore such symbols, as they can't
be a valid per-CPU variable anyways.
Reported-by: Érico Rolim <erico.erc@gmail.com>
Reported-by: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Tested-by: Jiri Slaby <jirislaby@kernel.org>
Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1177921
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This was detected with:
In file included from /home/acme/git/pahole/strings.h:9,
from /usr/include/string.h:432,
from /home/acme/git/pahole/lib/bpf/src/libbpf_common.h:12,
from /home/acme/git/pahole/lib/bpf/src/libbpf.h:20,
from /home/acme/git/pahole/lib/bpf/src/ringbuf.c:20:
/home/acme/git/pahole/lib/bpf/src/btf.h:33:11: error: expected ‘;’ before ‘void’
33 | LIBBPF_API void btf__free(struct btf *btf);
| ^~~~~
| ;
libbpf_common.h has:
#include <string.h>
#ifndef LIBBPF_API
#define LIBBPF_API __attribute__((visibility("default")))
#endif
So before defining LIBBPF_API it includes libc's string.h that in turn
includes pahole's strings.h and now it includes:
#include "lib/bpf/src/btf.h"
That will need the LIBBPF_API, b00m.
So lets just rename pahole's strings.h to pahole_strings.h to avoid this
pitfall.
This patch was moved to before this problem takes place so that we keep
everything bisectable.
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
When doing BTF encoding/deduping, DWARF CUs are never used after BTF encoding
is done, so there is no point in wasting memory and keeping them in memory. So
discard them immediately.
Committer testing:
$ pahole -J vmlinux
$ ./btfdiff vmlinux
$
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Cc: kernel-team@fb.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Fix the logic of determining if __ARRAY_SIZE_TYPE__ needs to be emitted.
Previously, such type could be emitted unnecessarily due to some
particular CU not having an int type in it. That would happen even if
there was no array type in that CU. Fix it by keeping track of 'int'
type across CUs and only emitting __ARRAY_SIZE_TYPE__ if a given CU has
array type, but we still haven't found 'int' type.
Testing against vmlinux shows that now there are no __ARRAY_SIZE_TYPE__
integers emitted.
Committer testing:
$ pahole -J vmlinux
$ ./btfdiff vmlinux
$
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Cc: kernel-team@fb.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Switch BTF loading to completely use libbpf's own struct btf and related
APIs.
BTF encoding is still happening with pahole's own code, so these two
code paths are not sharing anything now. String fetching is happening
based on whether btfe->strings were set to non-NULL pointer by
btf_encoder.
Committer testing:
$ cp ~/git/build/bpf-next-v5.9.0-rc8+/vmlinux .
$ readelf -SW vmlinux | grep BTF
[24] .BTF PROGBITS ffffffff82494ac0 1694ac0 340207 00 A 0 0 1
[25] .BTF_ids PROGBITS ffffffff827d4cc8 19d4cc8 0000a4 00 A 0 0 1
$ ./btfdiff vmlinux
$
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Cc: kernel-team@fb.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Maintain a pointer to debug_fmt_ops corresponding to currently used debug info
format loader (DWARF, BTF, or CTF), to allow various parts of libdwarves to do
things like resolve string offset to actual string pointer in
a format-agnostic format. This allows to, say, load DWARF debug info, and use
it for BTF generation, without either of them making assumptions about how
strings are actually stored internally.
This is going to be used in the next patch to allow BTF loader and encoder to
use a very different way of storing strings (not a global shared gobuffer).
Committer notes:
Since it is available in multiple object files, add a dwarves__ prefix
namespace and add an extern for it in dwarves.h.
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Don't silently swallow BTF encoding errors and continue onto next CU. If
any of CU fails to properly encode BTF, exit with an error message.
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
To show just packed structs.
For instance, here are the top packed structures in the Linux kernel,
using BTF data:
$ pahole --packed --sizes | sort -k2 -nr | head
e820_table 64004 0
boot_params 4096 0
btrfs_super_block 3531 0
efi_variable 2084 0
ntb_info_regs 800 0
tboot 568 0
_legacy_mbr 512 0
disklabel 512 0
btrfs_root_item 439 0
saved_context 317 0
$
If you then look at:
$ pahole e820_table
struct e820_table {
__u32 nr_entries; /* 0 4 */
struct e820_entry entries[3200]; /* 4 64000 */
/* size: 64004, cachelines: 1001, members: 2 */
/* last cacheline: 4 bytes */
} __attribute__((__packed__));
$
In arch/x86/include/asm/e820/types.h we have:
/*
* The whole array of E820 entries:
*/
struct e820_table {
__u32 nr_entries;
struct e820_entry entries[E820_MAX_ENTRIES];
};
I.e. no explicit __packed__ attributes, but if we expand this a bit:
$ pahole -E e820_table
struct e820_table {
/* typedef __u32 */ unsigned int nr_entries; /* 0 4 */
struct e820_entry {
/* typedef u64 -> __u64 */ long long unsigned int addr; /* 4 8 */
/* typedef u64 -> __u64 */ long long unsigned int size; /* 12 8 */
enum e820_type type; /* 20 4 */
} __attribute__((__packed__)) entries[3200]; /* 4 64000 */
/* size: 64004, cachelines: 1001, members: 2 */
/* last cacheline: 4 bytes */
} __attribute__((__packed__));
$
We see that is that entries member that is packed, because:
$ pahole e820_entry
struct e820_entry {
u64 addr; /* 0 8 */
u64 size; /* 8 8 */
enum e820_type type; /* 16 4 */
/* size: 20, cachelines: 1, members: 3 */
/* last cacheline: 20 bytes */
} __attribute__((__packed__));
$
In arch/x86/include/asm/e820/types.h we have:
/*
* A single E820 map entry, describing a memory range of [addr...addr+size-1],
* of 'type' memory type:
*
* (We pack it because there can be thousands of them on large systems.)
*/
struct e820_entry {
u64 addr;
u64 size;
enum e820_type type;
} __attribute__((packed));
So yeah, it is there, BTF doesn't explicitly states it is packed (as
DWARF does) and pahole was able to infer that correctly.
Tested-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>