Don't accept fuzz when patching
PATCH 1/3 Don't accept fuzz when patching
When testing and applying patches, set fuzz=0 so that patches must apply exactly. Also set "-f" to avoid interactive questions, and reorder so that patches are tested before the output directory is created.
--- livepatch-build | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
livepatch-build +5 -6
@@ -257,23 +257,22 @@ echo if [ "${SKIP}" != "build" ]; then [ -e "${OUTPUT}" ] && die "Output directory exists" - mkdir -p "${OUTPUT}" || die - - echo "Testing patch file..." cd "$SRCDIR" || die - patch -s -N -p1 --dry-run < "$PATCHFILE" || die "source patch file failed to apply" + patch -s -N -p1 -f --fuzz=0 --dry-run < "$PATCHFILE" || die "Source patch file failed to apply" + + mkdir -p "${OUTPUT}" || die echo "Perform full initial build with ${CPUS} CPU(s)..." build_full echo "Apply patch and build with ${CPUS} CPU(s)..." cd "$SRCDIR" || die - patch -s -N -p1 < "$PATCHFILE" || die + patch -s -N -p1 -f --fuzz=0 < "$PATCHFILE" || die build_special patched echo "Unapply patch and build with ${CPUS} CPU(s)..." cd "$SRCDIR" || die - patch -s -R -p1 < "$PATCHFILE" || die + patch -s -R -p1 -f --fuzz=0 < "$PATCHFILE" || die build_special original fi
Signature · 7 lines
2.4.11 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH 2/3 Update to use a .config file
Remove the old --xen-debug option, and instead, require the user to pass a .config file matching the original build's .config.
--- livepatch-build | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
livepatch-build +16 -8
@@ -66,7 +66,7 @@ function build_full() { cd "${SRCDIR}/xen" || die make "-j$CPUS" clean &> "${OUTPUT}/build_full_clean.log" || die - make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_full_compile.log" || die + make "-j$CPUS" &> "${OUTPUT}/build_full_compile.log" || die cp xen-syms "$OUTPUT" }
@@ -86,7 +86,7 @@ function build_special() # Build with special GCC flags cd "${SRCDIR}/xen" || die sed -i 's/CFLAGS += -nostdinc/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/' Rules.mk - make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_${name}_compile.log" || die + make "-j$CPUS" &> "${OUTPUT}/build_${name}_compile.log" || die sed -i 's/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/CFLAGS += -nostdinc/' Rules.mk unset LIVEPATCH_BUILD_DIR
@@ -158,17 +158,17 @@ usage() { echo " -h, --help Show this help message" >&2 echo " -s, --srcdir Xen source directory" >&2 echo " -p, --patch Patch file" >&2 + echo " -c, --config .config file" >&2 echo " -o, --output Output directory" >&2 echo " -j, --cpus Number of CPUs to use" >&2 echo " -k, --skip Skip build or diff phase" >&2 echo " -d, --debug Enable debug logging" >&2 - echo " --xen-debug Build debug Xen" >&2 echo " --xen-syms Build against a xen-syms" >&2 echo " --depends Required build-id" >&2 echo " --prelink Prelink" >&2 } -options=$(getopt -o hs:p:o:j:k:d -l "help,srcdir:patch:output:cpus:,skip:,debug,xen-debug,xen-syms:,depends:,prelink" -- "$@") || die "getopt failed" +options=$(getopt -o hs:p:c:o:j:k:d -l "help,srcdir:patch:config:output:cpus:,skip:,debug,xen-syms:,depends:,prelink" -- "$@") || die "getopt failed" eval set -- "$options"
@@ -192,10 +192,6 @@ while [[ $# -gt 0 ]]; do DEBUG=1 shift ;; - --xen-debug) - XEN_DEBUG=y - shift - ;; -s|--srcdir) shift srcarg="$1"
@@ -206,6 +202,11 @@ while [[ $# -gt 0 ]]; do patcharg="$1" shift ;; + -c|--config) + shift + configarg="$1" + shift + ;; -o|--output) shift outputarg="$1"
@@ -235,15 +236,18 @@ done [ -z "$srcarg" ] && die "Xen directory not given" [ -z "$patcharg" ] && die "Patchfile not given" +[ -z "$configarg" ] && die ".config not given" [ -z "$outputarg" ] && die "Output directory not given" [ -z "$DEPENDS" ] && die "Build-id dependency not given" SRCDIR="$(readlink -m -- "$srcarg")" PATCHFILE="$(readlink -m -- "$patcharg")" +CONFIGFILE="$(readlink -m -- "$configarg")" OUTPUT="$(readlink -m -- "$outputarg")" [ -d "${SRCDIR}" ] || die "Xen directory does not exist" [ -f "${PATCHFILE}" ] || die "Patchfile does not exist" +[ -f "${CONFIGFILE}" ] || die ".config does not exist" PATCHNAME=$(make_patch_name "${PATCHFILE}")
@@ -251,16 +255,20 @@ echo "Building LivePatch patch: ${PATCHNAME}" echo echo "Xen directory: ${SRCDIR}" echo "Patch file: ${PATCHFILE}" +echo ".config file: ${CONFIGFILE}" echo "Output directory: ${OUTPUT}" echo "================================================" echo if [ "${SKIP}" != "build" ]; then [ -e "${OUTPUT}" ] && die "Output directory exists" + grep -q 'CONFIG_LIVEPATCH=y' "${CONFIGFILE}" || die "CONFIG_LIVEPATCH must be enabled" cd "$SRCDIR" || die patch -s -N -p1 -f --fuzz=0 --dry-run < "$PATCHFILE" || die "Source patch file failed to apply" mkdir -p "${OUTPUT}" || die + cp -f "${CONFIGFILE}" "${OUTPUT}/.config" + cp -f "${OUTPUT}/.config" "xen/.config" echo "Perform full initial build with ${CPUS} CPU(s)..." build_full
Signature · 7 lines
2.4.11 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH 2/3] Update to use a .config file
Quoted 2 lines · Ross Lagerwall
Remove the old --xen-debug option, and instead, require the user to pass a .config file matching the original build's .config.
Hm, that throws this off a bit for the older hypervisors (to which I had backported livepatch). Perhaps we could add some logic to check if common/Kconfig exist?
And I also wonder if the --xen-debug option removal should be a seperate patch?
Quoted 114 lines
Signed-off-by Ross Lagerwall <[email protected]>--- livepatch-build | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)livepatch-build +16
-8@@ -66,7 +66,7 @@ function build_full() { cd "${SRCDIR}/xen" || die make "-j$CPUS" clean &> "${OUTPUT}/build_full_clean.log" || die - make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_full_compile.log" || die + make "-j$CPUS" &> "${OUTPUT}/build_full_compile.log" || die cp xen-syms "$OUTPUT" }@@ -86,7 +86,7 @@ function build_special() # Build with special GCC flags cd "${SRCDIR}/xen" || die sed -i 's/CFLAGS += -nostdinc/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/' Rules.mk - make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_${name}_compile.log" || die + make "-j$CPUS" &> "${OUTPUT}/build_${name}_compile.log" || die sed -i 's/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/CFLAGS += -nostdinc/' Rules.mk unset LIVEPATCH_BUILD_DIR@@ -158,17 +158,17 @@ usage() { echo " -h, --help Show this help message" >&2 echo " -s, --srcdir Xen source directory" >&2 echo " -p, --patch Patch file" >&2 + echo " -c, --config .config file" >&2 echo " -o, --output Output directory" >&2 echo " -j, --cpus Number of CPUs to use" >&2 echo " -k, --skip Skip build or diff phase" >&2 echo " -d, --debug Enable debug logging" >&2 - echo " --xen-debug Build debug Xen" >&2 echo " --xen-syms Build against a xen-syms" >&2 echo " --depends Required build-id" >&2 echo " --prelink Prelink" >&2 } -options=$(getopt -o hs:p:o:j:k:d -l "help,srcdir:patch:output:cpus:,skip:,debug,xen-debug,xen-syms:,depends:,prelink" -- "$@") || die "getopt failed" +options=$(getopt -o hs:p:c:o:j:k:d -l "help,srcdir:patch:config:output:cpus:,skip:,debug,xen-syms:,depends:,prelink" -- "$@") || die "getopt failed" eval set -- "$options"@@ -192,10 +192,6 @@ while [[ $# -gt 0 ]]; do DEBUG=1 shift ;; - --xen-debug) - XEN_DEBUG=y - shift - ;; -s|--srcdir) shift srcarg="$1"@@ -206,6 +202,11 @@ while [[ $# -gt 0 ]]; do patcharg="$1" shift ;; + -c|--config) + shift + configarg="$1" + shift + ;; -o|--output) shift outputarg="$1"@@ -235,15 +236,18 @@ done [ -z "$srcarg" ] && die "Xen directory not given" [ -z "$patcharg" ] && die "Patchfile not given" +[ -z "$configarg" ] && die ".config not given" [ -z "$outputarg" ] && die "Output directory not given" [ -z "$DEPENDS" ] && die "Build-id dependency not given" SRCDIR="$(readlink -m -- "$srcarg")" PATCHFILE="$(readlink -m -- "$patcharg")" +CONFIGFILE="$(readlink -m -- "$configarg")" OUTPUT="$(readlink -m -- "$outputarg")" [ -d "${SRCDIR}" ] || die "Xen directory does not exist" [ -f "${PATCHFILE}" ] || die "Patchfile does not exist" +[ -f "${CONFIGFILE}" ] || die ".config does not exist" PATCHNAME=$(make_patch_name "${PATCHFILE}")@@ -251,16 +255,20 @@ echo "Building LivePatch patch: ${PATCHNAME}" echo echo "Xen directory: ${SRCDIR}" echo "Patch file: ${PATCHFILE}" +echo ".config file: ${CONFIGFILE}" echo "Output directory: ${OUTPUT}" echo "================================================" echo if [ "${SKIP}" != "build" ]; then [ -e "${OUTPUT}" ] && die "Output directory exists" + grep -q 'CONFIG_LIVEPATCH=y' "${CONFIGFILE}" || die "CONFIG_LIVEPATCH must be enabled" cd "$SRCDIR" || die patch -s -N -p1 -f --fuzz=0 --dry-run < "$PATCHFILE" || die "Source patch file failed to apply" mkdir -p "${OUTPUT}" || die + cp -f "${CONFIGFILE}" "${OUTPUT}/.config" + cp -f "${OUTPUT}/.config" "xen/.config" echo "Perform full initial build with ${CPUS} CPU(s)..." build_fullSignature · 1 line
2.4.11
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 2/3] Update to use a .config file
Quoted 7 lines · Konrad Rzeszutek Wilk
Quoted 2 lines · Ross Lagerwall
Remove the old --xen-debug option, and instead, require the user to pass a .config file matching the original build's .config.
Hm, that throws this off a bit for the older hypervisors (to which I had backported livepatch). Perhaps we could add some logic to check if common/Kconfig exist?
At this point rather than adding extra logic to support different still-experimental versions, I'd rather just have a different branch. Maybe have a branch per Xen release?
Quoted 4 lines
And I also wonder if the --xen-debug option removal should be a seperate patch?
Well the two are related -- the motivation to use the .config is because the debug flag is now controlled by the .config rather than the command-line argument.
Signature · 6 lines
Ross Lagerwall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH 2/3] Update to use a .config file
Quoted 14 lines · Ross Lagerwall
Quoted 7 lines · Konrad Rzeszutek Wilk
Quoted 2 lines · Ross Lagerwall
Remove the old --xen-debug option, and instead, require the user to pass a .config file matching the original build's .config.
Hm, that throws this off a bit for the older hypervisors (to which I had backported livepatch). Perhaps we could add some logic to check if common/Kconfig exist?
At this point rather than adding extra logic to support different still-experimental versions, I'd rather just have a different branch. Maybe have a branch per Xen release?
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
And I also wonder if the --xen-debug option removal should be a seperate patch?
Well the two are related -- the motivation to use the .config is because the debug flag is now controlled by the .config rather than the command-line argument.
But not in the 4.7 that is going out - that 'debug=y' is non-Kconfig?
Quoted 3 lines
Signature · 2 lines
-- Ross Lagerwall
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 2/3] Update to use a .config file
Quoted 19 lines · Konrad Rzeszutek Wilk
Quoted 18 lines · Ross Lagerwall
Quoted 7 lines · Konrad Rzeszutek Wilk
Quoted 2 lines · Ross Lagerwall
Remove the old --xen-debug option, and instead, require the user to pass a .config file matching the original build's .config.
Hm, that throws this off a bit for the older hypervisors (to which I had backported livepatch). Perhaps we could add some logic to check if common/Kconfig exist?
At this point rather than adding extra logic to support different still-experimental versions, I'd rather just have a different branch. Maybe have a branch per Xen release?
Quoted 4 lines
And I also wonder if the --xen-debug option removal should be a seperate patch?
Quoted 6 lines
Quoted 3 lines
Well the two are related -- the motivation to use the .config is because the debug flag is now controlled by the .config rather than the command-line argument.
But not in the 4.7 that is going out - that 'debug=y' is non-Kconfig?
Quoted 1 line
OK, I'll split it into two. Feel free to create a stable-47 branch in livepatch-build-tools.git with only the .config patch. Personally, I'd rather not spend much time backporting stuff to support a tech preview feature on an older branch.
Signature · 6 lines
Ross Lagerwall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 2/3] Update to use a .config file
Quoted 24 lines · Ross Lagerwall
Quoted 23 lines · Konrad Rzeszutek Wilk
Quoted 21 lines · Ross Lagerwall
Quoted 7 lines · Konrad Rzeszutek Wilk
Quoted 2 lines · Ross Lagerwall
Remove the old --xen-debug option, and instead, require the user to pass a .config file matching the original build's .config.
Hm, that throws this off a bit for the older hypervisors (to which I had backported livepatch). Perhaps we could add some logic to check if common/Kconfig exist?
At this point rather than adding extra logic to support different still-experimental versions, I'd rather just have a different branch. Maybe have a branch per Xen release?
Quoted 4 lines
And I also wonder if the --xen-debug option removal should be a seperate patch?
Well the two are related -- the motivation to use the .config is because the debug flag is now controlled by the .config rather than the command-line argument.
Quoted 7 lines
Quoted 2 lines
But not in the 4.7 that is going out - that 'debug=y' is non-Kconfig?
Quoted 1 line
OK, I'll split it into two. Feel free to create a stable-47 branch in livepatch-build-tools.git with only the .config patch. Personally, I'd rather not spend much time backporting stuff to support a tech preview feature on an older branch.
We will need to update the Wiki a bit too...
What if I we do something simpler?
livepatch-build +15 -3
@@ -66,7 +66,11 @@ function build_full() { cd "${SRCDIR}/xen" || die make "-j$CPUS" clean &> "${OUTPUT}/build_full_clean.log" || die - make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_full_compile.log" || die + if [ "x$XEN_DEBUG" == "xignore" ]; then + make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_full_compile.log" || die + else + make "-j$CPUS" &> "${OUTPUT}/build_full_compile.log" || die + fi cp xen-syms "$OUTPUT" }
@@ -87,7 +91,11 @@ function build_special() cd "${SRCDIR}/xen" || die sed -i 's/CFLAGS += -nostdinc/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/' Rules.mk sed -i 's/--section-alignment=0x200000/--section-alignment=0x1000/' arch/x86/Makefile - make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_${name}_compile.log" || die + if [ "x$XEN_DEBUG" == "xignore" ]; then + make "-j$CPUS" &> "${OUTPUT}/build_${name}_compile.log" || die + else + make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_${name}_compile.log" || die + fi sed -i 's/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/CFLAGS += -nostdinc/' Rules.mk sed -i 's/--section-alignment=0x1000/--section-alignment=0x200000/' arch/x86/Makefile
@@ -165,7 +173,7 @@ usage() { echo " -j, --cpus Number of CPUs to use" >&2 echo " -k, --skip Skip build or diff phase" >&2 echo " -d, --debug Enable debug logging" >&2 - echo " --xen-debug Build debug Xen" >&2 + echo " --xen-debug Build debug Xen (if your .config does not have the options)" >&2 echo " --xen-syms Build against a xen-syms" >&2 echo " --depends Required build-id" >&2 echo " --prelink Prelink" >&2
@@ -277,6 +285,10 @@ if [ "${SKIP}" != "build" ]; then cp -f "${CONFIGFILE}" "${OUTPUT}/.config" cp -f "${OUTPUT}/.config" "xen/.config" + grep -q CONFIG_DEBUG "xen/.config" + if [ $? -eq 0 ]; then + XEN_DEBUG=ignore + fi echo "Perform full initial build with ${CPUS} CPU(s)..." build_full
?
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/3] Update to use a .config file
Quoted 8 lines
Quoted 4 lines
OK, I'll split it into two. Feel free to create a stable-47 branch in livepatch-build-tools.git with only the .config patch. Personally, I'd rather not spend much time backporting stuff to support a tech preview feature on an older branch.
We will need to update the Wiki a bit too...
What if I we do something simpler?
And the offical patch:
From 929a92b3dbb8467e0a69b50706b69fb206b51ff3 Mon Sep 17 00:00:00 2001
From: Konrad Rzeszutek Wilk <[email protected]>
Date: Fri, 15 Jul 2016 09:36:23 -0400
Subject: [PATCH] Check .config for CONFIG_DEBUG. If not found use --xen-debug
(if specified)
Xen 4.8 ditched the 'debug=y' and now has CONFIG_DEBUG in the .config. To still support 4.7 lets just poke the .config file and see.
--- livepatch-build | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
livepatch-build +17 -3
@@ -66,7 +66,7 @@ function build_full() { cd "${SRCDIR}/xen" || die make "-j$CPUS" clean &> "${OUTPUT}/build_full_clean.log" || die - make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_full_compile.log" || die + make "-j$CPUS" "$XEN_DEBUG" &> "${OUTPUT}/build_full_compile.log" || die cp xen-syms "$OUTPUT" }
@@ -87,7 +87,7 @@ function build_special() cd "${SRCDIR}/xen" || die sed -i 's/CFLAGS += -nostdinc/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/' Rules.mk sed -i 's/--section-alignment=0x200000/--section-alignment=0x1000/' arch/x86/Makefile - make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_${name}_compile.log" || die + make "-j$CPUS" "$XEN_DEBUG" &> "${OUTPUT}/build_${name}_compile.log" || die sed -i 's/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/CFLAGS += -nostdinc/' Rules.mk sed -i 's/--section-alignment=0x1000/--section-alignment=0x200000/' arch/x86/Makefile
@@ -165,7 +165,7 @@ usage() { echo " -j, --cpus Number of CPUs to use" >&2 echo " -k, --skip Skip build or diff phase" >&2 echo " -d, --debug Enable debug logging" >&2 - echo " --xen-debug Build debug Xen" >&2 + echo " --xen-debug Build debug Xen (if your .config does not have the options)" >&2 echo " --xen-syms Build against a xen-syms" >&2 echo " --depends Required build-id" >&2 echo " --prelink Prelink" >&2
@@ -277,6 +277,20 @@ if [ "${SKIP}" != "build" ]; then cp -f "${CONFIGFILE}" "${OUTPUT}/.config" cp -f "${OUTPUT}/.config" "xen/.config" + grep -q CONFIG_DEBUG "xen/.config" + if [ $? -eq 0 ]; then + if [ "$XEN_DEBUG" == "y" ]; then + grep -q "CONFIG_DEBUG=y" "xen/.config" + if [ $? -ne 0 ]; then + echo "CONFIG_DEBUG and --xen-debug mismatch!" + die + fi + fi + XEN_DEBUG="" + else + XEN_DEBUG="--xen-debug $XEN_DEBUG" + fi + echo "Perform full initial build with ${CPUS} CPU(s)..." build_full
Signature · 7 lines
2.5.5 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 2/3] Update to use a .config file
Quoted 17 lines · Konrad Rzeszutek Wilk
Quoted 8 lines
Quoted 4 lines
OK, I'll split it into two. Feel free to create a stable-47 branch in livepatch-build-tools.git with only the .config patch. Personally, I'd rather not spend much time backporting stuff to support a tech preview feature on an older branch.
We will need to update the Wiki a bit too...
What if I we do something simpler?
And the offical patch:
From
929a92b3dbb8467e0a69b50706b69fb206b51ff3Mon Sep 17 00:00:00 2001
From: Konrad Rzeszutek Wilk <[email protected]>
Date: Fri, 15 Jul 2016 09:36:23 -0400
Subject: [PATCH] Check .config forCONFIG_DEBUG. If not found use --xen-debug
(if specified)
Quoted 5 lines
Xen 4.8 ditched the 'debug=y' and now has
CONFIG_DEBUGin the .config. To still support 4.7 lets just poke the .config file and see.Signed-off-by Konrad Rzeszutek Wilk <[email protected]>
Is the intention that this gets applied on top of "[PATCH LIVEPATCH-BUILD-TOOLS v2 1/3] Update to use a .config file" and that "[PATCH LIVEPATCH-BUILD-TOOLS v2 2/3] Remove --xen-debug" is dropped?
If so, then the approach looks OK to me.
Quoted 9 lines
--- livepatch-build | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)livepatch-build +0
-0
livepatch-build function build_full() · line 69
Quoted 5 lines
livepatch-build +1
-1@@ -66,7 +66,7 @@ function build_full() { cd "${SRCDIR}/xen" || die make "-j$CPUS" clean &> "${OUTPUT}/build_full_clean.log" || die - make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_full_compile.log" || die + make "-j$CPUS" "$XEN_DEBUG" &> "${OUTPUT}/build_full_compile.log" || die
$XEN_DEBUG needs to be unquoted, otherwise you get a build error from make:
make: *** empty string invalid as file name. Stop.
livepatch-build function build_special() · line 90
Quoted 9 lines
livepatch-build +1
-1cp xen-syms "$OUTPUT" }@@ -87,7 +87,7 @@ function build_special() cd "${SRCDIR}/xen" || die sed -i 's/CFLAGS += -nostdinc/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/' Rules.mk sed -i 's/--section-alignment=0x200000/--section-alignment=0x1000/' arch/x86/Makefile - make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_${name}_compile.log" || die + make "-j$CPUS" "$XEN_DEBUG" &> "${OUTPUT}/build_${name}_compile.log" || die
Same here.
Quoted 14 lines
livepatch-build +1
-1sed -i 's/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/CFLAGS += -nostdinc/' Rules.mk sed -i 's/--section-alignment=0x1000/--section-alignment=0x200000/' arch/x86/Makefile@@ -165,7 +165,7 @@ usage() { echo " -j, --cpus Number of CPUs to use" >&2 echo " -k, --skip Skip build or diff phase" >&2 echo " -d, --debug Enable debug logging" >&2 - echo " --xen-debug Build debug Xen" >&2 + echo " --xen-debug Build debug Xen (if your .config does not have the options)" >&2 echo " --xen-syms Build against a xen-syms" >&2 echo " --depends Required build-id" >&2 echo " --prelink Prelink" >&2@@ -277,6 +277,20 @@ if [ "${SKIP}" != "build" ]; then cp -f "${CONFIGFILE}" "${OUTPUT}/.config"
livepatch-build if [ "${SKIP}" != "build" ]; then · line 287
Quoted 10 lines
livepatch-build +8
-0cp -f "${OUTPUT}/.config" "xen/.config" + grep -q CONFIG_DEBUG "xen/.config" + if [ $? -eq 0 ]; then + if [ "$XEN_DEBUG" == "y" ]; then + grep -q "CONFIG_DEBUG=y" "xen/.config" + if [ $? -ne 0 ]; then + echo "CONFIG_DEBUG and --xen-debug mismatch!" + die + fi
This would be cleaner as a oneliner:
grep -q "CONFIG_DEBUG=y" "xen/.config" || die "CONFIG_DEBUG and --xen-debug mismatch!"
Signature · 6 lines
Ross Lagerwall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 2/3] Update to use a .config file
Quoted 22 lines · Ross Lagerwall
Quoted 21 lines · Konrad Rzeszutek Wilk
Quoted 8 lines
Quoted 4 lines
OK, I'll split it into two. Feel free to create a stable-47 branch in livepatch-build-tools.git with only the .config patch. Personally, I'd rather not spend much time backporting stuff to support a tech preview feature on an older branch.
We will need to update the Wiki a bit too...
What if I we do something simpler?
And the offical patch:
From
929a92b3dbb8467e0a69b50706b69fb206b51ff3Mon Sep 17 00:00:00 2001
From: Konrad Rzeszutek Wilk <[email protected]>
Date: Fri, 15 Jul 2016 09:36:23 -0400
Subject: [PATCH] Check .config forCONFIG_DEBUG. If not found use --xen-debug
(if specified)Xen 4.8 ditched the 'debug=y' and now has
CONFIG_DEBUGin the .config. To still support 4.7 lets just poke the .config file and see.
Quoted 7 lines
Quoted 1 line
Signed-off-by Konrad Rzeszutek Wilk <[email protected]>Is the intention that this gets applied on top of "[PATCH LIVEPATCH-BUILD-TOOLS v2 1/3] Update to use a .config file" and that "[PATCH LIVEPATCH-BUILD-TOOLS v2 2/3] Remove --xen-debug" is dropped?
If so, then the approach looks OK to me.
Yup.
Quoted 47 lines
Quoted 10 lines
--- livepatch-build | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)livepatch-build +0
-0livepatch-build function build_full() · line 69
Quoted 5 lines
livepatch-build +1
-1@@ -66,7 +66,7 @@ function build_full() { cd "${SRCDIR}/xen" || die make "-j$CPUS" clean &> "${OUTPUT}/build_full_clean.log" || die - make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_full_compile.log" || die + make "-j$CPUS" "$XEN_DEBUG" &> "${OUTPUT}/build_full_compile.log" || die$XEN_DEBUG needs to be unquoted, otherwise you get a build error from make:
make: *** empty string invalid as file name. Stop.livepatch-build function build_special() · line 90
Quoted 9 lines
livepatch-build +1
-1cp xen-syms "$OUTPUT" }@@ -87,7 +87,7 @@ function build_special() cd "${SRCDIR}/xen" || die sed -i 's/CFLAGS += -nostdinc/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/' Rules.mk sed -i 's/--section-alignment=0x200000/--section-alignment=0x1000/' arch/x86/Makefile - make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_${name}_compile.log" || die + make "-j$CPUS" "$XEN_DEBUG" &> "${OUTPUT}/build_${name}_compile.log" || dieSame here.
Quoted 16 lines
livepatch-build +1
-1sed -i 's/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/CFLAGS += -nostdinc/' Rules.mk sed -i 's/--section-alignment=0x1000/--section-alignment=0x200000/' arch/x86/Makefile@@ -165,7 +165,7 @@ usage() { echo " -j, --cpus Number of CPUs to use" >&2 echo " -k, --skip Skip build or diff phase" >&2 echo " -d, --debug Enable debug logging" >&2 - echo " --xen-debug Build debug Xen" >&2 + echo " --xen-debug Build debug Xen (if your .config does not have the options)" >&2 echo " --xen-syms Build against a xen-syms" >&2 echo " --depends Required build-id" >&2 echo " --prelink Prelink" >&2@@ -277,6 +277,20 @@ if [ "${SKIP}" != "build" ]; then cp -f "${CONFIGFILE}" "${OUTPUT}/.config" cp -f "${OUTPUT}/.config" "xen/.config"
Quoted 12 lines
livepatch-build if [ "${SKIP}" != "build" ]; then · line 287
Quoted 8 lines
livepatch-build +8
-0+ grep -q CONFIG_DEBUG "xen/.config" + if [ $? -eq 0 ]; then + if [ "$XEN_DEBUG" == "y" ]; then + grep -q "CONFIG_DEBUG=y" "xen/.config" + if [ $? -ne 0 ]; then + echo "CONFIG_DEBUG and --xen-debug mismatch!" + die + fiThis would be cleaner as a oneliner:
grep -q "CONFIG_DEBUG=y" "xen/.config" || die "CONFIG_DEBUGand --xen-debug mismatch!"
Yeah, let me put that in the conditional.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 3/3 Update README.md
In reply to Ross LagerwallUpdate the example and project status. Add Contributing and Maintainers sections.
--- README.md | 76 ++++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 23 deletions(-)
README.md +53 -23
@@ -2,27 +2,34 @@ livepatch-build ============= livepatch-build is a tool for building LivePatch patches from source code -patches. It takes as input, a Xen tree and a patch and outputs an +patches. It takes as input, a Xen tree and a patch and outputs a `.livepatch` module containing containing the live patch. Quick start ----------- First checkout the code, and then run `make` to build it. -Here is an example of building a patch for XSA-106: +Here is an example of building a live patch for Xen for some XSA. +First build Xen, install it on a host somewhere and reboot: +``` +$ cp -r ~/src/xen ~/src/xenbuild +$ cd ~/src/xen/xen +$ make nconfig # Make sure to set CONFIG_LIVEPATCH=y +$ make +$ BUILDID=$(readelf -Wn xen-syms | awk '/Build ID:/ {print $3}') +``` + +Next, build a live patch, using a patch and the source, build ID, and +.config from the original build: ``` -$ cd ~/src/xen -$ git reset --hard -$ git clean -x -f -d -$ git checkout 346d4545569928b652c40c7815c1732676f8587c^ $ cd ~/src/livepatch-build -$ wget -q 'http://xenbits.xen.org/xsa/xsa106.patch' -$ ./livepatch-build --xen-debug -s ~/src/xen -p xsa106.patch -o out -Building LivePatch patch: xsa106 +$ ./livepatch-build -s ~/src/xenbuild -p ~/src/xsa.patch -o out \ + -c ~/src/xen/xen/.config --depends $BUILDID +Building LivePatch patch: xsa -Xen directory: /home/ross/src/xen -Patch file: /home/ross/src/livepatch-build/xsa106.patch -Output directory: /home/ross/src/livepatch-build/out +Xen directory: /home/ross/src/xenbuild +Patch file: /home/ross/src/xsa.patch +Output directory: /home/ross/src/livepatch-build-tools/out ================================================ Testing patch file...
@@ -32,22 +39,45 @@ Unapply patch and build with 4 CPU(s)... Extracting new and modified ELF sections... Processing xen/arch/x86/x86_emulate.o Creating patch module... -xsa106.livepatch created successfully +xsa.livepatch created successfully -$ ls -lh out/xsa106.livepatch --rw-rw-r--. 1 ross ross 418K Oct 12 12:02 out/xsa106.livepatch +$ ls -lh out/xsa.livepatch +-rwxrwxr-x. 1 ross ross 135K Jun 10 09:32 out/xsa.livepatch +``` + +Finally, copy the live patch to the host and load it: +``` +$ scp out/xsa.livepatch myhost: +$ ssh myhost 'xen-livepatch load xsa.livepatch' +Uploading xsa.livepatch (135840 bytes) +Performing apply:. completed +$ ssh myhost 'xen-livepatch list' + ID | status +----------------------------------------+------------ +xsa | APPLIED ``` Project Status -------------- -This is prototype code: - * There's no way to apply built patches - * Patches cannot be built for some source patches - * The output format does not correspond to the latest LivePatch design - -With no source patch modifications, live patches can be built for every -XSA that applies to x86 back to XSA-90 except for XSA-97, XSA-111, -XSA-112, and XSA-114 (83% success rate). +Live patches can be built and applied for many changes, including most +XSAs; however, there are still some cases which require changing the +source patch to allow it to be built as a live patch. + +This tool currently supports x86 only. + +It is intended that some or all of this project will merge back into +kpatch-build rather being maintained as a fork. + +Contributing +------------ +Please send patches created with `git-format-patch` and an appropriate +Signed-off-by: line to <[email protected]>, CCing the maintainers +listed below. + +Maintainers +----------- +* Ross Lagerwall <[email protected]> +* Konrad Rzeszutek Wilk <[email protected]> License -------
Signature · 7 lines
2.4.11 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH 3/3] Update README.md
Quoted 2 lines · Ross Lagerwall
Update the example and project status. Add Contributing and Maintainers sections.
Quoted 117 lines
Signed-off-by Ross Lagerwall <[email protected]>--- README.md | 76 ++++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 23 deletions(-)README.md +53
-23@@ -2,27 +2,34 @@ livepatch-build ============= livepatch-build is a tool for building LivePatch patches from source code -patches. It takes as input, a Xen tree and a patch and outputs an +patches. It takes as input, a Xen tree and a patch and outputs a `.livepatch` module containing containing the live patch. Quick start ----------- First checkout the code, and then run `make` to build it. -Here is an example of building a patch for XSA-106: +Here is an example of building a live patch for Xen for some XSA. +First build Xen, install it on a host somewhere and reboot: +``` +$ cp -r ~/src/xen ~/src/xenbuild +$ cd ~/src/xen/xen +$ make nconfig # Make sure to set CONFIG_LIVEPATCH=y +$ make +$ BUILDID=$(readelf -Wn xen-syms | awk '/Build ID:/ {print $3}') +``` + +Next, build a live patch, using a patch and the source, build ID, and +.config from the original build: ``` -$ cd ~/src/xen -$ git reset --hard -$ git clean -x -f -d -$ git checkout 346d4545569928b652c40c7815c1732676f8587c^ $ cd ~/src/livepatch-build -$ wget -q 'http://xenbits.xen.org/xsa/xsa106.patch' -$ ./livepatch-build --xen-debug -s ~/src/xen -p xsa106.patch -o out -Building LivePatch patch: xsa106 +$ ./livepatch-build -s ~/src/xenbuild -p ~/src/xsa.patch -o out \ + -c ~/src/xen/xen/.config --depends $BUILDID +Building LivePatch patch: xsa -Xen directory: /home/ross/src/xen -Patch file: /home/ross/src/livepatch-build/xsa106.patch -Output directory: /home/ross/src/livepatch-build/out +Xen directory: /home/ross/src/xenbuild +Patch file: /home/ross/src/xsa.patch +Output directory: /home/ross/src/livepatch-build-tools/out ================================================ Testing patch file...@@ -32,22 +39,45 @@ Unapply patch and build with 4 CPU(s)... Extracting new and modified ELF sections... Processing xen/arch/x86/x86_emulate.o Creating patch module... -xsa106.livepatch created successfully +xsa.livepatch created successfully -$ ls -lh out/xsa106.livepatch --rw-rw-r--. 1 ross ross 418K Oct 12 12:02 out/xsa106.livepatch +$ ls -lh out/xsa.livepatch +-rwxrwxr-x. 1 ross ross 135K Jun 10 09:32 out/xsa.livepatch +``` + +Finally, copy the live patch to the host and load it: +``` +$ scp out/xsa.livepatch myhost: +$ ssh myhost 'xen-livepatch load xsa.livepatch' +Uploading xsa.livepatch (135840 bytes) +Performing apply:. completed +$ ssh myhost 'xen-livepatch list' + ID | status +----------------------------------------+------------ +xsa | APPLIED ``` Project Status -------------- -This is prototype code: - * There's no way to apply built patches - * Patches cannot be built for some source patches - * The output format does not correspond to the latest LivePatch design - -With no source patch modifications, live patches can be built for every -XSA that applies to x86 back to XSA-90 except for XSA-97, XSA-111, -XSA-112, and XSA-114 (83% success rate). +Live patches can be built and applied for many changes, including most +XSAs; however, there are still some cases which require changing the +source patch to allow it to be built as a live patch. + +This tool currently supports x86 only. + +It is intended that some or all of this project will merge back into +kpatch-build rather being maintained as a fork. + +Contributing +------------ +Please send patches created with `git-format-patch` and an appropriate +Signed-off-by: line to <[email protected]>, CCing the maintainers +listed below. + +Maintainers +----------- +* Ross Lagerwall <[email protected]> +* Konrad Rzeszutek Wilk <[email protected]> License -------Signature · 1 line
2.4.11
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
livepatch-build
Quoted 10 lines · Ross Lagerwall
When testing and applying patches, set fuzz=0 so that patches must apply exactly. Also set "-f" to avoid interactive questions, and reorder so that patches are tested before the output directory is created.
Signed-off-by Ross Lagerwall <[email protected]>--- livepatch-build | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)livepatch-build +0
-0
I take it this is in the "livepatch" repo, not the core Xen repo?
I think unless / until livepatch has its own mailing list, all patches sent to xen-devel to the livepatch should be prefixed with
"livepatch:", so that people can filter them properly. I realize
this is a bit annoying as then when doing "git log" inside of livepatch.git, you see "livepatch:" at the beginning of every line; but I think it's worth it. That's what raisin does, FWIW.
-George
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 14 lines · George Dunlap
livepatch-build
Quoted 10 lines · Ross Lagerwall
When testing and applying patches, set fuzz=0 so that patches must apply exactly. Also set "-f" to avoid interactive questions, and reorder so that patches are tested before the output directory is created.
Signed-off-by Ross Lagerwall <[email protected]>--- livepatch-build | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)livepatch-build +0
-0I take it this is in the "livepatch" repo, not the core Xen repo?
Quoted 6 lines
I think unless / until livepatch has its own mailing list, all patches sent to xen-devel to the livepatch should be prefixed with
"livepatch:", so that people can filter them properly. I realize
this is a bit annoying as then when doing "git log" inside of livepatch.git, you see "livepatch:" at the beginning of every line; but I think it's worth it. That's what raisin does, FWIW.
An alternative is to use git format-patch --subject-prefix="PATCH livepatch"
This puts livepatch into the email subjects, but gets stripped when applying the patch.
I personally go out of my way to avoid things like "livepatch: " prefixes getting committed into the repo.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 22 lines · Andrew Cooper
Quoted 14 lines · George Dunlap
livepatch-build
Quoted 10 lines · Ross Lagerwall
When testing and applying patches, set fuzz=0 so that patches must apply exactly. Also set "-f" to avoid interactive questions, and reorder so that patches are tested before the output directory is created.
Signed-off-by Ross Lagerwall <[email protected]>--- livepatch-build | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)livepatch-build +0
-0I take it this is in the "livepatch" repo, not the core Xen repo?
Quoted 6 lines
I think unless / until livepatch has its own mailing list, all patches sent to xen-devel to the livepatch should be prefixed with
"livepatch:", so that people can filter them properly. I realize
this is a bit annoying as then when doing "git log" inside of livepatch.git, you see "livepatch:" at the beginning of every line; but I think it's worth it. That's what raisin does, FWIW.
Quoted 4 lines
An alternative is to use git format-patch --subject-prefix="PATCH livepatch"
This puts livepatch into the email subjects, but gets stripped when applying the patch.
Yes, this is a better idea, thanks.
-George
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 15 lines · George Dunlap
livepatch-build
Quoted 10 lines · Ross Lagerwall
When testing and applying patches, set fuzz=0 so that patches must apply exactly. Also set "-f" to avoid interactive questions, and reorder so that patches are tested before the output directory is created.
Signed-off-by Ross Lagerwall <[email protected]>--- livepatch-build | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)livepatch-build +0
-0I take it this is in the "livepatch" repo, not the core Xen repo?
Quoted 7 lines
I think unless / until livepatch has its own mailing list, all patches sent to xen-devel to the livepatch should be prefixed with
"livepatch:", so that people can filter them properly. I realize
this is a bit annoying as then when doing "git log" inside of livepatch.git, you see "livepatch:" at the beginning of every line; but I think it's worth it. That's what raisin does, FWIW.
OK sure, I can do that. I'll take Andrew's suggestion and use a subject prefix.
Thanks,
Signature · 6 lines
Ross Lagerwall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 5 lines · Ross Lagerwall
When testing and applying patches, set fuzz=0 so that patches must apply exactly. Also set "-f" to avoid interactive questions, and reorder so that patches are tested before the output directory is created.
Signed-off-by Ross Lagerwall <[email protected]>
Quoted 40 lines
--- livepatch-build | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)livepatch-build +5
-6@@ -257,23 +257,22 @@ echo if [ "${SKIP}" != "build" ]; then [ -e "${OUTPUT}" ] && die "Output directory exists" - mkdir -p "${OUTPUT}" || die - - echo "Testing patch file..." cd "$SRCDIR" || die - patch -s -N -p1 --dry-run < "$PATCHFILE" || die "source patch file failed to apply" + patch -s -N -p1 -f --fuzz=0 --dry-run < "$PATCHFILE" || die "Source patch file failed to apply" + + mkdir -p "${OUTPUT}" || die echo "Perform full initial build with ${CPUS} CPU(s)..." build_full echo "Apply patch and build with ${CPUS} CPU(s)..." cd "$SRCDIR" || die - patch -s -N -p1 < "$PATCHFILE" || die + patch -s -N -p1 -f --fuzz=0 < "$PATCHFILE" || die build_special patched echo "Unapply patch and build with ${CPUS} CPU(s)..." cd "$SRCDIR" || die - patch -s -R -p1 < "$PATCHFILE" || die + patch -s -R -p1 -f --fuzz=0 < "$PATCHFILE" || die build_special original fiSignature · 1 line
2.4.11
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel