Commit 72fc7d7f authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2020-06-16' into staging



* Latest fuzzer patches from Alexander
* Fixes for the qtest bios-tables-test
* LGPL information cleanup in qtest code
* sh4 acceptance test
* Improved submodule handling for the s390x CI test

# gpg: Signature made Tue 16 Jun 2020 08:56:10 BST
# gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg:                issuer "thuth@redhat.com"
# gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" [full]
# gpg:                 aka "Thomas Huth <thuth@redhat.com>" [full]
# gpg:                 aka "Thomas Huth <huth@tuxfamily.org>" [full]
# gpg:                 aka "Thomas Huth <th.huth@posteo.de>" [unknown]
# Primary key fingerprint: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5

* remotes/huth-gitlab/tags/pull-request-2020-06-16:
  configure: Let SLOF be initialized by ./scripts/git-submodule.sh
  tests/acceptance: Add boot tests for sh4 QEMU advent calendar image
  tests/qtest: Fix LGPL information in the file headers
  fuzz: add oss-fuzz build-script
  fuzz: Add support for logging QTest commands
  fuzz: skip QTest serialization
  bios-tables-test: Fix "-tpmdev: invalid option"

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents 53550e81 1ef6bfc2
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -293,7 +293,7 @@ jobs:
    - name: "GCC check-acceptance"
      dist: bionic
      env:
        - CONFIG="--enable-tools --target-list=aarch64-softmmu,alpha-softmmu,arm-softmmu,m68k-softmmu,microblaze-softmmu,mips-softmmu,mips64el-softmmu,nios2-softmmu,or1k-softmmu,ppc-softmmu,ppc64-softmmu,s390x-softmmu,sparc-softmmu,x86_64-softmmu,xtensa-softmmu"
        - CONFIG="--enable-tools --target-list=aarch64-softmmu,alpha-softmmu,arm-softmmu,m68k-softmmu,microblaze-softmmu,mips-softmmu,mips64el-softmmu,nios2-softmmu,or1k-softmmu,ppc-softmmu,ppc64-softmmu,s390x-softmmu,sh4-softmmu,sparc-softmmu,x86_64-softmmu,xtensa-softmmu"
        - TEST_CMD="make check-acceptance"
        - CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-acceptance"
      after_script:
@@ -496,7 +496,6 @@ jobs:
        - CONFIG="--disable-containers --target-list=${MAIN_SOFTMMU_TARGETS},s390x-linux-user"
        - UNRELIABLE=true
      script:
        - ( cd ${SRC_DIR} ; git submodule update --init roms/SLOF )
        - BUILD_RC=0 && make -j${JOBS} || BUILD_RC=$?
        - |
          if [ "$BUILD_RC" -eq 0 ] ; then
+1 −0
Original line number Diff line number Diff line
@@ -2339,6 +2339,7 @@ R: Bandan Das <bsd@redhat.com>
R: Stefan Hajnoczi <stefanha@redhat.com>
S: Maintained
F: tests/qtest/fuzz/
F: scripts/oss-fuzz/

Register API
M: Alistair Francis <alistair@alistair23.me>
+5 −0
Original line number Diff line number Diff line
@@ -6600,6 +6600,11 @@ if test "$cpu" = "s390x" ; then
  write_c_skeleton
  if compile_prog "-march=z900" ""; then
    roms="$roms s390-ccw"
    # SLOF is required for building the s390-ccw firmware on s390x,
    # since it is using the libnet code from SLOF for network booting.
    if test -e "${source_path}/.git" ; then
      git_submodules="${git_submodules} roms/SLOF"
    fi
  fi
fi

+105 −0
Original line number Diff line number Diff line
#!/bin/sh -e
#
# OSS-Fuzz build script. See:
# https://google.github.io/oss-fuzz/getting-started/new-project-guide/#buildsh
#
# The file is consumed by:
# https://github.com/google/oss-fuzz/blob/master/projects/qemu/Dockerfiles
#
# This code is licensed under the GPL version 2 or later.  See
# the COPYING file in the top-level directory.
#

# build project
# e.g.
# ./autogen.sh
# ./configure
# make -j$(nproc) all

# build fuzzers
# e.g.
# $CXX $CXXFLAGS -std=c++11 -Iinclude \
#     /path/to/name_of_fuzzer.cc -o $OUT/name_of_fuzzer \
#     $LIB_FUZZING_ENGINE /path/to/library.a

fatal () {
    echo "Error : ${*}, exiting."
    exit 1
}

OSS_FUZZ_BUILD_DIR="./build-oss-fuzz/"

# There seems to be a bug in clang-11 (used for builds on oss-fuzz) :
#   accel/tcg/cputlb.o: In function `load_memop':
#   accel/tcg/cputlb.c:1505: undefined reference to `qemu_build_not_reached'
#
# When building with optimization, the compiler is expected to prove that the
# statement cannot be reached, and remove it. For some reason clang-11 doesn't
# remove it, resulting in an unresolved reference to qemu_build_not_reached
# Undefine the __OPTIMIZE__ macro which compiler.h relies on to choose whether
# to " #define qemu_build_not_reached()  g_assert_not_reached() "
EXTRA_CFLAGS="$CFLAGS -U __OPTIMIZE__"

