• Mark Rutland's avatar
    arm64: Cleanup system cpucap handling · 63a2d92e
    Mark Rutland authored
    Recent changes to remove cpus_have_const_cap() introduced new users of
    cpus_have_cap() in the period between detecting system cpucaps and
    patching alternatives. It would be preferable to defer these until after
    the relevant cpucaps have been patched so that these can use the usual
    feature check helper functions, which is clearer and has less risk of
    accidental usage of code relying upon an alternative which has not yet
    been patched.
    
    This patch reworks the system-wide cpucap detection and patching to
    minimize this transient period:
    
    * The detection, enablement, and patching of system cpucaps is moved
      into a new setup_system_capabilities() function so that these can be
      grouped together more clearly, with no other functions called in the
      period between detection and patching. This is called from
      setup_system_features() before the subsequent checks that depend on
      the cpucaps.
    
      The logging of TTBR0 PAN and cpucaps with a mask is also moved here to
      keep these as close as possible to update_cpu_capabilities().
    
      At the same time, comments are corrected and improved to make the
      intent clearer.
    
    * As hyp_mode_check() only tests system register values (not hwcaps) and
      must be called prior to patching, the call to hyp_mode_check() is
      moved before the call to setup_system_features().
    
    * In setup_system_features(), the use of system_uses_ttbr0_pan() is
      restored, now that this occurs after alternatives are patched. This is
      a partial revert of commit:
    
        53d62e99 ("arm64: Avoid cpus_have_const_cap() for ARM64_HAS_PAN")
    
    * In sve_setup() and sme_setup(), the use of system_supports_sve() and
      system_supports_sme() respectively are restored, now that these occur
      after alternatives are patched. This is a partial revert of commit:
    
        a76521d1 ("arm64: Avoid cpus_have_const_cap() for ARM64_{SVE,SME,SME2,FA64}")
    Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
    Cc: Ard Biesheuvel <ardb@kernel.org>
    Cc: Catalin Marinas <catalin.marinas@arm.com>
    Cc: Will Deacon <will@kernel.org>
    Link: https://lore.kernel.org/r/20231212170910.3745497-2-mark.rutland@arm.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
    63a2d92e
fpsimd.c 56.2 KB