Skip to content

Fix and rewrite arm64 spectre mitigations

Will Deacon linux-arm-kernel stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest19 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/19arm64: Make use of ARCH_WORKAROUND_1 even when KVM is not enabledarch/arm64/kernel/cpu_errata.c+5 -20 replies
2/19arm64: Run ARCH_WORKAROUND_1 enabling code on all CPUsarch/arm64/kernel/cpu_errata.c+8 -01 reply
3/19arm64: Run ARCH_WORKAROUND_2 enabling code on all CPUsarch/arm64/kernel/cpu_errata.c+7 -01 reply
4/19arm64: Remove Spectre-related CONFIG_* optionsarch/arm64/Kconfig arch/arm64/include/asm/cpufeature.h arch/arm64/include/asm/kvm_mmu.h +8 more+4 -800 replies
5/19KVM: arm64: Replace CONFIG_KVM_INDIRECT_VECTORS with CONFIG_RANDOMIZE_BASEarch/arm64/include/asm/kvm_asm.h arch/arm64/include/asm/kvm_mmu.h arch/arm64/kernel/cpu_errata.c +3 more+6 -90 replies
6/19KVM: arm64: Simplify install_bp_hardening_cb()arch/arm64/kernel/cpu_errata.c+7 -200 replies
7/19arm64: Rename ARM64_HARDEN_BRANCH_PREDICTOR to ARM64_SPECTRE_V2arch/arm64/include/asm/cpucaps.h arch/arm64/include/asm/kvm_mmu.h arch/arm64/include/asm/mmu.h +1 more+16 -170 replies
8/19arm64: Introduce separate file for spectre mitigations and reportingarch/arm64/kernel/Makefile arch/arm64/kernel/cpu_errata.c arch/arm64/kernel/proton-pack.c+33 -70 replies
9/19arm64: Rewrite Spectre-v2 mitigation codearch/arm64/include/asm/cpufeature.h arch/arm64/include/asm/kvm_host.h arch/arm64/include/asm/processor.h +5 more+327 -2640 replies
10/19KVM: arm64: Set CSV2 for guests on hardware unaffected by Spectre-v2arch/arm64/kvm/sys_regs.c+3 -00 replies
11/19arm64: Group start_thread() functions togetherarch/arm64/include/asm/processor.h+12 -120 replies
12/19arm64: Treat SSBS as a non-strict system featurearch/arm64/kernel/cpufeature.c+3 -30 replies
13/19arm64: Rename ARM64_SSBD to ARM64_SPECTRE_V4arch/arm64/include/asm/cpucaps.h arch/arm64/kernel/cpu_errata.c arch/arm64/kvm/hyp/include/hyp/switch.h+3 -30 replies
14/19arm64: Move SSBD prctl() handler alongside other spectre mitigation codearch/arm64/kernel/Makefile arch/arm64/kernel/proton-pack.c arch/arm64/kernel/ssbd.c+119 -1300 replies
15/19arm64: Rewrite Spectre-v4 mitigation codearch/arm64/include/asm/processor.h arch/arm64/include/asm/spectre.h arch/arm64/kernel/cpu_errata.c +6 more+401 -3520 replies
16/19KVM: arm64: Simplify handling of ARCH_WORKAROUND_2arch/arm64/include/asm/kvm_asm.h arch/arm64/include/asm/kvm_emulate.h arch/arm64/include/asm/kvm_mmu.h +11 more+41 -1630 replies
17/19KVM: arm64: Get rid of kvm_arm_have_ssbd()arch/arm64/include/asm/kvm_host.h+0 -230 replies
18/19KVM: arm64: Convert ARCH_WORKAROUND_2 to arm64_get_spectre_v4_state()arch/arm64/kvm/arm.c arch/arm64/kvm/hypercalls.c arch/arm64/kvm/psci.c+30 -140 replies
19/19arm64: Get rid of arm64_ssbd_statearch/arm64/include/asm/cpufeature.h arch/arm64/kernel/cpu_errata.c+0 -160 replies

Reviews trailers per patch

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

PatchSuzuki K Poulose
1/19
2/19R-b
3/19R-b
4/19
5/19
6/19
7/19
8/19
9/19
10/19
11/19
12/19
13/19
14/19
15/19
16/19
17/19
18/19
19/19

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 00/19] Fix and rewrite arm64 spectre mitigations

Hi everyone,

If there's something strange in your CPU, who you gonna call?

Well, if you're trundling along on an arm64 processor, git blame will suggest that Marc and I need to pick up the phone. Unfortunately, if the ghost in question is Spectre v2 or Spectre v4, then we'll have to call you back because our mitigations are in a pretty bad way. They used to work, but due to changes with the cpufeature code, they haven't been working properly for some time. And guess what? People haven't noticed because this stuff is practically impossible to test, even if you have a system where mitigations are available.

The temptation was to remove the code entirely, but after putting in some effort to untangle it, we ended up knocking it into a much better shape. Although that doesn't change the fact that we can't test it very well, it certainly appears to behave better than the old code in situations such as:

