arm64: VHE: Enable EL2 MMU from the idmap
authorMarc Zyngier <maz@kernel.org>
Wed, 24 Feb 2021 09:37:36 +0000 (09:37 +0000)
committerWill Deacon <will@kernel.org>
Wed, 24 Feb 2021 11:32:28 +0000 (11:32 +0000)
commitf1b6cff7c98be2747d2fe16e42dcdcf2fc02c7e6
treee187d288f505f10a933b3f5956add57fabcd3791
parent610e4dc8ac463815f5180ae2e6fadae834891b86
arm64: VHE: Enable EL2 MMU from the idmap

Enabling the MMU requires the write to SCTLR_ELx (and the ISB
that follows) to live in some identity-mapped memory. Otherwise,
the translation will result in something totally unexpected
(either fetching the wrong instruction stream, or taking a
fault of some sort).

This is exactly what happens in mutate_to_vhe(), as this code
lives in the .hyp.text section, which isn't identity-mapped.
With the right configuration, this explodes badly.

Extract the MMU-enabling part of mutate_to_vhe(), and move
it to its own function that lives in the idmap. This ensures
nothing bad happens.

Fixes: f359182291c7 ("arm64: Provide an 'upgrade to VHE' stub hypercall")
Reported-by: "kernelci.org bot" <bot@kernelci.org>
Tested-by: Guillaume Tucker <guillaume.tucker@collabora.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210224093738.3629662-2-maz@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kernel/hyp-stub.S