xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] Don't accept fuzz when patching
@ 2016-06-10 11:02 Ross Lagerwall
  2016-06-10 11:02 ` [PATCH 2/3] Update to use a .config file Ross Lagerwall
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Ross Lagerwall @ 2016-06-10 11:02 UTC (permalink / raw)
  To: xen-devel; +Cc: 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 <ross.lagerwall@citrix.com>
---
 livepatch-build | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/livepatch-build b/livepatch-build
index a49e0d4..8dc8889 100755
--- a/livepatch-build
+++ b/livepatch-build
@@ -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
 
-- 
2.4.11


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/3] Update to use a .config file
  2016-06-10 11:02 [PATCH 1/3] Don't accept fuzz when patching Ross Lagerwall
@ 2016-06-10 11:02 ` Ross Lagerwall
  2016-06-14 15:35   ` Konrad Rzeszutek Wilk
  2016-06-10 11:02 ` [PATCH 3/3] Update README.md Ross Lagerwall
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 17+ messages in thread
From: Ross Lagerwall @ 2016-06-10 11:02 UTC (permalink / raw)
  To: xen-devel; +Cc: Ross Lagerwall

Remove the old --xen-debug option, and instead, require the user to pass
a .config file matching the original build's .config.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 livepatch-build | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/livepatch-build b/livepatch-build
index 8dc8889..e9d1e8d 100755
--- a/livepatch-build
+++ b/livepatch-build
@@ -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
-- 
2.4.11


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/3] Update README.md
  2016-06-10 11:02 [PATCH 1/3] Don't accept fuzz when patching Ross Lagerwall
  2016-06-10 11:02 ` [PATCH 2/3] Update to use a .config file Ross Lagerwall
@ 2016-06-10 11:02 ` Ross Lagerwall
  2016-06-14 15:36   ` Konrad Rzeszutek Wilk
  2016-06-13 10:08 ` [PATCH 1/3] Don't accept fuzz when patching George Dunlap
  2016-06-14 15:33 ` Konrad Rzeszutek Wilk
  3 siblings, 1 reply; 17+ messages in thread
From: Ross Lagerwall @ 2016-06-10 11:02 UTC (permalink / raw)
  To: xen-devel; +Cc: Ross Lagerwall

Update the example and project status. Add Contributing and Maintainers
sections.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 README.md | 76 ++++++++++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 53 insertions(+), 23 deletions(-)

diff --git a/README.md b/README.md
index 9fb709f..653c624 100644
--- a/README.md
+++ b/README.md
@@ -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 <xen-devel@lists.xen.org>, CCing the maintainers
+listed below.
+
+Maintainers
+-----------
+* Ross Lagerwall <ross.lagerwall@citrix.com>
+* Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
 
 License
 -------
-- 
2.4.11


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] Don't accept fuzz when patching
  2016-06-10 11:02 [PATCH 1/3] Don't accept fuzz when patching Ross Lagerwall
  2016-06-10 11:02 ` [PATCH 2/3] Update to use a .config file Ross Lagerwall
  2016-06-10 11:02 ` [PATCH 3/3] Update README.md Ross Lagerwall
@ 2016-06-13 10:08 ` George Dunlap
  2016-06-13 10:16   ` Andrew Cooper
  2016-06-13 10:23   ` Ross Lagerwall
  2016-06-14 15:33 ` Konrad Rzeszutek Wilk
  3 siblings, 2 replies; 17+ messages in thread
From: George Dunlap @ 2016-06-13 10:08 UTC (permalink / raw)
  To: Ross Lagerwall; +Cc: xen-devel

On Fri, Jun 10, 2016 at 12:02 PM, Ross Lagerwall
<ross.lagerwall@citrix.com> wrote:
> 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 <ross.lagerwall@citrix.com>
> ---
>  livepatch-build | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/livepatch-build b/livepatch-build

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
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] Don't accept fuzz when patching
  2016-06-13 10:08 ` [PATCH 1/3] Don't accept fuzz when patching George Dunlap
