From 2e85ec5672081a55860f19511408f9b498b56d9f Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Wed, 18 Oct 2017 06:33:27 -0500 Subject: [PATCH] kpatch-build: add support for CONFIG_LIVEPATCH on RHEL Fix the version checks for when we enable CONFIG_LIVEPATCH on RHEL. It will be based on the latest upstream code. Signed-off-by: Josh Poimboeuf --- kmod/patch/livepatch-patch-hook.c | 9 ++++++--- kpatch-build/kpatch-build | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/kmod/patch/livepatch-patch-hook.c b/kmod/patch/livepatch-patch-hook.c index 40cb27f..6c89ff8 100644 --- a/kmod/patch/livepatch-patch-hook.c +++ b/kmod/patch/livepatch-patch-hook.c @@ -35,17 +35,20 @@ #define UTS_UBUNTU_RELEASE_ABI 0 #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0) || \ + defined(RHEL_RELEASE_CODE) #define HAVE_ELF_RELOCS #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) || \ (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) && \ - UTS_UBUNTU_RELEASE_ABI >= 7) + UTS_UBUNTU_RELEASE_ABI >= 7) || \ + defined(RHEL_RELEASE_CODE) #define HAVE_SYMPOS #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) || \ + defined(RHEL_RELEASE_CODE) #define HAVE_IMMEDIATE #endif diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build index dd1ac29..90ddb72 100755 --- a/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build @@ -136,6 +136,10 @@ version_gte() { [ "$1" = "$(echo -e "$1\n$2" | sort -rV | head -n1)" ] } +is_rhel() { + [[ $1 =~ \.el[78]\. ]] +} + find_dirs() { if [[ -e "$SCRIPTDIR/create-diff-object" ]]; then # git repo @@ -599,10 +603,10 @@ KPATCH_MODULE=true grep -q "CONFIG_DEBUG_INFO=y" "$CONFIGFILE" || die "kernel doesn't have 'CONFIG_DEBUG_INFO' enabled" if grep -q "CONFIG_LIVEPATCH=y" "$CONFIGFILE"; then # The kernel supports livepatch. - if version_gte "${ARCHVERSION//-*/}" 4.7.0; then + if version_gte "${ARCHVERSION//-*/}" 4.7.0 || is_rhel "$ARCHVERSION"; then # Use new .klp.rela. sections KPATCH_MODULE=false - if version_gte "${ARCHVERSION//-*/}" 4.9.0; then + if version_gte "${ARCHVERSION//-*/}" 4.9.0 || is_rhel "$ARCHVERSION"; then KPATCH_LDFLAGS="--unique=.parainstructions --unique=.altinstructions" fi fi