if ! { [ -e "./COPYING" ] &&
   [ -e "./MAINTAINERS" ] &&
   [ -e "./Makefile" ] &&
   [ -e "./docs" ] &&
   [ -e "./VERSION" ] &&
   [ -e "./linux-user" ] &&
   [ -e "./softmmu" ];} ; then
    fatal "Please run the script from the top of the QEMU tree"
fi

mkdir -p $OSS_FUZZ_BUILD_DIR || fatal "mkdir $OSS_FUZZ_BUILD_DIR failed"
cd $OSS_FUZZ_BUILD_DIR || fatal "cd $OSS_FUZZ_BUILD_DIR failed"


if [ -z ${LIB_FUZZING_ENGINE+x} ]; then
    LIB_FUZZING_ENGINE="-fsanitize=fuzzer"
fi

if [ -z ${OUT+x} ]; then
    DEST_DIR=$(realpath "./DEST_DIR")
else
    DEST_DIR=$OUT
fi

mkdir -p "$DEST_DIR/lib/"  # Copy the shared libraries here

# Build once to get the list of dynamic lib paths, and copy them over
../configure --disable-werror --cc="$CC" --cxx="$CXX" \
    --extra-cflags="$EXTRA_CFLAGS"

if ! make CONFIG_FUZZ=y CFLAGS="$LIB_FUZZING_ENGINE" "-j$(nproc)" \
    i386-softmmu/fuzz; then
    fatal "Build failed. Please specify a compiler with fuzzing support"\
          "using the \$CC and \$CXX environemnt variables, or specify a"\
          "\$LIB_FUZZING_ENGINE compatible with your compiler"\
          "\nFor example: CC=clang CXX=clang++ $0"
fi

for i in $(ldd ./i386-softmmu/qemu-fuzz-i386 | cut -f3 -d' '); do
    cp "$i" "$DEST_DIR/lib/"
done
rm ./i386-softmmu/qemu-fuzz-i386

# Build a second time to build the final binary with correct rpath
../configure --bindir="$DEST_DIR" --datadir="$DEST_DIR/data/" --disable-werror \
    --cc="$CC" --cxx="$CXX" --extra-cflags="$EXTRA_CFLAGS" \
    --extra-ldflags="-Wl,-rpath,'\$\$ORIGIN/lib'"
make CONFIG_FUZZ=y CFLAGS="$LIB_FUZZING_ENGINE" "-j$(nproc)" i386-softmmu/fuzz

# Copy over the datadir
cp  -r ../pc-bios/ "$DEST_DIR/pc-bios"

# Run the fuzzer with no arguments, to print the help-string and get the list
# of available fuzz-targets. Copy over the qemu-fuzz-i386, naming it according
# to each available fuzz target (See 05509c8e6d fuzz: select fuzz target using
# executable name)
for target in $(./i386-softmmu/qemu-fuzz-i386 | awk '$1 ~ /\*/  {print $2}');
do
    cp ./i386-softmmu/qemu-fuzz-i386 "$DEST_DIR/qemu-fuzz-i386-target-$target"
done

echo "Done. The fuzzers are located in $DEST_DIR"
exit 0
+11 −2
Original line number Diff line number Diff line
@@ -858,12 +858,12 @@ class BootLinuxConsole(LinuxKernelTest):
        console_pattern = 'No filesystem could mount root'
        self.wait_for_console_pattern(console_pattern)

    def do_test_advcal_2018(self, day, tar_hash, kernel_name):
    def do_test_advcal_2018(self, day, tar_hash, kernel_name, console=0):
        tar_url = ('https://www.qemu-advent-calendar.org'
                   '/2018/download/day' + day + '.tar.xz')
        file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
        archive.extract(file_path, self.workdir)
        self.vm.set_console()
        self.vm.set_console(console_index=console)
        self.vm.add_args('-kernel',
                         self.workdir + '/day' + day + '/' + kernel_name)
        self.vm.launch()
@@ -937,6 +937,15 @@ class BootLinuxConsole(LinuxKernelTest):
        self.vm.add_args('-M', 'graphics=off')
        self.do_test_advcal_2018('15', tar_hash, 'invaders.elf')

    def test_sh4_r2d(self):
        """
        :avocado: tags=arch:sh4
        :avocado: tags=machine:r2d
        """
        tar_hash = 'fe06a4fd8ccbf2e27928d64472939d47829d4c7e'
        self.vm.add_args('-append', 'console=ttySC1')
        self.do_test_advcal_2018('09', tar_hash, 'zImage', console=1)

    def test_sparc_ss20(self):
        """
        :avocado: tags=arch:sparc
Loading