freebsd-skq/sys/x86/include
Konstantin Belousov 0a110d5b17 Use VT-d interrupt remapping block (IR) to perform FSB messages
translation.  In particular, despite IO-APICs only take 8bit apic id,
IR translation structures accept 32bit APIC Id, which allows x2APIC
mode to function properly.  Extend msi_cpu of struct msi_intrsrc and
io_cpu of ioapic_intsrc to full int from one byte.

KPI of IR is isolated into the x86/iommu/iommu_intrmap.h, to avoid
bringing all dmar headers into interrupt code. The non-PCI(e) devices
which generate message interrupts on FSB require special handling. The
HPET FSB interrupts are remapped, while DMAR interrupts are not.

For each msi and ioapic interrupt source, the iommu cookie is added,
which is in fact index of the IRE (interrupt remap entry) in the IR
table. Cookie is made at the source allocation time, and then used at
the map time to fill both IRE and device registers. The MSI
address/data registers and IO-APIC redirection registers are
programmed with the special values which are recognized by IR and used
to restore the IRE index, to find proper delivery mode and target.
Map all MSI interrupts in the block when msi_map() is called.

Since an interrupt source setup and dismantle code are done in the
non-sleepable context, flushing interrupt entries cache in the IR
hardware, which is done async and ideally waits for the interrupt,
requires busy-wait for queue to drain.  The dmar_qi_wait_for_seq() is
modified to take a boolean argument requesting busy-wait for the
written sequence number instead of waiting for interrupt.

Some interrupts are configured before IR is initialized, e.g. ACPI
SCI.  Add intr_reprogram() function to reprogram all already
configured interrupts, and call it immediately before an IR unit is
enabled.  There is still a small window after the IO-APIC redirection
entry is reprogrammed with cookie but before the unit is enabled, but
to fix this properly, IR must be started much earlier.

Add workarounds for 5500 and X58 northbridges, some revisions of which
have severe flaws in handling IR.  Use the same identification methods
as employed by Linux.

Review:	https://reviews.freebsd.org/D1892
Reviewed by:	neel
Discussed with:	jhb
Tested by:	glebius, pho (previous versions)
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
2015-03-19 13:57:47 +00:00
..
_align.h
_inttypes.h
_limits.h
_stdint.h
_types.h
acpica_machdep.h x86/madt: make the interrupt override parser a public function 2014-08-04 08:58:50 +00:00
apicreg.h Add x2APIC support. Enable it by default if CPU is capable. The 2015-02-09 21:00:56 +00:00
apicvar.h Use VT-d interrupt remapping block (IR) to perform FSB messages 2015-03-19 13:57:47 +00:00
apm_bios.h
bus.h
busdma_impl.h
dump.h Factor out duplicated code from dumpsys() on each architecture into generic 2015-01-07 01:01:39 +00:00
elf.h
endian.h
fdt.h
float.h
fpu.h Improve support for XSAVE with debuggers. 2014-11-21 20:53:17 +00:00
frame.h
init.h msi: add Xen MSI implementation 2014-09-30 16:46:45 +00:00
legacyvar.h
mca.h
mptable.h
ofw_machdep.h
pci_cfgreg.h
psl.h
ptrace.h Improve support for XSAVE with debuggers. 2014-11-21 20:53:17 +00:00
pvclock.h Add interface to derive a TSC frequency from the pvclock 2015-02-04 08:33:04 +00:00
reg.h
segments.h
setjmp.h
sigframe.h
signal.h
specialreg.h Add x2APIC support. Enable it by default if CPU is capable. The 2015-02-09 21:00:56 +00:00
stdarg.h
sysarch.h
trap.h
ucontext.h
vdso.h
vmware.h Detect whether x2APIC on VMWare is usable without interrupt 2015-02-14 09:00:12 +00:00