Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BPF-CHECKPOINT-COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e06e6b8001233241eb5b2e2791162f0585f50f4b
d8a9a4b11a137909e306e50346148fc5c3b63f9d
2 changes: 1 addition & 1 deletion CHECKPOINT-COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ca0f39a369c5f927c3d004e63a5a778b08a9df94
a0c584fc18056709c8e047a82a6045d6c209f4ce
4 changes: 3 additions & 1 deletion include/uapi/linux/bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -4645,7 +4645,9 @@ union bpf_attr {
* Description
* Discard reserved ring buffer sample, pointed to by *data*.
* If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification
* of new data availability is sent.
* of new data availability is sent. Discarded records remain in
* the ring buffer until consumed by user space, so a later submit
* using adaptive wakeup might not wake up the consumer.
* If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification
* of new data availability is sent unconditionally.
* If **0** is specified in *flags*, an adaptive notification
Expand Down
12 changes: 12 additions & 0 deletions include/uapi/linux/btf.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
#define BTF_MAGIC 0xeB9F
#define BTF_VERSION 1

/*
* BTF layout section consists of a struct btf_layout for each known
* kind at BTF encoding time.
*/
struct btf_layout {
__u8 info_sz; /* size of singular element after btf_type */
__u8 elem_sz; /* size of each of btf_vlen(t) elements */
__u16 flags; /* currently unused */
};

struct btf_header {
__u16 magic;
__u8 version;
Expand All @@ -19,6 +29,8 @@ struct btf_header {
__u32 type_len; /* length of type section */
__u32 str_off; /* offset of string section */
__u32 str_len; /* length of string section */
__u32 layout_off; /* offset of layout section */
__u32 layout_len; /* length of layout section */
};

/* Max # of type identifier */
Expand Down
2 changes: 1 addition & 1 deletion include/uapi/linux/perf_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,7 @@ union perf_mem_data_src {
#define PERF_MEM_LVLNUM_L4 0x0004 /* L4 */
#define PERF_MEM_LVLNUM_L2_MHB 0x0005 /* L2 Miss Handling Buffer */
#define PERF_MEM_LVLNUM_MSC 0x0006 /* Memory-side Cache */
#define PERF_MEM_LVLNUM_L0 0x0007 /* L0 */
#define PERF_MEM_LVLNUM_L0 0x0007 /* L0 */
#define PERF_MEM_LVLNUM_UNC 0x0008 /* Uncached */
#define PERF_MEM_LVLNUM_CXL 0x0009 /* CXL */
#define PERF_MEM_LVLNUM_IO 0x000a /* I/O */
Expand Down
30 changes: 26 additions & 4 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ RM ?= rm -f

FEATURE_USER = .bpftool

# Skip optional dependencies: LLVM (JIT disasm), libbfd (fallback
# disasm), libcrypto (program signing).
SKIP_LLVM ?=
SKIP_LIBBFD ?=
SKIP_CRYPTO ?=
ifneq ($(SKIP_CRYPTO),1)
CRYPTO_LIBS := -lcrypto
endif

FEATURE_TESTS := clang-bpf-co-re
FEATURE_TESTS += llvm
FEATURE_TESTS += libcap
Expand Down Expand Up @@ -124,8 +133,8 @@ ifeq ($(check_feat),1)
include Makefile.feature
endif

LIBS = $(LIBBPF) -lelf -lcrypto -lz
LIBS_BOOTSTRAP = $(LIBBPF_BOOTSTRAP) -lelf -lcrypto -lz
LIBS = $(LIBBPF) -lelf $(CRYPTO_LIBS) -lz
LIBS_BOOTSTRAP = $(LIBBPF_BOOTSTRAP) -lelf $(CRYPTO_LIBS) -lz

ifeq ($(feature-libelf-zstd),1)
LIBS += -lzstd
Expand All @@ -144,7 +153,12 @@ all: $(OUTPUT)bpftool
SRCS := $(wildcard *.c)

ifeq ($(feature-llvm),1)
# If LLVM is available, use it for JIT disassembly
ifneq ($(SKIP_LLVM),1)
HAS_LLVM := 1
endif
endif

ifeq ($(HAS_LLVM),1)
CFLAGS += -DHAVE_LLVM_SUPPORT
LLVM_CONFIG_LIB_COMPONENTS := mcdisassembler all-targets
# llvm-config always adds -D_GNU_SOURCE, however, it may already be in CFLAGS
Expand All @@ -159,6 +173,7 @@ ifeq ($(feature-llvm),1)
endif
LDFLAGS += $(shell $(LLVM_CONFIG) --ldflags)
else
ifneq ($(SKIP_LIBBFD),1)
# Fall back on libbfd
ifeq ($(feature-libbfd),1)
LIBS += -lbfd -ldl -lopcodes
Expand All @@ -180,15 +195,22 @@ else
CFLAGS += -DDISASM_INIT_STYLED
endif
endif
endif # SKIP_LIBBFD
endif
ifeq ($(filter -DHAVE_LLVM_SUPPORT -DHAVE_LIBBFD_SUPPORT,$(CFLAGS)),)
# No support for JIT disassembly
SRCS := $(filter-out jit_disasm.c,$(SRCS))
endif

ifeq ($(SKIP_CRYPTO),1)
CFLAGS += -DBPFTOOL_WITHOUT_CRYPTO
HOST_CFLAGS += -DBPFTOOL_WITHOUT_CRYPTO
SRCS := $(filter-out sign.c,$(SRCS))
endif

BPFTOOL_BOOTSTRAP := $(BOOTSTRAP_OUTPUT)bpftool

BOOTSTRAP_OBJS = $(addprefix $(BOOTSTRAP_OUTPUT),main.o common.o json_writer.o gen.o btf.o sign.o)
BOOTSTRAP_OBJS = $(addprefix $(BOOTSTRAP_OUTPUT),main.o common.o json_writer.o gen.o btf.o $(if $(CRYPTO_LIBS),sign.o))
$(BOOTSTRAP_OBJS): $(LIBBPF_BOOTSTRAP)

OBJS = $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o
Expand Down
11 changes: 10 additions & 1 deletion src/jit_disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,16 @@ init_context(disasm_ctx_t *ctx, const char *arch,
p_err("Failed to retrieve triple");
return -1;
}
*ctx = LLVMCreateDisasm(triple, NULL, 0, NULL, symbol_lookup_callback);

/*
* Enable all aarch64 ISA extensions so the disassembler can handle any
* instruction the kernel JIT might emit (e.g. ARM64 LSE atomics).
*/
if (!strncmp(triple, "aarch64", 7))
*ctx = LLVMCreateDisasmCPUFeatures(triple, "", "+all", NULL, 0, NULL,
symbol_lookup_callback);
else
*ctx = LLVMCreateDisasm(triple, NULL, 0, NULL, symbol_lookup_callback);
LLVMDisposeMessage(triple);

if (!*ctx) {
Expand Down
7 changes: 7 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ static int do_version(int argc, char **argv)
const bool has_skeletons = false;
#else
const bool has_skeletons = true;
#endif
#ifdef BPFTOOL_WITHOUT_CRYPTO
const bool has_crypto = false;
#else
const bool has_crypto = true;
#endif
bool bootstrap = false;
int i;
Expand Down Expand Up @@ -163,6 +168,7 @@ static int do_version(int argc, char **argv)
jsonw_start_object(json_wtr); /* features */
jsonw_bool_field(json_wtr, "libbfd", has_libbfd);
jsonw_bool_field(json_wtr, "llvm", has_llvm);
jsonw_bool_field(json_wtr, "crypto", has_crypto);
jsonw_bool_field(json_wtr, "skeletons", has_skeletons);
jsonw_bool_field(json_wtr, "bootstrap", bootstrap);
jsonw_end_object(json_wtr); /* features */
Expand All @@ -181,6 +187,7 @@ static int do_version(int argc, char **argv)
printf("features:");
print_feature("libbfd", has_libbfd, &nb_features);
print_feature("llvm", has_llvm, &nb_features);
print_feature("crypto", has_crypto, &nb_features);
print_feature("skeletons", has_skeletons, &nb_features);
print_feature("bootstrap", bootstrap, &nb_features);
printf("\n");
Expand Down
14 changes: 14 additions & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,20 @@ struct kernel_config_option {
int read_kernel_config(const struct kernel_config_option *requested_options,
size_t num_options, char **out_values,
const char *define_prefix);
#ifndef BPFTOOL_WITHOUT_CRYPTO
int bpftool_prog_sign(struct bpf_load_and_run_opts *opts);
__u32 register_session_key(const char *key_der_path);
#else
static inline int bpftool_prog_sign(struct bpf_load_and_run_opts *opts)
{
p_err("bpftool was built without signing support");
return -ENOTSUP;
}

static inline __u32 register_session_key(const char *key_der_path)
{
p_err("bpftool was built without signing support");
return -1;
}
#endif
#endif
Loading