Skip to content

KVM: arm64: Fix handling of host fpsimd/sve state in protected mode

Fuad Tabba kvmarm linux-arm-kernel 4 versions – Applied

Status from this message: Applied to fixes, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest9 patches 14 repliesApplied
  2. v311 patches 14 repliesSuperseded
  3. v27 patches 13 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v17 patches15 repliesSuperseded

Patches in v4 Applied

#Subject and filesSizeRepliesApplied
1/9KVM: arm64: Reintroduce __sve_save_statearch/arm64/include/asm/kvm_hyp.h arch/arm64/kvm/hyp/fpsimd.S+7 -03 replies
2/9KVM: arm64: Fix prototype for __sve_save_state/__sve_restore_statearch/arm64/include/asm/kvm_hyp.h arch/arm64/kvm/hyp/include/hyp/switch.h+4 -31 reply
3/9KVM: arm64: Abstract set/clear of CPTR_EL2 bits behind helperarch/arm64/include/asm/kvm_arm.h arch/arm64/include/asm/kvm_emulate.h arch/arm64/kvm/hyp/include/hyp/switch.h +1 more+73 -190 replies
4/9KVM: arm64: Specialize handling of host fpsimd state on traparch/arm64/kvm/hyp/include/hyp/switch.h arch/arm64/kvm/hyp/nvhe/switch.c arch/arm64/kvm/hyp/vhe/switch.c+13 -10 replies
5/9KVM: arm64: Allocate memory mapped at hyp for host sve state in pKVMarch/arm64/include/asm/kvm_host.h arch/arm64/include/asm/kvm_hyp.h arch/arm64/include/asm/kvm_pkvm.h +4 more+124 -02 replies
6/9KVM: arm64: Eagerly restore host fpsimd/sve state in pKVMarch/arm64/kvm/hyp/include/hyp/switch.h arch/arm64/kvm/hyp/nvhe/hyp-main.c arch/arm64/kvm/hyp/nvhe/pkvm.c +1 more+93 -55 replies
7/9KVM: arm64: Consolidate initializing the host data's fpsimd_state/sve in pKVMarch/arm64/include/asm/kvm_host.h arch/arm64/kvm/arm.c arch/arm64/kvm/hyp/include/nvhe/pkvm.h +2 more+22 -211 reply
8/9KVM: arm64: Refactor CPACR trap bit setting/clearing to use ELx formatarch/arm64/include/asm/el2_setup.h arch/arm64/include/asm/kvm_emulate.h arch/arm64/kvm/fpsimd.c +3 more+14 -190 replies
9/9KVM: arm64: Ensure that SME controls are disabled in protected modearch/arm64/kvm/fpsimd.c arch/arm64/kvm/hyp/nvhe/hyp-main.c+18 -01 reply

Reviews trailers per patch

8 of 9 patches have a Reviewed-by or Acked-by.

PatchOliver UptonMark Brown
1/9R-b
2/9R-b
3/9R-b
4/9R-b R-b
5/9R-b
6/9R-b
7/9R-b R-b
8/9R-b
9/9

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

Read the v4 thread

Cover letter [PATCH v4 0/9] KVM: arm64: Fix handling of host fpsimd/sve state in protected mode

Changes since v3 [1]:
- Rebased on Linux 6.10-rc2 (c3f38fa61af7)
- Dropped v3 patches 8--11 (Oliver)
- Removed unnecessary isb()s (Oliver)
- Formatting/comments (Mark)
- Fix __sve_save_state()/__sve_restore_state() prototypes (Mark)
- Save/restore ffr with the sve state
- Added a patch that checks at hyp that SME features aren't enabled on guest entry, to ensure it's not in streaming mode

With the KVM host data rework [2], handling of fpsimd and sve state in protected mode is done at hyp. For protected VMs, we don't want to leak any guest state to the host, including whether a guest has used fpsimd/sve.

To complete the work started with the host data rework, in regards to protected mode, ensure that the host's fpsimd context and its sve context are restored on guest exit, since the rework has hidden the fpsimd/sve state from the host.

This patch series eagerly restores the host fpsimd/sve state on guest exit when running in protected mode, which happens only if the guest has used fpsimd/sve. This means that the saving of the state is lazy, similar to the behavior of KVM in other modes, but the restoration of the host state is eager.

This series is based on Linux 6.10-rc2 (c3f38fa61af7).

Tested on qemu, with the kernel sve stress tests.

Cheers,
/fuad

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

Fuad Tabba (9):
KVM: arm64: Reintroduce __sve_save_state
KVM: arm64: Fix prototype for __sve_save_state/__sve_restore_state
KVM: arm64: Abstract set/clear of CPTR_EL2 bits behind helper
KVM: arm64: Specialize handling of host fpsimd state on trap
KVM: arm64: Allocate memory mapped at hyp for host sve state in pKVM
KVM: arm64: Eagerly restore host fpsimd/sve state in pKVM
KVM: arm64: Consolidate initializing the host data's fpsimd_state/sve
in pKVM
KVM: arm64: Refactor CPACR trap bit setting/clearing to use ELx format
KVM: arm64: Ensure that SME controls are disabled in protected mode

 arch/arm64/include/asm/el2_setup.h      |  6 +-
 arch/arm64/include/asm/kvm_arm.h        |  6 ++
 arch/arm64/include/asm/kvm_emulate.h    | 71 +++++++++++++++++++--
 arch/arm64/include/asm/kvm_host.h       | 25 +++++++-
 arch/arm64/include/asm/kvm_hyp.h        |  4 +-
 arch/arm64/include/asm/kvm_pkvm.h       |  9 +++
 arch/arm64/kvm/arm.c                    | 76 ++++++++++++++++++++++
 arch/arm64/kvm/fpsimd.c                 | 11 +++-
 arch/arm64/kvm/hyp/fpsimd.S             |  6 ++
 arch/arm64/kvm/hyp/include/hyp/switch.h | 36 ++++++-----
 arch/arm64/kvm/hyp/include/nvhe/pkvm.h  |  1 -
 arch/arm64/kvm/hyp/nvhe/hyp-main.c      | 84 ++++++++++++++++++++++---
 arch/arm64/kvm/hyp/nvhe/pkvm.c          | 17 ++---
 arch/arm64/kvm/hyp/nvhe/setup.c         | 25 +++++++-
 arch/arm64/kvm/hyp/nvhe/switch.c        | 24 ++++++-
 arch/arm64/kvm/hyp/vhe/switch.c         | 12 ++--
 arch/arm64/kvm/reset.c                  |  3 +
 17 files changed, 358 insertions(+), 58 deletions(-)

base-commit: c3f38fa61af77b49866b006939479069cd451173

Signature · 1 line
2.45.1.288.g0e0cd299f1-goog