[kvm/x86]: single step fails to exit VM after some instructions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On x86, when executing a VM in single-step mode (from kvmtool), one
instruction may be skipped after some instructions. Following is a way
to reproduce.

Examples of instruction that triggers the behavior (intel syntax):
- out (but not in),
- rdmsr, wrmsr
- mov cr0,ax (but not mov ax, cr0)
- wbinvd
- ...

The skipped instruction is executed as this can be checked with the
details of the single-step information but fail to appear when running
kvmtool --debug-single-step option.

This is a little annoyance but I wonder if it does not make surface a
deeper issue in kvm debugger support.

FF

cat /etc/lsb-release
#DISTRIB_ID=Ubuntu
#DISTRIB_RELEASE=16.10
#DISTRIB_CODENAME=yakkety
#DISTRIB_DESCRIPTION="Ubuntu 16.10"

modinfo kvm
#filename:       /lib/modules/4.8.0-34-generic/kernel/arch/x86/kvm/kvm.ko
#license:        GPL
#author:         Qumranet
#srcversion:     07F4273C7963D92A67AC6C8
#depends:        irqbypass
#intree:         Y
#vermagic:       4.8.0-34-generic SMP mod_unload modversions

uname -a
#Linux XXXXXXXX 4.8.0-34-generic #36-Ubuntu SMP Wed Dec 21 17:24:18
UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

cat <<EOF > nop.S
[SECTION .code]
[BITS 16]
start:
        mov ax,1
        mov bx,ax
        wbinvd
        mov ax,2
        wbinvd
        mov ax,3
        hlt
EOF
nasm nop.S -o nop.bin

#ndisasm -b 16 nop.bin
# gives
#00000000  B80100            mov ax,0x1
#00000003  89C3              mov bx,ax
#00000005  0F09              wbinvd
#00000007  B80200            mov ax,0x2
#0000000A  0F09              wbinvd
#0000000C  B80300            mov ax,0x3
#0000000F  F4                hlt


kvmtool/lkvm run  --cpus 1 --mem 2  --name nop \
 --kernel nop.bin --debug-single-step

#grep on rip: will give
# no VM exit expected for RIP=0
# rip: 0000000000000003   rsp: 0000000000008000 flags: 0000000000000002
# rip: 0000000000000005   rsp: 0000000000008000 flags: 0000000000000002
# no VM exit for RIP=7! but ax is properly set at 2
# rip: 000000000000000a   rsp: 0000000000008000 flags: 0000000000000002
# no VM exit for RIP=c! but ax is properly set at 3
# rip: 000000000000000f   rsp: 0000000000008000 flags: 0000000000000002



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux