Skip to content

Fix racing TLBI with ASID/VMID reallocation

Will Deacon kvmarm linux-arch linux-arm-kernel stable 1 version Applied

Status from this message: Applied to arm64 (for-next/misc), thanks!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 10 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/4arm64: mm: Fix TLBI vs ASID rolloverarch/arm64/include/asm/mmu.h arch/arm64/include/asm/tlbflush.h+31 -93 replies
2/4KVM: arm64: Move kern_hyp_va() usage in __load_guest_stage2() into the callersarch/arm64/include/asm/kvm_mmu.h arch/arm64/kvm/hyp/nvhe/switch.c arch/arm64/kvm/hyp/nvhe/tlb.c +2 more+9 -60 replies
3/4KVM: arm64: Convert the host S2 over to __load_guest_stage2()arch/arm64/include/asm/kvm_mmu.h arch/arm64/kvm/hyp/include/nvhe/mem_protect.h arch/arm64/kvm/hyp/nvhe/mem_protect.c+5 -103 replies
4/4KVM: arm64: Upgrade VMID accesses to {READ,WRITE}_ONCEarch/arm64/include/asm/kvm_mmu.h arch/arm64/kvm/arm.c arch/arm64/kvm/hyp/nvhe/mem_protect.c +1 more+10 -51 reply

Reviews trailers per patch

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

PatchCatalin MarinasQuentin Perret
1/4R-b
2/4
3/4
4/4R-b

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

Read the v1 thread

Cover letter [PATCH 0/4] Fix racing TLBI with ASID/VMID reallocation

Hi all,

While reviewing Shameer's reworked VMID allocator [1] and discussing with Marc, we spotted a race between TLB invalidation (which typically takes an ASID or VMID argument) and reallocation of ASID/VMID for the context being targetted.

The first patch spells out an example with try_to_unmap_one() in a comment, which Catalin has kindly modelled in TLA+ at [2].

Although I'm posting all this together for ease of review, the intention is that the first patch will go via arm64 with the latter going via kvm.

Cheers,

Will

[1] https://lore.kernel.org/r/[email protected]
[2] https://git.kernel.org/pub/scm/linux/kernel/git/cmarinas/kernel-tla.git/commit/

Cc Catalin Marinas <[email protected]>
Cc Marc Zyngier <[email protected]>
Cc Jade Alglave <[email protected]>
Cc Shameer Kolothum <[email protected]>

--->8

Marc Zyngier (3):
KVM: arm64: Move kern_hyp_va() usage in __load_guest_stage2() into the
callers
KVM: arm64: Convert the host S2 over to __load_guest_stage2()
KVM: arm64: Upgrade VMID accesses to {READ,WRITE}_ONCE

Will Deacon (1):
arm64: mm: Fix TLBI vs ASID rollover

 arch/arm64/include/asm/kvm_mmu.h              | 17 ++++++-----
 arch/arm64/include/asm/mmu.h                  | 29 ++++++++++++++++---
 arch/arm64/include/asm/tlbflush.h             | 11 +++----
 arch/arm64/kvm/arm.c                          |  2 +-
 arch/arm64/kvm/hyp/include/nvhe/mem_protect.h |  2 +-
 arch/arm64/kvm/hyp/nvhe/mem_protect.c         |  6 ++--
 arch/arm64/kvm/hyp/nvhe/switch.c              |  4 ++-
 arch/arm64/kvm/hyp/nvhe/tlb.c                 |  2 +-
 arch/arm64/kvm/hyp/vhe/switch.c               |  2 +-
 arch/arm64/kvm/hyp/vhe/tlb.c                  |  2 +-
 arch/arm64/kvm/mmu.c                          |  2 +-
 11 files changed, 52 insertions(+), 27 deletions(-)
Signature · 1 line
2.32.0.605.g8dce9f2422-goog