cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

libbpf_legacy.h (3936B)


      1/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
      2
      3/*
      4 * Libbpf legacy APIs (either discouraged or deprecated, as mentioned in [0])
      5 *
      6 *   [0] https://docs.google.com/document/d/1UyjTZuPFWiPFyKk1tV5an11_iaRuec6U-ZESZ54nNTY
      7 *
      8 * Copyright (C) 2021 Facebook
      9 */
     10#ifndef __LIBBPF_LEGACY_BPF_H
     11#define __LIBBPF_LEGACY_BPF_H
     12
     13#include <linux/bpf.h>
     14#include <stdbool.h>
     15#include <stddef.h>
     16#include <stdint.h>
     17#include "libbpf_common.h"
     18
     19#ifdef __cplusplus
     20extern "C" {
     21#endif
     22
     23enum libbpf_strict_mode {
     24	/* Turn on all supported strict features of libbpf to simulate libbpf
     25	 * v1.0 behavior.
     26	 * This will be the default behavior in libbpf v1.0.
     27	 */
     28	LIBBPF_STRICT_ALL = 0xffffffff,
     29
     30	/*
     31	 * Disable any libbpf 1.0 behaviors. This is the default before libbpf
     32	 * v1.0. It won't be supported anymore in v1.0, please update your
     33	 * code so that it handles LIBBPF_STRICT_ALL mode before libbpf v1.0.
     34	 */
     35	LIBBPF_STRICT_NONE = 0x00,
     36	/*
     37	 * Return NULL pointers on error, not ERR_PTR(err).
     38	 * Additionally, libbpf also always sets errno to corresponding Exx
     39	 * (positive) error code.
     40	 */
     41	LIBBPF_STRICT_CLEAN_PTRS = 0x01,
     42	/*
     43	 * Return actual error codes from low-level APIs directly, not just -1.
     44	 * Additionally, libbpf also always sets errno to corresponding Exx
     45	 * (positive) error code.
     46	 */
     47	LIBBPF_STRICT_DIRECT_ERRS = 0x02,
     48	/*
     49	 * Enforce strict BPF program section (SEC()) names.
     50	 * E.g., while prefiously SEC("xdp_whatever") or SEC("perf_event_blah") were
     51	 * allowed, with LIBBPF_STRICT_SEC_PREFIX this will become
     52	 * unrecognized by libbpf and would have to be just SEC("xdp") and
     53	 * SEC("xdp") and SEC("perf_event").
     54	 *
     55	 * Note, in this mode the program pin path will be based on the
     56	 * function name instead of section name.
     57	 *
     58	 * Additionally, routines in the .text section are always considered
     59	 * sub-programs. Legacy behavior allows for a single routine in .text
     60	 * to be a program.
     61	 */
     62	LIBBPF_STRICT_SEC_NAME = 0x04,
     63	/*
     64	 * Disable the global 'bpf_objects_list'. Maintaining this list adds
     65	 * a race condition to bpf_object__open() and bpf_object__close().
     66	 * Clients can maintain it on their own if it is valuable for them.
     67	 */
     68	LIBBPF_STRICT_NO_OBJECT_LIST = 0x08,
     69	/*
     70	 * Automatically bump RLIMIT_MEMLOCK using setrlimit() before the
     71	 * first BPF program or map creation operation. This is done only if
     72	 * kernel is too old to support memcg-based memory accounting for BPF
     73	 * subsystem. By default, RLIMIT_MEMLOCK limit is set to RLIM_INFINITY,
     74	 * but it can be overriden with libbpf_set_memlock_rlim_max() API.
     75	 * Note that libbpf_set_memlock_rlim_max() needs to be called before
     76	 * the very first bpf_prog_load(), bpf_map_create() or bpf_object__load()
     77	 * operation.
     78	 */
     79	LIBBPF_STRICT_AUTO_RLIMIT_MEMLOCK = 0x10,
     80	/*
     81	 * Error out on any SEC("maps") map definition, which are deprecated
     82	 * in favor of BTF-defined map definitions in SEC(".maps").
     83	 */
     84	LIBBPF_STRICT_MAP_DEFINITIONS = 0x20,
     85
     86	__LIBBPF_STRICT_LAST,
     87};
     88
     89LIBBPF_API int libbpf_set_strict_mode(enum libbpf_strict_mode mode);
     90
     91#define DECLARE_LIBBPF_OPTS LIBBPF_OPTS
     92
     93/* "Discouraged" APIs which don't follow consistent libbpf naming patterns.
     94 * They are normally a trivial aliases or wrappers for proper APIs and are
     95 * left to minimize unnecessary disruption for users of libbpf. But they
     96 * shouldn't be used going forward.
     97 */
     98
     99struct bpf_program;
    100struct bpf_map;
    101struct btf;
    102struct btf_ext;
    103
    104LIBBPF_API enum bpf_prog_type bpf_program__get_type(const struct bpf_program *prog);
    105LIBBPF_API enum bpf_attach_type bpf_program__get_expected_attach_type(const struct bpf_program *prog);
    106LIBBPF_API const char *bpf_map__get_pin_path(const struct bpf_map *map);
    107LIBBPF_API const void *btf__get_raw_data(const struct btf *btf, __u32 *size);
    108LIBBPF_API const void *btf_ext__get_raw_data(const struct btf_ext *btf_ext, __u32 *size);
    109
    110#ifdef __cplusplus
    111} /* extern "C" */
    112#endif
    113
    114#endif /* __LIBBPF_LEGACY_BPF_H */