@ 2016-06-13 10:16   ` Andrew Cooper
  2016-06-13 10:57     ` George Dunlap
  2016-06-13 10:23   ` Ross Lagerwall
  1 sibling, 1 reply; 17+ messages in thread
From: Andrew Cooper @ 2016-06-13 10:16 UTC (permalink / raw)
  To: George Dunlap, Ross Lagerwall; +Cc: xen-devel

On 13/06/16 11:08, George Dunlap wrote:
> On Fri, Jun 10, 2016 at 12:02 PM, Ross Lagerwall
> <ross.lagerwall@citrix.com> wrote:
>> 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 <ross.lagerwall@citrix.com>
>> ---
>>  livepatch-build | 11 +++++------
>>  1 file changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/livepatch-build b/livepatch-build
> 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.

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
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] Don't accept fuzz when patching
  2016-06-13 10:08 ` [PATCH 1/3] Don't accept fuzz when patching George Dunlap
  2016-06-13 10:16   ` Andrew Cooper
@ 2016-06-13 10:23   ` Ross Lagerwall
  1 sibling, 0 replies; 17+ messages in thread
From: Ross Lagerwall @ 2016-06-13 10:23 UTC (permalink / raw)
  To: George Dunlap; +Cc: xen-devel

On 06/13/2016 11:08 AM, George Dunlap wrote:
> On Fri, Jun 10, 2016 at 12:02 PM, Ross Lagerwall
> <ross.lagerwall@citrix.com> wrote:
>> 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 <ross.lagerwall@citrix.com>
>> ---
>>   livepatch-build | 11 +++++------
>>   1 file changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/livepatch-build b/livepatch-build
>
> 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.
>

OK sure, I can do that. I'll take Andrew's suggestion and use a subject 
prefix.

Thanks,
-- 
Ross Lagerwall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] Don't accept fuzz when patching
  2016-06-13 10:16   ` Andrew Cooper
@ 2016-06-13 10:57     ` George Dunlap
  0 siblings, 0 replies; 17+ messages in thread
From: George Dunlap @ 2016-06-13 10:57 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Ross Lagerwall, xen-devel

On Mon, Jun 13, 2016 at 11:16 AM, Andrew Cooper
<andrew.cooper3@citrix.com> wrote:
> On 13/06/16 11:08, George Dunlap wrote:
>> On Fri, Jun 10, 2016 at 12:02 PM, Ross Lagerwall
>> <ross.lagerwall@citrix.com> wrote:
>>> 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 <ross.lagerwall@citrix.com>
>>> ---
>>>  livepatch-build | 11 +++++------
>>>  1 file changed, 5 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/livepatch-build b/livepatch-build
>> 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.
>
> 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
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] Don't accept fuzz when patching
  2016-06-10 11:02 [PATCH 1/3] Don't accept fuzz when patching Ross Lagerwall
                   ` (2 preceding siblings ...)
  2016-06-13 10:08 ` [PATCH 1/3] Don't accept fuzz when patching George Dunlap
@ 2016-06-14 15:33 ` Konrad Rzeszutek Wilk
  3 siblings, 0 replies; 17+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-06-14 15:33 UTC (permalink / raw)
  To: Ross Lagerwall; +Cc: xen-devel

On Fri, Jun 10, 2016 at 12:02:43PM +0100, Ross Lagerwall wrote:
> 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 <ross.lagerwall@citrix.com>

Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
>  livepatch-build | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/livepatch-build b/livepatch-build
> index a49e0d4..8dc8889 100755
> --- a/livepatch-build
> +++ b/livepatch-build
> @@ -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
>  
> -- 
> 2.4.11
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/3] Update to use a .config file
  2016-06-10 11:02 ` [PATCH 2/3] Update to use a .config file Ross Lagerwall
@ 2016-06-14 15:35   ` Konrad Rzeszutek Wilk
  2016-06-15  8:08     ` Ross Lagerwall
  0 siblings, 1 reply; 17+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-06-14 15:35 UTC (permalink / raw)
  To: Ross Lagerwall; +Cc: xen-devel

On Fri, Jun 10, 2016 at 12:02:44PM +0100, Ross Lagerwall wrote:
> 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?

