CHAPTER 03
3. hart context별 enable, priority와 threshold를 계산한다
PLIC target context는 hart와 privilege mode 조합입니다. global source priority와 context별 enable/threshold를 모두 통과해야 external interrupt가 hart에 전달됩니다.
context
hart 하나에 M-mode와 S-mode context가 따로 있을 수 있습니다.
enable
같은 source도 context별 enable bitmap이 다릅니다.
threshold
source priority가 threshold보다 높아야 전달됩니다.
tie
같은 priority source의 tie-break는 낮은 source ID가 우선입니다.
레지스터·번호·소유권 대조
| 항목 | 소유자 | 값의 의미 | 정상 증거 | 오류 해석 |
|---|---|---|---|---|
| priority[source] | global | source 우선순위 | threshold보다 큼 | 0 또는 낮음 |
| enable[context] | target context | source 허용 | 현재 hart/mode bit 1 | 다른 context를 씀 |
| threshold[context] | target context | 최소 전달 priority | 시험 정책 일치 | 모든 source 차단 |
| context base/stride | SoC map | hart/mode address | firmware context map과 일치 | 잘못된 MMIO context |
| hart external pending | CSR | context 출력 | qualified source 존재 시 set | PLIC 설정과 CSR 불일치 |
실패 경계 판정
| 증상 | 직전 통과 | 우선 확인 | 반증 시험 | 판정 |
|---|---|---|---|---|
| hart0만 수신 | global pending | hart1 context enable | enable bitmap diff | per-context 설정 |
| S-mode는 안 옴 | M-mode context 성공 | S context와 delegation | context/CSR를 분리 시험 | privilege context |
| priority 바꿔도 순서 동일 | 둘 다 전달 | threshold/tie/source ID | 서로 다른 priority로 재시험 | 설정 address 오류 |
| threshold 0인데 차단 | enable/priority 정상 | 현재 context 식별 | claim register 주소 비교 | context map |
| CPU hotplug 후 enable 유실 | boot 시 정상 | per-CPU restore | online 전후 bitmap diff | lifecycle |
실제 검증 절차
| 순서 | 실행 | 남길 증거 | 판정 목적 |
|---|---|---|---|
| 1 | firmware의 context list를 hart/mode/MMIO base로 펼칩니다. | context map | 주소 확인 |
| 2 | source별 priority와 모든 context enable을 CSV로 저장합니다. | 정책 matrix | 차단 지점 |
| 3 | threshold를 단계별로 올려 전달 경계를 측정합니다. | priority ordering | comparator 확인 |
| 4 | hart hotplug 후 context bitmap을 비교합니다. | restore 증거 | lifecycle 검증 |
주의context 번호를 hart ID와 동일하게 가정하지 않습니다. 구현과 firmware가 제공한 context 순서를 사용합니다.
공개적으로 다시 확인할 수 있는 자료
공개되지 않은 vendor register나 integration별 offset을 추측해서 채우지 않았습니다. 아래 제조사 자료, architecture 문서와 Linux v6.18.37 원본에서 다시 확인할 수 있는 범위만 사용했습니다.
RISC-V PLIC specification
gateway, priority, target context와 claim/complete
RISC-V AIA specification
APLIC, IMSIC, interrupt files와 virtualization
Linux SiFive PLIC driver
PLIC domain, enable, claim/complete와 chained handler
Linux RISC-V INTC
local interrupt cause와 root domain