11b7dd7d3SSergey Bronnikov#!/usr/bin/env bash 2928ec374SMichael S. Tsirkin 357ab5a6dSThomas Huthif [ -z "$KUT_STANDALONE" ]; then 4786bfc8dSAndrew Jones if [ ! -f config.mak ]; then 5786bfc8dSAndrew Jones echo "run ./configure && make first. See ./configure -h" 6786bfc8dSAndrew Jones exit 2 7786bfc8dSAndrew Jones fi 8786bfc8dSAndrew Jones source config.mak 9786bfc8dSAndrew Jones source scripts/arch-run.bash 10db9c4e1cSAlexandru Elisei source scripts/vmm.bash 11786bfc8dSAndrew Jonesfi 12b2a2aa5dSAndrew Jones 1301e047d0SGavin Shanset_qemu_accelerator || exit $? 1423505cedSRadim Krčmář 15fcf4e0d9SRadim Krčmářqemu=$(search_qemu_binary) || 16fcf4e0d9SRadim Krčmář exit $? 17b895b967SBandan Das 18eff4e220SBalamuruhan Sif ! ${qemu} -device '?' 2>&1 | grep -F -e \"testdev\" -e \"pc-testdev\" > /dev/null; 19b895b967SBandan Dasthen 20b895b967SBandan Das echo "No Qemu test device support found" 21a3831260SAndrew Jones exit 2 22928ec374SMichael S. Tsirkinfi 23928ec374SMichael S. Tsirkin 24ec3c77fbSRen, Yongjieif 25740001b3SRen, Yongjie ${qemu} -device '?' 2>&1 | grep -F "pci-testdev" > /dev/null; 265292dbf7SMichael S. Tsirkinthen 275292dbf7SMichael S. Tsirkin pci_testdev="-device pci-testdev" 285292dbf7SMichael S. Tsirkinelse 295292dbf7SMichael S. Tsirkin pci_testdev="" 305292dbf7SMichael S. Tsirkinfi 315292dbf7SMichael S. Tsirkin 32928ec374SMichael S. Tsirkinif 33740001b3SRen, Yongjie ${qemu} -device '?' 2>&1 | grep -F "pc-testdev" > /dev/null; 34928ec374SMichael S. Tsirkinthen 355292dbf7SMichael S. Tsirkin pc_testdev="-device pc-testdev -device isa-debug-exit,iobase=0xf4,iosize=0x4" 36928ec374SMichael S. Tsirkinelse 375292dbf7SMichael S. Tsirkin pc_testdev="-device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out" 38928ec374SMichael S. Tsirkinfi 3909142098SKevin Wolf 403dab6993SSean Christopherson# Discard lost ticks from the Programmable Interval Timer (PIT, a.k.a 8254), as 413dab6993SSean Christopherson# enabling KVM's re-injection mode inhibits (x2)AVIC, i.e. prevents validating 423dab6993SSean Christopherson# (x2)AVIC. Note, the realmode test relies on the PIT, but not re-injection. 433dab6993SSean Christophersonpit="-global kvm-pit.lost_tick_policy=discard" 443dab6993SSean Christopherson 45*af1490ddSPaolo Bonzinicommand="${qemu} --no-reboot -nodefaults $pit $pc_testdev -display none -serial stdio $pci_testdev" 4601e047d0SGavin Shancommand+=" -machine accel=$ACCEL$ACCEL_PROPS" 47c98ce6e0SAlexandru Eliseiif [ "${CONFIG_EFI}" != y ]; then 48ad5fb883SZixuan Wang command+=" -kernel" 49ad5fb883SZixuan Wangfi 50fd149358SAndrew Jonescommand="$(timeout_cmd) $command" 5192a1afcbSAndrew Jones 52c98ce6e0SAlexandru Eliseiif [ "${CONFIG_EFI}" = y ]; then 53ad5fb883SZixuan Wang # Set ENVIRON_DEFAULT=n to remove '-initrd' flag for QEMU (see 54ad5fb883SZixuan Wang # 'scripts/arch-run.bash' for more details). This is because when using 55ad5fb883SZixuan Wang # UEFI, the test case binaries are passed to QEMU through the disk 56ad5fb883SZixuan Wang # image, not through the '-kernel' flag. And QEMU reports an error if it 57ad5fb883SZixuan Wang # gets '-initrd' without a '-kernel' 58db9c4e1cSAlexandru Elisei ENVIRON_DEFAULT=n run_test ${command} "$@" 59ad5fb883SZixuan Wangelse 60db9c4e1cSAlexandru Elisei run_test ${command} "$@" 61ad5fb883SZixuan Wangfi 62