Page MenuHomeFreeBSD

Local APIC: add support for extended LVT entries found in AMD processors
ClosedPublic

Authored by avg on Feb 15 2017, 2:09 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, May 3, 5:31 AM
Unknown Object (File)
Wed, Apr 17, 4:05 AM
Unknown Object (File)
Tue, Apr 16, 11:23 AM
Unknown Object (File)
Mar 19 2024, 10:34 PM
Unknown Object (File)
Mar 19 2024, 10:09 PM
Unknown Object (File)
Mar 19 2024, 7:56 PM
Unknown Object (File)
Mar 19 2024, 7:54 PM
Unknown Object (File)
Mar 8 2024, 1:49 AM
Subscribers

Details

Summary

The extended LVT entries can be used to configure interrupt delivery
for various events that are internal to a processor and can use this
feature.

All current processors that support the feature have four of such entries.
The entries are all masked upon the processor reset, but it's possible
that firmware may use some of them.

BIOS and Kernel Developer's Guides for some processor models do not assign
any particular names to the extended LVTs, while other BKDGs provide names
and suggested usage for them.
However, there is no fixed mapping between the LVTs and the processor
events in any processor model that support the feature. Any entry can be
assigned to any event. The assignment is done by programming an offset
of an entry into configuration bits corresponding to an event.

This change does not expose the flexibility that the feature offers.
The change adds just a single method to configure a hardcoded extended LVT
entry to deliver APIC_CMC_INT. The method is designed to be used with
Machine Check Error Thresholding mechanism on supported processor models.

For references please see BKDGs for families 10h - 16h and specifically
descriptions of APIC30, APIC400, APIC[530:500] registers.
For a description of the Error Thresholding mechanism see, for example,
BKDG for family 10h, section 2.12.1.6.
http://developer.amd.com/resources/developer-guides-manuals/

Diff Detail

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

Event Timeline

avg retitled this revision from to Local APIC: add support for extended LVT entries found in AMD processors.
avg updated this object.
avg edited the test plan for this revision. (Show Details)
avg added reviewers: jhb, kib, markj.
sys/x86/include/apicreg.h
264 ↗(On Diff #25216)

Please look at this comment and use of LAPIC_MEM_REGION in x86/io_apic.c:apic_attach(). You definitely want to reserve the upper part of the apir registers page when AMD extensions are detected. Even in case if system cannot use them.

sys/x86/x86/local_apic.c
1346 ↗(On Diff #25216)

Unneeded {}.

From my reading of the docs, AMD Specific End Of Interrupt feature is very similar to Intel EIO Suppression feature, if not simpler. You might try to experiment with it, look at io_apic.c:_ioapic_eio_source().

I think this looks fine once kib's note about fixing apic_attach() to use a variable-sized LAPIC_MEM_REGION is fixed.

avg edited edge metadata.
  • grow LAPIC_MEM_REGION
  • address style comments
  • switch to the more regular handling of ELVTs, similar to LVTs
  • use a better name for APIC_ELVT_3 (from BKDG 15h)
sys/x86/include/apicreg.h
244 ↗(On Diff #25702)

Use tab consistently before '=' ?

265 ↗(On Diff #25702)

Problem might be if some CPU vendor starts co-locating APIC registers with something else on the same page. I do not suggest to handle this hypothetical situation now, the code is fine, but a comment noting that we eat a space which does not belong to LAPIC, is due.

452 ↗(On Diff #25702)

AMD extended LVT ...

sys/x86/x86/local_apic.c
646 ↗(On Diff #25702)

Use ANSI C definition: specify void as arg list.

650 ↗(On Diff #25702)

Do not read the register at all, if vendor != AMD ?

659 ↗(On Diff #25702)

Same,

1411 ↗(On Diff #25702)

Check for x2apic_mode for AMD is weird.

avg marked an inline comment as done.Feb 26 2017, 2:08 PM
avg added inline comments.
sys/x86/include/apicreg.h
244 ↗(On Diff #25702)

I used the example of LAPIC_LVT_THERMAL a few lines above.
This looks uglier in the diff, but prettier in the actual code.

265 ↗(On Diff #25702)

Okay. Not sure how to word that, but I'll try.

452 ↗(On Diff #25702)

okay

sys/x86/x86/local_apic.c
646 ↗(On Diff #25702)

okay

650 ↗(On Diff #25702)

okay

659 ↗(On Diff #25702)

okay

1411 ↗(On Diff #25702)

I copy-pasted this code from the preceding cmc function.
I'll remove x2apic_mode check, because if/when AMD starts supporting xAPIC the code will probably need revisiting anyway.

avg marked an inline comment as done.

address comments from kib

kib edited edge metadata.
This revision is now accepted and ready to land.Feb 26 2017, 4:05 PM
avg edited edge metadata.

rebase

This revision now requires review to proceed.Feb 28 2017, 6:40 PM
avg edited edge metadata.

APIC_ELVT_MAX is a maximum _allowed_ value

This revision was automatically updated to reflect the committed changes.