Skip to content

Fix setting SVE and SME traps in (h)VHE

Fuad Tabba kvmarm 3 versions – Applied

Status from this message: Applied to kvmarm/fixes, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest7 patches 3 repliesApplied
  2. v27 patches 3 repliesSuperseded
  3. v15 patches 7 repliesSuperseded

Changes in v3 from the cover letter

- Rebased onto Linux 6.5-rc3
- s/__check_e2h/__check_hvhe/g (Oliver)
- Fixed bug in calculating CPACR_EL1 reset value for hVHE in trapping SVE

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/7KVM: arm64: Factor out code for checking E2H into a macroarch/arm64/include/asm/el2_setup.h+10 -91 reply
1/7KVM: arm64: Factor out code for checking (h)VHE mode into a macroarch/arm64/include/asm/el2_setup.h+10 -90 replies
2/7KVM: arm64: Use the appropriate feature trap register for SVE at EL2 setuparch/arm64/include/asm/el2_setup.h+9 -60 replies
3/7KVM: arm64: Disable SME traps for (h)VHE at setuparch/arm64/include/asm/el2_setup.h+10 -00 replies
4/7KVM: arm64: Helper to write to appropriate feature trap register based on modearch/arm64/include/asm/kvm_emulate.h+9 -40 replies
5/7KVM: arm64: Use the appropriate feature trap register when activating trapsarch/arm64/kvm/hyp/nvhe/switch.c+1 -10 replies
6/7KVM: arm64: Fix resetting SVE trap values on reset for hVHEarch/arm64/include/asm/kvm_emulate.h+4 -00 replies
7/7KVM: arm64: Fix resetting SME trap values on reset for (h)VHEarch/arm64/include/asm/kvm_emulate.h+4 -00 replies

Reviews trailers per patch

None of the 8 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchMarc Zyngier
SeriesR-b
1/7
1/7
2/7
3/7
4/7
5/7
6/7
7/7

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/7] Fix setting SVE and SME traps in (h)VHE

Hi,

Changes from V2:
- Rebased onto Linux 6.5-rc3
- s/__check_e2h/__check_hvhe/g (Oliver)
- Fixed bug in calculating CPACR_EL1 reset value for hVHE in trapping SVE

Changes from V1:
- Expanded the cover letter to clarify the reasoning behind being consistent in writing to the architectural trap register based on the KVM mode (Marc)
- Factored out the code for checking E2H into a macro (Oliver)
- Factored out the code that selects which register to write to into a function (Oliver)

The (re)setting and disabling of SVE/SME trap handling (mostly) done for the hVHE work [*] misses a couple of cases.

This patch series ensures that these traps are disabled on setup and reset. Moreover, it makes the code consistent in using CPACR_EL1 or CPTR_EL2, depending on the mode.

CPACR_EL1 aliases to CPTR_EL2 when HCR_EL2.E2H == 1, but by being consistent we don't need to issue a synchronisation when alternating between one or the other accessor. Moreover, when running hVHE under NV, we don't trap unnecessarily on accessing CPTR_EL2, while CPACR_EL1 can be used directly without any trap.

Based on Linux 6.5-rc3.

Cheers,
/fuad

Fuad Tabba (7):
KVM: arm64: Factor out code for checking (h)VHE mode into a macro
KVM: arm64: Use the appropriate feature trap register for SVE at EL2
setup
KVM: arm64: Disable SME traps for (h)VHE at setup
KVM: arm64: Helper to write to appropriate feature trap register based
on mode
KVM: arm64: Use the appropriate feature trap register when activating
traps
KVM: arm64: Fix resetting SVE trap values on reset for hVHE
KVM: arm64: Fix resetting SME trap values on reset for (h)VHE

 arch/arm64/include/asm/el2_setup.h   | 44 ++++++++++++++++++----------
 arch/arm64/include/asm/kvm_emulate.h | 21 ++++++++++---
 arch/arm64/kvm/hyp/nvhe/switch.c     |  2 +-
 3 files changed, 47 insertions(+), 20 deletions(-)

base-commit: 6eaae198076080886b9e7d57f4ae06fa782f90ef

Signature · 1 line
2.41.0.487.g6d72f3e995-goog