mbox series

[PATCHv2,0/2] arm64: add finalized cap helper

Message ID 20200221145022.27217-1-mark.rutland@arm.com (mailing list archive)
Headers show
Series arm64: add finalized cap helper | expand

Message

Mark Rutland Feb. 21, 2020, 2:50 p.m. UTC
Across arm64 we use cpus_have_const_cap() to check for a capability
without a runtime check. Prior to capabilities being finalized
cpus_have_const_cap() falls back to a runtime check of the cpu_hwcaps
array. In some cases we know that code is never invoked prior to the
capabilities being finalized, and the fallback code is redundant (and
unsound if ever executed in hyp context).

So that we can avoid the redundant code and detect when the caps are
unexpectedly checked too early, this series adds a new
cpus_have_final_cap() helper, and migrates the KVM hyp code over to it.

I'm hoping to use this as part of the entry.S -> entry-common.c
conversion, and there are other places in arm64 that could potentially
use this today.

Since v1 [1]
* Use system_capabilities_finalized() per Suzuki's comments
* Remove extraneous whitespace
* Add R-b tags from Marc and Suzuki

[1] https://lore.kernel.org/linux-arm-kernel/20200210122708.38826-1-mark.rutland@arm.com/

Thanks,
Mark.

Mark Rutland (2):
  arm64: cpufeature: add cpus_have_final_cap()
  arm64: kvm: hyp: use cpus_have_final_cap()

 arch/arm64/include/asm/cpufeature.h | 58 ++++++++++++++++++++++++++++++-------
 arch/arm64/kvm/hyp/switch.c         | 14 ++++-----
 arch/arm64/kvm/hyp/sysreg-sr.c      |  8 ++---
 arch/arm64/kvm/hyp/tlb.c            |  8 ++---
 4 files changed, 62 insertions(+), 26 deletions(-)

Comments

Catalin Marinas March 13, 2020, 5:51 p.m. UTC | #1
On Fri, Feb 21, 2020 at 02:50:20PM +0000, Mark Rutland wrote:
> Mark Rutland (2):
>   arm64: cpufeature: add cpus_have_final_cap()
>   arm64: kvm: hyp: use cpus_have_final_cap()

Queued for 5.7. Thanks.