x86usbinterruptosdevhci

What does the MSI-X capability of PCI devices push on the stack?


I have a small hobby OS I boot with UEFI. I set up the Intel's xHC to trigger interrupts using MSI-X and then I reset all root hub ports which triggers 2 Port Status Change Events and one interrupt. This interrupt is doing nothing for now. It simply attempts to come back to the normal flow of execution using iretq in inline assembly.

This was failing until I had the idea of looking onto the stack for what was making it fail. I found out that something seems to be pushed on the stack by the MSI-X functionality of the xHC. I simply had to do one pop operation or increment RSP by 8 to make it work.

My questions are:

  1. What is it that the xHC pushes on the stack?

  2. Where is it documented in the specification? Is it in the xHCI spec or the PCI spec? (I don't have access to the latter).

  3. Is it a conventional thing that must be pushed by all PCI devices or is it specific to the Intel's xHC?


Solution

  • I found out what was the culprit. I simply didn't mark my interrupt handlers with __attribute__((interrupt)). G++ was pushing ebp for some reason as the entry to the function and it was messing up my interrupt stack. I simply removed the iretq and I'm letting g++ do the job of correctly returning from the interrupt.

    Also, I needed to use -mgeneral-regs-only -mno-red-zone g++ options to avoid some compiler errors.