• Mark Rutland's avatar
    arm64: kvm: hyp: use cpus_have_final_cap() · b5475d8c
    Mark Rutland authored
    The KVM hyp code is only run after system capabilities have been
    finalized, and thus all const cap checks have been patched. This is
    noted in in __cpu_init_hyp_mode(), where we BUG() if called too early:
    
    | /*
    |  * Call initialization code, and switch to the full blown HYP code.
    |  * If the cpucaps haven't been finalized yet, something has gone very
    |  * wrong, and hyp will crash and burn when it uses any
    |  * cpus_have_const_cap() wrapper.
    |  */
    
    Given this, the hyp code can use cpus_have_final_cap() and avoid
    generating code to check the cpu_hwcaps array, which would be unsafe to
    run in hyp context.
    
    This patch migrate the KVM hyp code to cpus_have_final_cap(), avoiding
    this redundant code generation, and making it possible to detect if we
    accidentally invoke this code too early. In the latter case, the BUG()
    in cpus_have_final_cap() will cause a hyp panic.
    Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
    Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
    Cc: James Morse <james.morse@arm.com>
    Cc: Julien Thierry <julien.thierry.kdev@gmail.com>
    Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
    Cc: Will Deacon <will@kernel.org>
    Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
    b5475d8c
sysreg-sr.c 10.8 KB