RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 924164 - qemu-kvm segmentation fault when enable multifunction, assign two NIC cards to guest, hot unplug one nic card, run system_reset.
Summary: qemu-kvm segmentation fault when enable multifunction, assign two NIC cards t...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm
Version: 7.0
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Alex Williamson
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-03-21 10:19 UTC by huiqingding
Modified: 2014-07-17 12:56 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-07-17 12:56:36 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description huiqingding 2013-03-21 10:19:44 UTC
Description of problem:

Enable multifunction, assign two NIC cards to guest, hot unplug one nic card, run system_reset. qemu-kvm segmentation fault.

Version-Release number of selected component (if applicable):
# uname -r
3.8.0-0.40.el7.x86_64
# uname -r
# rpm -qa | grep qemu-kvm
qemu-kvm-1.4.0-1.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Enable multifunction, assign two NIC cards to guest and boot the guest:
/usr/libexec/qemu-kvm -M pc-1.3 -cpu SandyBridge -enable-kvm -m 2048 -smp 2,sockets=1,cores=2,threads=1 -name rhel7 -uuid 6afa5f93-2d4f-420f-81c6-e5fdddbd1c83 -drive file=/dev/sdb,if=none,id=drive-virtio-disk0,format=qcow2,serial=40c061dd-5d60-4fc5-865f-55db700407f0,cache=none,werror=stop,rerror=stop,aio=threads -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0 -netdev tap,id=hostnet0,vhost=on -device pci-assign,host=00:19.0,multifunction=on,addr=8.0,id=h2guest_nic_1 -device pci-assign,host=04:00.1,addr=8.1,id=h2guest_nic_2 -vnc :1 -qmp tcp:0:4445,server,nowait -monitor stdio

2. On guest, use "lspci" to check NIC card
# lspci | grep Ethernet

2. Hot unplug one NIC card
{"execute":"device_del","arguments":{"id":"h2guest_nic_2"}}

3. On guest, use "lspci" to check NIC card
# lspci | grep Ethernet

4. On host, run system_reset
{"execute":"system_reset"}}

Actual results:
After step4, qemu-kvm segmentation fault

Expected results:
After step4, guest can be rebooted.

Additional info:
(gdb) bt
#0  0x00007ffff2c20e50 in __memcmp_sse4_1 () from /lib64/libc.so.6
#1  0x0000555555793f92 in patch_hypercalls (s=0x55555669e9d0) at /usr/src/debug/qemu-1.4.0/hw/kvmvapic.c:544
#2  vapic_prepare (s=s@entry=0x55555669e9d0) at /usr/src/debug/qemu-1.4.0/hw/kvmvapic.c:609
#3  0x0000555555794316 in vapic_write (opaque=0x55555669e9d0, addr=<optimized out>, data=<optimized out>, size=<optimized out>) at /usr/src/debug/qemu-1.4.0/hw/kvmvapic.c:646
#4  0x00005555557c2942 in access_with_adjusted_size (addr=addr@entry=0, value=value@entry=0x7fffe7dfdae8, size=2, access_size_min=<optimized out>, access_size_max=<optimized out>, 
    access=access@entry=0x5555557c2f60 <memory_region_write_accessor>, opaque=opaque@entry=0x5555566a0cf8) at /usr/src/debug/qemu-1.4.0/memory.c:364
#5  0x00005555557c3fb7 in memory_region_iorange_write (iorange=<optimized out>, offset=0, width=2, data=32) at /usr/src/debug/qemu-1.4.0/memory.c:439
#6  0x00005555557c0d85 in kvm_handle_io (count=1, size=2, direction=1, data=<optimized out>, port=126) at /usr/src/debug/qemu-1.4.0/kvm-all.c:1429
#7  kvm_cpu_exec (env=env@entry=0x5555566852d0) at /usr/src/debug/qemu-1.4.0/kvm-all.c:1581
#8  0x000055555576a871 in qemu_kvm_cpu_thread_fn (arg=0x5555566852d0) at /usr/src/debug/qemu-1.4.0/cpus.c:759
#9  0x00007ffff6487d15 in start_thread () from /lib64/libpthread.so.0
#10 0x00007ffff2bb746d in clone () from /lib64/libc.so.6