> 
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
> ---
>  livepatch-build | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/livepatch-build b/livepatch-build
> index 8dc8889..e9d1e8d 100755
> --- a/livepatch-build
> +++ b/livepatch-build
> @@ -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
> -- 
> 2.4.11
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/3] Update README.md
  2016-06-10 11:02 ` [PATCH 3/3] Update README.md Ross Lagerwall
@ 2016-06-14 15:36   ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 17+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-06-14 15:36 UTC (permalink / raw)
  To: Ross Lagerwall; +Cc: xen-devel

On Fri, Jun 10, 2016 at 12:02:45PM +0100, Ross Lagerwall wrote:
> Update the example and project status. Add Contributing and Maintainers
> sections.

Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> 
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
> ---
>  README.md | 76 ++++++++++++++++++++++++++++++++++++++++++++-------------------
>  1 file changed, 53 insertions(+), 23 deletions(-)
> 
> diff --git a/README.md b/README.md
> index 9fb709f..653c624 100644
> --- a/README.md
> +++ b/README.md
> @@ -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 <xen-devel@lists.xen.org>, CCing the maintainers
> +listed below.
> +
> +Maintainers
> +-----------
> +* Ross Lagerwall <ross.lagerwall@citrix.com>
> +* Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>  
>  License
>  -------
> -- 
> 2.4.11
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/3] Update to use a .config file
  2016-06-14 15:35   ` Konrad Rzeszutek Wilk
@ 2016-06-15  8:08     ` Ross Lagerwall
  2016-06-15 14:00       ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 17+ messages in thread
From: Ross Lagerwall @ 2016-06-15  8:08 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk; +Cc: xen-devel

On 06/14/2016 04:35 PM, Konrad Rzeszutek Wilk wrote:
> On Fri, Jun 10, 2016 at 12:02:44PM +0100, Ross Lagerwall wrote:
>> 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?

>
> 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.

-- 
Ross Lagerwall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/3] Update to use a .config file
  2016-06-15  8:08     ` Ross Lagerwall
@ 2016-06-15 14:00       ` Konrad Rzeszutek Wilk
  2016-07-14  8:05         ` Ross Lagerwall
  0 siblings, 1 reply; 17+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-06-15 14:00 UTC (permalink / raw)
  To: Ross Lagerwall; +Cc: xen-devel

On Wed, Jun 15, 2016 at 09:08:46AM +0100, Ross Lagerwall wrote:
> On 06/14/2016 04:35 PM, Konrad Rzeszutek Wilk wrote:
> >On Fri, Jun 10, 2016 at 12:02:44PM +0100, Ross Lagerwall wrote:
> >>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?
> 
> >
> >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?
> 
> -- 
> Ross Lagerwall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/3] Update to use a .config file
  2016-06-15 14:00       ` Konrad Rzeszutek Wilk
@ 2016-07-14  8:05         ` Ross Lagerwall
  2016-07-15 13:36           ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 17+ messages in thread
From: Ross Lagerwall @ 2016-07-14  8:05 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk; +Cc: xen-devel

On 06/15/2016 03:00 PM, Konrad Rzeszutek Wilk wrote:
> On Wed, Jun 15, 2016 at 09:08:46AM +0100, Ross Lagerwall wrote:
>> On 06/14/2016 04:35 PM, Konrad Rzeszutek Wilk wrote:
>>> On Fri, Jun 10, 2016 at 12:02:44PM +0100, Ross Lagerwall wrote:
>>>> 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?
>>
>>>
>>> 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?
>>

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.

-- 
Ross Lagerwall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/3] Update to use a .config file
  2016-07-14  8:05         ` Ross Lagerwall
@ 2016-07-15 13:36           ` Konrad Rzeszutek Wilk
  2016-07-16  1:55             ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 17+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-07-15 13:36 UTC (permalink / raw)
  To: Ross Lagerwall; +Cc: xen-devel

On Thu, Jul 14, 2016 at 09:05:36AM +0100, Ross Lagerwall wrote:
> On 06/15/2016 03:00 PM, Konrad Rzeszutek Wilk wrote:
> >On Wed, Jun 15, 2016 at 09:08:46AM +0100, Ross Lagerwall wrote:
> >>On 06/14/2016 04:35 PM, Konrad Rzeszutek Wilk wrote:
> >>>On Fri, Jun 10, 2016 at 12:02:44PM +0100, Ross Lagerwall wrote:
> >>>>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?
> >>
> >>>
> >>>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?
> >>
> 
> 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?


