Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 2 | # SPDX-License-Identifier: GPL-2.0 |
Jiri Olsa | aeafd62 | 2016-12-06 14:18:51 +0100 | [diff] [blame] | 3 | |
Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 4 | YELLOW='\033[0;33m' |
| 5 | NC='\033[0m' # No Color |
Jiri Olsa | aeafd62 | 2016-12-06 14:18:51 +0100 | [diff] [blame] | 6 | |
Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 7 | declare -a FILES |
| 8 | FILES=( |
| 9 | "include/uapi/linux/const.h" |
| 10 | "include/uapi/drm/drm.h" |
| 11 | "include/uapi/drm/i915_drm.h" |
Arnaldo Carvalho de Melo | 450f941 | 2024-04-26 15:52:09 -0300 | [diff] [blame] | 12 | "include/uapi/linux/bits.h" |
Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 13 | "include/uapi/linux/fadvise.h" |
Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 14 | "include/uapi/linux/fscrypt.h" |
| 15 | "include/uapi/linux/kcmp.h" |
| 16 | "include/uapi/linux/kvm.h" |
| 17 | "include/uapi/linux/in.h" |
Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 18 | "include/uapi/linux/perf_event.h" |
Arnaldo Carvalho de Melo | 417ecb6 | 2023-09-13 08:35:09 -0300 | [diff] [blame] | 19 | "include/uapi/linux/seccomp.h" |
Arnaldo Carvalho de Melo | 61ba075 | 2024-04-18 18:15:33 -0300 | [diff] [blame] | 20 | "include/uapi/linux/stat.h" |
Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 21 | "include/linux/bits.h" |
| 22 | "include/vdso/bits.h" |
| 23 | "include/linux/const.h" |
| 24 | "include/vdso/const.h" |
| 25 | "include/linux/hash.h" |
| 26 | "include/linux/list-sort.h" |
| 27 | "include/uapi/linux/hw_breakpoint.h" |
| 28 | "arch/x86/include/asm/disabled-features.h" |
| 29 | "arch/x86/include/asm/required-features.h" |
| 30 | "arch/x86/include/asm/cpufeatures.h" |
| 31 | "arch/x86/include/asm/inat_types.h" |
| 32 | "arch/x86/include/asm/emulate_prefix.h" |
Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 33 | "arch/x86/include/asm/msr-index.h" |
Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 34 | "arch/x86/lib/x86-opcode-map.txt" |
| 35 | "arch/x86/tools/gen-insn-attr-x86.awk" |
| 36 | "arch/arm/include/uapi/asm/perf_regs.h" |
| 37 | "arch/arm64/include/uapi/asm/perf_regs.h" |
| 38 | "arch/loongarch/include/uapi/asm/perf_regs.h" |
| 39 | "arch/mips/include/uapi/asm/perf_regs.h" |
| 40 | "arch/powerpc/include/uapi/asm/perf_regs.h" |
| 41 | "arch/s390/include/uapi/asm/perf_regs.h" |
| 42 | "arch/x86/include/uapi/asm/perf_regs.h" |
| 43 | "arch/x86/include/uapi/asm/kvm.h" |
| 44 | "arch/x86/include/uapi/asm/kvm_perf.h" |
| 45 | "arch/x86/include/uapi/asm/svm.h" |
| 46 | "arch/x86/include/uapi/asm/unistd.h" |
| 47 | "arch/x86/include/uapi/asm/vmx.h" |
| 48 | "arch/powerpc/include/uapi/asm/kvm.h" |
| 49 | "arch/s390/include/uapi/asm/kvm.h" |
| 50 | "arch/s390/include/uapi/asm/kvm_perf.h" |
| 51 | "arch/s390/include/uapi/asm/sie.h" |
| 52 | "arch/arm/include/uapi/asm/kvm.h" |
| 53 | "arch/arm64/include/uapi/asm/kvm.h" |
| 54 | "arch/arm64/include/uapi/asm/unistd.h" |
| 55 | "arch/alpha/include/uapi/asm/errno.h" |
| 56 | "arch/mips/include/asm/errno.h" |
| 57 | "arch/mips/include/uapi/asm/errno.h" |
| 58 | "arch/parisc/include/uapi/asm/errno.h" |
| 59 | "arch/powerpc/include/uapi/asm/errno.h" |
| 60 | "arch/sparc/include/uapi/asm/errno.h" |
| 61 | "arch/x86/include/uapi/asm/errno.h" |
| 62 | "include/asm-generic/bitops/arch_hweight.h" |
| 63 | "include/asm-generic/bitops/const_hweight.h" |
| 64 | "include/asm-generic/bitops/__fls.h" |
| 65 | "include/asm-generic/bitops/fls.h" |
| 66 | "include/asm-generic/bitops/fls64.h" |
| 67 | "include/linux/coresight-pmu.h" |
| 68 | "include/uapi/asm-generic/errno.h" |
| 69 | "include/uapi/asm-generic/errno-base.h" |
| 70 | "include/uapi/asm-generic/ioctls.h" |
| 71 | "include/uapi/asm-generic/mman-common.h" |
| 72 | "include/uapi/asm-generic/unistd.h" |
| 73 | ) |
| 74 | |
| 75 | declare -a SYNC_CHECK_FILES |
| 76 | SYNC_CHECK_FILES=( |
| 77 | "arch/x86/include/asm/inat.h" |
| 78 | "arch/x86/include/asm/insn.h" |
| 79 | "arch/x86/lib/inat.c" |
| 80 | "arch/x86/lib/insn.c" |
| 81 | ) |
Borislav Petkov | d30c7b8 | 2021-02-22 13:34:40 +0100 | [diff] [blame] | 82 | |
Arnaldo Carvalho de Melo | d758d5d | 2020-09-29 08:56:38 -0300 | [diff] [blame] | 83 | # These copies are under tools/perf/trace/beauty/ as they are not used to in |
| 84 | # building object files only by scripts in tools/perf/trace/beauty/ to generate |
| 85 | # tables that then gets included in .c files for things like id->string syscall |
| 86 | # tables (and the reverse lookup as well: string -> id) |
| 87 | |
Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 88 | declare -a BEAUTY_FILES |
| 89 | BEAUTY_FILES=( |
Arnaldo Carvalho de Melo | c8bfe3f | 2024-03-11 17:07:33 -0300 | [diff] [blame] | 90 | "arch/x86/include/asm/irq_vectors.h" |
Arnaldo Carvalho de Melo | eb01fe7 | 2024-03-11 17:07:33 -0300 | [diff] [blame] | 91 | "arch/x86/include/uapi/asm/prctl.h" |
Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 92 | "include/linux/socket.h" |
Arnaldo Carvalho de Melo | 3d6cfba | 2024-03-19 14:49:32 -0300 | [diff] [blame] | 93 | "include/uapi/linux/fcntl.h" |
Arnaldo Carvalho de Melo | faf7217 | 2024-03-11 17:07:33 -0300 | [diff] [blame] | 94 | "include/uapi/linux/fs.h" |
Arnaldo Carvalho de Melo | ab33161 | 2024-03-11 17:07:33 -0300 | [diff] [blame] | 95 | "include/uapi/linux/mount.h" |
Arnaldo Carvalho de Melo | eb01fe7 | 2024-03-11 17:07:33 -0300 | [diff] [blame] | 96 | "include/uapi/linux/prctl.h" |
Arnaldo Carvalho de Melo | 2316ef5 | 2024-03-19 14:49:32 -0300 | [diff] [blame] | 97 | "include/uapi/linux/sched.h" |
Arnaldo Carvalho de Melo | f122b3d | 2024-03-19 14:49:32 -0300 | [diff] [blame] | 98 | "include/uapi/linux/stat.h" |
Arnaldo Carvalho de Melo | 44512bd | 2024-03-11 17:07:33 -0300 | [diff] [blame] | 99 | "include/uapi/linux/usbdevice_fs.h" |
Arnaldo Carvalho de Melo | 4962e19 | 2024-03-11 17:07:33 -0300 | [diff] [blame] | 100 | "include/uapi/linux/vhost.h" |
Arnaldo Carvalho de Melo | 7050e33 | 2024-03-11 17:07:33 -0300 | [diff] [blame] | 101 | "include/uapi/sound/asound.h" |
Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 102 | ) |
| 103 | |
| 104 | declare -a FAILURES |
Arnaldo Carvalho de Melo | d758d5d | 2020-09-29 08:56:38 -0300 | [diff] [blame] | 105 | |
Jiri Olsa | 58247297 | 2018-04-23 11:08:16 +0200 | [diff] [blame] | 106 | check_2 () { |
Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 107 | tools_file=$1 |
| 108 | orig_file=$2 |
Jiri Olsa | 58247297 | 2018-04-23 11:08:16 +0200 | [diff] [blame] | 109 | |
| 110 | shift |
| 111 | shift |
| 112 | |
Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 113 | cmd="diff $* $tools_file $orig_file > /dev/null" |
Jiri Olsa | 58247297 | 2018-04-23 11:08:16 +0200 | [diff] [blame] | 114 | |
Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 115 | if [ -f "$orig_file" ] && ! eval "$cmd" |
| 116 | then |
| 117 | FAILURES+=( |
| 118 | "$tools_file $orig_file" |
| 119 | ) |
| 120 | fi |
Jiri Olsa | 58247297 | 2018-04-23 11:08:16 +0200 | [diff] [blame] | 121 | } |
| 122 | |
Jiri Olsa | aeafd62 | 2016-12-06 14:18:51 +0100 | [diff] [blame] | 123 | check () { |
| 124 | file=$1 |
Jiri Olsa | aeafd62 | 2016-12-06 14:18:51 +0100 | [diff] [blame] | 125 | |
| 126 | shift |
Jiri Olsa | aeafd62 | 2016-12-06 14:18:51 +0100 | [diff] [blame] | 127 | |
Kajol Jain | e936584 | 2023-07-09 23:57:49 +0530 | [diff] [blame] | 128 | check_2 "tools/$file" "$file" "$@" |
Jiri Olsa | aeafd62 | 2016-12-06 14:18:51 +0100 | [diff] [blame] | 129 | } |
| 130 | |
Arnaldo Carvalho de Melo | d758d5d | 2020-09-29 08:56:38 -0300 | [diff] [blame] | 131 | beauty_check () { |
| 132 | file=$1 |
| 133 | |
| 134 | shift |
| 135 | |
Kajol Jain | e936584 | 2023-07-09 23:57:49 +0530 | [diff] [blame] | 136 | check_2 "tools/perf/trace/beauty/$file" "$file" "$@" |
Arnaldo Carvalho de Melo | d758d5d | 2020-09-29 08:56:38 -0300 | [diff] [blame] | 137 | } |
| 138 | |
Arnaldo Carvalho de Melo | d7e05ce | 2017-10-16 15:53:08 -0300 | [diff] [blame] | 139 | # Check if we have the kernel headers (tools/perf/../../include), else |
| 140 | # we're probably on a detached tarball, so no point in trying to check |
| 141 | # differences. |
Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 142 | if ! [ -d ../../include ] |
| 143 | then |
| 144 | echo -e "${YELLOW}Warning${NC}: Skipped check-headers due to missing ../../include" |
| 145 | exit 0 |
| 146 | fi |
Arnaldo Carvalho de Melo | d7e05ce | 2017-10-16 15:53:08 -0300 | [diff] [blame] | 147 | |
Jiri Olsa | 7ea6e98 | 2018-08-13 13:15:03 +0200 | [diff] [blame] | 148 | cd ../.. |
| 149 | |
Jiri Olsa | aeafd62 | 2016-12-06 14:18:51 +0100 | [diff] [blame] | 150 | # simple diff check |
Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 151 | for i in "${FILES[@]}" |
| 152 | do |
| 153 | check "$i" -B |
Jiri Olsa | aeafd62 | 2016-12-06 14:18:51 +0100 | [diff] [blame] | 154 | done |
| 155 | |
Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 156 | for i in "${SYNC_CHECK_FILES[@]}" |
| 157 | do |
| 158 | check "$i" '-I "^.*\/\*.*__ignore_sync_check__.*\*\/.*$"' |
Borislav Petkov | d30c7b8 | 2021-02-22 13:34:40 +0100 | [diff] [blame] | 159 | done |
| 160 | |
Jiri Olsa | aeafd62 | 2016-12-06 14:18:51 +0100 | [diff] [blame] | 161 | # diff with extra ignore lines |
Arnaldo Carvalho de Melo | 4402e36 | 2019-12-02 11:40:57 -0300 | [diff] [blame] | 162 | check 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>"' |
Arnaldo Carvalho de Melo | bd5c6b8 | 2019-12-02 11:40:57 -0300 | [diff] [blame] | 163 | check arch/x86/lib/memset_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" -I"^SYM_FUNC_START\(_LOCAL\)*(memset_\(erms\|orig\))"' |
Kim Phillips | dde994d | 2021-08-17 17:15:08 -0500 | [diff] [blame] | 164 | check arch/x86/include/asm/amd-ibs.h '-I "^#include [<\"]\(asm/\)*msr-index.h"' |
Ali Saidi | 1314376 | 2022-03-24 18:33:20 +0000 | [diff] [blame] | 165 | check arch/arm64/include/asm/cputype.h '-I "^#include [<\"]\(asm/\)*sysreg.h"' |
Al Viro | 5f60d5f | 2024-10-01 15:35:57 -0400 | [diff] [blame] | 166 | check include/linux/unaligned.h '-I "^#include <linux/unaligned/packed_struct.h>" -I "^#include <asm/byteorder.h>" -I "^#pragma GCC diagnostic"' |
Arnaldo Carvalho de Melo | be709d4 | 2019-03-25 14:06:07 -0300 | [diff] [blame] | 167 | check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common\(-tools\)*.h>"' |
Jiri Olsa | 15019e9 | 2018-04-23 11:08:15 +0200 | [diff] [blame] | 168 | check include/uapi/linux/mman.h '-I "^#include <\(uapi/\)*asm/mman.h>"' |
Arnaldo Carvalho de Melo | e3698b2 | 2020-04-14 10:27:39 -0300 | [diff] [blame] | 169 | check include/linux/build_bug.h '-I "^#\(ifndef\|endif\)\( \/\/\)* static_assert$"' |
Arnaldo Carvalho de Melo | 3052ba5 | 2019-06-25 17:27:31 -0300 | [diff] [blame] | 170 | check include/linux/ctype.h '-I "isdigit("' |
| 171 | check lib/ctype.c '-I "^EXPORT_SYMBOL" -I "^#include <linux/export.h>" -B' |
Ian Rogers | 92ec3cc | 2021-10-15 10:21:12 -0700 | [diff] [blame] | 172 | check lib/list_sort.c '-I "^#include <linux/bug.h>"' |
Jiri Olsa | 7ea6e98 | 2018-08-13 13:15:03 +0200 | [diff] [blame] | 173 | |
Jiri Olsa | c9b51a0 | 2018-08-13 13:15:04 +0200 | [diff] [blame] | 174 | # diff non-symmetric files |
Arnaldo Carvalho de Melo | 0e7eb23 | 2024-08-30 19:53:47 -0300 | [diff] [blame] | 175 | check_2 tools/perf/arch/x86/entry/syscalls/syscall_32.tbl arch/x86/entry/syscalls/syscall_32.tbl |
Jiri Olsa | c9b51a0 | 2018-08-13 13:15:04 +0200 | [diff] [blame] | 176 | check_2 tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86/entry/syscalls/syscall_64.tbl |
Tiezhu Yang | 9bad32b | 2020-12-18 15:59:21 +0800 | [diff] [blame] | 177 | check_2 tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/powerpc/kernel/syscalls/syscall.tbl |
Tiezhu Yang | 22ffc3f | 2020-12-18 15:59:22 +0800 | [diff] [blame] | 178 | check_2 tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/s390/kernel/syscalls/syscall.tbl |
Tiezhu Yang | d9fd5a7 | 2021-02-04 11:35:24 +0800 | [diff] [blame] | 179 | check_2 tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl arch/mips/kernel/syscalls/syscall_n64.tbl |
Jiri Olsa | c9b51a0 | 2018-08-13 13:15:04 +0200 | [diff] [blame] | 180 | |
Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 181 | for i in "${BEAUTY_FILES[@]}" |
| 182 | do |
| 183 | beauty_check "$i" -B |
Arnaldo Carvalho de Melo | d758d5d | 2020-09-29 08:56:38 -0300 | [diff] [blame] | 184 | done |
Arnaldo Carvalho de Melo | f3cf7fa | 2020-08-12 08:43:51 -0300 | [diff] [blame] | 185 | |
Ian Rogers | eee1950 | 2020-05-15 15:17:29 -0700 | [diff] [blame] | 186 | # check duplicated library files |
| 187 | check_2 tools/perf/util/hashmap.h tools/lib/bpf/hashmap.h |
| 188 | check_2 tools/perf/util/hashmap.c tools/lib/bpf/hashmap.c |
| 189 | |
Kajol Jain | e936584 | 2023-07-09 23:57:49 +0530 | [diff] [blame] | 190 | cd tools/perf || exit |
Ian Rogers | d674838 | 2023-06-05 13:34:25 -0700 | [diff] [blame] | 191 | |
| 192 | if [ ${#FAILURES[@]} -gt 0 ] |
| 193 | then |
| 194 | echo -e "${YELLOW}Warning${NC}: Kernel ABI header differences:" |
| 195 | for i in "${FAILURES[@]}" |
| 196 | do |
| 197 | echo " diff -u $i" |
| 198 | done |
| 199 | fi |