// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */
#include <linux/capability.h>
#include <linux/err.h>
#include <stdlib.h>
#include <test_progs.h>
#include <bpf/btf.h>
#include "autoconf_helper.h"
#include "disasm_helpers.h"
#include "unpriv_helpers.h"
#include "cap_helpers.h"
#include "jit_disasm_helpers.h"
static inline const char *str_has_pfx(const char *str, const char *pfx)
{
size_t len = strlen(pfx);
return strncmp(str, pfx, len) == 0 ? str + len : NULL;
}
#define TEST_LOADER_LOG_BUF_SZ 2097152
/* Warning: duplicated in bpf_misc.h */
#define POINTER_VALUE 0xbadcafe
#define TEST_DATA_LEN 64
#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
#define EFFICIENT_UNALIGNED_ACCESS 1
#else
#define EFFICIENT_UNALIGNED_ACCESS 0
#endif
static int sysctl_unpriv_disabled = -1;
enum mode {
PRIV = 1,
UNPRIV = 2
};
enum load_mode {
JITED = 1 << 0,
NO_JITED = 1 << 1,
};
struct test_subspec {
char *name;
char *description;
bool expect_failure;
struct expected_msgs expect_msgs;
struct expected_msgs expect_xlated;
struct expected_msgs jited;
struct expected_msgs stderr;
struct expected_msgs stdout;
int retval;