Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Generic arch dependent fprobe macros.
4 */
5#ifndef __ASM_GENERIC_FPROBE_H__
6#define __ASM_GENERIC_FPROBE_H__
7
8#include <linux/bits.h>
9
10#ifdef CONFIG_64BIT
11/*
12 * Encoding the size and the address of fprobe into one 64bit entry.
13 * The 32bit architectures should use 2 entries to store those info.
14 */
15
16#define ARCH_DEFINE_ENCODE_FPROBE_HEADER
17
18#define FPROBE_HEADER_MSB_SIZE_SHIFT (BITS_PER_LONG - FPROBE_DATA_SIZE_BITS)
19#define FPROBE_HEADER_MSB_MASK \
20 GENMASK(FPROBE_HEADER_MSB_SIZE_SHIFT - 1, 0)
21
22/*
23 * By default, this expects the MSBs in the address of kprobe is 0xf.
24 * If any arch needs another fixed pattern (e.g. s390 is zero filled),
25 * override this.
26 */
27#define FPROBE_HEADER_MSB_PATTERN \
28 GENMASK(BITS_PER_LONG - 1, FPROBE_HEADER_MSB_SIZE_SHIFT)
29
30#define arch_fprobe_header_encodable(fp) \
31 (((unsigned long)(fp) & ~FPROBE_HEADER_MSB_MASK) == \
32 FPROBE_HEADER_MSB_PATTERN)
33
34#define arch_encode_fprobe_header(fp, size) \
35 (((unsigned long)(fp) & FPROBE_HEADER_MSB_MASK) | \
36 ((unsigned long)(size) << FPROBE_HEADER_MSB_SIZE_SHIFT))
37
38#define arch_decode_fprobe_header_size(val) \
39 ((unsigned long)(val) >> FPROBE_HEADER_MSB_SIZE_SHIFT)
40
41#define arch_decode_fprobe_header_fp(val) \
42 ((struct fprobe *)(((unsigned long)(val) & FPROBE_HEADER_MSB_MASK) | \
43 FPROBE_HEADER_MSB_PATTERN))
44#endif /* CONFIG_64BIT */
45
46#endif /* __ASM_GENERIC_FPROBE_H__ */