freebsd-nq/sys/riscv
Mitchell Horne a45a86c8c7 plic: fix context calculation
The RISC-V PLIC (platform level interrupt controller) registers are divided up
by "context", which is purposefully left ambiguous in the PLIC spec. Currently
we assume each CPU number corresponds 1-to-1 with a context number, but that is
not correct. Most existing PLIC implementations (such as SiFive's) have
multiple contexts per-cpu. For example, a single CPU might have a context for
machine mode interrupts and a context for supervisor mode interrupts. To
complicate things further, FreeBSD renumbers the CPUs during boot, but the PLIC
driver still assumes that CPU ID equals the RISC-V hart number, meaning
interrupt enables/claims might be performed for the wrong context registers.

To fix this, we must calculate each CPU's context number during
attachment. This is done by reading the interrupt properties from the
device tree, from which a mapping from context to RISC-V hart to CPU
number can be created.

Reviewed by:	br
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D21927
2019-11-15 03:15:14 +00:00
..
conf RISC-V: Remove EARLY_AP_STARTUP from GENERIC 2019-11-02 19:33:02 +00:00
include Fix atomic_*cmpset32 on riscv64 with clang. 2019-10-23 16:41:31 +00:00
riscv plic: fix context calculation 2019-11-15 03:15:14 +00:00