From 337965ad71520c758a2cae03705a29afb1c56883 Mon Sep 17 00:00:00 2001 From: Joe Lawrence Date: Wed, 8 Feb 2017 17:02:12 -0500 Subject: [PATCH] kpatch-build: consider CONFIG_PARAVIRT optional CONFIG_PARAVIRT is not required for building kpatch patch modules. The sizeof paravirt_patch_site struct was only needed to create .parainstructions sections as part of create-diff-object. As long as the original objects were built without such sections then this kernel option (and struct handling) can be considered optional. --- kpatch-build/kpatch-build | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build index cd55473..46dfb50 100755 --- a/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build @@ -505,6 +505,13 @@ else KBUILD_EXTRA_SYMBOLS="$SYMVERSFILE" fi +# optional kernel configs: CONFIG_PARAVIRT +if grep "CONFIG_PARAVIRT=y" "$OBJDIR/.config" > /dev/null; then + CONFIG_PARAVIRT=1 +else + CONFIG_PARAVIRT=0 +fi + # unsupported kernel option checking: CONFIG_DEBUG_INFO_SPLIT grep -q "CONFIG_DEBUG_INFO_SPLIT=y" "$OBJDIR/.config" && die "kernel option 'CONFIG_DEBUG_INFO_SPLIT' not supported" @@ -516,8 +523,9 @@ cp -LR "$DATADIR/patch" "$TEMPDIR" || die export KCFLAGS="-I$DATADIR/patch -ffunction-sections -fdata-sections" echo "Reading special section data" +[[ $CONFIG_PARAVIRT -eq 0 ]] && AWK_OPTIONS="-vskip_p=1" SPECIAL_VARS=$(readelf -wi "$VMLINUX" | - gawk --non-decimal-data ' + gawk --non-decimal-data $AWK_OPTIONS ' BEGIN { a = b = p = e = 0 } # Set state if name matches @@ -539,14 +547,15 @@ SPECIAL_VARS=$(readelf -wi "$VMLINUX" | e == 1 {printf("export EX_STRUCT_SIZE=%d\n", $4); e = 2} # Bail out once we have everything - a == 2 && b == 2 && p == 2 && e == 2 {exit}') + a == 2 && b == 2 && (p == 2 || skip_p) && e == 2 {exit}') [[ -n $SPECIAL_VARS ]] && eval "$SPECIAL_VARS" -if [[ -z $ALT_STRUCT_SIZE ]] || [[ -z $BUG_STRUCT_SIZE ]] || - [[ -z $PARA_STRUCT_SIZE ]] || [[ -z $EX_STRUCT_SIZE ]]; then - die "can't find special struct size" -fi +[[ -z $ALT_STRUCT_SIZE ]] && die "can't find special struct alt_instr size" +[[ -z $BUG_STRUCT_SIZE ]] && die "can't find special struct bug_entry size" +[[ -z $EX_STRUCT_SIZE ]] && die "can't find special struct paravirt_patch_site size" +[[ -z $PARA_STRUCT_SIZE && $CONFIG_PARAVIRT -ne 0 ]] && die "can't find special struct paravirt_patch_site size" + for i in $ALT_STRUCT_SIZE $BUG_STRUCT_SIZE $PARA_STRUCT_SIZE $EX_STRUCT_SIZE; do if [[ ! $i -gt 0 ]] || [[ ! $i -le 16 ]]; then die "invalid special struct size $i"