xref: /openbmc/linux/tools/perf/check-headers.sh (revision 2fa5ebe3)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3
4FILES='
5include/uapi/linux/const.h
6include/uapi/drm/drm.h
7include/uapi/drm/i915_drm.h
8include/uapi/linux/fadvise.h
9include/uapi/linux/fcntl.h
10include/uapi/linux/fs.h
11include/uapi/linux/fscrypt.h
12include/uapi/linux/kcmp.h
13include/uapi/linux/kvm.h
14include/uapi/linux/in.h
15include/uapi/linux/mount.h
16include/uapi/linux/openat2.h
17include/uapi/linux/perf_event.h
18include/uapi/linux/prctl.h
19include/uapi/linux/sched.h
20include/uapi/linux/stat.h
21include/uapi/linux/usbdevice_fs.h
22include/uapi/linux/vhost.h
23include/uapi/sound/asound.h
24include/linux/bits.h
25include/vdso/bits.h
26include/linux/const.h
27include/vdso/const.h
28include/linux/hash.h
29include/linux/list-sort.h
30include/uapi/linux/hw_breakpoint.h
31arch/x86/include/asm/disabled-features.h
32arch/x86/include/asm/required-features.h
33arch/x86/include/asm/cpufeatures.h
34arch/x86/include/asm/inat_types.h
35arch/x86/include/asm/emulate_prefix.h
36arch/x86/include/asm/irq_vectors.h
37arch/x86/include/asm/msr-index.h
38arch/x86/include/uapi/asm/prctl.h
39arch/x86/lib/x86-opcode-map.txt
40arch/x86/tools/gen-insn-attr-x86.awk
41arch/arm/include/uapi/asm/perf_regs.h
42arch/arm64/include/uapi/asm/perf_regs.h
43arch/loongarch/include/uapi/asm/perf_regs.h
44arch/mips/include/uapi/asm/perf_regs.h
45arch/powerpc/include/uapi/asm/perf_regs.h
46arch/s390/include/uapi/asm/perf_regs.h
47arch/x86/include/uapi/asm/perf_regs.h
48arch/x86/include/uapi/asm/kvm.h
49arch/x86/include/uapi/asm/kvm_perf.h
50arch/x86/include/uapi/asm/svm.h
51arch/x86/include/uapi/asm/unistd.h
52arch/x86/include/uapi/asm/vmx.h
53arch/powerpc/include/uapi/asm/kvm.h
54arch/s390/include/uapi/asm/kvm.h
55arch/s390/include/uapi/asm/kvm_perf.h
56arch/s390/include/uapi/asm/ptrace.h
57arch/s390/include/uapi/asm/sie.h
58arch/arm/include/uapi/asm/kvm.h
59arch/arm64/include/uapi/asm/kvm.h
60arch/arm64/include/uapi/asm/unistd.h
61arch/alpha/include/uapi/asm/errno.h
62arch/mips/include/asm/errno.h
63arch/mips/include/uapi/asm/errno.h
64arch/parisc/include/uapi/asm/errno.h
65arch/powerpc/include/uapi/asm/errno.h
66arch/sparc/include/uapi/asm/errno.h
67arch/x86/include/uapi/asm/errno.h
68include/asm-generic/bitops/arch_hweight.h
69include/asm-generic/bitops/const_hweight.h
70include/asm-generic/bitops/__fls.h
71include/asm-generic/bitops/fls.h
72include/asm-generic/bitops/fls64.h
73include/linux/coresight-pmu.h
74include/uapi/asm-generic/errno.h
75include/uapi/asm-generic/errno-base.h
76include/uapi/asm-generic/ioctls.h
77include/uapi/asm-generic/mman-common.h
78include/uapi/asm-generic/unistd.h
79'
80
81SYNC_CHECK_FILES='
82arch/x86/include/asm/inat.h
83arch/x86/include/asm/insn.h
84arch/x86/lib/inat.c
85arch/x86/lib/insn.c
86'
87
88# These copies are under tools/perf/trace/beauty/ as they are not used to in
89# building object files only by scripts in tools/perf/trace/beauty/ to generate
90# tables that then gets included in .c files for things like id->string syscall
91# tables (and the reverse lookup as well: string -> id)
92
93BEAUTY_FILES='
94include/linux/socket.h
95'
96
97check_2 () {
98  file1=$1
99  file2=$2
100
101  shift
102  shift
103
104  cmd="diff $* $file1 $file2 > /dev/null"
105
106  test -f $file2 && {
107    eval $cmd || {
108      echo "Warning: Kernel ABI header at '$file1' differs from latest version at '$file2'" >&2
109      echo diff -u $file1 $file2
110    }
111  }
112}
113
114check () {
115  file=$1
116
117  shift
118
119  check_2 tools/$file $file $*
120}
121
122beauty_check () {
123  file=$1
124
125  shift
126
127  check_2 tools/perf/trace/beauty/$file $file $*
128}
129
130# Check if we have the kernel headers (tools/perf/../../include), else
131# we're probably on a detached tarball, so no point in trying to check
132# differences.
133test -d ../../include || exit 0
134
135cd ../..
136
137# simple diff check
138for i in $FILES; do
139  check $i -B
140done
141
142for i in $SYNC_CHECK_FILES; do
143  check $i '-I "^.*\/\*.*__ignore_sync_check__.*\*\/.*$"'
144done
145
146# diff with extra ignore lines
147check arch/x86/lib/memcpy_64.S        '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" -I"^SYM_FUNC_START\(_LOCAL\)*(memcpy_\(erms\|orig\))" -I"^#include <linux/cfi_types.h>"'
148check arch/x86/lib/memset_64.S        '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" -I"^SYM_FUNC_START\(_LOCAL\)*(memset_\(erms\|orig\))"'
149check arch/x86/include/asm/amd-ibs.h  '-I "^#include [<\"]\(asm/\)*msr-index.h"'
150check arch/arm64/include/asm/cputype.h '-I "^#include [<\"]\(asm/\)*sysreg.h"'
151check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common\(-tools\)*.h>"'
152check include/uapi/linux/mman.h       '-I "^#include <\(uapi/\)*asm/mman.h>"'
153check include/linux/build_bug.h       '-I "^#\(ifndef\|endif\)\( \/\/\)* static_assert$"'
154check include/linux/ctype.h	      '-I "isdigit("'
155check lib/ctype.c		      '-I "^EXPORT_SYMBOL" -I "^#include <linux/export.h>" -B'
156check lib/list_sort.c		      '-I "^#include <linux/bug.h>"'
157
158# diff non-symmetric files
159check_2 tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86/entry/syscalls/syscall_64.tbl
160check_2 tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/powerpc/kernel/syscalls/syscall.tbl
161check_2 tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/s390/kernel/syscalls/syscall.tbl
162check_2 tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl arch/mips/kernel/syscalls/syscall_n64.tbl
163
164for i in $BEAUTY_FILES; do
165  beauty_check $i -B
166done
167
168# check duplicated library files
169check_2 tools/perf/util/hashmap.h tools/lib/bpf/hashmap.h
170check_2 tools/perf/util/hashmap.c tools/lib/bpf/hashmap.c
171
172cd tools/perf
173