<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Sorry, false alarm (of sorts), I was sending corrupt file descriptors when registering the IRQ eventfd descriptors. Still not very good that the kernel went bang...<BR> <BR>I reduced the code to a small test case, which produced a recursive kernel fault instead, if anyone wants to investigate.<BR> <BR>Cheers,<BR>Chris<br> <BR><div><hr id="stopSpelling">From: the_cartographer@hotmail.com<br>To: alex.williamson@redhat.com<br>Date: Fri, 12 Aug 2016 10:27:28 +0000<br>CC: vfio-users@redhat.com<br>Subject: Re: [vfio-users] Cannot register eventfd with MSI/MSI-X interrupts<br><br>

<style><!--
.ExternalClass .ecxhmmessage P {
padding:0px;
}

.ExternalClass body.ecxhmmessage {
font-size:12pt;
font-family:Calibri;
}

--></style>
<div dir="ltr">> Date: Fri, 5 Aug 2016 18:19:01 -0600<br>> From: alex.williamson@redhat.com<br>> To: the_cartographer@hotmail.com<br>> CC: vfio-users@redhat.com<br>> Subject: Re: [vfio-users] Cannot register eventfd with MSI/MSI-X interrupts<br>> <br>> On Wed, 3 Aug 2016 12:47:21 +0000<br>> chris thompson <the_cartographer@hotmail.com> wrote:<br>> <br>> >  <br>> > > Date: Tue, 2 Aug 2016 16:29:52 -0600<br>> > > From: alex.williamson@redhat.com<br>> > > To: the_cartographer@hotmail.com<br>> > > CC: vfio-users@redhat.com<br>> > > Subject: Re: [vfio-users] Cannot register eventfd with MSI/MSI-X interrupts<br>> > > <br>> > > On Tue, 2 Aug 2016 09:54:19 -0600<br>> > > Alex Williamson <alex.williamson@redhat.com> wrote:<br>> > >   <br>> > > > On Tue, 2 Aug 2016 10:21:30 +0000<br>> > > > chris thompson <the_cartographer@hotmail.com> wrote:<br>> > > >   <br>> > > > > Hi Alex,<br>> > > > >  <br>> > > > > Thanks for your patience, I noticed the count != 0 issue shortly after, but I get the same EINVAL error anyway when it is zero - but this is because the IRQ does not have a mapping yet. When I change the code to map it then unmap it then I get:<br>> > > > > IRQx - successful map then unmap<br>> > > > > MSI - unsuccessful map (and unsuccessful unmap)<br>> > > > > MSIX - successful map then unmap (despite the device still being in IRQx mode?)<br>> > > > > Error - successfully map, kernel driver crash on the unmap!    <br>> > > <br>> > > I remembered that there is a trick here specific to MSI, your device<br>> > > probably supports more than one MSI vector.  MSI is a little bit<br>> > > special, not all platforms support multiple MSI vectors and they were<br>> > > pretty much outdated by the much more flexible MSI-X capability for<br>> > > that reason.  To help with this the SET_IRQS ioctl returns negative on<br>> > > error, 0 on success, and a positive value indicating the available<br>> > > vectors to retry with if the requested count is not supported/available.<br>> > > <br>> > > BTW, this should fix the oops you found:<br>> > > https://lkml.org/lkml/2016/8/2/1912<br>> > > <br>> > > Thanks,<br>> > > Alex Hi Alex, Indeed I realise now that the MSI registration ioctl returns 8, the number of IRQs I would expect (the same as the MSIX ones). The question is, why doesn't the IRQ_INFO ioctl reply count = 8 like the MSIX one? Instead it returns 64 (I thought MSI only went up to 32 too?) config IRQ index 1  <br>> > Info:<br>> > argsz 0x10, flags 0x9, index 0x1, count 0x40,<br>> > Register:<br>> > failed to register interrupt set 1 : 0-63, error 8 Invalid argument config IRQ index 2<br>> > Info:<br>> > argsz 0x10, flags 0x9, index 0x2, count 0x8,<br>> > Register:<br>> > successfully registered interrupt set 2 : 0-7, ret 0 Thanks,Chris<br>> >                                      <br>> <br>> I believe this was fixed in the v3.16 kernel by:<br>> <br>> fd49c81 drivers/vfio/pci: Fix wrong MSI interrupt count<br>> <br>> Your previous oops shows you're running an old v3.13 kernel.<br><br>Hi Alex,<br> <br>You are right unfortunately I have to make do with a standard Ubuntu14.04 install (our regular RHEL6.6 doesn't even have VFIO). Glad to hear this is also fixed later and I correctly understood the intent, even if my kernel doesn't do it right.<br> <br>I've made some progress getting the PCIe device talking to my simulated kernel, and have a new PCIe device which I'm trying to work with - an Intel e1000e Ethernet controller (the xhci drivers expose a bug in our simulated PCIe host controller driver code which I haven't sorted yet).<br><br>Unfortunately when trying to setup the MSI-X interrupts I trigger a bug in the host kernel again:<br> <br><font size="1"><font face="Arial,sans-serif" size="2">[ 2238.755804] vfio-pci 0000:01:00.0: irq 46 for MSI/MSI-X</font><br><font face="Arial,sans-serif" size="2">[ 2238.755812] vfio-pci 0000:01:00.0: irq 47 for MSI/MSI-X</font><br><font face="Arial,sans-serif" size="2">[ 2238.755817] vfio-pci 0000:01:00.0: irq 48 for MSI/MSI-X</font><br><font face="Arial,sans-serif" size="2">[ 2238.755822] vfio-pci 0000:01:00.0: irq 49 for MSI/MSI-X</font><br><font face="Arial,sans-serif" size="2">[ 2238.755826] vfio-pci 0000:01:00.0: irq 50 for MSI/MSI-X</font><br><font face="Arial,sans-serif" size="2">[ 2238.755908] BUG: unable to handle kernel paging request at ffffebe000004000</font><br><font face="Arial,sans-serif" size="2">[ 2238.755942] IP: [<ffffffff811a53e6>] kfree+0x56/0x160</font><br><font face="Arial,sans-serif" size="2">[ 2238.755964] PGD 0</font><br><font face="Arial,sans-serif" size="2">[ 2238.755973] Oops: 0000 [#1] SMP</font><br><font face="Arial,sans-serif" size="2">[ 2238.755987] Modules linked in: vfio_pci vfio_iommu_type1 vfio nfsv3 nfsv4 cuse autofs4 dm_crypt hp_wmi gpio_ich bnep sparse_keymap rfcomm bluetooth intel_rapl x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel kvm crct        10dif_pclmul crc32_pclmul snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_intel snd_hda_codec snd_hwdep snd_pcm snd_page_alloc aesni_intel snd_seq_midi snd_seq_midi_event aes_x86_64 lrw snd_rawmidi gf128mul glue_helper ablk_he        lper cryptd snd_seq serio_raw lpc_ich snd_seq_device wmi snd_timer snd soundcore mac_hid shpchp nfsd mei_me tpm_infineon mei auth_rpcgss nfs_acl parport_pc nfs lockd ppdev sunrpc lp fscache parport binfmt_misc btrfs xor raid6_p        q libcrc32c i915 video i2c_algo_bit e1000e drm_kms_helper ahci psmouse ptp libahci drm pps_core</font><br><font face="Arial,sans-serif" size="2">[ 2238.756292] CPU: 1 PID: 2782 Comm: sim Not tainted 3.13.0-87-generic #133-Ubuntu</font><br><font face="Arial,sans-serif" size="2">[ 2238.756318] Hardware name: Hewlett-Packard HP Compaq 8200 Elite SFF PC/1495, BIOS J01 v02.15 11/10/2011</font><br><font face="Arial,sans-serif" size="2">[ 2238.756350] task: ffff8800b65d4800 ti: ffff8800b6688000 task.ti: ffff8800b6688000</font><br><font face="Arial,sans-serif" size="2">[ 2238.756375] RIP: 0010:[<ffffffff811a53e6>]  [<ffffffff811a53e6>] kfree+0x56/0x160</font><br><font face="Arial,sans-serif" size="2">[ 2238.756403] RSP: 0018:ffff8800b6689cf0  EFLAGS: 00010286</font><br><font face="Arial,sans-serif" size="2">[ 2238.756421] RAX: ffffebe000004000 RBX: 0000000000100000 RCX: 0000000000000001</font><br><font face="Arial,sans-serif" size="2">[ 2238.756445] RDX: ffffea0000000000 RSI: 00000000000fff37 RDI: 0000000000100000</font><br><font face="Arial,sans-serif" size="2">[ 2238.756469] RBP: ffff8800b6689d08 R08: 0000000000015fa0 R09: ffff880225400000</font><br><font face="Arial,sans-serif" size="2">[ 2238.756493] R10: ffff88022273a000 R11: ffffffffa06ec898 R12: ffffffffffffff38</font><br><font face="Arial,sans-serif" size="2">[ 2238.756517] R13: ffffffffa06ec898 R14: 00000000000fff37 R15: 00000000ffffffff</font><br><font face="Arial,sans-serif" size="2">[ 2238.756541] FS:  00007f7147398780(0000) GS:ffff88022e280000(0000) knlGS:0000000000000000</font><br><font face="Arial,sans-serif" size="2">[ 2238.756569] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033</font><br><font face="Arial,sans-serif" size="2">[ 2238.756588] CR2: ffffebe000004000 CR3: 00000000b66c1000 CR4: 00000000000407e0</font><br><font face="Arial,sans-serif" size="2">[ 2238.756612] Stack:</font><br><font face="Arial,sans-serif" size="2">[ 2238.756620]  ffff88021fd37b00 ffffffffffffff38 00000000fffffffb ffff8800b6689d50</font><br><font face="Arial,sans-serif" size="2">[ 2238.756647]  ffffffffa06ec898 ffff88022273a000 ffffffffa06f1453 ffff88021f513ee0</font><br><font face="Arial,sans-serif" size="2">[ 2238.756674]  0000000000000000 0000000000000002 00000000fffffffa 00000000ffffffea</font><br><font face="Arial,sans-serif" size="2">[ 2238.756702] Call Trace:</font><br><font face="Arial,sans-serif" size="2">[ 2238.756714]  [<ffffffffa06ec898>] vfio_msi_set_vector_signal+0x88/0x210 [vfio_pci]</font><br><font face="Arial,sans-serif" size="2">[ 2238.756742]  [<ffffffffa06ecac8>] vfio_msi_set_block+0xa8/0xe0 [vfio_pci]</font><br><font face="Arial,sans-serif" size="2">[ 2238.756766]  [<ffffffffa06ed446>] vfio_pci_set_msi_trigger+0x216/0x2d0 [vfio_pci]</font><br><font face="Arial,sans-serif" size="2">[ 2238.756793]  [<ffffffffa06ed9ec>] vfio_pci_set_irqs_ioctl+0x8c/0xa0 [vfio_pci]</font><br><font face="Arial,sans-serif" size="2">[ 2238.756818]  [<ffffffffa06ebe7d>] vfio_pci_ioctl+0x31d/0xa30 [vfio_pci]</font><br><font face="Arial,sans-serif" size="2">[ 2238.756843]  [<ffffffff812035e1>] ? fsnotify+0x241/0x320</font><br><font face="Arial,sans-serif" size="2">[ 2238.756863]  [<ffffffffa06e3193>] vfio_device_fops_unl_ioctl+0x23/0x30 [vfio]</font><br><font face="Arial,sans-serif" size="2">[ 2238.756889]  [<ffffffff811d46e0>] do_vfs_ioctl+0x2e0/0x4c0</font><br><font face="Arial,sans-serif" size="2">[ 2238.756910]  [<ffffffff811c119c>] ? vfs_write+0x15c/0x1f0</font><br><font face="Arial,sans-serif" size="2">[ 2238.756930]  [<ffffffff811d4941>] SyS_ioctl+0x81/0xa0</font><br><font face="Arial,sans-serif" size="2">[ 2238.756949]  [<ffffffff811c1b5c>] ? SyS_write+0x7c/0xa0</font><br><font face="Arial,sans-serif" size="2">[ 2238.756969]  [<ffffffff8173a3dd>] system_call_fastpath+0x1a/0x1f</font><br><font face="Arial,sans-serif" size="2">[ 2238.756989] Code: 00 00 00 80 ff 77 00 00 48 01 d8 48 0f 42 15 42 fc a6 00 48 01 d0 48 ba 00 00 00 00 00 ea ff ff 48 c1 e8 0c 48 c1 e0 06 48 01 d0 <48> 8b 10 80 e6 80 0f 85 e1 00 00 00 49 89 c2 49 8b 02 a8 80 0f</font><br><font face="Arial,sans-serif" size="2">[ 2238.758263] RIP  [<ffffffff811a53e6>] kfree+0x56/0x160</font><br><font face="Arial,sans-serif" size="2">[ 2238.759464]  RSP <ffff8800b6689cf0></font><br><font face="Arial,sans-serif" size="2">[ 2238.760664] CR2: ffffebe000004000</font><br><font face="Arial,sans-serif" size="2">[ 2238.901817] ---[ end trace 2df3e50788542fe4 ]---</font><br></font> <br> <br>Here is a summary of the writes that have been made to the important bits of the device (all in PCI Config space, except the MSI-X table programming):<br><br>Command : 0x0100<br>#test BAR0<br>Command : 0x0103<br>Command : 0x0100<br>#test BAR1<br>Command : 0x0100<br>#test BAR2<br>Command : 0x0103<br>Command : 0x0100<br>#test BAR3<br>Command : 0x0103<br>Command : 0x0100<br>#test BAR4<br>Command : 0x0103<br>Command : 0x0100<br>#test BAR5<br>Command : 0x0103<br>Command : 0x0100<br>Expansion ROM Address 0xFFFFF800<br>Expansion ROM Address 0xFE580000<br>Command : 0x0103<br>MSI Message Control 0x0080<br>MSI-X Message Control 0x0004<br>Pwer Management Control/Status 0xA000<br>Command : 0x0143<br>Cache Line Size : 0x10<br>PCIe Capability Register : 0x01010<br>Interrupt Line : 0x02<br>BAR0 : 0x0<br>BAR1 : 0xC0000<br>BAR3 : 0xE0000<br>BAR2 : 0x1000<br>PCIe Device Control : 0x000F<br>Command : 0x0147<br>MSI-X Message Control : 0x0004<br>#Program MSI-X Table, addresses and value for MSI-X 0,1,2<br>MSI-X Message Control : 0xC004 <- Enable MSI-X interrupts<br>- at this point I try to register the MSI-X interrupts 0-4 with eventfd (the device has 5, even thourgh only 0-2 are progreammed by the simulated kernel driver just now)<br>The driver would then go on to do<br>#Program MSI-X Table masks (all 0xFFFFFFFF)<br>Command : 0x0547  <- disable legacy INTx interrupts (seems a bit late to me?)<br> <br>My simulated kernel is quite happy up until this point, when my simulation process turns into a zombie, and I have to reboot the machine to get access to vfio devices again.<br> <br>Anything obvious here? perhaps a known bug in my rather ancient kernel?<br> <br>Thanks and regards,<br>Chris<br><br> <br>                                      </div>
<br>_______________________________________________
vfio-users mailing list
vfio-users@redhat.com
https://www.redhat.com/mailman/listinfo/vfio-users</div>                                    </div></body>
</html>