Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/boot: Add XZ support to the wrapper script

This modifies the wrapper script so that the -Z option takes an argument
to specify the compression type. It can either be 'gz', 'xz' or 'none'.

The legazy --no-gzip and -z options are still supported and will set the
compression to none and gzip respectively, but they are not documented.

Only XZ -6 is used for compression rather than XZ -9. Using compression
levels higher than 6 requires the decompressor to build a large (64MB)
dictionary when decompressing and some environments cannot satisfy such
large allocations (e.g. POWER 6 LPAR partition firmware).

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Oliver O'Halloran and committed by
Michael Ellerman
f1e510bb a4da56fb

+50 -18
+5 -2
arch/powerpc/boot/Makefile
··· 225 225 endif 226 226 endif 227 227 228 + compressor-$(CONFIG_KERNEL_GZIP) := gz 229 + 228 230 # args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd 229 231 quiet_cmd_wrap = WRAP $@ 230 - cmd_wrap =$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \ 231 - $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) vmlinux 232 + cmd_wrap =$(CONFIG_SHELL) $(wrapper) -Z $(compressor-y) -c -o $@ -p $2 \ 233 + $(CROSSWRAP) $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) \ 234 + vmlinux 232 235 233 236 image-$(CONFIG_PPC_PSERIES) += zImage.pseries 234 237 image-$(CONFIG_PPC_POWERNV) += zImage.pseries
+45 -16
arch/powerpc/boot/wrapper
··· 20 20 # -D dir specify directory containing data files used by script 21 21 # (default ./arch/powerpc/boot) 22 22 # -W dir specify working directory for temporary files (default .) 23 + # -z use gzip (legacy) 24 + # -Z zsuffix compression to use (gz, xz or none) 23 25 24 26 # Stop execution if any command fails 25 27 set -e ··· 40 38 dts= 41 39 cacheit= 42 40 binary= 43 - gzip=.gz 41 + compression=.gz 44 42 pie= 45 43 format= 46 44 ··· 61 59 usage() { 62 60 echo 'Usage: wrapper [-o output] [-p platform] [-i initrd]' >&2 63 61 echo ' [-d devtree] [-s tree.dts] [-c] [-C cross-prefix]' >&2 64 - echo ' [-D datadir] [-W workingdir] [--no-gzip] [vmlinux]' >&2 62 + echo ' [-D datadir] [-W workingdir] [-Z (gz|xz|none)]' >&2 63 + echo ' [--no-compression] [vmlinux]' >&2 65 64 exit 1 66 65 } 67 66 ··· 129 126 [ "$#" -gt 0 ] || usage 130 127 tmpdir="$1" 131 128 ;; 129 + -z) 130 + compression=.gz 131 + ;; 132 + -Z) 133 + shift 134 + [ "$#" -gt 0 ] || usage 135 + [ "$1" != "gz" -o "$1" != "xz" -o "$1" != "none" ] || usage 136 + 137 + compression=".$1" 138 + 139 + if [ $compression = ".none" ]; then 140 + compression= 141 + fi 142 + ;; 132 143 --no-gzip) 133 - gzip= 144 + # a "feature" of the the wrapper script is that it can be used outside 145 + # the kernel tree. So keeping this around for backwards compatibility. 146 + compression= 134 147 ;; 135 148 -?) 136 149 usage ··· 158 139 esac 159 140 shift 160 141 done 142 + 161 143 162 144 if [ -n "$dts" ]; then 163 145 if [ ! -r "$dts" -a -r "$object/dts/$dts" ]; then ··· 232 212 ;; 233 213 cuboot*) 234 214 binary=y 235 - gzip= 215 + compression= 236 216 case "$platform" in 237 217 *-mpc866ads|*-mpc885ads|*-adder875*|*-ep88xc) 238 218 platformo=$object/cuboot-8xx.o ··· 263 243 ps3) 264 244 platformo="$object/ps3-head.o $object/ps3-hvcall.o $object/ps3.o" 265 245 lds=$object/zImage.ps3.lds 266 - gzip= 246 + compression= 267 247 ext=bin 268 248 objflags="-O binary --set-section-flags=.bss=contents,alloc,load,data" 269 249 ksection=.kernel:vmlinux.bin ··· 330 310 esac 331 311 332 312 vmz="$tmpdir/`basename \"$kernel\"`.$ext" 333 - if [ -z "$cacheit" -o ! -f "$vmz$gzip" -o "$vmz$gzip" -ot "$kernel" ]; then 334 - ${CROSS}objcopy $objflags "$kernel" "$vmz.$$" 335 313 336 - strip_size=$(stat -c %s $vmz.$$) 314 + # Calculate the vmlinux.strip size 315 + ${CROSS}objcopy $objflags "$kernel" "$vmz.$$" 316 + strip_size=$(stat -c %s $vmz.$$) 337 317 338 - if [ -n "$gzip" ]; then 318 + if [ -z "$cacheit" -o ! -f "$vmz$compression" -o "$vmz$compression" -ot "$kernel" ]; then 319 + # recompress the image if we need to 320 + case $compression in 321 + .xz) 322 + xz --check=crc32 -f -6 "$vmz.$$" 323 + ;; 324 + .gz) 339 325 gzip -n -f -9 "$vmz.$$" 340 - fi 326 + ;; 327 + *) 328 + # drop the compression suffix so the stripped vmlinux is used 329 + compression= 330 + ;; 331 + esac 341 332 342 333 if [ -n "$cacheit" ]; then 343 - mv -f "$vmz.$$$gzip" "$vmz$gzip" 334 + mv -f "$vmz.$$$compression" "$vmz$compression" 344 335 else 345 336 vmz="$vmz.$$" 346 337 fi 347 338 else 348 - # Calculate the vmlinux.strip size 349 - ${CROSS}objcopy $objflags "$kernel" "$vmz.$$" 350 - strip_size=$(stat -c %s $vmz.$$) 351 339 rm -f $vmz.$$ 352 340 fi 341 + 342 + vmz="$vmz$compression" 353 343 354 344 if [ "$make_space" = "y" ]; then 355 345 # Round the size to next higher MB limit ··· 375 345 link_address=$round_size 376 346 fi 377 347 fi 378 - 379 - vmz="$vmz$gzip" 380 348 381 349 # Extract kernel version information, some platforms want to include 382 350 # it in the image header ··· 445 417 if [ -n "$link_address" ] ; then 446 418 text_start="-Ttext $link_address" 447 419 fi 420 + #link everything 448 421 ${CROSS}ld -m $format -T $lds $text_start $pie -o "$ofile" \ 449 422 $platformo $tmp $object/wrapper.a 450 423 rm $tmp