arm64: cpufeature: upgrade hyp caps to final
authorMark Rutland <mark.rutland@arm.com>
Mon, 26 Oct 2020 13:49:31 +0000 (13:49 +0000)
committerMarc Zyngier <maz@kernel.org>
Fri, 30 Oct 2020 08:53:10 +0000 (08:53 +0000)
commitd86de40decaa14e6613af1b2783bf4d589d0f38b
treeb2403210b1625e1a829a5c43249a2a4f61a409ba
parentdfc4e3f08903ed8fe0b66cc25b64524a82654166
arm64: cpufeature: upgrade hyp caps to final

We finalize caps before initializing kvm hyp code, and any use of
cpus_have_const_cap() in kvm hyp code generates redundant and
potentially unsound code to read the cpu_hwcaps array.

A number of helper functions used in both hyp context and regular kernel
context use cpus_have_const_cap(), as some regular kernel code runs
before the capabilities are finalized. It's tedious and error-prone to
write separate copies of these for hyp and non-hyp code.

So that we can avoid the redundant code, let's automatically upgrade
cpus_have_const_cap() to cpus_have_final_cap() when used in hyp context.
With this change, there's never a reason to access to cpu_hwcaps array
from hyp code, and we don't need to create an NVHE alias for this.

This should have no effect on non-hyp code.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Acked-by: Will Deacon <will@kernel.org>
Cc: David Brazdil <dbrazdil@google.com>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20201026134931.28246-4-mark.rutland@arm.com
arch/arm64/include/asm/cpufeature.h
arch/arm64/include/asm/virt.h
arch/arm64/kernel/image-vars.h