KVM: arm64: Fix HCR_EL2 for non-protected VMs in pKVM
Status from this message: Applied to fixes, thanks!
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest4 patches 3 repliesApplied
- v24 patches 4 repliesSuperseded
- v14 patches 5 repliesSuperseded
Patches in v3 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | KVM: arm64: Apply the fine-grained UNDEFs without FEAT_FGTarch/ | +0 | 2 replies | |
| 2/4 | KVM: arm64: Clear HCR_EL2.RW for 32-bit non-protected vCPUsarch/ | +9 | 0 replies | |
| 3/4 | KVM: arm64: Use the host's HCR_EL2 for non-protected VMs in pKVMarch/ arch/ arch/ | +21 | 0 replies | |
| 4/4 | KVM: arm64: selftests: Check a feature hidden in an ID register is UNDEFtools/ tools/ | +185 | 0 replies |
Reviews trailers per patch
1 of 4 patches has a Reviewed-by or Acked-by.
| Patch | Wei-Lin Chang |
|---|---|
| 1/4 | R-b |
| 2/4 | |
| 3/4 | |
| 4/4 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v3 0/4] KVM: arm64: Fix HCR_EL2 for non-protected VMs in pKVM
Hi folks,
Changes since v2 [1]:
- Patch 1: apply the FGUs on a CPU without FEAT_FGT instead of moving the check in handle_tlbi_el1() (Oliver [2]). Wei-Lin's Reviewed-by dropped with the rewrite.
In pKVM, EL2 sets a non-protected VM's HCR_EL2 in pkvm_vcpu_reset_hcr(), which misses the RW, TID5 and TTLBOS handling of vcpu_set_hcr(), and takes only TWI, TWE and VSE from the host. As a result, an AArch32 VM can't run, a VM can read GMID_EL1 or execute a TLBI OS its ID registers hide, and the host's TVM, VI and VF never reach it.
The second patch clears RW for an AArch32 vCPU. The third also takes from the host, for a non-protected VM, the bits the host varies with the VM's configuration or at runtime: VI, VF, TVM, TID2, TID4, TID5 and TTLBOS. The rest stay EL2's, and a protected VM still takes only TWI, TWE and VSE.
The third patch depends on the first: once TTLBOS reaches the VM, a trapped TLBI OS from a non-nested guest on a CPU without FEAT_FGT hits a WARN in handle_tlbi_el1(), as it does without pKVM. The first makes the FGUs apply on such a CPU too, so the access is UNDEFINED before it reaches handle_tlbi_el1().
The last patch adds a selftest that checks a feature hidden in an ID register is UNDEFINED in the guest. Its TLBI OS case fails in pKVM before the third patch.
VSE still comes from the host as before. Syncing it back after delivery is a separate fix [3].
Based on Linux 7.3-rc4 (93f51579e7df2).
Cheers,
/fuad
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/
Fuad Tabba (4):
KVM: arm64: Apply the fine-grained UNDEFs without FEAT_FGT
KVM: arm64: Clear HCR_EL2.RW for 32-bit non-protected vCPUs
KVM: arm64: Use the host's HCR_EL2 for non-protected VMs in pKVM
KVM: arm64: selftests: Check a feature hidden in an ID register is
UNDEF
arch/arm64/kvm/emulate-nested.c | 3 - arch/arm64/kvm/hyp/include/nvhe/pkvm.h | 9 + arch/arm64/kvm/hyp/nvhe/hyp-main.c | 7 +- arch/arm64/kvm/hyp/nvhe/pkvm.c | 25 ++- tools/testing/selftests/kvm/Makefile.kvm | 1 + .../selftests/kvm/arm64/hidden_features.c | 184 ++++++++++++++++++ 6 files changed, 214 insertions(+), 15 deletions(-) create mode 100644 tools/testing/selftests/kvm/arm64/hidden_features.c
base-commit: 93f51579e7df248780214094418f205253383cc5
Signature · 1 line
2.39.5