diff --git a/livepatch-build b/livepatch-build
index 6254c29..97b33a5 100755
--- a/livepatch-build
+++ b/livepatch-build
@@ -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
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/3] Update to use a .config file
  2016-07-15 13:36           ` Konrad Rzeszutek Wilk
@ 2016-07-16  1:55             ` Konrad Rzeszutek Wilk
  2016-07-18  9:33               ` Ross Lagerwall
  0 siblings, 1 reply; 17+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-07-16  1:55 UTC (permalink / raw)
  To: Ross Lagerwall; +Cc: xen-devel

> > 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 <konrad.wilk@oracle.com>
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.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 livepatch-build | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/livepatch-build b/livepatch-build
index 6254c29..2165e3b 100755
--- a/livepatch-build
+++ b/livepatch-build
@@ -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
 
-- 
2.5.5


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/3] Update to use a .config file
  2016-07-16  1:55             ` Konrad Rzeszutek Wilk
@ 2016-07-18  9:33               ` Ross Lagerwall
  2016-07-18 10:28                 ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 17+ messages in thread
From: Ross Lagerwall @ 2016-07-18  9:33 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk; +Cc: xen-devel

On 07/16/2016 02:55 AM, Konrad Rzeszutek Wilk wrote:
>>> 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 <konrad.wilk@oracle.com>
> 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.
>
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

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.

> ---
>  livepatch-build | 20 +++++++++++++++++---
>  1 file changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/livepatch-build b/livepatch-build
> index 6254c29..2165e3b 100755
> --- a/livepatch-build
> +++ b/livepatch-build
> @@ -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.

>      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

Same here.

>      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

This would be cleaner as a oneliner:
grep -q "CONFIG_DEBUG=y" "xen/.config" || die "CONFIG_DEBUG and 
--xen-debug mismatch!"

-- 
Ross Lagerwall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/3] Update to use a .config file
  2016-07-18  9:33               ` Ross Lagerwall
@ 2016-07-18 10:28                 ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 17+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-07-18 10:28 UTC (permalink / raw)
  To: Ross Lagerwall; +Cc: xen-devel

On Mon, Jul 18, 2016 at 10:33:49AM +0100, Ross Lagerwall wrote:
> On 07/16/2016 02:55 AM, Konrad Rzeszutek Wilk wrote:
> > > > 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 <konrad.wilk@oracle.com>
> > 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.
> > 
> > Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> 
> 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.
> 
> > ---
> >  livepatch-build | 20 +++++++++++++++++---
> >  1 file changed, 17 insertions(+), 3 deletions(-)
> > 
> > diff --git a/livepatch-build b/livepatch-build
> > index 6254c29..2165e3b 100755
> > --- a/livepatch-build
> > +++ b/livepatch-build
> > @@ -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.
> 
> >      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
> 
> Same here.
> 
> >      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
> 
> This would be cleaner as a oneliner:
> grep -q "CONFIG_DEBUG=y" "xen/.config" || die "CONFIG_DEBUG and --xen-debug
> mismatch!"

Yeah, let me put that in the conditional.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2016-07-18 10:28 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-10 11:02 [PATCH 1/3] Don't accept fuzz when patching Ross Lagerwall
2016-06-10 11:02 ` [PATCH 2/3] Update to use a .config file Ross Lagerwall
2016-06-14 15:35   ` Konrad Rzeszutek Wilk
2016-06-15  8:08     ` Ross Lagerwall
2016-06-15 14:00       ` Konrad Rzeszutek Wilk
2016-07-14  8:05         ` Ross Lagerwall
2016-07-15 13:36           ` Konrad Rzeszutek Wilk
2016-07-16  1:55             ` Konrad Rzeszutek Wilk
2016-07-18  9:33               ` Ross Lagerwall
2016-07-18 10:28                 ` Konrad Rzeszutek Wilk
2016-06-10 11:02 ` [PATCH 3/3] Update README.md Ross Lagerwall
2016-06-14 15:36   ` Konrad Rzeszutek Wilk
2016-06-13 10:08 ` [PATCH 1/3] Don't accept fuzz when patching George Dunlap
2016-06-13 10:16   ` Andrew Cooper
2016-06-13 10:57     ` George Dunlap
2016-06-13 10:23   ` Ross Lagerwall
2016-06-14 15:33 ` Konrad Rzeszutek Wilk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).