Repository navigation
KVM: arm64: bound deferred stage-2 TLB invalidation to the cleared leaves - #731
Conversation
KVM guests on the MacBook Neo (T8140, Tahiti cores) livelock as soon as two private interrupts are pending while the guest has IRQs masked: the vCPU takes the vGIC maintenance interrupt on every entry and never retires an instruction. This is the T6040 problem again: the Tahiti MIDRs are missing from apple_broken_seis_cpus, so kvm_patch_ich_vtr_el2() leaves vgic_ich_vtr() at its placeholder and KVM uses nr_lr = 1 although ICH_VTR_EL2 reads 0x90580007 (8 LRs, SEIS=1). With one LR, KVM sets ICH_HCR_EL2.UIE and the underflow maintenance interrupt fires the moment the guest is entered. Measured under aura's FEAT_NV2 monitor: at every exit of a 2-vCPU guest the hardware reported ICH_MISR_EL2.U with ICH_HCR_EL2 = 0x449b and only LR0 in use (alternately vINTID 27 and SGI 1). Assisted-by: Claude Opus 5.5
Expose the verified cycle and instruction counters through one PMU instance spanning both Tahiti clusters. Keep unknown programmable events rejected while enabling KVM-backed perf migration across P and E cores. Include the T8140 PMU DT binding and IMPDEF PMUv3 capability. Assisted-by: GPT-6.1 Sol
Track the actual valid leaf span cleared by a stage-2 unmap and flush only that range after the walk. Sparse or empty unmaps no longer invalidate the caller's full IPA range, while table retirement keeps its immediate TTL_UNKNOWN flush. Assisted-by: GPT-6.1 Sol
6f60e2d to
a7f5058
Compare
|
Heads-up about overlap with #865 (A18 Pro and M4 Pro CPU PMU, also aimed at integration/aurora). The two PRs conflict in
Only one of them can land as written. The KVM stage-2 TLB change and the T8140 broken-SEIS/IMPDEF errata entry here don't depend on the PMU driver. A test merge of this PR on integration/aurora f153499 builds clean, and a Neo boot of it is queued tonight (perf stat on both clusters, plus a stage-2 memslot unmap/re-add test). Could you say which PMU model you want? If it's 865's, splitting the pgtable and errata commits into their own PR would let them land without waiting. |
|
@DjDeveloperr I've reworked #865 around your KVM point. It now uses one PMU instance per SoC (your The reason it can do that and still expose more than the fixed counters: a probe that counts reference loops on both core types shows the E and P cores share the same event encoding, the same 16-bit PMESR fields (counters 2-5 in PMESR0 and 6-9 in PMESR1) and the same working counters (0-7). PMC8/9 stay at zero, and the M1 event numbers don't apply. #865 has the tables. So one instance covering all six CPUs is correct for the configurable counters too, not only cycles and instructions, and guest counters survive migration the way yours do. To check the migration case directly I wrote If this works for you, #731 could carry just the stage-2 TLB and broken-SEIS/IMPDEF errata commits, and the PMU part would come from #865. Please look at #865 before anything merges; this is your area too. |
|
Status note from the power lane: the T8140 PMU half of this series is now on integration/aurora through bd7141a (one apple,t8140-pmu instance across both clusters, M4/A18 event table), which is why this PR conflicts. The bounded nested stage-2 TLB flush in arch/arm64/kvm/hyp/pgtable.c is not covered there. Could you rebase that part on its own, with the pressure numbers from this description? |
|
The T8140 PMU and the T8140 vGIC errata from this series are on integration/aurora (110861f) through #865 (bd7141a) and 6ebbafe, which is why the branch conflicts. The bounded deferred stage-2 TLB flush in arch/arm64/kvm/hyp/pgtable.c is not on the tip, and that commit alone applies cleanly to 110861f. @DjDeveloperr could you push this branch as just that commit, with your Signed-off-by added (it has none now), and keep the pressure numbers in the description? A rebased copy is on this repository as Build check of 110861f plus this change (arm64, LLVM=1, Image, dtbs and every directory it touches, Fedora config plus asahi.config): builds, no warnings in the files it touches. |
There was a problem hiding this comment.
Verdict: FINISH, then merge at a7f50586 (or close if no longer needed)
Blockers:
- Merge conflict (
CONFLICTING) againstmain: the T8140 PMU and vGIC errata commits from this branch already landed via#865(bd7141af1559) and6ebbafe21752. Rebase to retain only the remaining bounded stage-2 TLB flush change (or close if superseded). - Missing CI run and hardware row at the rebased head.
Checked:
- Verified mergeability (
CONFLICTING), 0 CI checks at head, and prior overlap note regarding#865and6ebbafe21752.
Evidence
- Head
a7f50586vsmain:CONFLICTING. - Labels:
merge-conflict,needs-hw-row,needs-template.
The T8140 PMU description and driver support landed on main with #865, so take main's pmu.yaml, t8140.dtsi and apple_m1_cpu_pmu.c. Also take main's cpu_errata.c: main keeps T8140 out of apple_cpus while its IMPDEF PMUv3 traps are unverified and already treats its vGIC SEIS as broken. What this branch still adds is the bounded deferred stage-2 TLB invalidation in kvm_pgtable_stage2_unmap(). Signed-off-by: DjDeveloperr <[email protected]>
There was a problem hiding this comment.
Verdict: HOLD at 1e5136138643
Blockers:
- Hosted CI at
1e5136138643is still pending/queued (3queued,1pending) — wait for build and checks to complete green. - Confirm exact-head
1e5136138643KVM boot/guest verification (existing J700 nested-pressure A/B ran on the earlier pre-merge branch prior to dropping the#865PMU/errata commits).
Checked:
- Audited the full 1-file diff (
arch/arm64/kvm/hyp/pgtable.c,+33/-7,MERGEABLEagainstmain):stage2_unmap_put_pte()tracks[flush_start, flush_end)viaALIGN_DOWN(ctx->addr, granule)andstart + granulestrictly for cleared leaf entries understage2_unmap_defer_tlb_flush(), while preserving immediate__kvm_tlb_flush_vmid_ipa()for cleared table entries and non-deferred configurations.kvm_pgtable_stage2_unmap()initializesflush_start = U64_MAX,flush_end = 0, and issueskvm_tlb_flush_vmid_range(pgt->mmu, data.flush_start, data.flush_end - data.flush_start)only whendata.flush_end > data.flush_start, safely skipping invalidation on empty walks.- Confirmed
1e5136138643cleanly keepsmain's#865T8140 PMU andcpu_errata.cversions.
Evidence
- Head:
1e513613864308448de66f795b1679715b50bd15(basemain,MERGEABLE). - No code defects found in
arch/arm64/kvm/hyp/pgtable.c.
RyanTheTide
left a comment
There was a problem hiding this comment.
Reviewed the conflict-pass merge commit 1e51361 only: no conflicts in the merge. The resolution keeps what each side had and adds nothing outside the conflict. Approved for the merge-up; merging still waits on CI and the rows at this head.
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: MERGE at 1e5136138643
Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.
Checked: - Audited the full 1-file diff (arch/arm64/kvm/hyp/pgtable.c, +33/-7, MERGEABLE against main):
stage2_unmap_put_pte()tracks[flush_start, flush_end)viaALIGN_DOWN(ctx->addr, granule)andstart + granulestrictly for cleared leaf entries understage2_unmap_defer_tlb_flush(), while preserving immediate__kvm_tlb_flush_vmid_ipa()for cleared table entries and non-deferred configurations.kvm_pgtable_stage2_unmap()initializesflush_start = U64_MAX,flush_end = 0, and issueskvm_tlb_flush_vmid_range(pgt->mmu, data.flush_start, data.flush_end - data.flush_start)only whendata.flush_end > data.flush_start, safely skipping invalidation on empty walks.- Confirmed
1e5136138643cleanly keepsmain's#865T8140 PMU andcpu_errata.cversions.
Follow-ups (not blocking): hosted CI; exact-head KVM guest row
|
Merging at |
What:
kvm_pgtable_stage2_unmap()now issues its deferred stage-2 TLB invalidation only over the IPA span of the leaves the walk actually cleared, not the whole requested range. A walk over a range with nothing mapped, such as the whole-IPA-space unmap of a sparse nested stage 2 on every MMU notifier event, needs no invalidation at all. Table entries are still invalidated as they are cleared.The T8140 PMU description and driver support that this branch first carried landed on main with #865, so the merge of main at
1e513613keeps main's versions of those files and ofcpu_errata.c.Tested:
1e513613:pgtable.oand its nVHE copy build against the 7.3 config.Risk: two-way. KVM on arm64 hosts that defer stage-2 unmap invalidation (range TLBI with FWB). The immediate-invalidation path is unchanged.
Not yet: a row at
1e513613on J700 (guest boot plus the nested-pressure A/B), and a second Mac running KVM guests. The pressure workload is synthetic compaction, so it doesn't show that the earlier ISO-download slowdown is gone.