From 6971f60c1426585c63a3bc0da60de706e1871889 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 30 Apr 2019 14:27:19 +0000 Subject: [PATCH] scripts: Merge r8007:8277 from trunk git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.3.x@8281 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scripts/checkpatch | 10 +++- scripts/generate-kernel-patch | 60 +++++++++++--------- scripts/generate-patched-kernel | 4 +- scripts/generate-scst-patch | 26 --------- scripts/kernel-functions | 84 ++++++++++++++++++++++------ scripts/rhel-rpm-functions | 98 --------------------------------- scripts/run-regression-tests | 16 ++++-- scripts/specialize-patch | 51 +++++++++++------ 8 files changed, 155 insertions(+), 194 deletions(-) delete mode 100755 scripts/generate-scst-patch delete mode 100644 scripts/rhel-rpm-functions diff --git a/scripts/checkpatch b/scripts/checkpatch index 2c499ded8..bddb1b765 100755 --- a/scripts/checkpatch +++ b/scripts/checkpatch @@ -1,3 +1,11 @@ #!/bin/bash -../linux-kernel/scripts/checkpatch.pl -f --show-types --ignore SPDX_LICENSE_TAG,LINUX_VERSION_CODE,SYMBOLIC_PERMS,CONSTANT_COMPARISON,RETURN_VOID $(list-source-files | grep -vE 'fcst/linux-patches|patch$|pdf$|png$|^ibmvstgt/|^mpt/|^qla_isp/|^mvsas_tgt/') | sed 's/^#[0-9]*: FILE: \(.*\):/\1:1:/' +ignore=( + CONSTANT_COMPARISON + LINUX_VERSION_CODE + LONG_LINE_STRING + RETURN_VOID + SPDX_LICENSE_TAG + SYMBOLIC_PERMS +) +../linux-kernel/scripts/checkpatch.pl -f --show-types --ignore="$(echo "${ignore[@]}" | sed 's/ /,/g')" $(list-source-files | grep -vE 'fcst/linux-patches|patch$|pdf$|png$|^ibmvstgt/|^mpt/|^qla_isp/|^mvsas_tgt/') | sed 's/^#[0-9]*: FILE: \(.*\):/\1:1:/' diff --git a/scripts/generate-kernel-patch b/scripts/generate-kernel-patch index 8ecdecf1c..8ed1c4938 100755 --- a/scripts/generate-kernel-patch +++ b/scripts/generate-kernel-patch @@ -24,7 +24,7 @@ ######################## # shellcheck source=./kernel-functions -source $(dirname "$0")/kernel-functions +source "$(dirname "$0")/kernel-functions" function usage { echo "Usage: $0 [-d] [-h] [-m] [-n] [-p ] [-s] [-u] " @@ -173,9 +173,10 @@ generating_upstream_patch="false" mpt_scst="false" multiple_patches="false" patchdir="" -qla2x00t="true" +qla2x00t="false" +qla2x00t_32gbit="true" replace_sbug_by_bug="true" -specialize_patch_options=(-v delete_disabled_code=1) +specialize_patch_options=(-v "delete_disabled_code=1") srpt="true" if [ ! -e scst ] || [ ! -e iscsi-scst ] || [ ! -e srpt ] || @@ -193,7 +194,7 @@ do '-h') usage; exit 1;; '-l') shift;; '-m') mpt_scst="true"; shift;; - '-n') specialize_patch_options=(-v blank_deleted_code=1) + '-n') specialize_patch_options=(-v "blank_deleted_code=1") shift ;; '-p') multiple_patches="true"; patchdir="$2"; shift; shift;; @@ -219,7 +220,7 @@ else fi # Include fcst in the patch for kernel versions 2.6.33 and later. -if kernel_version_le "2.6.33" "${kver}"; then +if kernel_version_le "2.6.37" "${kver}"; then include_fcst="true" else include_fcst="false" @@ -236,15 +237,16 @@ fi if grep -qw scst_sysfs scst/kernel/in-tree/${scst_makefile} \ || [ "${generating_upstream_patch}" = "true" ]; then - specialize_patch_options+=(-v config_scst_proc_undefined=1) + specialize_patch_options+=(-v "config_scst_proc_undefined=1") else include_proc_impl="true" fi if [ "${debug_specialize}" = "true" ]; then - specialize_patch_options+=(-v debug=1) + specialize_patch_options+=(-v "debug=1") fi if [ "${generating_upstream_patch}" = "true" ]; then - specialize_patch_options+=(-v generating_upstream_patch_defined=1 -v config_tcp_zero_copy_transfer_completion_notification_undefined=1) + specialize_patch_options+=(-v "generating_upstream_patch_defined=1" + -v "config_tcp_zero_copy_transfer_completion_notification_undefined=1") fi if [ "${multiple_patches}" = "true" ]; then @@ -262,7 +264,7 @@ fi # Patch Generation # #################### -for f in fcst/linux-patches/series-${kver}* +for f in fcst/linux-patches/series-"${kver}"* do if [ -e "$f" ]; then fcst_patch_series="$f" @@ -493,7 +495,7 @@ add_file "iscsi-scst/README_in-tree" "Documentation/scst/README.iscsi" \ | process_patch "iscsi-scst-doc.diff" -# Directory drivers/scst/qla2x00-target/ +# Directory drivers/scsi/qla2xxx/ if [ "${qla2x00t}" = "true" ]; then @@ -514,33 +516,37 @@ if [ "${qla2x00t}" = "true" ]; then add_file "qla2x00t/qla2x_tgt_def.h" \ "drivers/scsi/qla2xxx/qla2x_tgt_def.h" - if [ -e "qla2x00t/qla2x00-target/Makefile_in-tree-${kver}" ] - then - add_file "qla2x00t/qla2x00-target/Makefile_in-tree-${kver}" \ - "drivers/scst/qla2xxx-target/Makefile" - else - add_file "qla2x00t/qla2x00-target/Makefile_in-tree" \ - "drivers/scst/qla2xxx-target/Makefile" - fi - - add_file "qla2x00t/qla2x00-target/Kconfig" \ - "drivers/scst/qla2xxx-target/Kconfig" - for f in qla2x00t/qla2x00-target/*.[ch]; do - [ -e "$f" ] || continue - add_file "${f}" "drivers/scst/qla2xxx-target/${f#qla2x00t/qla2x00-target/}" + [ -e "$f" ] && + add_file "${f}" "drivers/scsi/qla2xxx/${f#qla2x00t/qla2x00-target/}" done add_file "qla2x00t/qla2x00-target/README" \ "Documentation/scst/README.qla2x00t" \ | process_patch "qla2x00t-doc.diff" -else +elif [ "${qla2x00t_32gbit}" = "true" ]; then - add_empty_file "drivers/scst/qla2xxx-target/Makefile" + download_kernel "${kver3}" || exit $? - add_empty_file "drivers/scst/qla2xxx-target/Kconfig" + ( cd qla2x00t-32gbit && ./generate-in-tree-patches "$1" ) + 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}" + done + + for f in qla2x00t-32gbit/qla2x00-target/*.[ch]; do + [ -e "$f" ] || continue + add_file "${f}" "drivers/scsi/qla2xxx/${f#qla2x00t-32gbit/qla2x00-target/}" + done + + add_file "qla2x00t-32gbit/qla2x00-target/README" \ + "Documentation/scst/README.qla2x00t" \ + | process_patch "qla2x00t-doc.diff" + fi \ | process_patch "qla2x00t.diff" diff --git a/scripts/generate-patched-kernel b/scripts/generate-patched-kernel index 1f0cee235..a42990bcc 100755 --- a/scripts/generate-patched-kernel +++ b/scripts/generate-patched-kernel @@ -42,9 +42,7 @@ target="linux-$1" kernel_version="$(kernel_version "$1")" patchlevel="$(patchlevel "$1")" -download_kernel "$1" || exit $? - -extract_kernel_tree "$1" || exit $? +download_and_extract_kernel_tree "$1" || exit $? cd "${target}" || exit $? diff --git a/scripts/generate-scst-patch b/scripts/generate-scst-patch deleted file mode 100755 index ddcb6d68d..000000000 --- a/scripts/generate-scst-patch +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# -# A script to prepare a patch for posting on scst-devel@sourceforge.net. -# -# Copyright (C) 2012 Chetan Loke -# Copyright (C) 2012 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 -# as published by the Free Software Foundation, version 2 -# of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -echo "Patch description:" -echo "Your description goes here..." -echo -echo "Signed-off-by: Write your name here " -echo --- -/usr/bin/svn diff "$@" | /usr/bin/diffstat -echo -/usr/bin/svn diff -x -p "$@" -echo diff --git a/scripts/kernel-functions b/scripts/kernel-functions index 95b93044f..de2be73e7 100644 --- a/scripts/kernel-functions +++ b/scripts/kernel-functions @@ -3,7 +3,8 @@ # from kernel.org. kernel_mirror="http://cdn.kernel.org/pub/linux/kernel" -kernel_sources="$HOME/software/downloads" +kernel_downloads="$HOME/software/downloads" +kernel_tree="$HOME/software/linux-kernel" # Whether or not kernel version $1 is lower than or equal kernel version $2. function kernel_version_le { @@ -42,7 +43,7 @@ function download_file { } # Make sure the kernel tarball and patch file are present in directory -# ${kernel_sources}. Download any missing files from ${kernel_mirror}. +# ${kernel_downloads}. Download any missing files from ${kernel_mirror}. function download_kernel { local kver="$(kernel_version $1)" local plevel="$(patchlevel $1)" @@ -52,10 +53,10 @@ function download_kernel { [12].*) series="${series:0:3}";; *) series="${series/.*/}.x";; esac - mkdir -p "${kernel_sources}" || return $? - test -w "${kernel_sources}" || return $? + mkdir -p "${kernel_downloads}" || return $? + test -w "${kernel_downloads}" || return $? ( - cd "${kernel_sources}" || return $? + cd "${kernel_downloads}" || return $? if [ "$plevel" = "" -o "$plevel" = "0" ] || download_file "${kernel_mirror}/v$series/patch-$1.xz" then @@ -73,15 +74,15 @@ function extract_kernel_archive { local plevel="$(patchlevel $1)" local series="$1" - if [ -e "${kernel_sources}/linux-$1.tar.xz" ]; then - xz -cd "${kernel_sources}/linux-$1.tar.xz" | tar xf - - elif [ -e "${kernel_sources}/linux-$kver.tar.xz" ]; then - xz -cd "${kernel_sources}/linux-$kver.tar.xz" | tar xf - && + if [ -e "${kernel_downloads}/linux-$1.tar.xz" ]; then + xz -cd "${kernel_downloads}/linux-$1.tar.xz" | tar xf - + elif [ -e "${kernel_downloads}/linux-$kver.tar.xz" ]; then + xz -cd "${kernel_downloads}/linux-$kver.tar.xz" | tar xf - && mv linux-$kver linux-$1 - elif [ -e "${kernel_sources}/linux-$1.tar.bz2" ]; then - tar xjf "${kernel_sources}/linux-$1.tar.bz2" - elif [ -e "${kernel_sources}/linux-$kver.tar.bz2" ]; then - tar xjf "${kernel_sources}/linux-$kver.tar.bz2" && + elif [ -e "${kernel_downloads}/linux-$1.tar.bz2" ]; then + tar xjf "${kernel_downloads}/linux-$1.tar.bz2" + elif [ -e "${kernel_downloads}/linux-$kver.tar.bz2" ]; then + tar xjf "${kernel_downloads}/linux-$kver.tar.bz2" && mv linux-$kver linux-$1 else return 1 @@ -100,10 +101,10 @@ function extract_kernel_tree { ( cd "${tmpdir}" || return $? if [ "$plevel" != "" -a "$plevel" != "0" -a \ - -e "${kernel_sources}/patch-$1.xz" ]; then + -e "${kernel_downloads}/patch-$1.xz" ]; then extract_kernel_archive $kver || return $? mv linux-$kver linux-$1 - ( cd linux-$1 && xz -cd "${kernel_sources}/patch-$1.xz" \ + ( cd linux-$1 && xz -cd "${kernel_downloads}/patch-$1.xz" \ | patch -p1 -f -s; ) \ || return $? else @@ -113,6 +114,12 @@ function extract_kernel_tree { fi mv "linux-$1" ".." || return $? cd "../linux-$1" || return $? + ) + rmdir "${tmpdir}" +} + +# Patch a kernel tree where $1 is the kernel version. +function patch_kernel { if [ "$1" = "2.6.29" -o "$1" = "2.6.29.1" -o "$1" = "2.6.29.2" -o "$1" = "2.6.29.3" ] then patch -f -s -p1 <<'EOF' @@ -321,7 +328,7 @@ index d6d65537b0d9..6aad8308a0ac 100644 EOF fi case "$1" in - 3.[0-9].*|3.1[01345].*|3.17.*|3.19.*|4.[023567].*) + 2.6.3[6-9]*|3.[0-9]|3.[0-9].*|3.1[01345]|3.1[01345].*|3.17|3.17.*|3.19|3.19.*|4.[023567]|4.[023567].*) patch -p1 <<'EOF' From c6a385539175ebc603da53aafb7753d39089f32e Mon Sep 17 00:00:00 2001 From: Borislav Petkov @@ -383,9 +390,38 @@ index 0ed6ce300543..c324b43712f0 100644 KBUILD_AFLAGS_MODULE := -DMODULE KBUILD_CFLAGS_MODULE := -DMODULE KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds +EOF + ;; + 2.6.3[1-5]*) + patch -p1 <<'EOF' +diff --git a/Makefile b/Makefile +index 141da26fda4b..343ec388ae2e 100644 +--- a/Makefile ++++ b/Makefile +@@ -349,12 +349,13 @@ LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \ + + 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 \ + -fno-delete-null-pointer-checks +-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 ;; esac + + # 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 + # After patch-v4.14.1[12] has been applied, the execute bit has to be # set for sync-check.sh since patch can't do that. for f in "tools/objtool/sync-check.sh"; do @@ -393,7 +429,19 @@ EOF chmod a+x "$f" fi done - ) - rmdir "${tmpdir}" } +function download_and_extract_kernel_tree { + if [ -e "${kernel_tree}" ]; then + rm -rf "linux-$1" + mkdir "linux-$1" + ( + cd "${kernel_tree}" && + { git tag -l "v$1" >/dev/null || git fetch stable; } && + git archive "v$1" + ) | tar -C "linux-$1" -xf- + else + download_kernel "$1" && extract_kernel_tree "$1" + fi && + (cd linux-$1 && patch_kernel "$1") +} diff --git a/scripts/rhel-rpm-functions b/scripts/rhel-rpm-functions deleted file mode 100644 index a6765ae3f..000000000 --- a/scripts/rhel-rpm-functions +++ /dev/null @@ -1,98 +0,0 @@ -# -*- 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" - IFS=. - set -- "$2" - unset IFS - releasevermajor="$1" - releaseverminor="$2" - - case "$distro" in - "CentOS"*) - case $releasever in - 5.*|6.[01]) - echo "http://vault.centos.org/${releasever}/os/SRPMS http://vault.centos.org/${releasever}/updates/SRPMS";; - [67].*) - echo "http://vault.centos.org/${releasever}/os/Source/SPackages http://vault.centos.org/${releasever}/updates/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 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 http://public-yum.oracle.com/repo/OracleLinux/OL${releasevermajor}/latest/${arch}/getPackageSource 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" - IFS=. - set -- "$2" - unset IFS - 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 http://vault.centos.org/${releasever}/updates/${arch}/Packages";; - [67].*) - echo "http://vault.centos.org/${releasever}/os/${arch}/Packages http://vault.centos.org/${releasever}/updates/${arch}/Packages";; - esac - ;; - "Red Hat Enterprise Linux"*) - echo "";; - "Oracle Linux Server") - echo "http://public-yum.oracle.com/repo/OracleLinux/OL${releasevermajor}/${releaseverminor}/base/${arch}/getPackageSource http://public-yum.oracle.com/repo/OracleLinux/OL${releasevermajor}/latest/${arch}/getPackageSource 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 e8b27f896..5b1f34452 100755 --- a/scripts/run-regression-tests +++ b/scripts/run-regression-tests @@ -291,6 +291,7 @@ CONFIG_MAC80211_DRIVER_API_TRACER \ CONFIG_MMIOTRACE \ CONFIG_NET_DROP_MONITOR \ CONFIG_NOP_TRACER \ +CONFIG_RETPOLINE \ CONFIG_SCHED_TRACER \ CONFIG_SECURITY_SELINUX \ CONFIG_STACK_TRACER \ @@ -298,9 +299,11 @@ CONFIG_STACK_VALIDATION \ CONFIG_TRACEPOINTS \ CONFIG_TRACER_MAX_TRACE \ CONFIG_TRACING \ +CONFIG_UNWINDER_ORC \ CONFIG_X86_32 \ CONFIG_X86_X32 \ " + local enable="CONFIG_UNWINDER_FRAME_POINTER" echo "Patching and configuring kernel ..." if [ "$ipv6" = "false" ]; then @@ -319,6 +322,7 @@ CONFIG_X86_X32 \ fi && 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 ) } @@ -648,14 +652,10 @@ do patchdir="patchdir-${kv}" k="${kv}" - if ! download_kernel "$k"; then - echo "Downloading kernel version $k failed" - continue - fi generate_kernel_patch "$k" "${generate_kernel_patch_options}" || continue ( cd "${outputdir}" && - extract_kernel_tree "$k" && + 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 @@ -671,6 +671,12 @@ do run_checkpatch "$k" fi patch_and_configure_kernel "$k" + 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" + export KCFLAGS;; + esac subdirs=(drivers/scst) if [ "${run_sparse}" = "true" ]; then run_sparse "$k" "${subdirs[@]}" diff --git a/scripts/specialize-patch b/scripts/specialize-patch index a4bf4e6f4..188e556cf 100755 --- a/scripts/specialize-patch +++ b/scripts/specialize-patch @@ -20,7 +20,8 @@ ############################################################################ # Usage: -# * Specify the kernel version code as follows: -v kernel_version=... +# * Specify the kernel version code and optionally the RHEL version as follows: +# -v kernel_version=... -vRHEL_MAJOR=... -vRHEL_MINOR=... # * Provide the patch to be processed to stdin. # # The output of this script will be a patch that is specialized for the @@ -64,31 +65,39 @@ function evaluate(stmnt, pattern, arg, op, result) { } gsub("defined\\(REGISTER_MAD_AGENT_HAS_FLAGS_ARG\\)", - "(LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0))", stmnt) + "(LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0) || " \ + "RHEL_RELEASE_CODE -0 >= 6 * 256 + 10)", 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 + 6)", stmnt) gsub("defined\\(IB_CREATE_CQ_HAS_INIT_ATTR\\)", - "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0))", stmnt) + "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) || " \ + "RHEL_RELEASE_CODE -0 >= 7 * 256 + 6)", stmnt) gsub("defined\\(CREATE_SEND_MAD_HAS_BASE_ARG\\)", - "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0))", stmnt) + "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) || " \ + "RHEL_RELEASE_CODE -0 >= 7 * 256 + 6)", 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 + 6)", stmnt) gsub("defined\\(IB_CLIENT_REMOVE_TAKES_TWO_ARGS\\)", - "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0))", stmnt) + "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) || " \ + "RHEL_RELEASE_CODE -0 >= 7 * 256 + 6)", stmnt) gsub("defined\\(IB_QUERY_GID_HAS_ATTR_ARG\\)", - "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))", stmnt) + "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) || " \ + "RHEL_RELEASE_CODE -0 >= 7 * 256 + 6)", stmnt) gsub("RDMA_CREATE_ID_TAKES_NET_ARG", - "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))", stmnt) + "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) || " \ + "RHEL_RELEASE_CODE -0 >= 7 * 256 + 6)", stmnt) gsub("HAVE_DEV_ATTR_MAX_SEND_SGE", "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0))", stmnt) @@ -108,17 +117,25 @@ function evaluate(stmnt, pattern, arg, op, result) { 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) + 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 + 6)", stmnt) gsub("defined\\(MAD_HANDLER_TAKES_SEND_BUF\\)", - "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0))", stmnt) + "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) || " \ + "RHEL_RELEASE_CODE -0 >= 7 * 256 + 6)", stmnt) gsub("defined\\(HAVE_IB_SET_CPI_RESP_TIME\\)", - "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))", stmnt) + "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0) || " \ + "RHEL_RELEASE_CODE -0 >= 7 * 256 + 6)", stmnt) gsub("defined\\(IB_PD_HAS_LOCAL_DMA_LKEY\\)", - "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0))", stmnt) + "(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0) || " \ + "RHEL_RELEASE_CODE -0 >= 7 * 256 + 6)", stmnt) gsub("defined\\(HAVE_IB_DMA_MAP_OPS\\)", "(LINUX_VERSION_CODE >= KERNEL_VERSION(0, 0, 0))", stmnt) @@ -180,6 +197,8 @@ function evaluate(stmnt, pattern, arg, op, result) { "(\\1) * 256 + (\\2)", "g", stmnt) } + gsub("defined\\(UEK_KABI_RENAME\\)", "0", stmnt) + if (SCSI_EXEC_REQ_FIFO_DEFINED != "") { gsub("defined[[:blank:]]+SCSI_EXEC_REQ_FIFO_DEFINED", @@ -371,6 +390,7 @@ function handle_if(evaluated) || $0 ~ "RHEL_MINOR" \ || $0 ~ "RHEL_RELEASE_CODE" \ || $0 ~ "SOCK_RECVMSG_HAS_FOUR_ARGS" \ + || $0 ~ "UEK_KABI_RENAME" \ || $0 ~ "USE_PRE_440_WR_STRUCTURE" \ || generating_upstream_patch_defined \ && $0 ~ "GENERATING_UPSTREAM_PATCH" \ @@ -505,9 +525,8 @@ function process_preprocessor_statement(evaluated, condition) { ei = substr(ei, 6) else if (ei ~ "^+#ifdef") ei = substr(ei, 9) - evaluated = sprintf("%s /* %s */", - $0 ~ " " ? substr($0, 1, index($0, " ")) : $0, - ei); + match($0, "([^/ ]*)[[:blank:]]*/\\*[^*]*\\*/[[:blank:]]*", arg) + evaluated = sprintf("%s /* %s */", arg[1], ei); if (match(evaluated, "([^/ ]*) */\\* defined\\(([^()]*)\\) \\*/", arg)) {