- Err... wanting mitigation on more than one CPU

- Not changing the mitigation state at runtime (i.e. after userspace has started running)

- Gracefully handling failure to bring late CPUs online (previously this would only happen _after_ updating the mitigation state!)

- Clear separation between mitigation state (am I vulnerable?) and policy (the user wants to go fast)

- Removal of the hideously expensive "dynamic" Spectre-v2 mitigation for KVM guests

- Being easier to read, including the addition of comments

As this is a complete rewrite, parts of the series are pretty grotty to review; it's easier to apply the whole lot first and then look at the new code, especially as the old implementation is pretty much unreadable anyway.

The first three patches are fixes targetting stable. Given the current state of this stuff, I think that the rest of the series is 5.10 material, as we're hardly going to make anything worse here.

Cheers,

Will

Cc Catalin Marinas <[email protected]>
Cc Suzuki K Poulose <[email protected]>
Cc David Brazdil <[email protected]>

--->8

Marc Zyngier (8):
arm64: Make use of ARCH_WORKAROUND_1 even when KVM is not enabled
arm64: Run ARCH_WORKAROUND_1 enabling code on all CPUs
arm64: Run ARCH_WORKAROUND_2 enabling code on all CPUs
KVM: arm64: Set CSV2 for guests on hardware unaffected by Spectre-v2
KVM: arm64: Simplify handling of ARCH_WORKAROUND_2
KVM: arm64: Get rid of kvm_arm_have_ssbd()
KVM: arm64: Convert ARCH_WORKAROUND_2 to arm64_get_spectre_v4_state()
arm64: Get rid of arm64_ssbd_state

Will Deacon (11):
arm64: Remove Spectre-related CONFIG_* options
KVM: arm64: Replace CONFIG_KVM_INDIRECT_VECTORS with
CONFIG_RANDOMIZE_BASE
KVM: arm64: Simplify install_bp_hardening_cb()
arm64: Rename ARM64_HARDEN_BRANCH_PREDICTOR to ARM64_SPECTRE_V2
arm64: Introduce separate file for spectre mitigations and reporting
arm64: Rewrite Spectre-v2 mitigation code
arm64: Group start_thread() functions together
arm64: Treat SSBS as a non-strict system feature
arm64: Rename ARM64_SSBD to ARM64_SPECTRE_V4
arm64: Move SSBD prctl() handler alongside other spectre mitigation
code
arm64: Rewrite Spectre-v4 mitigation code

 arch/arm64/Kconfig                      |  26 -
 arch/arm64/include/asm/cpucaps.h        |   4 +-
 arch/arm64/include/asm/cpufeature.h     |  24 -
 arch/arm64/include/asm/kvm_asm.h        |   5 +-
 arch/arm64/include/asm/kvm_emulate.h    |  14 -
 arch/arm64/include/asm/kvm_host.h       |  40 --
 arch/arm64/include/asm/kvm_mmu.h        |  53 +-
 arch/arm64/include/asm/mmu.h            |  11 +-
 arch/arm64/include/asm/processor.h      |  44 +-
 arch/arm64/include/asm/spectre.h        |  32 +
 arch/arm64/include/uapi/asm/kvm.h       |   9 +
 arch/arm64/kernel/Makefile              |   3 +-
 arch/arm64/kernel/cpu_errata.c          | 487 +--------------
 arch/arm64/kernel/cpufeature.c          |  51 +-
 arch/arm64/kernel/entry.S               |  10 +-
 arch/arm64/kernel/hibernate.c           |   6 +-
 arch/arm64/kernel/image-vars.h          |   2 -
 arch/arm64/kernel/process.c             |  17 +-
 arch/arm64/kernel/proton-pack.c         | 763 ++++++++++++++++++++++++
 arch/arm64/kernel/ssbd.c                | 129 ----
 arch/arm64/kernel/suspend.c             |   3 +-
 arch/arm64/kvm/Kconfig                  |   3 -
 arch/arm64/kvm/arm.c                    |   6 +-
 arch/arm64/kvm/hyp/Makefile             |   2 +-
 arch/arm64/kvm/hyp/hyp-entry.S          |  31 +-
 arch/arm64/kvm/hyp/include/hyp/switch.h |  33 -
 arch/arm64/kvm/hyp/nvhe/switch.c        |   4 -
 arch/arm64/kvm/hyp/vhe/switch.c         |   4 -
 arch/arm64/kvm/hypercalls.c             |  33 +-
 arch/arm64/kvm/psci.c                   |  74 ++-
 arch/arm64/kvm/reset.c                  |   4 -
 arch/arm64/kvm/sys_regs.c               |   3 +
 32 files changed, 920 insertions(+), 1010 deletions(-)
 create mode 100644 arch/arm64/include/asm/spectre.h
 create mode 100644 arch/arm64/kernel/proton-pack.c
 delete mode 100644 arch/arm64/kernel/ssbd.c
Signature · 7 lines
2.28.0.681.g6f77f65b4e-goog


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel