KVM: arm64: Move HCRX_EL2 switch to load/put on VHE systems
authorMarc Zyngier <maz@kernel.org>
Tue, 15 Aug 2023 18:39:01 +0000 (19:39 +0100)
committerMarc Zyngier <maz@kernel.org>
Thu, 17 Aug 2023 09:00:28 +0000 (10:00 +0100)
commita63cf31139b7f41d468dc8ef63dbf6bae213d960
tree7341a9666010ea47e1c224586b01f982db54da06
parent0a5d28433ad94cc38ecb3dbb5138b8ae30ffb98a
KVM: arm64: Move HCRX_EL2 switch to load/put on VHE systems

Although the nVHE behaviour requires HCRX_EL2 to be switched
on each switch between host and guest, there is nothing in
this register that would affect a VHE host.

It is thus possible to save/restore this register on load/put
on VHE systems, avoiding unnecessary sysreg access on the hot
path. Additionally, it avoids unnecessary traps when running
with NV.

To achieve this, simply move the read/writes to the *_common()
helpers, which are called on load/put on VHE, and more eagerly
on nVHE.

Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Jing Zhang <jingzhangos@google.com>
Link: https://lore.kernel.org/r/20230815183903.2735724-28-maz@kernel.org
arch/arm64/kvm/hyp/include/hyp/switch.h