|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Fail on errors |
| 4 | +# set -e # not for now |
| 5 | + |
| 6 | +# Show steps we execute |
| 7 | +set -x |
| 8 | + |
| 9 | +# This script needs to operate in the root directory of the CBMC repository |
| 10 | +SCRIPT=$(readlink -e "$0") |
| 11 | +readonly SCRIPT |
| 12 | +SCRIPTDIR=$(dirname "$SCRIPT") |
| 13 | +readonly SCRIPTDIR |
| 14 | +cd "$SCRIPTDIR/../.." |
| 15 | + |
| 16 | +# Build CBMC tools |
| 17 | +make -C src minisat2-download |
| 18 | +make -C src CXX='ccache /usr/bin/g++' cbmc.dir goto-cc.dir goto-diff.dir -j$(nproc) |
| 19 | + |
| 20 | +# Get one-line-scan, if we do not have it already |
| 21 | +[ -d one-line-scan ] || git clone https://github.com/awslabs/one-line-scan.git one-line-scan |
| 22 | + |
| 23 | +# Get Linux v5.10, if we do not have it already |
| 24 | +[ -d linux_5_10 ] || git clone -b v5.10 --depth=1 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux_5_10 |
| 25 | + |
| 26 | +# Prepare compile a part of the kernel with CBMC via one-line-scan |
| 27 | +ln -s goto-cc src/goto-cc/goto-ld |
| 28 | +ln -s goto-cc src/goto-cc/goto-as |
| 29 | +ln -s goto-cc src/goto-cc/goto-g++ |
| 30 | + |
| 31 | + |
| 32 | +configure_linux () |
| 33 | +{ |
| 34 | + pushd linux_5_10 |
| 35 | + |
| 36 | + cat > kvm-config <<EOF |
| 37 | +CONFIG_64BIT=y |
| 38 | +CONFIG_X86_64=y |
| 39 | +CONFIG_HIGH_RES_TIMERS=y |
| 40 | +CONFIG_MULTIUSER=y |
| 41 | +CONFIG_NET=y |
| 42 | +CONFIG_VIRTUALIZATION=y |
| 43 | +CONFIG_HYPERVISOR_GUEST=y |
| 44 | +CONFIG_PARAVIRT=y |
| 45 | +CONFIG_KVM_GUEST=y |
| 46 | +CONFIG_KVM=y |
| 47 | +CONFIG_KVM_INTEL=y |
| 48 | +CONFIG_KVM_AMD=y |
| 49 | +EOF |
| 50 | + # use the configuration from the generated file |
| 51 | + export KCONFIG_ALLCONFIG=kvm-config |
| 52 | + |
| 53 | + # ... and use it during configuration |
| 54 | + make allnoconfig |
| 55 | + popd |
| 56 | +} |
| 57 | + |
| 58 | +# Configure kernel, and compile all of it |
| 59 | +configure_linux |
| 60 | +make -C linux_5_10 bzImage -j $(nproc) |
| 61 | + |
| 62 | +# Clean files we want to be able to re-compile |
| 63 | +find linux_5_10/arch/x86/kvm/ -name "*.o" -delete |
| 64 | + |
| 65 | +# Compile Linux with CBMC via one-line-scan, and check for goto-cc section |
| 66 | +# Re-Compile with goto-cc, and measure disk space |
| 67 | +declare -i STATUS=0 |
| 68 | +du -h --max-depth=1 |
| 69 | +one-line-scan/one-line-scan \ |
| 70 | + --add-to-path $(pwd)/src/cbmc --add-to-path $(pwd)/src/goto-diff --add-to-path $(pwd)/src/goto-cc \ |
| 71 | + --cbmc \ |
| 72 | + --no-analysis \ |
| 73 | + --trunc-existing \ |
| 74 | + --extra-cflags -Wno-error \ |
| 75 | + -o CPROVER -j 5 -- \ |
| 76 | + make -C linux_5_10 bzImage -j $(nproc) || STATUS=$? |
| 77 | +du -h --max-depth=1 |
| 78 | + |
| 79 | +# Check for faulty input |
| 80 | +ls CPROVER/faultyInput/* || true |
| 81 | + |
| 82 | +# Check for produced output in the files we deleted above |
| 83 | +objdump -h linux_5_10/arch/x86/kvm/x86.o | grep "goto-cc" || STATUS=$? |
| 84 | + |
| 85 | +# Propagate failures |
| 86 | +exit "$STATUS" |
0 commit comments