Page MenuHomeFreeBSD

msi: remove the check that interrupt sources have been added
ClosedPublic

Authored by royger on Sep 3 2018, 9:25 AM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 4 2024, 7:24 PM
Unknown Object (File)
Dec 31 2023, 3:32 AM
Unknown Object (File)
Dec 6 2023, 4:06 PM
Unknown Object (File)
Aug 27 2023, 8:33 PM
Unknown Object (File)
Jun 19 2023, 8:54 AM
Unknown Object (File)
May 14 2023, 6:36 AM
Unknown Object (File)
May 9 2023, 6:13 PM
Unknown Object (File)
Apr 25 2023, 6:34 PM
Subscribers

Details

Summary

When running as a specific type of Xen guest the hypervisor won't
provide any emulated IO-APICs or legacy PICs at all, thus hitting the
following assert in the MSI code:

panic: Assertion num_io_irqs > 0 failed at /usr/src/sys/x86/x86/msi.c:334
cpuid = 0
time = 1
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xffffffff826ffa70
vpanic() at vpanic+0x1a3/frame 0xffffffff826ffad0
panic() at panic+0x43/frame 0xffffffff826ffb30
msi_init() at msi_init+0xed/frame 0xffffffff826ffb40
apic_setup_io() at apic_setup_io+0x72/frame 0xffffffff826ffb50
mi_startup() at mi_startup+0x118/frame 0xffffffff826ffb70
start_kernel() at start_kernel+0x10

Fix this by removing the assert in the MSI code, since it's possible
to get to the MSI initialization without having registered any other
interrupt sources.

Sponsored by: Citrix Systems R&D

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Would be useful to assert that there is no IO APICs or AT PICs configured when num_io_irqs == 0, but I am not sure that this is straightforward.

This revision is now accepted and ready to land.Sep 3 2018, 10:15 AM
In D17001#362583, @kib wrote:

Would be useful to assert that there is no IO APICs or AT PICs configured when num_io_irqs == 0, but I am not sure that this is straightforward.

I thought about this too, but I didn't find any straightforward way to check whether there are any PICs in the system. I will wait for John in case he has a suggestion.

In D17001#362583, @kib wrote:

Would be useful to assert that there is no IO APICs or AT PICs configured when num_io_irqs == 0, but I am not sure that this is straightforward.

I thought about this too, but I didn't find any straightforward way to check whether there are any PICs in the system. I will wait for John in case he has a suggestion.

There isn't a good way to assert that. The ATPIC code always assumes it can use the first 16 IRQs if 'device atpic' is enabled in the kernel which is a bit of a landmine. 'device atpic' isn't in GENERIC, but it might be nice to force it to be disabled for this particular Xen case? Or is there an emulated ATPIC with no useful interrupts? (In a kernel without 'device atpic' we use unconditional logic to init the 8259A's into a silent state.) If Xen is still providing a dummy set of 8259A's, then I think what I'd actually prefer is to patch the SYSINIT in local_apic.c that does 'apic_setup_io' to bump num_io_irqs up to 16 if it is still zero to avoid any possible conflicts with IRQs 0 - 15. Note that one idea I'm considering is removing MINIMUM_MSI_INT post-branch so that MSI IRQs would start at the end of the PIC range rather than at 256 in which case explicitly reserving 0-15 would still matter.

In D17001#362843, @jhb wrote:
In D17001#362583, @kib wrote:

Would be useful to assert that there is no IO APICs or AT PICs configured when num_io_irqs == 0, but I am not sure that this is straightforward.

I thought about this too, but I didn't find any straightforward way to check whether there are any PICs in the system. I will wait for John in case he has a suggestion.

There isn't a good way to assert that. The ATPIC code always assumes it can use the first 16 IRQs if 'device atpic' is enabled in the kernel which is a bit of a landmine. 'device atpic' isn't in GENERIC, but it might be nice to force it to be disabled for this particular Xen case? Or is there an emulated ATPIC with no useful interrupts? (In a kernel without 'device atpic' we use unconditional logic to init the 8259A's into a silent state.) If Xen is still providing a dummy set of 8259A's, then I think what I'd actually prefer is to patch the SYSINIT in local_apic.c that does 'apic_setup_io' to bump num_io_irqs up to 16 if it is still zero to avoid any possible conflicts with IRQs 0 - 15. Note that one idea I'm considering is removing MINIMUM_MSI_INT post-branch so that MSI IRQs would start at the end of the PIC range rather than at 256 in which case explicitly reserving 0-15 would still matter.

In this case there's no IO-APIC or ATPIC at all, just a local APIC. When using pci-passthrough an emulated IO-APIC will be available to route the legacy IRQs.

Doing something like:

num_io_irqs = max(num_io_irqs, 16);

In apic_setup_io seems sensible, but it's not going to make much of a difference until MINIMUM_MSI_INT is removed and MSI IRQs start just after the IO-APIC (or ATPIC) ranges end.

Let me know whether you want me to add this chunk here, or you would rather do it when removing MINIMUM_MSI_INT.

The current patch is fine. We should perhaps neuter the atpic driver in sys/x86/isa/atpic.c for such systems by having it fail to add any PICs or interrupt sources at all.

This revision was automatically updated to reflect the committed changes.