Skip to content

kvm: arm64: Pointer Authentication handling fixes

Marc Zyngier kvm kvmarm linux-arm-kernel stable 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 0 repliesNew
  2. v13 patches 4 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4KVM: arm64: Save the host's PtrAuth keys in non-preemptible contextarch/arm64/include/asm/kvm_emulate.h arch/arm64/kvm/arm.c arch/arm64/kvm/handle_exit.c+19 -240 replies
2/4KVM: arm64: Handle PtrAuth traps earlyarch/arm64/kvm/arm.c arch/arm64/kvm/handle_exit.c arch/arm64/kvm/hyp/switch.c +1 more+70 -380 replies
3/4KVM: arm64: Stop sparse from moaning at __hyp_this_cpu_ptrarch/arm64/include/asm/kvm_asm.h+10 -30 replies
4/4KVM: arm64: Remove host_cpu_context member from vcpu structurearch/arm64/include/asm/kvm_host.h arch/arm64/kvm/arm.c arch/arm64/kvm/hyp/debug-sr.c +3 more+11 -190 replies

Reviews trailers per patch

3 of 4 patches have a Reviewed-by or Acked-by.

PatchMark RutlandAndrew Scull
1/4R-b
2/4R-b
3/4
4/4A-b R-b

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

Read the v2 thread

Cover letter [PATCH v2 0/4] kvm: arm64: Pointer Authentication handling fixes

I recently discovered that the Pointer Authentication (PtrAuth) handling code in KVM is busted, and has been for a while. The main issue is that the we save the host's keys from a preemptible context. Things will go wrong at some point.

In order to address this, the first patch move the saving of the host's keys to vcpu_load(). It is done eagerly, which is a bore, but is at least safe. This is definitely stable material.

The following patch is adding an optimisatioe: we handle key saving and HCR massaging as a fixup, much like the FPSIMD code.

Subsequent patch cleans up our HYP per-CPU accessor and make it sparse friendly, asthe last patch makes heavy use of it by killing the per-vcpu backpointer to the physical CPU context, avoiding the first bug altogether.

This has been very lightly tested on a model. Unless someone shouts, I plan to send this as part of the pending set of fixes.

* From v1:
- Dropped the misbehaving guest handling patch
- Added the two cleanup patches to the series (previously posted separately)

Marc Zyngier (4):
KVM: arm64: Save the host's PtrAuth keys in non-preemptible context
KVM: arm64: Handle PtrAuth traps early
KVM: arm64: Stop sparse from moaning at __hyp_this_cpu_ptr
KVM: arm64: Remove host_cpu_context member from vcpu structure

 arch/arm64/include/asm/kvm_asm.h     | 13 ++++--
 arch/arm64/include/asm/kvm_emulate.h |  6 ---
 arch/arm64/include/asm/kvm_host.h    |  3 --
 arch/arm64/kvm/arm.c                 |  6 +--
 arch/arm64/kvm/handle_exit.c         | 32 ++------------
 arch/arm64/kvm/hyp/debug-sr.c        |  4 +-
 arch/arm64/kvm/hyp/switch.c          | 65 +++++++++++++++++++++++++++-
 arch/arm64/kvm/hyp/sysreg-sr.c       |  6 ++-
 arch/arm64/kvm/pmu.c                 |  8 +---
 arch/arm64/kvm/sys_regs.c            | 13 +++---
 10 files changed, 91 insertions(+), 65 deletions(-)
Signature · 1 line
2.26.2