Comment 2 Hai Huang 2013-03-22 14:27:01 UTC
Similar to BZ 924099, may not be a valid test case:
attempting to hot-unplug a pci-assigned device.

Please confirm and dispose appropriately.  Thanks.

Comment 4 Ronen Hod 2014-07-13 13:56:07 UTC
1. Not clear if the test case is valid
2. Reassigning to Alex, since it is about PCI assignment
3. Worth rechecking in 7.1 (Is it VFIO only?)

Comment 5 Alex Williamson 2014-07-13 15:38:07 UTC
Please re-test, hot unplug of a single function of a multifunction device should not be allowed.

Comment 6 huiqingding 2014-07-17 07:57:44 UTC
(In reply to Alex Williamson from comment #5)
> Please re-test, hot unplug of a single function of a multifunction device
> should not be allowed.

Hi, Alex,

I re-test this issue using the following version:
kernel-3.10.0-123.6.3.el7.x86_64
qemu-kvm-1.5.3-66.el7.x86_64

Use multifunction=on, asssign two functions of a device to the guest, when hot unplug a single function, two functions of the device will be removed.

Steps to test:
1. boot a guest and assign two functions with "multifunction=on"  
# /usr/libexec/qemu-kvm -M pc -enable-kvm -m 2048 -smp 2,sockets=1,cores=2,threads=1 -name rhel7 -uuid 6afa5f93-2d4f-420f-81c6-e5fdddbd1c83 -drive file=/home/huding/rhel7-test.qcow2,if=none,id=drive-virtio-disk0,format=qcow2,serial=40c061dd-5d60-4fc5-865f-55db700407f0,cache=none,werror=stop,rerror=stop,aio=threads -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0 -device vfio-pci,host=01:00.0,id=h2guest_nic_1,multifunction=on,addr=8.0 -device vfio-pci,host=01:00.1,id=h2guest_nic_2,addr=8.1 -vnc :1 -qmp tcp:0:4445,server,nowait -monitor stdio

2. use "info pci" to check the assigned device

3. hot unplug a single function
{"execute":"device_del","arguments":{"id":"h2guest_nic_2"}}
{"return": {}}
{"timestamp": {"seconds": 1405581765, "microseconds": 929385}, "event": "DEVICE_DELETED", "data": {"device": "h2guest_nic_2", "path": "/machine/peripheral/h2guest_nic_2"}}
{"timestamp": {"seconds": 1405581766, "microseconds": 161433}, "event": "DEVICE_DELETED", "data": {"device": "h2guest_nic_1", "path": "/machine/peripheral/h2guest_nic_1"}}

4. use "info pci" to check the assigned device

5. run "system_reset"

Actual results:
after step2, two functions can be found as following:
  Bus  0, device   8, function 0:
    Ethernet controller: PCI device 8086:1528
      IRQ 11.
      BAR0: 64 bit prefetchable memory at 0xfe000000 [0xfe1fffff].
      BAR4: 64 bit prefetchable memory at 0xfe400000 [0xfe403fff].
      BAR6: 32 bit memory at 0xffffffffffffffff [0x0007fffe].
      id "h2guest_nic_1"
  Bus  0, device   8, function 1:
    Ethernet controller: PCI device 8086:1528
      IRQ 10.
      BAR0: 64 bit prefetchable memory at 0xfe200000 [0xfe3fffff].
      BAR4: 64 bit prefetchable memory at 0xfe404000 [0xfe407fff].
      BAR6: 32 bit memory at 0xffffffffffffffff [0x0007fffe].
      id "h2guest_nic_2"
after step4, two functions are all removed.
after step5, the guest can reboot normally.

Comment 7 Alex Williamson 2014-07-17 12:56:36 UTC
Thanks for the re-test, it appears to function as expected.


Note You need to log in before you can comment on or make changes to this bug.