KVM: arm64: Simplify pKVM memory transitions
Status from this message: Applied to next, thanks!
Get series with b4
b4 am [email protected]Versions newest first
Patches in v1 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | KVM: arm64: Drop pkvm_mem_transition for FF-Aarch/ | +10 | 0 replies | |
| 2/3 | KVM: arm64: Drop pkvm_mem_transition for host/hyp sharingarch/ | +34 | 0 replies | |
| 3/3 | KVM: arm64: Drop pkvm_mem_transition for host/hyp donationsarch/ | +32 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/3] KVM: arm64: Simplify pKVM memory transitions
Since its early days, pKVM has formalized memory 'transitions' (shares and donations) using 'struct pkvm_mem_transition' and bunch of helpers to manipulate it. The intention was for all transitions to use this machinery to ensure we're checking things consistently. However, as development progressed, it became clear that the rigidity of this model made it really difficult to use in some use-cases which ended-up side-stepping it entirely. That is the case for the hyp_{un}pin_shared_mem() and host_{un}share_guest() paths upstream which use lower level helpers directly, as well as for several other pKVM features that should land upstream in the future (ex: when a guest relinquishes a page during ballooning, when annotating a page that is being DMA'd to, ...). On top of this, the pkvm_mem_transition machinery requires a lot of boilerplate which makes the code hard to read, but also adds layers of indirection that no compilers seems to see through, hence leading to suboptimal generated code.
Given all the above, this series removes the pkvm_mem_transition machinery from mem_protect.c, and converts all its users to use __*_{check,set}_page_state_range() low-level helpers directly.
A few things to note:
- the existing helpers to request, ack, initiate and complete transitions were mostly wrappers around __*_{check,set}_page_state_range() anyways, so we're not losing that much in terms of consistency
- the pkvm_mem_transition machinery did not suffice to avoid bugs such as [1]. The pkvm selftest [2] should do a much better job at that
- see diffstat ;-)
This series depends on support for NP guest stage-2 for pKVM [3] as well as the fix in [1]. I've pushed a branch with all the goodies applied [4] if that can be useful.
Thanks,
Quentin
[1] https://lore.kernel.org/kvmarm/[email protected]/
[2] https://lore.kernel.org/kvmarm/[email protected]/
[3] https://lore.kernel.org/kvmarm/[email protected]/
[4] https://android-kvm.googlesource.com/linux/+/refs/heads/qperret/no-mem-tx
Quentin Perret (3):
KVM: arm64: Drop pkvm_mem_transition for FF-A
KVM: arm64: Drop pkvm_mem_transition for host/hyp sharing
KVM: arm64: Drop pkvm_mem_transition for host/hyp donations
arch/arm64/kvm/hyp/nvhe/mem_protect.c | 640 +++----------------------- 1 file changed, 76 insertions(+), 564 deletions(-)
Signature · 1 line
2.47.1.688.g23fc6f90ad-goog