Skip to content

KVM: arm64: Add support for BBM level 3

Mostafa Saleh kvmarm linux-arm-kernel lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 2 repliesIn review
  2. v2 RFC2 patches 3 repliesSuperseded
  3. v1 RFC2 patches 7 repliesSuperseded

Changes in v3 from the cover letter

https://lore.kernel.org/all/[email protected]/
- Add extra checks to ensure PTE updates with BBML3 follow the arm architecture.
- Limit the extra smp_wmb() to non shared walkers.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2KVM: arm64: Add stage2_clean_old_pte()arch/arm64/kvm/hyp/pgtable.c+37 -300 replies
2/2KVM: arm64: Support BBM level 3arch/arm64/kvm/hyp/pgtable.c+90 -212 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 0/2] KVM: arm64: Add support for BBM level 3

This patch series adds support for BBM level 3 to KVM pgtable.

Changes from v2:
https://lore.kernel.org/all/[email protected]/
- Add extra checks to ensure PTE updates with BBML3 follow the arm architecture.
- Limit the extra smp_wmb() to non shared walkers.

Motivation
==========
I have been looking into this for the context of:
- Page table sharing between the host CPU stage-2 and the SMMUv3 for protected KVM.
- Use the pagtable code to populate SMMUv3 stage-2 shadowed page table [1]

However, BBM level 3 is still useful for CPU only operations as it avoids intermediately breaking translation.

Design
======
Some of the conditions that BBM level 3 will be useful in (RWHZWS):
1) Changing from block to table
2) Changing from table to block

Initially, I encapsulated the full logic of BBM in one function, which was not readable, due to different ordering and dealing with CMO, TLBI.

Instead, I kept the logic into 2 functions, where BBML3 is added in the make step.

One interesting case, as BBML3 will update the PTE atomically, it can only know it raced with another core at the point of the cmpxchg failing, unlike the SW implementation which locks the PTE first. And as we must issue CMOs to the new mapped page before the update, that means with BBML3 racing cores will issue redundant CMOs, to avoid this, we limit the use of BBML3 to systems with FWB and DIC.

Testing
=======
This was tested with:
- C1-Pro cores, unfortunately the version I have does not run upstream, I backported the patches to Android kernel (6.18).

- mainline(7.3-rc1) kernel on a Qualcomm X1 with a hacked cpufeature as it does not support BBM, I did not see conflict aborts or TLB corruption.

I tested with VHE and protected (hvhe) modes, running VMs (and protected), and running some selftests, that might exercise and stress this path tools/testing/selftests/kvm:
- demand_paging_test
- memslot_perf_test
- memslot_modification_stress_test
- dirty_log_test

Mostafa Saleh (2):
KVM: arm64: Add stage2_clean_old_pte()
KVM: arm64: Support BBM level 3

 arch/arm64/kvm/hyp/pgtable.c | 172 +++++++++++++++++++++++++----------
 1 file changed, 124 insertions(+), 48 deletions(-)
Signature · 1 line
2.55.0.979.g7e5102b832-goog