1 #!/bin/bash 1 #!/bin/bash 2 # SPDX-License-Identifier: GPL-2.0 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 YELLOW='\033[0;33m' 4 YELLOW='\033[0;33m' 5 NC='\033[0m' # No Color 5 NC='\033[0m' # No Color 6 6 7 declare -a FILES 7 declare -a FILES 8 FILES=( 8 FILES=( 9 "include/uapi/linux/const.h" 9 "include/uapi/linux/const.h" 10 "include/uapi/drm/drm.h" 10 "include/uapi/drm/drm.h" 11 "include/uapi/drm/i915_drm.h" 11 "include/uapi/drm/i915_drm.h" 12 "include/uapi/linux/bits.h" << 13 "include/uapi/linux/fadvise.h" 12 "include/uapi/linux/fadvise.h" >> 13 "include/uapi/linux/fcntl.h" >> 14 "include/uapi/linux/fs.h" 14 "include/uapi/linux/fscrypt.h" 15 "include/uapi/linux/fscrypt.h" 15 "include/uapi/linux/kcmp.h" 16 "include/uapi/linux/kcmp.h" 16 "include/uapi/linux/kvm.h" 17 "include/uapi/linux/kvm.h" 17 "include/uapi/linux/in.h" 18 "include/uapi/linux/in.h" >> 19 "include/uapi/linux/mount.h" >> 20 "include/uapi/linux/openat2.h" 18 "include/uapi/linux/perf_event.h" 21 "include/uapi/linux/perf_event.h" >> 22 "include/uapi/linux/prctl.h" >> 23 "include/uapi/linux/sched.h" 19 "include/uapi/linux/seccomp.h" 24 "include/uapi/linux/seccomp.h" 20 "include/uapi/linux/stat.h" 25 "include/uapi/linux/stat.h" >> 26 "include/uapi/linux/usbdevice_fs.h" >> 27 "include/uapi/linux/vhost.h" >> 28 "include/uapi/sound/asound.h" 21 "include/linux/bits.h" 29 "include/linux/bits.h" 22 "include/vdso/bits.h" 30 "include/vdso/bits.h" 23 "include/linux/const.h" 31 "include/linux/const.h" 24 "include/vdso/const.h" 32 "include/vdso/const.h" 25 "include/vdso/unaligned.h" << 26 "include/linux/hash.h" 33 "include/linux/hash.h" 27 "include/linux/list-sort.h" 34 "include/linux/list-sort.h" 28 "include/uapi/linux/hw_breakpoint.h" 35 "include/uapi/linux/hw_breakpoint.h" 29 "arch/x86/include/asm/disabled-features.h" 36 "arch/x86/include/asm/disabled-features.h" 30 "arch/x86/include/asm/required-features.h" 37 "arch/x86/include/asm/required-features.h" 31 "arch/x86/include/asm/cpufeatures.h" 38 "arch/x86/include/asm/cpufeatures.h" 32 "arch/x86/include/asm/inat_types.h" 39 "arch/x86/include/asm/inat_types.h" 33 "arch/x86/include/asm/emulate_prefix.h" 40 "arch/x86/include/asm/emulate_prefix.h" >> 41 "arch/x86/include/asm/irq_vectors.h" 34 "arch/x86/include/asm/msr-index.h" 42 "arch/x86/include/asm/msr-index.h" >> 43 "arch/x86/include/uapi/asm/prctl.h" 35 "arch/x86/lib/x86-opcode-map.txt" 44 "arch/x86/lib/x86-opcode-map.txt" 36 "arch/x86/tools/gen-insn-attr-x86.awk" 45 "arch/x86/tools/gen-insn-attr-x86.awk" 37 "arch/arm/include/uapi/asm/perf_regs.h" 46 "arch/arm/include/uapi/asm/perf_regs.h" 38 "arch/arm64/include/uapi/asm/perf_regs.h" 47 "arch/arm64/include/uapi/asm/perf_regs.h" 39 "arch/loongarch/include/uapi/asm/perf_regs.h 48 "arch/loongarch/include/uapi/asm/perf_regs.h" 40 "arch/mips/include/uapi/asm/perf_regs.h" 49 "arch/mips/include/uapi/asm/perf_regs.h" 41 "arch/powerpc/include/uapi/asm/perf_regs.h" 50 "arch/powerpc/include/uapi/asm/perf_regs.h" 42 "arch/s390/include/uapi/asm/perf_regs.h" 51 "arch/s390/include/uapi/asm/perf_regs.h" 43 "arch/x86/include/uapi/asm/perf_regs.h" 52 "arch/x86/include/uapi/asm/perf_regs.h" 44 "arch/x86/include/uapi/asm/kvm.h" 53 "arch/x86/include/uapi/asm/kvm.h" 45 "arch/x86/include/uapi/asm/kvm_perf.h" 54 "arch/x86/include/uapi/asm/kvm_perf.h" 46 "arch/x86/include/uapi/asm/svm.h" 55 "arch/x86/include/uapi/asm/svm.h" 47 "arch/x86/include/uapi/asm/unistd.h" 56 "arch/x86/include/uapi/asm/unistd.h" 48 "arch/x86/include/uapi/asm/vmx.h" 57 "arch/x86/include/uapi/asm/vmx.h" 49 "arch/powerpc/include/uapi/asm/kvm.h" 58 "arch/powerpc/include/uapi/asm/kvm.h" 50 "arch/s390/include/uapi/asm/kvm.h" 59 "arch/s390/include/uapi/asm/kvm.h" 51 "arch/s390/include/uapi/asm/kvm_perf.h" 60 "arch/s390/include/uapi/asm/kvm_perf.h" 52 "arch/s390/include/uapi/asm/sie.h" 61 "arch/s390/include/uapi/asm/sie.h" 53 "arch/arm/include/uapi/asm/kvm.h" 62 "arch/arm/include/uapi/asm/kvm.h" 54 "arch/arm64/include/uapi/asm/kvm.h" 63 "arch/arm64/include/uapi/asm/kvm.h" 55 "arch/arm64/include/uapi/asm/unistd.h" 64 "arch/arm64/include/uapi/asm/unistd.h" 56 "arch/alpha/include/uapi/asm/errno.h" 65 "arch/alpha/include/uapi/asm/errno.h" 57 "arch/mips/include/asm/errno.h" 66 "arch/mips/include/asm/errno.h" 58 "arch/mips/include/uapi/asm/errno.h" 67 "arch/mips/include/uapi/asm/errno.h" 59 "arch/parisc/include/uapi/asm/errno.h" 68 "arch/parisc/include/uapi/asm/errno.h" 60 "arch/powerpc/include/uapi/asm/errno.h" 69 "arch/powerpc/include/uapi/asm/errno.h" 61 "arch/sparc/include/uapi/asm/errno.h" 70 "arch/sparc/include/uapi/asm/errno.h" 62 "arch/x86/include/uapi/asm/errno.h" 71 "arch/x86/include/uapi/asm/errno.h" 63 "include/asm-generic/bitops/arch_hweight.h" 72 "include/asm-generic/bitops/arch_hweight.h" 64 "include/asm-generic/bitops/const_hweight.h" 73 "include/asm-generic/bitops/const_hweight.h" 65 "include/asm-generic/bitops/__fls.h" 74 "include/asm-generic/bitops/__fls.h" 66 "include/asm-generic/bitops/fls.h" 75 "include/asm-generic/bitops/fls.h" 67 "include/asm-generic/bitops/fls64.h" 76 "include/asm-generic/bitops/fls64.h" 68 "include/linux/coresight-pmu.h" 77 "include/linux/coresight-pmu.h" 69 "include/uapi/asm-generic/errno.h" 78 "include/uapi/asm-generic/errno.h" 70 "include/uapi/asm-generic/errno-base.h" 79 "include/uapi/asm-generic/errno-base.h" 71 "include/uapi/asm-generic/ioctls.h" 80 "include/uapi/asm-generic/ioctls.h" 72 "include/uapi/asm-generic/mman-common.h" 81 "include/uapi/asm-generic/mman-common.h" 73 "include/uapi/asm-generic/unistd.h" 82 "include/uapi/asm-generic/unistd.h" 74 ) 83 ) 75 84 76 declare -a SYNC_CHECK_FILES 85 declare -a SYNC_CHECK_FILES 77 SYNC_CHECK_FILES=( 86 SYNC_CHECK_FILES=( 78 "arch/x86/include/asm/inat.h" 87 "arch/x86/include/asm/inat.h" 79 "arch/x86/include/asm/insn.h" 88 "arch/x86/include/asm/insn.h" 80 "arch/x86/lib/inat.c" 89 "arch/x86/lib/inat.c" 81 "arch/x86/lib/insn.c" 90 "arch/x86/lib/insn.c" 82 ) 91 ) 83 92 84 # These copies are under tools/perf/trace/beau 93 # These copies are under tools/perf/trace/beauty/ as they are not used to in 85 # building object files only by scripts in too 94 # building object files only by scripts in tools/perf/trace/beauty/ to generate 86 # tables that then gets included in .c files f 95 # tables that then gets included in .c files for things like id->string syscall 87 # tables (and the reverse lookup as well: stri 96 # tables (and the reverse lookup as well: string -> id) 88 97 89 declare -a BEAUTY_FILES 98 declare -a BEAUTY_FILES 90 BEAUTY_FILES=( 99 BEAUTY_FILES=( 91 "arch/x86/include/asm/irq_vectors.h" << 92 "arch/x86/include/uapi/asm/prctl.h" << 93 "include/linux/socket.h" 100 "include/linux/socket.h" 94 "include/uapi/linux/fcntl.h" << 95 "include/uapi/linux/fs.h" << 96 "include/uapi/linux/mount.h" << 97 "include/uapi/linux/prctl.h" << 98 "include/uapi/linux/sched.h" << 99 "include/uapi/linux/stat.h" << 100 "include/uapi/linux/usbdevice_fs.h" << 101 "include/uapi/linux/vhost.h" << 102 "include/uapi/sound/asound.h" << 103 ) 101 ) 104 102 105 declare -a FAILURES 103 declare -a FAILURES 106 104 107 check_2 () { 105 check_2 () { 108 tools_file=$1 106 tools_file=$1 109 orig_file=$2 107 orig_file=$2 110 108 111 shift 109 shift 112 shift 110 shift 113 111 114 cmd="diff $* $tools_file $orig_file > /dev/n 112 cmd="diff $* $tools_file $orig_file > /dev/null" 115 113 116 if [ -f "$orig_file" ] && ! eval "$cmd" 114 if [ -f "$orig_file" ] && ! eval "$cmd" 117 then 115 then 118 FAILURES+=( 116 FAILURES+=( 119 "$tools_file $orig_file" 117 "$tools_file $orig_file" 120 ) 118 ) 121 fi 119 fi 122 } 120 } 123 121 124 check () { 122 check () { 125 file=$1 123 file=$1 126 124 127 shift 125 shift 128 126 129 check_2 "tools/$file" "$file" "$@" 127 check_2 "tools/$file" "$file" "$@" 130 } 128 } 131 129 132 beauty_check () { 130 beauty_check () { 133 file=$1 131 file=$1 134 132 135 shift 133 shift 136 134 137 check_2 "tools/perf/trace/beauty/$file" "$fi 135 check_2 "tools/perf/trace/beauty/$file" "$file" "$@" 138 } 136 } 139 137 140 check_ignore_some_hunks () { << 141 orig_file="$1" << 142 tools_file="tools/$orig_file" << 143 hunks_to_ignore="tools/perf/check-header_ign << 144 << 145 if [ ! -f "$hunks_to_ignore" ]; then << 146 echo "$hunks_to_ignore not found. Skipping << 147 FAILURES+=( << 148 "$tools_file $orig_file" << 149 ) << 150 return << 151 fi << 152 << 153 cmd="diff -u \"$tools_file\" \"$orig_file\" << 154 << 155 if [ -f "$orig_file" ] && ! eval "$cmd" << 156 then << 157 FAILURES+=( << 158 "$tools_file $orig_file" << 159 ) << 160 fi << 161 } << 162 << 163 << 164 # Check if we have the kernel headers (tools/p 138 # Check if we have the kernel headers (tools/perf/../../include), else 165 # we're probably on a detached tarball, so no 139 # we're probably on a detached tarball, so no point in trying to check 166 # differences. 140 # differences. 167 if ! [ -d ../../include ] 141 if ! [ -d ../../include ] 168 then 142 then 169 echo -e "${YELLOW}Warning${NC}: Skipped chec 143 echo -e "${YELLOW}Warning${NC}: Skipped check-headers due to missing ../../include" 170 exit 0 144 exit 0 171 fi 145 fi 172 146 173 cd ../.. 147 cd ../.. 174 148 175 # simple diff check 149 # simple diff check 176 for i in "${FILES[@]}" 150 for i in "${FILES[@]}" 177 do 151 do 178 check "$i" -B 152 check "$i" -B 179 done 153 done 180 154 181 for i in "${SYNC_CHECK_FILES[@]}" 155 for i in "${SYNC_CHECK_FILES[@]}" 182 do 156 do 183 check "$i" '-I "^.*\/\*.*__ignore_sync_check 157 check "$i" '-I "^.*\/\*.*__ignore_sync_check__.*\*\/.*$"' 184 done 158 done 185 159 186 # diff with extra ignore lines 160 # diff with extra ignore lines 187 check arch/x86/lib/memcpy_64.S '-I "^EX 161 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>"' 188 check arch/x86/lib/memset_64.S '-I "^EX 162 check arch/x86/lib/memset_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" -I"^SYM_FUNC_START\(_LOCAL\)*(memset_\(erms\|orig\))"' 189 check arch/x86/include/asm/amd-ibs.h '-I "^#i 163 check arch/x86/include/asm/amd-ibs.h '-I "^#include [<\"]\(asm/\)*msr-index.h"' 190 check arch/arm64/include/asm/cputype.h '-I "^# 164 check arch/arm64/include/asm/cputype.h '-I "^#include [<\"]\(asm/\)*sysreg.h"' 191 check include/linux/unaligned.h '-I "^#include << 192 check include/uapi/asm-generic/mman.h '-I "^#i 165 check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common\(-tools\)*.h>"' 193 check include/uapi/linux/mman.h '-I "^#i 166 check include/uapi/linux/mman.h '-I "^#include <\(uapi/\)*asm/mman.h>"' 194 check include/linux/build_bug.h '-I "^#\ 167 check include/linux/build_bug.h '-I "^#\(ifndef\|endif\)\( \/\/\)* static_assert$"' 195 check include/linux/ctype.h '-I "isd 168 check include/linux/ctype.h '-I "isdigit("' 196 check lib/ctype.c '-I "^EX 169 check lib/ctype.c '-I "^EXPORT_SYMBOL" -I "^#include <linux/export.h>" -B' >> 170 check lib/list_sort.c '-I "^#include <linux/bug.h>"' 197 171 198 # diff non-symmetric files 172 # diff non-symmetric files 199 check_2 tools/perf/arch/x86/entry/syscalls/sys << 200 check_2 tools/perf/arch/x86/entry/syscalls/sys 173 check_2 tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86/entry/syscalls/syscall_64.tbl 201 check_2 tools/perf/arch/powerpc/entry/syscalls 174 check_2 tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/powerpc/kernel/syscalls/syscall.tbl 202 check_2 tools/perf/arch/s390/entry/syscalls/sy 175 check_2 tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/s390/kernel/syscalls/syscall.tbl 203 check_2 tools/perf/arch/mips/entry/syscalls/sy 176 check_2 tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl arch/mips/kernel/syscalls/syscall_n64.tbl 204 177 205 for i in "${BEAUTY_FILES[@]}" 178 for i in "${BEAUTY_FILES[@]}" 206 do 179 do 207 beauty_check "$i" -B 180 beauty_check "$i" -B 208 done 181 done 209 182 210 # check duplicated library files 183 # check duplicated library files 211 check_2 tools/perf/util/hashmap.h tools/lib/bp 184 check_2 tools/perf/util/hashmap.h tools/lib/bpf/hashmap.h 212 check_2 tools/perf/util/hashmap.c tools/lib/bp 185 check_2 tools/perf/util/hashmap.c tools/lib/bpf/hashmap.c 213 << 214 # Files with larger differences << 215 << 216 check_ignore_some_hunks lib/list_sort.c << 217 186 218 cd tools/perf || exit 187 cd tools/perf || exit 219 188 220 if [ ${#FAILURES[@]} -gt 0 ] 189 if [ ${#FAILURES[@]} -gt 0 ] 221 then 190 then 222 echo -e "${YELLOW}Warning${NC}: Kernel ABI h 191 echo -e "${YELLOW}Warning${NC}: Kernel ABI header differences:" 223 for i in "${FAILURES[@]}" 192 for i in "${FAILURES[@]}" 224 do 193 do 225 echo " diff -u $i" 194 echo " diff -u $i" 226 done 195 done 227 fi 196 fi
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.