diff --git a/scripts/generate-kernel-patch b/scripts/generate-kernel-patch index 8800e589e..b6f3544e1 100755 --- a/scripts/generate-kernel-patch +++ b/scripts/generate-kernel-patch @@ -5,7 +5,7 @@ # Script for converting the SCST source tree as it exists in the Subversion # repository to a Linux kernel patch. # -# Copyright (C) 2008-2009 Bart Van Assche +# Copyright (C) 2008-2020 Bart Van Assche # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -105,6 +105,28 @@ EOF # Run the script specialize_patch with appropriate options on the patch # passed via stdin and send the specialized patch to stdout. function specialize_patch { + local ao + set -- ${1//^/ } + local kver=$1 + local distro=$2 + local release=$3 + set -- ${release//./ } + local releasevermajor="$1" + local releaseverminor="$2" + if [ -n "$releasevermajor" ]; then + ao=( + -v "RHEL_MAJOR=$releasevermajor" + -v "RHEL_MINOR=$releaseverminor" + -v "RHEL_RELEASE_CODE=$((releasevermajor * 256 + releaseverminor))" + ) + fi + local kver3 + set -- ${kver//[.-]/ } + if [ -n "$3" ]; then + kver3=$1.$2.$3 + else + kver3=$1.$2 + fi if [ "${enable_specialize}" = "true" ]; then if [ "${generating_upstream_patch}" = "true" ]; then scripts/filter-trace-entry-exit @@ -114,13 +136,13 @@ function specialize_patch { "$(dirname "$0")/specialize-patch" \ "${specialize_patch_options[@]}" \ -v kernel_version="${kver3}" \ - -v SCST_IO_CONTEXT="${scst_io_context}" + -v SCST_IO_CONTEXT="${scst_io_context}" "${ao[@]}" else cat fi } -# Read a patch from stdin, specialize it for kernel version ${kver} +# Read a patch from stdin, specialize it for kernel version ${full_kver} # and write the output either to stdout or to the file $1 (if not empty), # depending on the value of the variable ${multiple_patches}. function process_patch { @@ -132,7 +154,7 @@ function process_patch { fi tmppatch="$(/bin/mktemp)" ( - specialize_patch + specialize_patch "${full_kver}" ) >"${tmppatch}" touch "${tmppatch}" { @@ -151,7 +173,7 @@ function process_patch { true fi else - specialize_patch + specialize_patch "${full_kver}" fi } @@ -208,13 +230,8 @@ if [ $# != 1 ]; then fi # Strip patch level from the kernel version number. +full_kver="$1" kver="$(kernel_version "$1")" -# kver3: first three components of the version number. -if [ "${1#2.}" != "$1" ]; then - kver3="$kver" -else - kver3="$1" -fi # Include fcst in the patch for kernel versions 2.6.33 and later. if kernel_version_le "2.6.37" "${kver}"; then @@ -280,7 +297,6 @@ done # General kernel patches. -scsi_exec_req_fifo_defined=0 scst_io_context=0 scst_03_public_headers="scst/include/scst.h scst/include/scst_const.h \ @@ -325,7 +341,8 @@ else "drivers/Kconfig" fi -if [ -e "scst/kernel/in-tree/Makefile.drivers.Linux-${kver}.patch" ]; then +if [ "${full_kver#2.6.32-}" = "${full_kver}" ] && + [ -e "scst/kernel/in-tree/Makefile.drivers.Linux-${kver}.patch" ]; then add_patch "scst/kernel/in-tree/Makefile.drivers.Linux-${kver}.patch"\ "drivers/Makefile" else @@ -441,7 +458,7 @@ if [ "${include_fcst}" = true ]; then done fi - add_file "fcst/Makefile_in-tree" \ + add_file "fcst/Kbuild" \ "drivers/scst/fcst/Makefile" add_file "fcst/Kconfig" "drivers/scst/fcst/Kconfig" @@ -506,7 +523,7 @@ add_file "iscsi-scst/README_in-tree" "Documentation/scst/README.iscsi" \ if [ "${qla2x00t}" = "true" ]; then - ( cd qla2x00t && ./generate-in-tree-patches "$1" ) + ( cd qla2x00t && "$PWD/generate-in-tree-patches" "$1" ) || exit $? for f in qla2x00t/in-tree-patches/"$1"/*.patch; do [ -e "$f" ] || continue @@ -532,13 +549,17 @@ if [ "${qla2x00t}" = "true" ]; then elif [ "${qla2x00t_32gbit}" = "true" ]; then - ( cd qla2x00t-32gbit && ./generate-in-tree-patches "$1" ) + ( cd qla2x00t-32gbit && "$PWD/generate-in-tree-patches" "$1" ) || exit $? for f in qla2x00t-32gbit/in-tree-patches/"$1"/*.patch; do [ -e "$f" ] || continue g="${f#qla2x00t-32gbit/in-tree-patches/$1/}" g="${g%.patch}" - add_patch "${f}" "drivers/scsi/qla2xxx/${g}" + if [ "$g" = "qla.h" ]; then + add_patch "${f}" "include/trace/events/${g}" + else + add_patch "${f}" "drivers/scsi/qla2xxx/${g}" + fi done for f in qla2x00t-32gbit/qla2x00-target/*.[ch]; do diff --git a/scripts/kernel-functions b/scripts/kernel-functions index 87f75119e..07b1d9d09 100644 --- a/scripts/kernel-functions +++ b/scripts/kernel-functions @@ -2,6 +2,9 @@ # Shell functions for parsing the Linux kernel version and for downloading # from kernel.org. +# shellcheck source=./rhel-rpm-functions +source "$(dirname "$0")/../scripts/rhel-rpm-functions" || return $? + kernel_mirror="http://cdn.kernel.org/pub/linux/kernel" kernel_downloads="$HOME/software/downloads" kernel_tree="$HOME/software/linux-kernel" @@ -124,8 +127,92 @@ function extract_kernel_tree { # Patch a kernel tree where $1 is the kernel version. function patch_kernel { - if [ "$1" = "2.6.29" ] || [ "$1" = "2.6.29.1" ] || [ "$1" = "2.6.29.2" ] || [ "$1" = "2.6.29.3" ] - then + case "$1" in + *^*) + # RHEL / CentOS. + ;; + *) + # See also commit f153b82121b0 ("Sanitize gcc version header + # includes") # v2.6.29. See also commit 71458cfc782e ("kernel: add + # support for gcc 5") # v3.18. See also commit cb984d101b30 + # ("compiler-gcc: integrate the various compiler-gcc[345].h + # files") # v4.2. + if kernel_version_le 2.6.29 $1 && kernel_version_lt $1 4.2; then + # Tell the kernel that we are using gcc 4.6 since older kernel + # versions do not support recent gcc versions. + patch -f -s -p1 <<'EOF' || +diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h +index 02ae99e8e6d3..47e12c19c965 100644 +--- a/include/linux/compiler-gcc.h ++++ b/include/linux/compiler-gcc.h +@@ -103,7 +103,7 @@ + #define __gcc_header(x) #x + #define _gcc_header(x) __gcc_header(linux/compiler-gcc##x.h) + #define gcc_header(x) _gcc_header(x) +-#include gcc_header(__GNUC__) ++#include "linux/compiler-gcc4.h" + + #if !defined(__noclone) + #define __noclone /* not needed */ +EOF + patch -f -s -p1 <<'EOF' +diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h +index a3ed7cb8ca34..c5a6b8b52db4 100644 +--- a/include/linux/compiler-gcc.h ++++ b/include/linux/compiler-gcc.h +@@ -83,4 +83,4 @@ + #define __gcc_header(x) #x + #define _gcc_header(x) __gcc_header(linux/compiler-gcc##x.h) + #define gcc_header(x) _gcc_header(x) +-#include gcc_header(__GNUC__) ++#include "linux/compiler-gcc4.h" +EOF + patch -f -s -p1 <<'EOF' || +diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h +index 769e19864632..2ec6c7a11502 100644 +--- a/include/linux/compiler-gcc4.h ++++ b/include/linux/compiler-gcc4.h +@@ -2,13 +2,6 @@ + #error "Please don't include directly, include instead." + #endif + +-/* GCC 4.1.[01] miscompiles __weak */ +-#ifdef __KERNEL__ +-# if GCC_VERSION >= 40100 && GCC_VERSION <= 40101 +-# error Your version of gcc miscompiles the __weak directive +-# endif +-#endif +- + #define __used __attribute__((__used__)) + #define __must_check __attribute__((warn_unused_result)) + #define __compiler_offsetof(a,b) __builtin_offsetof(a,b) +EOF + patch -f -s -p1 <<'EOF' +diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h +index 412bc6c2b023..901ca31be7f8 100644 +--- a/include/linux/compiler-gcc4.h ++++ b/include/linux/compiler-gcc4.h +@@ -2,13 +2,6 @@ + #error "Please don't include directly, include instead." + #endif + +-/* GCC 4.1.[01] miscompiles __weak */ +-#ifdef __KERNEL__ +-# if __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ <= 1 +-# error Your version of gcc miscompiles the __weak directive +-# endif +-#endif +- + #define __used __attribute__((__used__)) + #define __must_check __attribute__((warn_unused_result)) + #define __compiler_offsetof(a,b) __builtin_offsetof(a,b) +EOF + fi + ;; + esac + + if [ "$1" = "2.6.29" ] || [ "$1" = "2.6.29.1" ] || [ "$1" = "2.6.29.2" ] || + [ "$1" = "2.6.29.3" ]; then patch -f -s -p1 <<'EOF' Make sure that branch profiling does not trigger sparse warnings. See also http://bugzilla.kernel.org/show_bug.cgi?id=12925 @@ -145,8 +232,8 @@ See also http://lkml.org/lkml/2009/4/5/120 #define likely_notrace(x) __builtin_expect(!!(x), 1) EOF fi - if [ "${1#2.6.31}" != "$1" ] - then + + if [ "${1#2.6.31}" != "$1" ]; then patch -f -s -p1 <<'EOF' Checking a 2.6.31.1 kernel configured with allyesconfig/allmodconfig with sparse (make C=2) triggers a sparse warning on code that uses the @@ -200,6 +287,7 @@ Get rid of sparse errors on sk_buff.protocol. #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) EOF fi + if [ "${1#3.13}" != "$1" ]; then if [ "$1" = "3.13" ] || [ "${1#3.13.}" -lt 6 ]; then patch -f -s -p1 <<'EOF' @@ -241,6 +329,7 @@ index 3f2793d..96e45ea 100644 EOF fi fi + if [ "${1#4.15}" != "$1" ]; then patch -f -s -p1 <<'EOF' From ad343a98e74e85aa91d844310e797f96fee6983b Mon Sep 17 00:00:00 2001 @@ -331,9 +420,9 @@ index d6d65537b0d9..6aad8308a0ac 100644 } EOF fi - case "$1" in - 2.6.3[6-9]*|3.[0-9]|3.[0-9].*|3.1[01345]|3.1[01345].*|3.1[789]|3.1[789].*|4.[023567]|4.[023567].*) - patch -p1 <<'EOF' + + if kernel_version_le 2.6.36 $1 && kernel_version_lt $1 4.8; then + patch -f -s -p1 <<'EOF' From c6a385539175ebc603da53aafb7753d39089f32e Mon Sep 17 00:00:00 2001 From: Borislav Petkov Date: Mon, 14 Nov 2016 19:41:31 +0100 @@ -395,9 +484,36 @@ index 0ed6ce300543..c324b43712f0 100644 KBUILD_CFLAGS_MODULE := -DMODULE KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds EOF - ;; - 2.6.3[1-5]*) - patch -p1 <<'EOF' + else + case "$1" in + # CentOS 6.x. + 2.6.32-*) + patch -f -s -p1 <<'EOF' +--- linux-2.6.32-754.29.1.el6/Makefile.orig 2020-05-13 14:09:18.448503420 -0700 ++++ linux-2.6.32-754.29.1.el6/Makefile 2020-05-13 14:11:24.265441790 -0700 +@@ -355,7 +355,8 @@ + + KBUILD_CPPFLAGS := -D__KERNEL__ + +-KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ ++KBUILD_CFLAGS := $(call cc-option,-fno-PIE) \ ++ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ + -fno-strict-aliasing -fno-common \ + -Werror-implicit-function-declaration \ + -Wno-format-security \ +@@ -380,7 +381,7 @@ + endif ##($(KBUILD_EXTMOD),) + endif #(,$(filter $(ARCH), i386 x86_64)) + +-KBUILD_AFLAGS := -D__ASSEMBLY__ ++KBUILD_AFLAGS := -D__ASSEMBLY__ $(call cc-option,-fno-PIE) + + # Read KERNELRELEASE from include/config/kernel.release (if it exists) + KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) +EOF + ;; + 2.6.3[1-5]*) + patch -f -s -p1 <<'EOF' diff --git a/Makefile b/Makefile index 141da26fda4b..343ec388ae2e 100644 --- a/Makefile @@ -418,10 +534,213 @@ index 141da26fda4b..343ec388ae2e 100644 # Read KERNELRELEASE from include/config/kernel.release (if it exists) KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) +EOF + ;; + esac + fi + + case "$1" in + 4.18.0-*) # CentOS 8.x + patch -f -s -p1 <<'EOF' +From a6e60d84989fa0e91db7f236eda40453b0e44afa Mon Sep 17 00:00:00 2001 +From: Miguel Ojeda +Date: Sat, 19 Jan 2019 20:59:34 +0100 +Subject: [PATCH] include/linux/module.h: copy __init/__exit attrs to + init/cleanup_module + +The upcoming GCC 9 release extends the -Wmissing-attributes warnings +(enabled by -Wall) to C and aliases: it warns when particular function +attributes are missing in the aliases but not in their target. + +In particular, it triggers for all the init/cleanup_module +aliases in the kernel (defined by the module_init/exit macros), +ending up being very noisy. + +These aliases point to the __init/__exit functions of a module, +which are defined as __cold (among other attributes). However, +the aliases themselves do not have the __cold attribute. + +Since the compiler behaves differently when compiling a __cold +function as well as when compiling paths leading to calls +to __cold functions, the warning is trying to point out +the possibly-forgotten attribute in the alias. + +In order to keep the warning enabled, we decided to silence +this case. Ideally, we would mark the aliases directly +as __init/__exit. However, there are currently around 132 modules +in the kernel which are missing __init/__exit in their init/cleanup +functions (either because they are missing, or for other reasons, +e.g. the functions being called from somewhere else); and +a section mismatch is a hard error. + +A conservative alternative was to mark the aliases as __cold only. +However, since we would like to eventually enforce __init/__exit +to be always marked, we chose to use the new __copy function +attribute (introduced by GCC 9 as well to deal with this). +With it, we copy the attributes used by the target functions +into the aliases. This way, functions that were not marked +as __init/__exit won't have their aliases marked either, +and therefore there won't be a section mismatch. + +Note that the warning would go away marking either the extern +declaration, the definition, or both. However, we only mark +the definition of the alias, since we do not want callers +(which only see the declaration) to be compiled as if the function +was __cold (and therefore the paths leading to those calls +would be assumed to be unlikely). + +Link: https://lore.kernel.org/lkml/20190123173707.GA16603@gmail.com/ +Link: https://lore.kernel.org/lkml/20190206175627.GA20399@gmail.com/ +Suggested-by: Martin Sebor +Acked-by: Jessica Yu +Signed-off-by: Miguel Ojeda +--- + include/linux/module.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/include/linux/module.h b/include/linux/module.h +index 8fa38d3e7538..f5bc4c046461 100644 +--- a/include/linux/module.h ++++ b/include/linux/module.h +@@ -129,13 +129,13 @@ extern void cleanup_module(void); + #define module_init(initfn) \ + static inline initcall_t __maybe_unused __inittest(void) \ + { return initfn; } \ +- int init_module(void) __attribute__((alias(#initfn))); ++ int init_module(void) __attribute__((__copy__(initfn))) __attribute__((alias(#initfn))); + + /* This is only required if you want to be unloadable. */ + #define module_exit(exitfn) \ + static inline exitcall_t __maybe_unused __exittest(void) \ + { return exitfn; } \ +- void cleanup_module(void) __attribute__((alias(#exitfn))); ++ void cleanup_module(void) __attribute__((__copy__(exitfn))) __attribute__((alias(#exitfn))); + + #endif + +EOF + ;; + 2.*|3.*) + patch -f -s -p1 <<'EOF' +--- linux-3.10.0-1127.el7/include/linux/init.h.orig 2020-05-09 20:55:48.638956513 -0700 ++++ linux-3.10.0-1127.el7/include/linux/init.h 2020-05-09 20:56:46.947612445 -0700 +@@ -309,13 +309,15 @@ + #define module_init(initfn) \ + static inline initcall_t __inittest(void) \ + { return initfn; } \ +- int init_module(void) __attribute__((alias(#initfn))); ++ int init_module(void) __attribute__((__copy__(initfn))) \ ++ __attribute__((alias(#initfn))); + + /* This is only required if you want to be unloadable. */ + #define module_exit(exitfn) \ + static inline exitcall_t __exittest(void) \ + { return exitfn; } \ +- void cleanup_module(void) __attribute__((alias(#exitfn))); ++ void cleanup_module(void) __attribute__((__copy__(exitfn)))\ ++ __attribute__((alias(#exitfn))); + + #define __setup_param(str, unique_id, fn) /* nothing */ + #define __setup(str, func) /* nothing */ EOF ;; esac + if kernel_version_le 3.2 $1 && kernel_version_lt $1 3.18; then + patch -f -s -p1 <<'EOF' +From eeeda4cd06e828b331b15741a204ff9f5874d28d Mon Sep 17 00:00:00 2001 +From: Ben Hutchings +Date: Wed, 24 Sep 2014 13:30:12 +0100 +Subject: [PATCH] x86/relocs: Make per_cpu_load_addr static + +per_cpu_load_addr is only used for 64-bit relocations, but is +declared in both configurations of relocs.c - with different +types. This has undefined behaviour in general. GNU ld is +documented to use the larger size in this case, but other tools +may differ and some warn about this. + +References: https://bugs.debian.org/748577 +Reported-by: Michael Tautschnig +Signed-off-by: Ben Hutchings +Cc: 748577@bugs.debian.org +Cc: Linus Torvalds +Link: http://lkml.kernel.org/r/1411561812.3659.23.camel@decadent.org.uk +Signed-off-by: Ingo Molnar +--- + arch/x86/tools/relocs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c +index bbb1d2259ecf..a5efb21d5228 100644 +--- a/arch/x86/tools/relocs.c ++++ b/arch/x86/tools/relocs.c +@@ -695,7 +695,7 @@ static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel, + * + */ + static int per_cpu_shndx = -1; +-Elf_Addr per_cpu_load_addr; ++static Elf_Addr per_cpu_load_addr; + + static void percpu_init(void) + { +EOF + fi + + # See also commit e33a814e772c ("scripts/dtc: Remove redundant YYLOC global + # declaration") # v5.6~10^2. + if kernel_version_lt $1 5.6; then + patch -p1 -f -s <<'EOF' +From e33a814e772cdc36436c8c188d8c42d019fda639 Mon Sep 17 00:00:00 2001 +From: Dirk Mueller +Date: Tue, 14 Jan 2020 18:53:41 +0100 +Subject: [PATCH] scripts/dtc: Remove redundant YYLOC global declaration + +gcc 10 will default to -fno-common, which causes this error at link +time: + + (.text+0x0): multiple definition of `yylloc'; dtc-lexer.lex.o (symbol from plugin):(.text+0x0): first defined here + +This is because both dtc-lexer as well as dtc-parser define the same +global symbol yyloc. Before with -fcommon those were merged into one +defintion. The proper solution would be to to mark this as "extern", +however that leads to: + + dtc-lexer.l:26:16: error: redundant redeclaration of 'yylloc' [-Werror=redundant-decls] + 26 | extern YYLTYPE yylloc; + | ^~~~~~ +In file included from dtc-lexer.l:24: +dtc-parser.tab.h:127:16: note: previous declaration of 'yylloc' was here + 127 | extern YYLTYPE yylloc; + | ^~~~~~ +cc1: all warnings being treated as errors + +which means the declaration is completely redundant and can just be +dropped. + +Signed-off-by: Dirk Mueller +Signed-off-by: David Gibson +[robh: cherry-pick from upstream] +Cc: stable@vger.kernel.org +Signed-off-by: Rob Herring +--- + scripts/dtc/dtc-lexer.l | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/scripts/dtc/dtc-lexer.l b/scripts/dtc/dtc-lexer.l +index 5c6c3fd557d7..b3b7270300de 100644 +--- a/scripts/dtc/dtc-lexer.l ++++ b/scripts/dtc/dtc-lexer.l +@@ -23,7 +23,6 @@ LINECOMMENT "//".*\n + #include "srcpos.h" + #include "dtc-parser.tab.h" + +-YYLTYPE yylloc; + extern bool treesource_error; + + /* CAUTION: this will stop working if we ever use yyless() or yyunput() */ +EOF + fi + # Use sed to patch the ____ilog2_NaN() prototype. sed -i 's/__attribute__((const, noreturn))/__attribute__((noreturn))/' \ include/linux/log2.h tools/include/linux/log2.h 2>/dev/null @@ -435,10 +754,37 @@ EOF done } +function download_and_extract_distro_rpm { + [ -n "$1" ] || return $? + set -- ${1//^/ } + local kver=$1 + local distro=$2 + local release=$3 + ( + cd "${kernel_downloads}" || exit $? + read -a urls -r <<<"$(get_srpm_urls "$distro" "$release" x86_64 | + tr '\n' ' ')" + for url in "${urls[@]}"; do + wget -q -nc "${url}/kernel-${kver}.src.rpm" && break + done + ) + local tmpdir=kernel-tree-tmp-$$ + rm -rf "linux-$1" "${tmpdir}" + mkdir "${tmpdir}" || return $? + ( + cd "${tmpdir}" && + rpm2cpio "${kernel_downloads}/kernel-${kver}.src.rpm" | + cpio -i --make-directories --quiet && + tar xaf "linux-${kver}.tar."* && + mv "linux-${kver}" ".." && + cd "../linux-${kver}" + ) || return $? + rm -rf "${tmpdir}" +} + function download_and_extract_kernel_tree { if [ -e "${kernel_tree}" ]; then - rm -rf "linux-$1" - mkdir "linux-$1" + { [ "${1/^}" = "$1" ] && ( cd "${kernel_tree}" && { @@ -450,12 +796,17 @@ function download_and_extract_kernel_tree { git fetch stable } } && + { git tag -l "v$1" | grep -q '^v'; } && git archive "v$1" - ) | tar -C "linux-$1" -xf- + ) | { + rm -rf "linux-$1" && + mkdir "linux-$1" && + tar -C "linux-$1" -xf- 2>/dev/null + }; } || download_and_extract_distro_rpm "$1" else download_kernel "$1" && extract_kernel_tree "$1" fi && - (cd "linux-$1" && patch_kernel "$1") + (cd "linux-${1/^*}" && patch_kernel "${1/^*}") } # For shellcheck diff --git a/scripts/list-source-files b/scripts/list-source-files index 09550eed8..06b22a3cc 100755 --- a/scripts/list-source-files +++ b/scripts/list-source-files @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh list_source_files() { local d r @@ -39,7 +39,17 @@ list_source_files() { hg manifest fi else - ( cd "$d" && find . -type f -o -type l | sed 's|^\./||' ) + ( + cd "$d" && + find . -type f -o -type l | \ + sed -e 's|^\./||' \ + -e '\|\.k\{0,1\}o\(\.\(cm\)\{0,1\}d\)\{0,1\}$|d' \ + -e '\|\.mod\(\.c\)\{0,1\}$|d' \ + -e '\|/conftest/.*/result-.*\.txt$|d' \ + -e '\|/modules\.order$|d' \ + -e '\,/Module\.\(symver\|marker\)s$,d' \ + -e '\,/\.tmp_versions\(/\|$\),d' + ) fi } diff --git a/scripts/rhel-rpm-functions b/scripts/rhel-rpm-functions new file mode 100644 index 000000000..69e86aada --- /dev/null +++ b/scripts/rhel-rpm-functions @@ -0,0 +1,108 @@ +# -*- mode: shell-script -*- +# Shell functions for downloading and extracting a RHEL or RHEL clone RPM + +# Arguments: +# $1: Linux distribution name +# $2: Linux distribution version (major.minor) +# $3: architecture +function get_srpm_urls() { + local arch distro releasever releasevermajor releaseverminor + + distro="$1" + releasever="$2" + arch="$3" + set -- ${2//./ } + releasevermajor="$1" + releaseverminor="$2" + + case "$distro" in + "CentOS"*) + case $releasever in + 5.*|6.[01]) + echo "http://vault.centos.org/${releasever}/os/SRPMS" + echo "http://vault.centos.org/${releasever}/updates/SRPMS";; + [67]*) + echo "http://vault.centos.org/${releasever}/os/Source/SPackages" + echo "http://vault.centos.org/${releasever}/updates/Source/SPackages";; + 8*) + echo "http://vault.centos.org/${releasever}/BaseOS/Source/SPackages/";; + esac + ;; + "Red Hat Enterprise Linux"*) + case $releasever in + [56].*) + echo "http://ftp.redhat.com/pub/redhat/linux/enterprise/${releasevermajor}Server/en/os/SRPMS" + echo "http://ftp.redhat.com/redhat/rhel/rc/7/Server/source/tree/Packages";; + esac + ;; + "Oracle Linux Server") + echo "http://public-yum.oracle.com/repo/OracleLinux/OL${releasevermajor}/${releaseverminor}/base/${arch}/getPackageSource" + echo "http://public-yum.oracle.com/repo/OracleLinux/OL${releasevermajor}/latest/${arch}/getPackageSource" + echo "http://public-yum.oracle.com/repo/OracleLinux/OL${releasevermajor}/UEK/latest/${arch}/getPackageSource" + ;; + "Scientific Linux") + case $releasever in + 5.*) + echo "http://ftp.scientificlinux.org/linux/scientific/$releasevermajor$releaseverminor/SRPMS/vendor";; + 6.*) + echo "http://ftp.scientificlinux.org/linux/scientific/$releasever/SRPMS/vendor";; + esac + ;; + *) + echo "Unknown type of distribution: $distro" >&2 + return 1 + ;; + esac +} + +# Arguments: +# $1: Linux distribution name +# $2: Linux distribution version (major.minor) +# $3: architecture +function get_rpm_urls() { + local arch distro releasever releasevermajor releaseverminor + + distro="$1" + releasever="$2" + arch="$3" + set -- ${2//./ } + releasevermajor="$1" + releaseverminor="$2" + + case "$distro" in + "CentOS"*) + case $releasever in + 5.*) + echo "http://vault.centos.org/${releasever}/os/${arch}/CentOS http://vault.centos.org/${releasever}/updates/${arch}/RPMS";; + 6.[01]) + echo "http://vault.centos.org/${releasever}/os/${arch}/Packages" + echo "http://vault.centos.org/${releasever}/updates/${arch}/Packages";; + [67]*) + echo "https://mirrors.edge.kernel.org/centos/${releasever}/updates/${arch}/Packages" + echo "http://vault.centos.org/${releasever}/updates/${arch}/Packages" + echo "http://vault.centos.org/${releasever}/os/${arch}/Packages http://vault.centos.org/${releasever}/updates/${arch}/Packages";; + 8*) + echo "https://mirrors.edge.kernel.org/centos/8-stream/BaseOS/${arch}/os/Packages";; + esac + ;; + "Red Hat Enterprise Linux"*) + echo "";; + "Oracle Linux Server") + echo "http://public-yum.oracle.com/repo/OracleLinux/OL${releasevermajor}/${releaseverminor}/base/${arch}/getPackageSource" + echo "http://public-yum.oracle.com/repo/OracleLinux/OL${releasevermajor}/latest/${arch}/getPackageSource" + echo "http://public-yum.oracle.com/repo/OracleLinux/OL${releasevermajor}/UEK/latest/${arch}/getPackageSource" + ;; + "Scientific Linux") + case $releasever in + 5.*) + echo "http://ftp.scientificlinux.org/linux/scientific/$releasevermajor$releaseverminor/SRPMS/vendor";; + 6.*) + echo "http://ftp.scientificlinux.org/linux/scientific/$releasever/SRPMS/vendor";; + esac + ;; + *) + echo "Unknown distribution type: $distro" >&2 + return 1 + ;; + esac +} diff --git a/scripts/run-regression-tests b/scripts/run-regression-tests index fa669dc4c..94a8bb483 100755 --- a/scripts/run-regression-tests +++ b/scripts/run-regression-tests @@ -4,7 +4,7 @@ # # Script for running those SCST regression tests that can be run automatically. # -# Copyright (C) 2008-2009 Bart Van Assche +# Copyright (C) 2008-2020 Bart Van Assche # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -176,7 +176,7 @@ function compile_scst_no_dlm { ) } -# Test out-of-tree compilation agains the kernel header files in +# Test out-of-tree compilation against the kernel header files in # /lib/modules/$(uname -r)/build. function compile_scst_patched { local scst="$PWD" @@ -199,22 +199,23 @@ function compile_scst_patched { } # Generate a kernel patch from the SCST source tree for kernel version $1 -# and with generate-kernel-patch options $2. +# and with generate-kernel-patch options $2. $1 may be a +# ${kver}^${distro}^${release} triplet. function generate_kernel_patch { local kver - local patchfile="${outputdir}/scst-$1-kernel.patch" - local patchfile_m="${outputdir}/scst-$1-kernel-matching-line-numbers.patch" + local patchfile="${outputdir}/scst-${1/^*}-kernel.patch" + local patchfile_m="${outputdir}/scst-${1/^*}-kernel-matching-line-numbers.patch" local driver_options="" - kver="$(kernel_version "$1")" + kver="$(kernel_version "${1/^*}")" driver_options=(-l) [ "${mpt_scst}" = "true" ] && driver_options+=("-m") - "${scriptsdir}"/generate-kernel-patch "${driver_options[@]}" "$2" "$1" > "${patchfile}" + "${scriptsdir}"/generate-kernel-patch "${driver_options[@]}" $2 "$1" > "${patchfile}" - "${scriptsdir}"/generate-kernel-patch "${driver_options[@]}" -n "$2" "$1" > "${patchfile_m}" + "${scriptsdir}"/generate-kernel-patch "${driver_options[@]}" -n $2 "$1" > "${patchfile_m}" - "${scriptsdir}"/generate-kernel-patch "${driver_options[@]}" -p "${outputdir}/${patchdir}" "$2" "$1" + "${scriptsdir}"/generate-kernel-patch "${driver_options[@]}" -p "${outputdir}/${patchdir}" $2 "$1" } # Run checkpatch on the generated kernel patch. Assumes that there is a @@ -262,15 +263,16 @@ function patch_and_configure_kernel { kver="$(kernel_version "$1")" local patchfile="${outputdir}/scst-$1-kernel-matching-line-numbers.patch" local patchoutput="${outputdir}/patch-command-output-$1.txt" + local configureoutput="${outputdir}/configure-output.txt" local disable=" \ CONFIG_BINARY_PRINTF \ CONFIG_BLK_DEV_IO_TRACE \ CONFIG_BRANCH_PROFILE_NONE \ CONFIG_CONTEXT_SWITCH_TRACER \ +CONFIG_DEBUG_SECTION_MISMATCH \ CONFIG_DEBUG_STRICT_USER_COPY_CHECKS \ CONFIG_DYNAMIC_FTRACE \ CONFIG_EVENT_TRACE_TEST_SYSCALLS \ -CONFIG_EVENT_TRACING \ CONFIG_FTRACE \ CONFIG_FTRACE_MCOUNT_RECORD \ CONFIG_FTRACE_NMI_ENTER \ @@ -292,6 +294,7 @@ CONFIG_MMIOTRACE \ CONFIG_NET_DROP_MONITOR \ CONFIG_NOP_TRACER \ CONFIG_RETPOLINE \ +CONFIG_RH_KABI_SIZE_ALIGN_CHECKS \ CONFIG_SCHED_TRACER \ CONFIG_SECURITY_SELINUX \ CONFIG_STACK_TRACER \ @@ -305,6 +308,18 @@ CONFIG_X86_X32 \ " local enable="CONFIG_UNWINDER_FRAME_POINTER" + case "$1" in + 2.6.32-*) + echo "Enabling CONFIG_EVENT_TRACING for CentOS 6.x" + enable="$enable \ + CONFIG_DEBUG_KERNEL \ + CONFIG_FTRACE \ + CONFIG_EVENT_TRACING \ + CONFIG_DYNAMIC_DEBUG";; + *) + disable="$disable CONFIG_EVENT_TRACING";; + esac + echo "Patching and configuring kernel ..." if [ "$ipv6" = "false" ]; then disable="$disable CONFIG_IPV6" @@ -312,7 +327,10 @@ CONFIG_X86_X32 \ ( cd "${outputdir}/linux-$1" && if [ "${multiple_patches}" = "false" ]; then - patch -p1 -f -s <"${patchfile}" >"${patchoutput}" + if ! patch -p1 -f -s <"${patchfile}" >"${patchoutput}"; then + echo "Error: applying ${patchfile} failed." + exit 1 + fi else rm -f "${patchoutput}" for p in "${outputdir}/${patchdir}"/*; do @@ -323,7 +341,11 @@ CONFIG_X86_X32 \ make -s allmodconfig &>"${outputdir}/make-config-output.txt" && for c in $disable; do sed -i.tmp "s/^$c=[ym]\$/$c=n/" .config; done && for c in $enable; do sed -i.tmp "s/^\(# \)*$c\(=.*\| is not set\)\$/$c=y/" .config; done && - make -s oldconfig /dev/null + make -s oldconfig "${configureoutput}" && + for c in $enable; do + grep -q "^$c=[ym]" .config || + echo "Enabling $c failed." + done ) } @@ -421,7 +443,7 @@ function run_smatch { kver="$(kernel_version "$1")" plevel="$(patchlevel "$1")" local outputfile="${outputdir}/smatch-$1-output.txt" - local disable="CONFIG_DYNAMIC_DEBUG" + local disable="" # "CONFIG_DYNAMIC_DEBUG" shift echo "Running smatch on the patched kernel in $* ..." @@ -630,7 +652,7 @@ do run_smatch="true" ipv6="true" global_multiple_patches="${multiple_patches}" - while [ "${kv%-?}" != "${kv}" ] || [ "${kv%-??}" != "${kv}" ]; do + while true; do kv_without_opt="${kv%-?}" if [ "${kv_without_opt}" = "${kv}" ]; then kv_without_opt="${kv%-??}" @@ -645,7 +667,7 @@ do '-nm') run_smatch="false";; '-u') generate_kernel_patch_options="-u";; '-p') multiple_patches="true";; - *) echo "Error: unknown option ${kopt}."; exit 1;; + *) break;; esac kv="${kv_without_opt}" done @@ -655,32 +677,24 @@ do generate_kernel_patch "$k" "${generate_kernel_patch_options}" || continue ( cd "${outputdir}" && - download_and_extract_kernel_tree "$k" && - cd "linux-$k/include/linux" && - if [ ! -e compiler-gcc6.h ]; then - for f in compiler-gcc5.h compiler-gcc4.h; do - if [ -e "$f" ]; then - cp "$f" compiler-gcc6.h - break - fi - done - fi + download_and_extract_kernel_tree "$k" ) || continue + k="${k/^*}" if [ "${run_checkpatch}" = "true" ]; then run_checkpatch "$k" fi - patch_and_configure_kernel "$k" + patch_and_configure_kernel "$k" || continue case "$k" in - 2.*|3.*) - # Tell the kernel that we are using gcc 4.6. - KCFLAGS="-U__GNUC__ -U__GNUC_MINOR__ -D__GNUC__=4 -D__GNUC_MINOR__=6" + 3.10.0-*) + # Make the CentOS 7.x build less noisy. + KCFLAGS+=" -Wno-deprecated-declarations"; esac # See also commit bd664f6b3e37 ("disable new gcc-7.1.1 warnings for now"; # v4.13) and commit 6f303d60534c ("gcc-9: silence 'address-of-packed-member' # warning"; v5.1). for w in -Wno-format-truncation -Wno-format-overflow -Wno-int-in-bool-context -Wno-address-of-packed-member; do - if gcc -c -xc - "$w" &/dev/null; then + if gcc -c -xc -E - "$w" &/dev/null; then KCFLAGS+=" $w" fi done diff --git a/scripts/specialize-patch b/scripts/specialize-patch index 40563a6fa..05f131c5d 100755 --- a/scripts/specialize-patch +++ b/scripts/specialize-patch @@ -66,90 +66,101 @@ function evaluate(stmnt, pattern, arg, op, result) { gsub("defined\\(REGISTER_MAD_AGENT_HAS_FLAGS_ARG\\)", "(LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0) || " \ - "RHEL_RELEASE_CODE -0 >= 6 * 256 + 10)", stmnt) + "RHEL_RELEASE_CODE -0 >= 6 * 256 + 9)", stmnt) gsub("SOCK_RECVMSG_HAS_FOUR_ARGS", "(LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0))", stmnt) gsub("defined\\(USE_PRE_440_WR_STRUCTURE\\)", - "(LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0))", stmnt) + "(LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) \\&\\& " \ + "RHEL_RELEASE_CODE -0 < 7 * 256 + 5)", stmnt) gsub("defined\\(IB_CREATE_CQ_HAS_INIT_ATTR\\)", "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) || " \ - "RHEL_RELEASE_CODE -0 >= 7 * 256 + 6)", stmnt) + "RHEL_RELEASE_CODE -0 >= 7 * 256 + 5)", stmnt) + + gsub("defined\\(CREATE_SEND_MAD_HAS_AH_ARG\\)", + "(LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16))", stmnt) gsub("defined\\(CREATE_SEND_MAD_HAS_BASE_ARG\\)", "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) || " \ - "RHEL_RELEASE_CODE -0 >= 7 * 256 + 6)", stmnt) + "RHEL_RELEASE_CODE -0 >= 7 * 256 + 5)", stmnt) gsub("defined\\(IB_CM_LISTEN_TAKES_FOURTH_ARG\\)", - "(LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0))", stmnt) + "(LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) \\&\\& " \ + "RHEL_RELEASE_CODE -0 < 7 * 256 + 5)", stmnt) + + gsub("IB_CLIENT_ADD_ONE_RETURNS_INT", + "(LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))", stmnt) gsub("defined\\(IB_CLIENT_REMOVE_TAKES_TWO_ARGS\\)", "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) || " \ - "RHEL_RELEASE_CODE -0 >= 7 * 256 + 6)", stmnt) - + "RHEL_RELEASE_CODE -0 >= 7 * 256 + 5)", stmnt) + gsub("defined\\(IB_QUERY_GID_HAS_ATTR_ARG\\)", "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) || " \ - "RHEL_RELEASE_CODE -0 >= 7 * 256 + 6)", stmnt) + "RHEL_RELEASE_CODE -0 >= 7 * 256 + 5)", stmnt) gsub("RDMA_CREATE_ID_TAKES_NET_ARG", "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) || " \ - "RHEL_RELEASE_CODE -0 >= 7 * 256 + 6)", stmnt) + "RHEL_RELEASE_CODE -0 >= 7 * 256 + 5)", stmnt) gsub("defined\\(HAVE_DEV_ATTR_MAX_RECV_SGE\\)", - "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0))", stmnt) + "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) || " \ + "RHEL_RELEASE_CODE -0 >= 7 * 256 + 7)", stmnt) gsub("HAVE_DEV_ATTR_MAX_SEND_SGE", "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) || " \ - "RHEL_RELEASE_CODE -0 >= 8 * 256 + 0)", stmnt) - - gsub("defined\\(HAVE_DEV_ATTR_MAX_RECV_SGE\\)", - "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) || " \ - "RHEL_RELEASE_CODE -0 >= 8 * 256 + 0)", stmnt) + "RHEL_RELEASE_CODE -0 >= 7 * 256 + 7)", stmnt) gsub("HAVE_RDMA_DESTROY_AH_WITH_FLAGS", - "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 21, 0))", stmnt) - + "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 21, 0) || " \ + "RHEL_RELEASE_CODE -0 >= 8 * 256 + 1)", stmnt) + gsub("HAVE_RDMA_DESTROY_AH", - "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))", stmnt) - + "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) || " \ + "RHEL_RELEASE_CODE -0 >= 7 * 256 + 5)", stmnt) + gsub("HAVE_RDMA_QUERY_GID", - "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0))", stmnt) + "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) || " \ + "RHEL_RELEASE_CODE -0 >= 8 * 256 + 1)", stmnt) gsub("HAVE_SRP_DATA_DESC_IMM", - "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 21, 0))", stmnt) + "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 21, 0) || " \ + "RHEL_RELEASE_CODE -0 >= 8 * 256 + 1)", stmnt) gsub("HAVE_STRUCT_SRP_LOGIN_REQ_RDMA", "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0))", stmnt) - gsub("defined\\(USE_PRE_440_WR_STRUCTURE\\)", - "(LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0))", stmnt) - gsub("defined\\(HAVE_IB_EVENT_GID_CHANGE\\)", "(LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0) || " \ - "RHEL_RELEASE_CODE -0 >= 6 * 256 + 10)", stmnt) + "RHEL_RELEASE_CODE -0 >= 6 * 256 + 9)", stmnt) gsub("defined\\(HAVE_IB_QUERY_DEVICE\\)", - "(LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0))", stmnt) + "(LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) \\&\\& " \ + "RHEL_RELEASE_CODE -0 < 7 * 256 + 5)", stmnt) gsub("defined\\(MAD_HANDLER_TAKES_SEND_BUF\\)", "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) || " \ - "RHEL_RELEASE_CODE -0 >= 7 * 256 + 6)", stmnt) + "RHEL_RELEASE_CODE -0 >= 7 * 256 + 5)", stmnt) gsub("defined\\(HAVE_IB_SET_CPI_RESP_TIME\\)", "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0) || " \ - "RHEL_RELEASE_CODE -0 >= 7 * 256 + 6)", stmnt) + "RHEL_RELEASE_CODE -0 >= 7 * 256 + 5)", stmnt) gsub("defined\\(IB_PD_HAS_LOCAL_DMA_LKEY\\)", "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0) || " \ - "RHEL_RELEASE_CODE -0 >= 7 * 256 + 6)", stmnt) + "RHEL_RELEASE_CODE -0 >= 7 * 256 + 5)", stmnt) gsub("defined\\(HAVE_IB_DMA_MAP_OPS\\)", "(LINUX_VERSION_CODE >= KERNEL_VERSION(0, 0, 0))", stmnt) gsub("HAVE_IB_SG_DMA_LEN", - "(LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0))", stmnt) + "(LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0) \\&\\& " \ + "RHEL_RELEASE_CODE -0 < 8 * 256 + 2)", stmnt) + + gsub("RDMA_REJECT_HAS_FOUR_ARGS", + "(LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))", stmnt) gsub("defined(ENABLE_NPIV)", 0, stmnt) @@ -162,7 +173,7 @@ function evaluate(stmnt, pattern, arg, op, result) { { sub(pattern, op[1] * 65536 + op[2] * 256 + op[3], stmnt) } - + gsub("defined\\(INSIDE_KERNEL_TREE\\)", "1", stmnt) gsub("defined\\(BACKPORT_LINUX_WORKQUEUE_TO_2_6_19\\)", "0", stmnt) @@ -170,7 +181,7 @@ function evaluate(stmnt, pattern, arg, op, result) { gsub("defined\\(CONFIG_SUSE_KERNEL\\)", "0", stmnt) gsub("defined\\(CONFIG_SCST_STRICT_SERIALIZING\\)", "0", stmnt) - + if (RHEL_MAJOR == "") { gsub("defined\\(RHEL_MAJOR\\)", "0", stmnt) @@ -268,13 +279,19 @@ function evaluate(stmnt, pattern, arg, op, result) { { sub(pattern, op[1] == 0, stmnt) } - + pattern = "![[:blank:]]*\\([[:blank:]]*(-*[0-9]+)[[:blank:]]*\\)" while (match(stmnt, pattern, op) != 0) { sub(pattern, op[1] == 0, stmnt) } - + + pattern = "\\([[:blank:]]*(-*[0-9]+)[[:blank:]]*\\)" + while (match(stmnt, pattern, op) != 0) + { + sub(pattern, op[1], stmnt) + } + pattern="(-*[0-9]+)[[:blank:]]*(\\*|/)[[:blank:]]*(-*[0-9]+)" while (match(stmnt, pattern, op) != 0) { @@ -283,7 +300,7 @@ function evaluate(stmnt, pattern, arg, op, result) { else if (op[2] == "/" && op[3] != 0) result = op[1] / op[3] sub(pattern, result, stmnt) } - + pattern="(-*[0-9]+)[[:blank:]]*(\\+|-)[[:blank:]]*(-*[0-9]+)" while (match(stmnt, pattern, op) != 0) { @@ -301,7 +318,7 @@ function evaluate(stmnt, pattern, arg, op, result) { else if (op[2] == ">>") result = int(op[1] / (2**op[3])) sub(pattern, result, stmnt) } - + pattern="(-*[0-9]+)[[:blank:]]*(<|<=|>|>=|==|!=)[[:blank:]]*(-*[0-9]+)" while (match(stmnt, pattern, op) != 0) { @@ -314,7 +331,7 @@ function evaluate(stmnt, pattern, arg, op, result) { else if (op[2] == "!=") result = op[1] != op[3] sub(pattern, result, stmnt) } - + pattern="(-*[0-9]+)[[:blank:]]*&&[[:blank:]]*\\([[:blank:]]*(-*[0-9]+)[[:blank:]]*\\)" while (match(stmnt, pattern, op) != 0) { @@ -326,43 +343,43 @@ function evaluate(stmnt, pattern, arg, op, result) { { sub(pattern, (op[1] != 0) && (op[2] != 0), stmnt) } - + pattern="^+#(if|elif)[[:blank:]]*([01])[[:blank:]]*&&[[:blank:]]*(!*[[:blank:]]*defined[[:blank:]]*\\([[:blank:]]*[A-Za-z0-9_]*[[:blank:]]*\\))$" while (match(stmnt, pattern, op) != 0) { stmnt = "+#" op[1] " " (op[2] != 0 ? op[3] : op[2]) } - + pattern="^+#(if|elif)[[:blank:]]*(!*[[:blank:]]*defined[[:blank:]]*\\([[:blank:]]*[A-Za-z0-9_]*[[:blank:]]*\\))&&[[:blank:]]*([01])[[:blank:]]*$" while (match(stmnt, pattern, op) != 0) { stmnt = "+#" op[1] " " (op[3] != 0 ? op[2] : op[3]) } - + pattern="^+#(if|elif)[[:blank:]]*(!*[[:blank:]]*[A-Za-z0-9_]*)[[:blank:]]*&&[[:blank:]]*([01])[[:blank:]]*$" while (match(stmnt, pattern, op) != 0) { stmnt = "+#" op[1] " " (op[3] != 0 ? op[2] : op[3]) } - + pattern="(-*[0-9]+)[[:blank:]]*\\|\\|[[:blank:]]*(-*[0-9]+)" while (match(stmnt, pattern, op) != 0) { sub(pattern, (op[1] != 0) || (op[2] != 0), stmnt) } - + pattern="^+#(if|elif)[[:blank:]]*([01])[[:blank:]]*\\|\\|[[:blank:]]*(!*[[:blank:]]*defined[[:blank:]]*\\([[:blank:]]*[A-Za-z0-9_]*[[:blank:]]*\\))$" while (match(stmnt, pattern, op) != 0) { stmnt = "+#" op[1] " " (op[2] == 0 ? op[3] : op[2]) } - + pattern="\\(([01])[[:blank:]]*\\|\\|[[:blank:]]*(!*[[:blank:]]*defined[[:blank:]]*\\([[:blank:]]*[A-Za-z0-9_]*[[:blank:]]*\\))\\)" while (match(stmnt, pattern, op) != 0) { sub(pattern, op[1] == 0 ? op[2] : op[1], stmnt) } - + pattern="\\([[:blank:]]*(-*[0-9]+)[[:blank:]]*\\)" while (match(stmnt, pattern, op) != 0) { @@ -393,6 +410,7 @@ function handle_if(evaluated) if ($0 ~ "LINUX_VERSION_CODE" \ || $0 ~ "CONFIG_SCST_PROC" \ || $0 ~ "CONFIG_SCST_STRICT_SERIALIZING" \ + || $0 ~ "CREATE_SEND_MAD_HAS_AH_ARG" \ || $0 ~ "CREATE_SEND_MAD_HAS_BASE_ARG" \ || $0 ~ "ENABLE_NPIV" \ || $0 ~ "FC_VPORT_CREATE_DEFINED" \ @@ -407,6 +425,7 @@ function handle_if(evaluated) || $0 ~ "HAVE_RDMA_QUERY_GID" \ || $0 ~ "HAVE_SRP_DATA_DESC_IMM" \ || $0 ~ "HAVE_STRUCT_SRP_LOGIN_REQ_RDMA" \ + || $0 ~ "IB_CLIENT_ADD_ONE_RETURNS_INT" \ || $0 ~ "IB_CLIENT_REMOVE_TAKES_TWO_ARGS" \ || $0 ~ "IB_CM_LISTEN_TAKES_FOURTH_ARG" \ || $0 ~ "IB_CREATE_CQ_HAS_INIT_ATTR" \ @@ -417,6 +436,7 @@ function handle_if(evaluated) || $0 ~ "MOFED_MAJOR" \ || $0 ~ "MOFED_MINOR" \ || $0 ~ "RDMA_CREATE_ID_TAKES_NET_ARG" \ + || $0 ~ "RDMA_REJECT_HAS_FOUR_ARGS" \ || $0 ~ "REGISTER_MAD_AGENT_HAS_FLAGS_ARG" \ || $0 ~ "RHEL_MAJOR" \ || $0 ~ "RHEL_MINOR" \ @@ -614,10 +634,13 @@ function dump_lines() { if (h[0] != "") printf "@@ -%d,%d +%d,%d @@%s\n",h[1],h[2]-lines_less_deleted,h[3],h[4]-lines_less_added,h[5] for (i = 0; i < lines; i++) { - gsub("BAD_WR_MODIFIER", - LINUX_VERSION_CODE < version_code("4.19.0") ? "" : "const", line[i]) - gsub("CM_HANDLER_EVENT_MODIFIER", - LINUX_VERSION_CODE < version_code("4.19.0") ? "" : "const", line[i]) + modifier = (LINUX_VERSION_CODE < version_code("4.19.0") && + (RHEL_MAJOR == "" || + RHEL_MAJOR * 256 + RHEL_MINOR < 7 * 256 + 7 || + RHEL_MAJOR * 256 + RHEL_MINOR == 8 * 256 + 0) ? + "" : "const"); + gsub("BAD_WR_MODIFIER", modifier, line[i]) + gsub("CM_HANDLER_EVENT_MODIFIER", modifier, line[i]) print line[i] } }